/* Smart Crew "Warm v2" design system. */
:root {
  --ember-500: #CC6B49;
  --ember-600: #B0553A;
  --ember-300: #E39A7C;
  /* ember-50 is not in the palette sheet: derived as a 10% Ember-500 tint over Card. */
  --ember-50: color-mix(in srgb, #CC6B49 10%, #FDFCF9);
  --ink: #1A1915;
  --parchment: #F7F5EF;
  --card: #FDFCF9;
  --sand: #EEEAE0;
  --line: #DEDACE;
  --stone: #B3AFA3;
  --mute: #7A766B;
  --graphite: #5E5B53;
  --night: #2A2925;
  --dusk: #6F92B8;
  --sage: #7F8F62;

  --bg: var(--parchment);
  --surface: var(--card);
  --surface-2: var(--sand);
  --border: var(--line);
  --text: var(--ink);
  --text-2: var(--graphite);
  --accent: var(--ember-600);
  --accent-text: var(--ember-600);
  --on-accent: #FFFFFF;
  --shadow: 0 1px 2px rgba(74, 52, 36, .06), 0 8px 24px rgba(74, 52, 36, .08);
  --focus: 0 0 0 3px color-mix(in srgb, var(--ember-600) 35%, transparent);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --enter: 320ms cubic-bezier(.2, .8, .2, 1);
  --exit: 200ms cubic-bezier(.4, 0, 1, 1);

  --ar: "Readex Pro", "Hanken Grotesk", sans-serif;
  --latin: "Hanken Grotesk", "Readex Pro", sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
  --serif: "Source Serif 4", serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141310;
    --surface: #1F1E1A;
    --surface-2: #2A2925;
    --border: #3A3833;
    --text: #F2EFE7;
    --text-2: #B3AFA3;
    --accent: #CC6B49;
    --accent-text: #E39A7C;
    --on-accent: #1A1915;
    --ember-50: color-mix(in srgb, #CC6B49 16%, #1F1E1A);
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--ar);
  font-size: 17px;
  font-weight: 300;
  line-height: 1.85;
}
h1, h2, h3 { font-family: var(--ar); color: var(--text); font-weight: 600; line-height: 1.3; margin: 0; }
h1 { font-size: 56px; }
h2 { font-size: 32px; }
h3 { font-size: 21px; }
strong { color: var(--text); font-weight: 600; }
.latin { font-family: var(--latin); }
.mono { font-family: var(--mono); font-size: 15px; }
.en { font-family: var(--latin); font-size: 14px; color: var(--text-2); font-weight: 500; }
.num-large { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; font-size: 40px; color: var(--text); line-height: 1; }
[hidden] { display: none !important; }
a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 40px; }
@media (max-width: 640px) { .wrap { padding: 0 20px; } h1 { font-size: 40px; } h2 { font-size: 26px; } }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; gap: var(--s4); min-height: 80px; }
.topbar nav { display: flex; gap: var(--s1); flex-wrap: nowrap; flex: 1; overflow-x: auto; }
.topbar .who { display: flex; gap: var(--s3); align-items: center; flex: none; }

.tab {
  background: none; border: 1px solid transparent; border-radius: 999px; padding: var(--s1) var(--s3); white-space: nowrap;
  font: inherit; font-size: 16px; color: var(--text-2); cursor: pointer;
}
.tab[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 400; }

main { padding: var(--s6) 0 var(--s8); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }

/* ---------- brand ---------- */
.lockup { display: flex; align-items: center; gap: var(--s3); text-decoration: none; }
.lockup .tile { width: 52px; height: 52px; border-radius: 15px; display: block; flex: none; }
.lockup .wordmark { font-family: var(--latin); font-weight: 700; font-size: 22px; color: var(--text); text-transform: lowercase; line-height: 1; }
.lockup .sub { font-size: 14px; color: var(--text-2); line-height: 1.3; }
.logo-placeholder {
  width: 52px; height: 52px; border-radius: 15px; border: 2px dashed var(--ember-600); flex: none;
  display: grid; place-items: center; font-family: var(--mono); font-size: 10px; color: var(--accent-text); text-align: center; line-height: 1.2;
}

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: var(--s6); box-shadow: var(--shadow); }
.card + .card { margin-top: var(--s5); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: var(--s5); }
.stat .label { font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2); border-radius: 12px; padding: 10px 18px;
  font: inherit; font-size: 16px; font-weight: 400; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: background var(--exit), border-color var(--exit);
  min-height: 44px; text-decoration: none;
}
.btn:hover { border-color: var(--stone); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.link { border: none; background: none; text-decoration: underline; color: var(--accent-text); padding: 0 var(--s1); min-height: 0; }
.btn.small { padding: 4px 10px; min-height: 36px; font-size: 15px; gap: 6px; }
.btn.small svg { width: 18px; height: 18px; }
.btn:disabled { background: var(--surface-2); color: var(--text-2); border-color: var(--surface-2); cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn .arrow { transform: scaleX(-1); } /* mirrored for RTL */
.btn-row { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
label.field { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
label.field > span { color: var(--text); font-weight: 400; font-size: 16px; display: flex; gap: var(--s2); align-items: baseline; }
input, select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; width: 100%; min-height: 44px; line-height: 1.6;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ember-600); box-shadow: var(--focus); }
input[dir="ltr"], .ltr { direction: ltr; text-align: left; }
textarea { min-height: 110px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s4); }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }
.hint { font-size: 15px; color: var(--text-2); margin: 0 0 var(--s4); }
.error { color: var(--accent-text); font-weight: 400; min-height: 1.85em; margin: 0; }

.filters { display: flex; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.filters .search { flex: 2 1 260px; position: relative; }
.filters .search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; }
.filters .search input { padding-inline-start: 42px; }
.filters select { flex: 1 1 160px; width: auto; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th { background: var(--surface-2); color: var(--text); font-weight: 400; text-align: start; padding: var(--s3); white-space: nowrap; }
th .en { display: block; font-size: 12px; line-height: 1.2; }
td { padding: var(--s3); border-top: 1px solid var(--border); vertical-align: middle; color: var(--text); line-height: 1.5; }
td.nowrap, td.mono { white-space: nowrap; }
td.secondary { color: var(--text-2); }
tr.row-expired td:first-child { box-shadow: inset -4px 0 0 var(--ember-600); }
tr.row-soon td:first-child { box-shadow: inset -4px 0 0 var(--ember-300); }
.empty { padding: var(--s7); text-align: center; }
.actions { display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: nowrap; }
.masked { font-family: var(--mono); letter-spacing: 2px; color: var(--text-2); }

/* ---------- pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 12px 2px 10px; font-size: 14px; font-weight: 400; white-space: nowrap; border: 1px solid transparent; }
.pill svg { width: 16px; height: 16px; }
.pill.expired { background: var(--ember-600); color: #FFFFFF; }
/* Spec: ember-300 on ember-50. Ember-300 text is below 4.5:1 there, so it carries the border/icon and Ink carries the text. */
.pill.soon { background: var(--ember-50); color: var(--text); border-color: var(--ember-300); }
.pill.soon svg { color: var(--ember-300); }
.pill.active { background: color-mix(in srgb, var(--sage) 16%, var(--surface)); color: var(--text); border-color: var(--sage); }
.pill.active svg { color: var(--sage); }
.pill.info { background: color-mix(in srgb, var(--dusk) 14%, var(--surface)); color: var(--text); border-color: var(--dusk); }
.pill.neutral { background: var(--surface-2); color: var(--text-2); }
@media (prefers-color-scheme: dark) { .pill.expired { background: var(--ember-500); color: var(--ink); } }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s6) 20px; }
.auth .card { width: 100%; max-width: 460px; }
.auth .lockup { margin-bottom: var(--s6); }
.auth h2 { margin-bottom: var(--s2); }
.auth footer { margin-top: var(--s5); text-align: center; font-family: var(--latin); color: var(--mute); font-size: 15px; }
.qr { display: block; width: 220px; height: 220px; margin: var(--s4) auto; border-radius: 12px; background: #FFFFFF; padding: 8px; }

/* ---------- dialogs ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text-2);
  width: min(640px, calc(100vw - 32px)); box-shadow: var(--shadow); max-height: calc(100vh - 48px);
}
dialog[open] { animation: enter var(--enter); }
dialog::backdrop { background: rgba(26, 25, 21, .45); }
dialog .dlg-body { padding: var(--s6); overflow-y: auto; }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); gap: var(--s4); }
dialog.wide { width: min(1000px, calc(100vw - 32px)); }
.secret-box { display: flex; gap: var(--s2); align-items: stretch; }
.secret-box output { flex: 1; font-family: var(--mono); direction: ltr; text-align: left; background: var(--surface-2); border-radius: 12px; padding: 10px 14px; color: var(--text); word-break: break-all; white-space: pre-wrap; user-select: all; }
.countdown { font-family: var(--mono); color: var(--accent-text); }
.warning-box { border: 1px solid var(--ember-600); background: var(--ember-50); border-radius: 12px; padding: var(--s4); color: var(--text); margin-bottom: var(--s4); display: flex; gap: var(--s3); }
.warning-box svg { flex: none; width: 24px; height: 24px; color: var(--accent-text); }

/* ---------- toast ---------- */
.toast {
  position: fixed; inset-inline-start: 24px; bottom: 24px; background: var(--night); color: #F2EFE7; border-radius: 12px;
  padding: var(--s3) var(--s5); animation: enter var(--enter); z-index: 10; max-width: calc(100vw - 48px);
}
@media (prefers-color-scheme: dark) { .toast { background: #2A2925; border: 1px solid #3A3833; } }

@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* icons: 24 grid, 1.75 stroke, round caps, one ember node */
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon .node { fill: var(--ember-500); stroke: none; }
.pill .icon .node, .btn.primary .icon .node { fill: currentColor; }
