/* luxurysearch — interface styles
   One sheet, no framework. Tokens first, then layout, then components. */

:root {
  --paper: #f5f3ee;
  --surface: #fffefb;
  --surface-2: #faf8f3;
  --ink: #1d1b18;
  --ink-2: #4a4640;
  --ink-3: #7b766d;
  --rule: #e4dfd5;
  --rule-strong: #cfc8ba;
  --accent: #6e5226;
  --accent-ink: #fffaf0;
  --accent-soft: #f1e9da;
  --good: #3f6b4a;
  --good-soft: #e5eee5;
  --warn: #8a5d12;
  --warn-soft: #f6ebd5;
  --bad: #8e3b2f;
  --bad-soft: #f5e1dc;
  --focus: #9a7a3f;
  --shadow: 0 1px 0 rgba(29, 27, 24, .04), 0 1px 2px rgba(29, 27, 24, .06);
  --radius: 6px;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151412;
    --surface: #1c1b18;
    --surface-2: #211f1c;
    --ink: #ece7dd;
    --ink-2: #c3bdb1;
    --ink-3: #8f897e;
    --rule: #2f2c27;
    --rule-strong: #403c35;
    --accent: #c9a465;
    --accent-ink: #1a1408;
    --accent-soft: #2c2519;
    --good: #8cb894;
    --good-soft: #1f2a21;
    --warn: #d8ae62;
    --warn-soft: #2d2517;
    --bad: #d98b7e;
    --bad-soft: #2f1f1b;
    --focus: #c9a465;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 20px 0; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--rule);
  background: var(--surface-2);
  padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 5px;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center;
  font: 600 13px/1 var(--mono); letter-spacing: -.04em;
}
.brand-name { font-weight: 600; letter-spacing: -.01em; }
.brand-sub { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 400; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none;
}
.nav a:hover { background: var(--rule); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.nav .count { font: 11.5px var(--mono); opacity: .7; }
.nav-label { margin: 18px 10px 6px; color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 12.5px; }
.sidebar-foot form { display: inline; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink-2); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; }

.main { min-width: 0; padding: 26px 32px 64px; max-width: 1480px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .lede { color: var(--ink-3); margin: 4px 0 0; max-width: 70ch; }
.crumbs { color: var(--ink-3); font-size: 12.5px; margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.mobile-bar { display: none; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.card-head .meta { color: var(--ink-3); font-size: 12.5px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.stack > * + * { margin-top: 16px; }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi-label { color: var(--ink-3); font-size: 12px; }
.kpi-value { font: 600 26px/1.2 var(--sans); letter-spacing: -.02em; margin-top: 2px; }
.kpi-note { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.kpi-note .up { color: var(--good); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th, .data td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: middle; white-space: nowrap; }
.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--ink-3); font-weight: 500; font-size: 12px; }
.data th a { text-decoration: none; }
.data th a[aria-sort]::after { content: " ↓"; }
.data th a[aria-sort="ascending"]::after { content: " ↑"; }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr:last-child td { border-bottom: 0; }
.data td.num, .data th.num { text-align: right; }
.data td.num { font-family: var(--mono); font-size: 12.5px; }
.data td.wrap { white-space: normal; min-width: 220px; }
.data td.muted { color: var(--ink-3); }
.data .check { width: 32px; padding-right: 0; }
.row-link { text-decoration: none; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }

/* ---------- identity cell ---------- */
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font: 600 12px/1 var(--sans); text-transform: uppercase;
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.who-text { min-width: 0; }
.who-handle { font-weight: 500; text-decoration: none; }
.who-name { display: block; color: var(--ink-3); font-size: 12.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- tags / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--rule-strong);
  font-size: 12px; line-height: 19px; color: var(--ink-2);
  background: var(--surface);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-3)); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { display: inline-block; padding: 0 7px; border-radius: 4px; font-size: 11.5px; line-height: 19px; font-weight: 500; background: var(--rule); color: var(--ink-2); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.platform { font: 500 11.5px var(--mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- score ---------- */
.score { display: inline-flex; align-items: center; gap: 8px; font: 500 12.5px var(--mono); }
.score-bar { width: 54px; height: 5px; border-radius: 3px; background: var(--rule); overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--ink-3); }
.score[data-band="high"] .score-bar i { background: var(--accent); }
.score[data-band="mid"] .score-bar i { background: var(--ink-2); }
.score-big { font: 600 40px/1 var(--sans); letter-spacing: -.03em; }

/* ---------- category tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-3); text-decoration: none; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 500; }
.tabs .n { font: 11.5px var(--mono); color: var(--ink-3); }
.tabs .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---------- filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters .grow { flex: 1 1 220px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--surface-2); flex-wrap: wrap; }
.toolbar .meta { color: var(--ink-3); font-size: 12.5px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=url], input[type=email], select, textarea {
  width: 100%; padding: 6px 9px; min-height: 32px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 13.5px/1.4 var(--sans);
}
textarea { min-height: 90px; resize: vertical; }
select { padding-right: 26px; }
.filters input, .filters select { width: auto; }
.filters .grow input { width: 100%; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; vertical-align: -2px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; color: var(--ink-2); white-space: nowrap; }
.field { margin-bottom: 14px; }
.field .help { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.field .error { color: var(--bad); font-size: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 600; font-size: 13px; margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 500 13px/1 var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { min-height: 26px; padding: 0 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--rule); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-group { display: inline-flex; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.btn-group .btn:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group .btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); position: relative; }

/* ---------- messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 9px 12px; border: 1px solid var(--rule); border-left: 3px solid var(--ink-3); border-radius: var(--radius); background: var(--surface); margin-bottom: 6px; }
.messages .success { border-left-color: var(--good); }
.messages .error { border-left-color: var(--bad); }
.messages .warning { border-left-color: var(--warn); }

/* ---------- definition lists ---------- */
dl.props { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 7px 12px; margin: 0; }
dl.props dt { color: var(--ink-3); font-size: 12.5px; }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- bars (category breakdown) ---------- */
.hbar { position: relative; height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; min-width: 80px; }
.hbar i { position: absolute; inset: 0 auto 0 0; background: var(--c, var(--ink-2)); border-radius: 3px; }

/* ---------- funnel ---------- */
.funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.funnel div { padding: 12px 16px; }
.funnel div + div { border-left: 1px solid var(--rule); }
.funnel b { display: block; font: 600 18px/1.3 var(--sans); }
.funnel span { color: var(--ink-3); font-size: 12px; }

/* ---------- timeline / evidence ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--rule); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--ink-3); font-size: 12px; }
.timeline .what { font-weight: 500; }
.quote { margin: 4px 0 0; padding-left: 10px; border-left: 2px solid var(--rule-strong); color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.evidence { margin: 0; padding-left: 18px; color: var(--ink-2); }
.evidence li + li { margin-top: 4px; }

pre.log { margin: 0; padding: 14px 16px; background: var(--surface-2); font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 560px; overflow: auto; }

/* ---------- pagination ---------- */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--rule); color: var(--ink-3); font-size: 12.5px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card .brand { padding: 0 0 22px; }
.login-card .card-body { padding: 22px; }

/* ---------- htmx ---------- */
.htmx-request .busy, .busy.htmx-request { opacity: .55; transition: opacity .15s ease; }
.spinner { display: none; color: var(--ink-3); font-size: 12px; }
.htmx-request .spinner, .htmx-request.spinner { display: inline; }

.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.side { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; display: none; }
  .shell.nav-open .sidebar { display: flex; }
  .mobile-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--rule); background: var(--surface-2); }
  .main { padding: 18px 16px 48px; }
  .kpis, .funnel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3), .funnel div:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3), .funnel div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .filters select { flex: 1 1 140px; }
  dl.props { grid-template-columns: 110px minmax(0, 1fr); }
}

/* account verification code prompt */
.verify { border-color: var(--warn); background: var(--warn-soft); }
.verify-form { display: flex; gap: 8px; margin: 10px 0 8px; }
.verify-form input { flex: 1 1 auto; min-width: 0; font-family: var(--mono, "IBM Plex Mono", monospace); font-size: 18px; letter-spacing: .2em; }
.badge-warn { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 500; text-decoration: none; }

/* help cards in narrow side columns: label above text */
dl.props.stacked, .grid.side dl.props.stacked { grid-template-columns: minmax(0, 1fr); gap: 2px; }
dl.props.stacked dt { font-weight: 600; color: var(--ink); margin-top: 12px; }
dl.props.stacked dt:first-child { margin-top: 0; }

td.rationale { min-width: 240px; max-width: 320px; }
