/* Chime web — ngnote house style. Warm neutral surfaces, serif display + system sans body +
   mono code (all system-font stacks, no web fonts), soft corners, subtle shadow, Sage accent.
   Tokens mirror ../artifact (ngnote) theme.ts + ui.css so the family shares one look. */
:root {
  --bg: #141413;
  --surface: #201f1c;      /* card */
  --surface-2: #1a1a18;    /* panel / chips / toast */
  --border: #2e2d29;
  --text: #eae9e4;
  --muted: #8f8d85;
  --accent: #9aa87f;       /* Sage (dark) — the ngnote default accent */
  --accent-strong: #a8b58f;
  --accent-weak: #262b1e;  /* accent wash */
  --on-accent: #16180f;
  --danger: #e5736b;
  --danger-weak: color-mix(in srgb, var(--danger) 15%, transparent);
  --ok: #7fb083;
  --code: #d5d8df;
  --topbar: rgba(20, 20, 19, 0.85);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --r: 9px;                /* controls */
  --r-lg: 14px;            /* cards / modals */
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 6px 22px rgba(0, 0, 0, 0.30);
}

/* Light mode — auto via the OS unless a theme is forced. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f4f2; --surface: #ffffff; --surface-2: #ecece9; --border: #e5e4e0;
    --text: #201f1c; --muted: #6e6c66; --accent: #6f7d5a; --accent-strong: #5d6a4a;
    --accent-weak: #edf1e6; --on-accent: #ffffff; --danger: #c0453d; --ok: #4c7a53;
    --code: #3a4150; --topbar: rgba(244, 244, 242, 0.85);
    --shadow: 0 1px 2px rgba(17, 20, 28, 0.06), 0 4px 16px rgba(17, 20, 28, 0.07);
  }
}
:root[data-theme="light"] {
  --bg: #f4f4f2; --surface: #ffffff; --surface-2: #ecece9; --border: #e5e4e0;
  --text: #201f1c; --muted: #6e6c66; --accent: #6f7d5a; --accent-strong: #5d6a4a;
  --accent-weak: #edf1e6; --on-accent: #ffffff; --danger: #c0453d; --ok: #4c7a53;
  --code: #3a4150; --topbar: rgba(244, 244, 242, 0.85);
  --shadow: 0 1px 2px rgba(17, 20, 28, 0.06), 0 4px 16px rgba(17, 20, 28, 0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
.hidden { display: none !important; }
code { font-family: var(--mono); font-size: 0.9em; color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--topbar); backdrop-filter: blur(10px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: -0.02em; }
.brand .logo { width: 30px; height: 30px; display: block; border-radius: 7px; }
.account { display: flex; align-items: center; gap: 14px; }
.account #who { color: var(--muted); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* Icon-only button (theme toggle). */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; padding: 0; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--r); transition: 0.13s;
}
.icon-btn:hover { background: var(--accent-weak); color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }

main { max-width: 720px; margin: 0 auto; padding: 34px 24px 90px; }

/* Login */
.login { text-align: center; padding: 90px 0; }
.login h1 { font-family: var(--serif); font-size: 34px; font-weight: 500; letter-spacing: -0.02em; margin: 0 0 8px; }
.login .muted { margin: 0 0 28px; color: var(--muted); }

/* Cards */
.dashboard { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 20px 8px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card h2 { font-family: var(--serif); font-size: 21px; font-weight: 500; margin: 0; letter-spacing: -0.02em; }
.card .muted { font-size: 13.5px; line-height: 1.55; margin: 8px 0 14px; color: var(--muted); }
.count { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); }

/* Lists */
.list { list-style: none; margin: 0 0 14px; padding: 0; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
.row:first-child { border-top: none; }
.row.revoked { opacity: 0.45; }
.row-title { font-size: 15px; font-weight: 600; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.tag { font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 999px; padding: 1px 8px; margin-left: 8px; vertical-align: middle; }
.empty { color: var(--muted); font-size: 13.5px; padding: 6px 0 18px; }

/* New token reveal */
.new-token { background: var(--surface-2); border: 1px solid var(--accent-weak); border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; }
.new-token .muted { font-size: 12px; color: var(--muted); }
.token-reveal { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.token-reveal code { color: var(--accent-strong); word-break: break-all; font-size: 13px; }

/* API docs */
.code {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; margin: 8px 0 14px; overflow-x: auto;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  color: var(--code); white-space: pre;
}
.doc { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; }
.doc-h { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; font-family: var(--mono); }
.doc-p { font-size: 13px; color: var(--muted); margin: 6px 0 4px; line-height: 1.5; }
.verb { color: var(--accent-strong); font-weight: 700; }
.pill { font-size: 10.5px; letter-spacing: 0.03em; text-transform: uppercase; color: var(--accent); background: var(--accent-weak); border: 1px solid var(--accent-weak); border-radius: 999px; padding: 2px 9px; font-family: var(--sans); font-weight: 600; }
.pill.quiet { color: var(--muted); background: var(--surface-2); border-color: var(--border); }
/* Repeat marker sits next to the status pill; text-transform off so "Weekdays" reads naturally. */
.pill.repeat { text-transform: none; letter-spacing: 0; color: var(--muted); background: transparent; border-color: var(--border); }

/* Buttons — ngnote: soft corners, accent-wash ghost hover. */
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
  border-radius: var(--r); border: 1px solid transparent; padding: 9px 16px; transition: 0.13s; line-height: 1;
}
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.big { padding: 12px 24px; font-size: 14.5px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: color-mix(in srgb, #000 10%, var(--accent)); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--accent-weak); color: var(--accent); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.danger:hover { background: var(--danger-weak); }

/* Spinner + toast */
.spinner { width: 24px; height: 24px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 11px 18px; border-radius: var(--r); font-size: 13.5px; box-shadow: var(--shadow);
}

/* Modal */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: 100%; max-width: 420px; padding: 24px; box-shadow: var(--shadow);
}
.modal h3 { font-family: var(--serif); margin: 0 0 6px; font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.modal p { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.modal input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r); padding: 10px 12px; font-size: 14px; font-family: inherit; margin-bottom: 18px; outline: none;
}
.modal input:focus { border-color: var(--accent); }
/* The input already carries the gap to the next block, so pull the chips up against it. */
.modal-choices { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Footer — Chime sits under the ngnote family. */
.footer {
  max-width: 720px; margin: 0 auto; padding: 4px 24px 44px;
  color: var(--muted); font-size: 12px; text-align: center; letter-spacing: 0.01em;
}
.footer a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--border); }
.footer a:hover { color: var(--accent); border-color: var(--accent); }
.footer .sep { color: var(--accent); margin: 0 6px; }

@media (max-width: 560px) {
  .row { flex-direction: column; align-items: flex-start; }
  .row-actions { width: 100%; }

  /* Topbar on phones: tighter, and the email truncates instead of blowing up the layout. */
  .topbar { padding: 12px 14px; gap: 8px; }
  .brand { font-size: 18px; gap: 8px; }
  .brand .logo { width: 26px; height: 26px; }
  .topbar-right { gap: 8px; min-width: 0; }
  .account { gap: 8px; min-width: 0; }
  .account #who {
    max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .btn { padding: 8px 12px; }
  main { padding: 24px 14px 70px; }
}
