* { box-sizing: border-box; }

html[data-theme="dark"] {
  --bg: #14161b;
  --panel: #1b1e25;
  --panel-hover: #21242c;
  --border: #262a33;
  --text-primary: #e9eaee;
  --text-secondary: #9195a3;
  --text-muted: #62666f;
  --accent: #5b8def;
  --accent-soft: rgba(91, 141, 239, 0.14);
  --danger: #e2574c;
  --ok: #3ba55d;
}

html[data-theme="light"] {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --panel-hover: #f0f0ec;
  --border: #e3e1d8;
  --text-primary: #1c1d20;
  --text-secondary: #63656e;
  --text-muted: #9a9ca3;
  --accent: #3866c9;
  --accent-soft: rgba(56, 102, 201, 0.10);
  --danger: #c0392b;
  --ok: #2f9e52;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  object-fit: cover; display: block; flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-secondary); text-decoration: none; font-size: 14px;
}
.nav-item:hover { background: var(--panel-hover); color: var(--text-primary); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}
.account {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; border-radius: 8px;
  background: none; border: none; cursor: pointer; color: var(--text-primary);
  font: inherit;
}
.account:hover { background: var(--panel-hover); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.account-name { flex: 1; text-align: left; font-size: 13px; }

.account-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.account-menu.is-open { display: flex; }
.account-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: 6px; font-size: 13px;
  color: var(--text-primary); text-decoration: none;
  background: none; border: none; cursor: pointer;
  text-align: left; width: 100%; font: inherit;
}
.account-menu-item:hover { background: var(--panel-hover); }
.account-menu-danger { color: var(--danger); }

.theme-icon-dark, .theme-icon-light { display: none; }
html[data-theme="dark"] .theme-icon-dark { display: inline-flex; }
html[data-theme="light"] .theme-icon-light { display: inline-flex; }

.fontsize-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: flex-end; justify-content: center; gap: 1px;
}
.fontsize-icon-a { font-size: 10px; font-weight: 700; line-height: 1; color: currentColor; }
.fontsize-icon-a-big { font-size: 15px; }

.main { flex: 1; padding: 32px 40px; max-width: 1500px; }

/* Text size preference — applied as zoom on the content area only (not the
   sidebar) so dense tables/cards get easier to read without touching every
   px value across style.css/popup.css. */
html[data-fontsize="large"] .main { zoom: 1.15; }
html[data-fontsize="xlarge"] .main { zoom: 1.3; }

.content-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 24px;
}
.eyebrow {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin: 0 0 4px;
}
h1 { font-size: 22px; font-weight: 600; margin: 0; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 340px);
  /*grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));*/
  gap: 14px;
}
.tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}
.tile:hover { border-color: var(--accent); }
.tile-label { font-size: 12px; color: var(--text-secondary); margin: 0 0 8px; }
.tile-value { font-family: 'JetBrains Mono', monospace; font-size: 20px; font-weight: 500; margin: 0; }

.sort-form { display: flex; align-items: center; gap: 8px; }
.sort-label { font-size: 12px; color: var(--text-secondary); }
.sort-form select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
}

.empty-state { color: var(--text-secondary); font-size: 14px; }

.view-tabs { display: flex; gap: 8px; }
.view-tabs .ghost-btn.is-active {
  border-color: var(--accent); color: var(--text-primary); background: var(--accent-soft);
}

.class-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--class-color, var(--accent)); flex-shrink: 0;
}

.roster-table-wrap { overflow-x: auto; }
.roster-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.roster-table th {
  text-align: left; color: var(--text-muted); font-weight: 500; white-space: nowrap;
  padding: 8px 10px; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px;
  border-bottom: 1px solid var(--border);
}
.roster-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
/* Class-colour hint, same wash the card view gets -- --class-tint (set once,
   per-user, from preferences.php) controls how strong it is; --class-color
   is set per-row in roster.php. td's own background paints over this on
   hover, so :hover still wins. */
.roster-table tbody tr { background: color-mix(in srgb, var(--class-color, var(--accent)) var(--class-tint, 8%), var(--panel)); }
.roster-table tbody tr td:first-child { border-left: 3px solid var(--class-color, var(--accent)); }
.roster-table tbody tr:hover td { background: var(--panel-hover); }
.roster-char-cell { display: flex; align-items: center; gap: 8px; }
.roster-char-thumb { border-radius: 6px; flex-shrink: 0; }
.roster-char-name { font-weight: 600; font-size: 13px; text-decoration: none; color: var(--text-primary); white-space: nowrap; }
.roster-char-name:hover { text-decoration: underline; }
.roster-char-meta { font-size: 11px; color: var(--text-secondary); margin: 1px 0 0; white-space: nowrap; }
.roster-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.roster-actions .ghost-btn { padding: 4px 8px; font-size: 11px; }
.gear-panel-row td { background: var(--panel-hover); padding: 12px; }

.char-grid {
  display: grid;
  /*grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));*/
  /*grid-template-columns: repeat(auto-fill, 540px);*/
  grid-template-columns: repeat(3, 540px);
  gap: 14px;
}

.char-card {
  background: color-mix(in srgb, var(--class-color, var(--accent)) var(--class-tint, 8%), var(--panel));
  border: 1px solid var(--border);
  border-left: 3px solid var(--class-color, var(--accent));
  border-radius: 12px;
  padding: 16px;
}

.char-card-head { display: flex; align-items: center; gap: 12px; }
.char-thumb { border-radius: 8px; flex-shrink: 0; }
.char-id { flex: 1; min-width: 0; }
.char-name { font-weight: 600; font-size: 15px; text-decoration: none; }
.char-name:hover { text-decoration: underline; }
.char-meta { font-size: 12px; color: var(--text-secondary); margin: 2px 0 0; }
.char-ilvl { text-align: right; flex-shrink: 0; }
.char-ilvl .tile-value { font-size: 18px; display: block; }
.char-ilvl .tile-label { font-size: 11px; }

.char-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin: 14px 0;
  font-size: 12px;
  color: var(--text-secondary);
}
.stat { display: flex; align-items: center; gap: 6px; }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--text-muted);
}
.status-dot.is-ok { background: var(--ok); }
.status-dot.is-bad { background: var(--danger); }

.char-professions { display: flex; align-items: center; gap: 6px; min-height: 24px; margin-bottom: 12px; }
.char-professions img { border-radius: 4px; }
.prof-empty { font-size: 12px; color: var(--text-secondary); }

.char-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ghost-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--text-primary); }
.chevron { transition: transform 0.15s ease; }
.gear-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.gear-panel { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.gear-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.gear-table th {
  text-align: left; color: var(--text-muted); font-weight: 500;
  padding: 4px 8px; text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px;
}
.gear-table td { padding: 6px 8px; border-top: 1px solid var(--border); }
.gear-table tr.is-lowest td:first-child { color: var(--danger); font-weight: 500; }
.quality-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--dot-color, var(--text-muted)); margin-right: 6px;
}

/* "Veteran 3 of 8" gear-upgrade-track progress, in the gear table's Track
   column -- a small filled/unfilled segment bar plus a text label, colored
   by the track's own tier colour (qualityColors doubles for this, same as
   the plain track-name tag it replaced). */
.track-progress { display: inline-flex; align-items: center; gap: 6px; }
.track-bar { display: inline-flex; gap: 2px; }
.track-seg {
  width: 6px; height: 10px; border-radius: 1px;
  background: var(--border);
}
.track-seg.is-filled { background: var(--track-color, var(--accent)); }
.track-label { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    flex-direction: row; align-items: center; overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .brand { padding: 0 12px 0 0; }
  .sidebar-footer {
    border-top: none; border-left: 1px solid var(--border);
    margin: 0 0 0 12px; padding: 0 0 0 12px;
  }
  .main { padding: 24px 20px; }
}

.tile-green {
    background-color: #166534;
}
.tile-yellow {
    background-color: #854d0e;
}