/* Soulmask Clan Manager — styles
 * Theming: switch via `data-theme="dark"|"light"` on <html>.
 */

/* ============== THEME TOKENS ============== */
:root[data-theme="dark"] {
  --bg:           #1c1f24;
  --bg2:          #252930;
  --bg3:          #2e333b;
  --border:       #3a4049;
  --text:         #d4d8de;
  --text-dim:     #8b94a0;
  --accent:       #c89978;
  --accent-hover: #d4a583;
  --accent-on:    #1c1f24;       /* text color on accent fill */
  --red:          #d97766;
  --red-bg:       #3a2422;
  --row-hover:    rgba(200, 153, 120, 0.06);
  --table-head-skill:  #3a4a55;
  --table-head-weapon: #5a3a44;
  --shadow:       0 8px 24px rgba(0,0,0,0.55);

  --tier-mastery:    #d49160;
  --tier-specialist: #e8d56a;
  --tier-iron:       #a8c9a8;
  --tier-sub:        #3f4651;
  --tier-sub-text:   #8b94a0;
  --tier-on:         #1c1f24;     /* text on the tier swatch backgrounds */

  --chip-group-bg:   #324452;
  --chip-group-fg:   #e8eef3;
  --chip-tag-bg:     #3d2f33;
  --chip-tag-fg:     #d4a583;

  /* Talent polarity borders (preference, origin, title) */
  --talent-preference: #c47fbb;   /* purple/pink */
  --talent-origin:     #d4a04a;   /* amber */
  --talent-title:      #8a99af;   /* blue/grey */
}

:root[data-theme="light"] {
  --bg:           #f4eee2;
  --bg2:          #fbf6ec;
  --bg3:          #e8dfca;
  --border:       #cdc1a4;
  --text:         #2c2620;
  --text-dim:     #7a6f5e;
  --accent:       #a06330;
  --accent-hover: #8a5022;
  --accent-on:    #fbf6ec;
  --red:          #a83e2e;
  --red-bg:       #f3dcd5;
  --row-hover:    rgba(160, 99, 48, 0.07);
  --table-head-skill:  #7a8a95;
  --table-head-weapon: #8a5560;
  --shadow:       0 8px 20px rgba(80,60,30,0.18);

  --tier-mastery:    #e8a872;
  --tier-specialist: #f0d75e;
  --tier-iron:       #b8d8b8;
  --tier-sub:        #d6cfbf;
  --tier-sub-text:   #7a6f5e;
  --tier-on:         #2c2620;

  --chip-group-bg:   #d3dde3;
  --chip-group-fg:   #2f4858;
  --chip-tag-bg:     #efddc8;
  --chip-tag-fg:     #8a5224;

  /* Talent polarity borders (preference, origin, title) */
  --talent-preference: #a8519a;
  --talent-origin:     #b8842c;
  --talent-title:      #5d6f8a;
}

/* Default: dark, until JS sets the attribute. Avoids flash of unstyled. */
:root:not([data-theme]) {
  color-scheme: dark;
  --bg: #1c1f24; --bg2: #252930; --bg3: #2e333b; --border: #3a4049;
  --text: #d4d8de; --text-dim: #8b94a0;
  --accent: #c89978; --accent-hover: #d4a583; --accent-on: #1c1f24;
  --red: #d97766; --red-bg: #3a2422; --row-hover: rgba(200, 153, 120, 0.06);
  --table-head-skill: #3a4a55; --table-head-weapon: #5a3a44;
  --shadow: 0 8px 24px rgba(0,0,0,0.55);
  --tier-mastery: #d49160; --tier-specialist: #e8d56a;
  --tier-iron: #a8c9a8; --tier-sub: #3f4651; --tier-sub-text: #8b94a0;
  --tier-on: #1c1f24;
  --chip-group-bg: #324452; --chip-group-fg: #e8eef3;
  --chip-tag-bg: #3d2f33; --chip-tag-fg: #d4a583;
  --talent-preference: #c47fbb; --talent-origin: #d4a04a; --talent-title: #8a99af;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}

/* ============== TOP BAR ============== */
header.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
header.topbar h1 {
  margin: 0;
  font-size: 18px;
  color: var(--accent);
  letter-spacing: 0.2px;
}
header.topbar .grow { flex: 1; }
header.topbar button, .toolbar button, .actions button {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s, border-color 0.12s;
}
header.topbar button:hover, .toolbar button:hover, .actions button:hover {
  background: var(--bg);
  border-color: var(--accent);
}
header.topbar button.primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
header.topbar button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
header.topbar button.danger { color: var(--red); }

/* ============== LAYOUT ============== */
main { padding: 20px; max-width: 100%; }
.view { display: none; }
.view.active { display: block; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar input[type="text"], .toolbar select {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  min-width: 180px;
}
.toolbar .legend { font-size: 12px; color: var(--text-dim); margin-left: auto; }
.toolbar .legend span.swatch {
  display: inline-block; padding: 2px 8px; margin-left: 4px; border-radius: 3px;
  color: var(--tier-on);
}
.swatch.t-mastery    { background: var(--tier-mastery); }
.swatch.t-specialist { background: var(--tier-specialist); }
.swatch.t-iron       { background: var(--tier-iron); }
.swatch.t-sub        { background: var(--tier-sub); color: var(--tier-sub-text); }

/* ============== ROSTER TABLE ============== */
/* The roster table scrolls inside its own wrapper, on both axes, so its
   sticky header + sticky name column have a real container to stick to.
   max-height leaves room for topbar (~50) + toolbar (~50) + main padding
   (40) + small buffer. */
#roster-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 180px);
}
table.roster {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
}
table.roster th, table.roster td {
  padding: 4px 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
table.roster th {
  background: var(--table-head-skill);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
  font-weight: 600;
}
/* Top-left corner: stick both axes, above other sticky headers and the
   sticky name column so it owns the corner during two-axis scroll. */
table.roster thead th:first-child {
  left: 0;
  z-index: 7;
}
table.roster th.weapon-col { background: var(--table-head-weapon); }
table.roster th.sortable { cursor: pointer; user-select: none; }
table.roster th.sortable:hover { filter: brightness(1.12); }
table.roster th .sort-ind {
  color: var(--accent);
  margin-left: 2px;
  font-weight: normal;
  font-size: 11px;
}
/* Row hover: combine three signals so it reads at a glance regardless of
   how much of the row is tier-colored:
   1. Wash non-tier cells with the row-hover tint.
   2. Bump tier cells' brightness slightly (preserves their text contrast).
   3. Drop a 3px accent bar on the leading cell (Name) as the left-edge
      anchor — visible across the whole row even when middle cells are
      tier-saturated. */
table.roster tr:hover td:not(.tier-mastery):not(.tier-specialist):not(.tier-iron):not(.tier-sub):not(.name-cell) {
  background: var(--row-hover);
}
table.roster tr:hover td.tier-mastery,
table.roster tr:hover td.tier-specialist,
table.roster tr:hover td.tier-iron,
table.roster tr:hover td.tier-sub {
  filter: brightness(1.06);
}
table.roster tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
table.roster td.skill-cell, table.roster td.weapon-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
table.roster td.tier-mastery    { background: var(--tier-mastery);    color: var(--tier-on); font-weight: 600; }
table.roster td.tier-specialist { background: var(--tier-specialist); color: var(--tier-on); font-weight: 600; }
table.roster td.tier-iron       { background: var(--tier-iron);       color: var(--tier-on); }
table.roster td.tier-sub        { background: var(--tier-sub);        color: var(--tier-sub-text); }
table.roster td.tier-empty      { color: var(--tier-sub-text); }
table.roster td.name {
  font-weight: 600;
  cursor: pointer;
  color: var(--accent);
}
table.roster td.name:hover { text-decoration: underline; }
table.roster .aligned-skill { font-weight: bold; }

/* Inline-editable roster cells */
table.roster.editable input.cell-input,
table.roster.editable select.cell-input {
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  padding: 2px 4px;
  border-radius: 3px;
  font: inherit;
  font-size: 12px;
  width: 100%;
  min-width: 0;
}
table.roster.editable input.cell-input.num {
  width: 56px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
table.roster.editable input.cell-input.num-tiny {
  width: 32px;
  text-align: right;
  padding: 1px 2px;
  font-variant-numeric: tabular-nums;
  color: inherit;
}
table.roster.editable input.cell-input.list-input {
  min-width: 120px;
  color: var(--accent);
}
table.roster.editable input.cell-input.list-input::placeholder {
  color: var(--text-dim); opacity: 0.6;
}
/* MozAppearance / WebkitAppearance: hide spinners to save horizontal space */
table.roster.editable input.cell-input.num-tiny::-webkit-outer-spin-button,
table.roster.editable input.cell-input.num-tiny::-webkit-inner-spin-button {
  -webkit-appearance: none; margin: 0;
}
table.roster.editable input.cell-input.num-tiny {
  -moz-appearance: textfield;
}
table.roster td.skill-cell, table.roster td.weapon-cell {
  padding: 2px 4px;
}
table.roster.editable td.skill-cell .cur-cap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  white-space: nowrap;
}
table.roster.editable td.skill-cell .cur-cap .sep {
  opacity: 0.55;
  font-size: 11px;
}
table.roster.editable td.weapon-cell {
  text-align: center;
}
table.roster.editable input.cell-input:hover,
table.roster.editable select.cell-input:hover {
  border-color: var(--border);
  background: var(--bg3);
}
table.roster.editable input.cell-input:focus,
table.roster.editable select.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}
table.roster.editable td.name-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 160px;
  position: sticky;
  left: 0;
  z-index: 3;
  background-color: var(--bg);
}
table.roster.editable td.name-cell input.name-input {
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}
table.roster.editable .row-go {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 1px 6px;
  font-size: 14px;
  line-height: 1;
}
table.roster.editable .row-go:hover {
  color: var(--accent);
  border-color: var(--border);
  background: var(--bg3);
}

/* ============== PROFILE VIEW ============== */
.profile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1400px;
}
.profile .card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.profile .card h3 {
  margin-top: 0;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.profile .card.full-row { grid-column: 1 / -1; }

.profile-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.profile-header h2 { margin: 0; color: var(--accent); }
.profile-header .meta { color: var(--text-dim); }

.btn-danger-strong {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid var(--red);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.btn-danger-strong:hover { background: var(--red); color: var(--accent-on); }

.prof-nav {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.prof-nav:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.prof-nav:disabled { opacity: 0.35; cursor: not-allowed; }
.prof-pos { font-size: 12px; margin-left: 4px; }

.field { margin-bottom: 10px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 3px; }
.field input, .field select, .field textarea {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 6px 8px; border-radius: 4px; font-size: 13px; width: 100%;
}
.field textarea { min-height: 80px; resize: vertical; font-family: inherit; }

.skill-row {
  display: grid;
  grid-template-columns: 110px 60px 60px 1fr;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.skill-row .label { color: var(--text); }
.skill-row .label.aligned { color: var(--accent); font-weight: 600; }
.skill-row .label.aligned::after { content: " ★"; color: var(--accent); }
.skill-row input {
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 3px 5px; border-radius: 3px; width: 100%; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.skill-row .bar {
  height: 8px; background: var(--bg3); border-radius: 4px; position: relative;
  overflow: hidden;
}
.skill-row .bar .fill {
  height: 100%; background: var(--accent); transition: width 0.2s;
}
.skill-row .bar .fill.tier-mastery    { background: var(--tier-mastery); }
.skill-row .bar .fill.tier-specialist { background: var(--tier-specialist); }
.skill-row .bar .fill.tier-iron       { background: var(--tier-iron); }
.skill-row .bar .fill.tier-sub        { background: var(--text-dim); }

/* ============== TALENTS ============== */
.talents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; }
.talent-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px;
  position: relative;
}
.talent-pill img { width: 36px; height: 36px; flex-shrink: 0; background: var(--bg); border-radius: 4px; }
.talent-pill .info { flex: 1; min-width: 0; }
.talent-pill .name { font-weight: 600; font-size: 13px; }
.talent-pill .effect { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talent-pill .lvl {
  background: var(--accent); color: var(--accent-on); padding: 2px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 700;
}
.talent-pill.negative { border-color: var(--red); }
.talent-pill.negative .lvl { background: var(--red); color: var(--accent-on); }
.talent-pill.preference { border-color: var(--talent-preference); }
.talent-pill.preference .lvl { background: var(--talent-preference); color: var(--accent-on); }
.talent-pill.origin { border-color: var(--talent-origin); }
.talent-pill.origin .lvl { background: var(--talent-origin); color: var(--accent-on); }
.talent-pill.title { border-color: var(--talent-title); }
.talent-pill.title .lvl { background: var(--talent-title); color: var(--accent-on); }
.talent-pill .remove {
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  padding: 2px 6px; font-size: 16px; line-height: 1;
}
.talent-pill .remove:hover { color: var(--red); }

.talent-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 10;
  width: max-content;
  max-width: 320px;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 60ms ease;
}
.talent-pill:hover .talent-tip,
.talent-pill:focus-within .talent-tip,
.talent-icon-mini:hover .talent-tip,
.talent-icon-mini:focus-within .talent-tip {
  opacity: 1;
  visibility: visible;
}

/* Compact talent icons in the roster's Talents column */
.talent-icon-row { display: flex; flex-wrap: wrap; gap: 2px; max-width: 240px; }
.talent-icon-mini {
  position: relative; display: inline-block;
  width: 22px; height: 22px;
  border-radius: 3px; border: 1px solid var(--border);
  background: var(--bg);
  cursor: help;
}
.talent-icon-mini img { width: 100%; height: 100%; object-fit: cover; border-radius: 2px; display: block; }
.talent-icon-mini.negative { border-color: var(--red); }
.talent-icon-mini.preference { border-color: var(--talent-preference); }
.talent-icon-mini.origin { border-color: var(--talent-origin); }
.talent-icon-mini.title { border-color: var(--talent-title); }

/* Talent preview inside a plan step (Learn / Upgrade subject area) */
.plan-step-talent-preview {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 4px; flex-basis: 100%;
}
.plan-step-talent-preview .talent-icon-mini { width: 26px; height: 26px; }
.talent-tip .tip-name { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.talent-tip .tip-effect { font-size: 12px; color: var(--text-dim); white-space: normal; line-height: 1.35; }

.add-talent-row { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
.add-talent-row input { flex: 1; }
.add-talent-row select { width: 80px; }

/* Talent autocomplete dropdown */
.talent-dropdown {
  position: absolute;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow);
  min-width: 320px;
}
.talent-dropdown .opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.talent-dropdown .opt:hover { background: var(--bg3); }
.talent-dropdown .opt img { width: 28px; height: 28px; background: var(--bg); border-radius: 3px; }
.talent-dropdown .opt .info { flex: 1; min-width: 0; }
.talent-dropdown .opt .n { font-weight: 600; font-size: 12px; }
.talent-dropdown .opt .e { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talent-dropdown .opt .cat { font-size: 10px; color: var(--text-dim); }

/* ============== TAGS / GROUPS ============== */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg3); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 12px;
  font-size: 11px; margin: 2px;
}
.chip.group { background: var(--chip-group-bg); color: var(--chip-group-fg); border-color: var(--chip-group-bg); }
.chip.tag   { background: var(--chip-tag-bg);   color: var(--chip-tag-fg);   border-color: var(--chip-tag-bg); }
.chip .x { cursor: pointer; opacity: 0.7; margin-left: 4px; }
.chip .x:hover { opacity: 1; color: var(--red); }

.add-chip-row { display: flex; gap: 6px; margin-top: 4px; }
.add-chip-row input { flex: 1; }

/* ============== TRAINING SUGGESTIONS ============== */
.suggestion {
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--row-hover);
  font-size: 13px;
}
.suggestion .head { font-weight: 600; color: var(--accent); }
.suggestion .why { color: var(--text-dim); font-size: 12px; margin-top: 2px; }

/* ============== MODALS ============== */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: none; align-items: center; justify-content: center; z-index: 200;
}
.modal-bg.active { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 24px; min-width: 420px; max-width: 90vw; max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; color: var(--accent); }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ============== HELP TOOLTIPS ============== */
/* Generic hover/focus tooltip system. Apply .has-help to a positioned
   parent and put a .help-tip child inside it. The optional .help-marker
   shows a small "?" badge next to the label. */
.has-help { position: relative; }
.help-marker {
  display: inline-block;
  width: 14px; height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--bg3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 10px; line-height: 14px;
  text-align: center;
  cursor: help;
  vertical-align: middle;
}
.has-help:hover .help-marker, .has-help:focus-within .help-marker {
  border-color: var(--accent); color: var(--accent);
}
.help-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: max-content;
  max-width: 360px;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 12px; line-height: 1.4;
  white-space: pre-line; /* honors \n in tip text */
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 60ms ease;
  font-weight: normal;
}
.has-help:hover .help-tip,
.has-help:focus-within .help-tip {
  opacity: 1;
  visibility: visible;
}

/* Sort hint chip in the toolbar legend */
.legend-hint {
  margin-left: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  cursor: help;
}
.legend-hint:hover { border-color: var(--accent); color: var(--accent); }
/* Open the tooltip *downward* (top: 100%) into the page area. The default
   .help-tip anchors above its parent, but this chip sits in the toolbar
   immediately under the sticky topbar — opening upward put the tip behind
   the topbar (z:100 > tip z:50). Right-anchored so it doesn't run off
   the right edge of the viewport. */
.legend-hint .help-tip { top: 100%; bottom: auto; left: auto; right: 0; max-width: 320px; }

/* Roster column header tip — anchor to the right of long-text columns
   so it doesn't fall off the left edge for early columns */
table.roster th.has-help .help-tip { top: 100%; bottom: auto; }

/* ============== UTILITY ============== */
.muted { color: var(--text-dim); }
.tag-list { margin-top: 4px; }
hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ============== FOOTER ============== */
footer.appfoot {
  margin-top: 32px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 12px;
}
footer.appfoot .meta {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px;
}
footer.appfoot .sep { opacity: 0.4; }
footer.appfoot a, footer.appfoot button.linklike {
  color: var(--accent); background: none; border: none; padding: 0;
  cursor: pointer; font: inherit; text-decoration: none;
}
footer.appfoot a:hover, footer.appfoot button.linklike:hover { text-decoration: underline; }
footer.appfoot .disclaimer { font-size: 11px; opacity: 0.75; }

footer.appfoot .theme-toggle {
  margin-left: auto;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
footer.appfoot .theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============== TRAINING PLANS ============== */
.plans-header {
  display: flex; align-items: center; gap: 12px; margin: 12px 0;
}
.plans-header h2 { margin: 0; color: var(--accent); }
.plans-header .grow { flex: 1; }

.plans-table {
  width: 100%; border-collapse: collapse; margin: 8px 0 16px;
}
.plans-table th, .plans-table td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.plans-table thead th {
  background: var(--bg3); color: var(--text-dim);
  font-weight: 600; font-size: 12px;
}
.plans-table tbody tr { cursor: pointer; }
.plans-table tbody tr:hover { background: var(--row-hover); }

.plan-status {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  border: 1px solid var(--border); background: var(--bg3); color: var(--text-dim);
}
.plan-status-draft     { color: var(--text-dim); }
.plan-status-active    { color: var(--accent-on); background: var(--accent); border-color: var(--accent); }
.plan-status-done      { color: var(--tier-on); background: var(--tier-iron); border-color: var(--tier-iron); }
.plan-status-abandoned { color: var(--red); border-color: var(--red); }

.plans-warnings {
  margin-top: 16px; padding: 12px 16px;
  background: var(--row-hover); border-left: 3px solid var(--accent);
}
.plans-warnings h3 { margin: 0 0 4px; color: var(--accent); font-size: 14px; }
.plans-warnings ul { margin: 6px 0 0 18px; padding: 0; font-size: 13px; }

/* Plan editor */
.plan-editor-head .plan-name-row {
  display: flex; gap: 12px; align-items: center; margin-bottom: 8px;
}
.plan-name-input {
  flex: 1; font-size: 18px; font-weight: 600;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); padding: 6px 10px; border-radius: 4px;
}
.plan-meta {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-dim); margin-bottom: 8px;
}
.plan-meta b { color: var(--text); font-weight: 600; }
.plan-actions {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px;
}
.plan-editor-head textarea {
  width: 100%; min-height: 60px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 4px; font-family: inherit; resize: vertical;
}
.plan-editor-head .field label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase;
}

/* Step card */
.plan-step {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--bg3); margin-bottom: 10px;
}
.plan-step.status-completed { opacity: 0.6; border-left-color: var(--tier-iron); }
.plan-step.status-abandoned { opacity: 0.45; border-left-color: var(--red); }
.plan-step.status-running   { border-left-color: var(--tier-specialist); }

.plan-step-head {
  display: flex; gap: 8px; align-items: center;
  padding: 6px 10px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.plan-step-head .step-num { color: var(--text-dim); }
.plan-step-head .step-type { font-weight: 600; color: var(--accent); }
.plan-step-head .step-dur { color: var(--text-dim); font-size: 12px; }
.plan-step-head .grow { flex: 1; }

.plan-step-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  padding: 10px 12px;
}
@media (max-width: 720px) {
  .plan-step-body { grid-template-columns: 1fr; }
}
.plan-step-fields, .plan-step-status {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.plan-step-fields label, .plan-step-status label {
  font-size: 11px; color: var(--text-dim); text-transform: uppercase; min-width: 56px;
}
.plan-step-fields select, .plan-step-fields input,
.plan-step-status input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); padding: 4px 8px; border-radius: 3px;
  font-size: 13px;
}
.plan-step-fields .small { font-size: 11px; }
.plan-step-status .status-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.plan-step-status input[type="text"] { flex: 1; min-width: 160px; }

button.small {
  font-size: 11px; padding: 3px 8px;
}
button.small.primary { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
button.small.danger { color: var(--red); }
button[disabled] { opacity: 0.4; cursor: not-allowed; }

.add-step-row {
  display: flex; gap: 8px; align-items: center;
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}

/* Calibration */
.calibration-panel {
  margin-top: 24px; padding: 12px 16px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px;
}
.calibration-panel summary { cursor: pointer; color: var(--accent); }
.calibration-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px;
}
@media (max-width: 720px) { .calibration-grid { grid-template-columns: 1fr; } }
.calibration-grid h4 { margin: 0 0 6px; color: var(--text-dim); font-size: 12px; text-transform: uppercase; }
.calibration-grid table { width: 100%; }
.calibration-grid td { padding: 3px 6px; font-size: 12px; }
.calibration-grid input {
  width: 70px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); padding: 2px 6px; border-radius: 3px;
  font-size: 12px;
}

/* + Add to plan button on each suggestion */
.suggestion { position: relative; }
.suggestion .suggestion-add {
  margin-top: 6px;
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 3px;
  font-size: 11px; padding: 2px 8px; cursor: pointer;
}
.suggestion .suggestion-add:hover { background: var(--accent); color: var(--accent-on); }

/* "✓ in plan: <name>" badge — shown when this suggestion is already a step
   in one of the trainee's draft/active plans (#32). Sits next to the
   + Add to plan button so the duplicate-plan signal is visible at a glance. */
.suggestion .suggestion-in-plan {
  display: inline-block;
  margin-top: 6px; margin-right: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--row-hover);
  color: var(--tier-iron);
  border: 1px solid var(--tier-iron);
  font-size: 11px;
  text-decoration: none;
}
a.suggestion-in-plan:hover { filter: brightness(1.15); text-decoration: underline; }
.suggestion.is-planned { opacity: 0.85; }

/* Profile-side Plans card */
.profile-plans-warning {
  background: var(--row-hover); border-left: 3px solid var(--tier-specialist);
  padding: 8px 12px; margin-bottom: 10px; font-size: 13px;
}
.profile-plans-actions { margin-bottom: 10px; }
.profile-plans-h {
  margin: 12px 0 4px; font-size: 12px; text-transform: uppercase;
  color: var(--text-dim); letter-spacing: 0.05em;
}
.profile-plans-list {
  list-style: none; padding: 0; margin: 0;
}
.profile-plans-list li {
  padding: 4px 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 13px;
}
.profile-plans-list a { color: var(--accent); text-decoration: none; }
.profile-plans-list a:hover { text-decoration: underline; }

/* Step with a missing mentor (cascade-delete leftover) */
.plan-step.mentor-missing { border-left-color: var(--red); }
.plan-step.mentor-too-low { border-left-color: var(--tier-specialist); }
.plan-step .step-warn {
  color: var(--red); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-step.mentor-too-low .step-warn {
  color: var(--tier-specialist); /* yellow — softer than mentor-missing red */
}
.plan-step .step-applied {
  color: var(--tier-iron); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-step.applied { border-left-color: var(--tier-iron); }

/* Modal field layout */
.modal .field { margin: 10px 0; }
.modal .field label { display: block; margin-bottom: 4px; font-size: 13px; }
.modal .field select, .modal .field input[type="text"] {
  width: 100%;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); padding: 8px 12px; border-radius: 4px;
  font-size: 14px;
}

/* Picker list (replaces tiny radios + dropdowns) */
.modal-picker-list {
  display: flex; flex-direction: column; gap: 8px;
  margin: 12px 0;
  max-height: 60vh; overflow-y: auto;
}
.modal-picker-item {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  text-align: left; cursor: pointer;
  font: inherit; font-size: 14px;
  transition: background 0.12s, border-color 0.12s;
}
.modal-picker-item:hover {
  background: var(--row-hover); border-color: var(--accent);
}
.modal-picker-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.modal-picker-item.danger { border-color: var(--red); color: var(--red); }
.modal-picker-label { font-weight: 600; }
.modal-picker-sub { font-size: 12px; }

/* Confirm-modal message body — multiline, normal-weight prose */
.modal-confirm-msg {
  margin: 8px 0 16px;
  font-size: 14px; line-height: 1.45;
  color: var(--text);
  white-space: normal;
}

/* Bigger, more clickable action buttons in any modal */
.modal .actions button {
  padding: 8px 16px;
  font-size: 14px;
  min-width: 96px;
}
