/* Quizrs — hi-fi design tokens & components
   Crisp, productive, minimal. Hairline borders, restrained shadow, one accent. */

:root {
  /* accent — overridden by Tweaks */
  --accent: #4f46e5;
  --accent-ink: #3730a3;
  --accent-tint: #eef0ff;
  --accent-contrast: #ffffff;

  /* radius scale — --r set by Tweaks (base unit) */
  --r: 12px;
  --r-sm: calc(var(--r) * 0.58);
  --r-lg: calc(var(--r) * 1.34);
  --r-pill: 999px;

  /* density — --space set by Tweaks */
  --space: 1;
  --gap-1: calc(4px * var(--space));
  --gap-2: calc(8px * var(--space));
  --gap-3: calc(12px * var(--space));
  --gap-4: calc(16px * var(--space));
  --gap-5: calc(20px * var(--space));
  --gap-6: calc(24px * var(--space));
  --gap-8: calc(32px * var(--space));

  /* neutral surfaces — light */
  --bg:        #fbfbfc;
  --surface:   #ffffff;
  --surface-2: #f6f6f8;
  --surface-3: #efeff2;
  --border:    #e7e7ea;
  --border-2:  #ededf0;
  --hairline:  #f0f0f3;

  /* text */
  --ink:    #1a1a1e;
  --ink-2:  #54545c;
  --ink-3:  #8a8a93;
  --ink-4:  #b6b6bd;

  /* semantic */
  --green: #18a058;  --green-tint: #e7f6ee;
  --amber: #c8881b;  --amber-tint: #fbf0db;
  --red:   #d64545;  --red-tint:   #fbe9e9;
  --blue:  #2f74d0;  --blue-tint:  #e7f0fb;

  --shadow-sm: 0 1px 2px rgba(20,20,30,.05);
  --shadow:    0 2px 6px rgba(20,20,30,.06), 0 1px 2px rgba(20,20,30,.04);
  --shadow-lg: 0 14px 40px rgba(20,20,40,.12), 0 2px 8px rgba(20,20,40,.06);

  --font: "Hanken Grotesk", -apple-system, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

[data-theme="dark"] {
  --bg:        #0c0c0e;
  --surface:   #161619;
  --surface-2: #1d1d21;
  --surface-3: #26262b;
  --border:    #2a2a30;
  --border-2:  #232328;
  --hairline:  #1e1e22;

  --ink:    #f4f4f6;
  --ink-2:  #aeaeb6;
  --ink-3:  #7a7a83;
  --ink-4:  #55555d;

  --accent-tint: #20203a;

  --green-tint: #11271c;
  --amber-tint: #2a2110;
  --red-tint:   #2c1717;
  --blue-tint:  #131f31;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 2px 8px rgba(0,0,0,.45);
  --shadow-lg: 0 18px 50px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }
::selection { background: var(--accent-tint); color: var(--accent-ink); }

/* dark-mode accent ink stays readable */
[data-theme="dark"] .accent-ink-fix { color: #c7c4ff; }

/* ── App shell ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 244px 1fr;
  height: 100%;
  background: var(--bg);
}
.app.compact { grid-template-columns: 224px 1fr; }

.sidebar {
  display: flex; flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  gap: 2px;
  min-height: 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: block;
  object-fit: contain;
  box-shadow: var(--shadow-sm);
}
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.3px; }

.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: .6px;
  color: var(--ink-4); text-transform: uppercase;
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
  cursor: pointer; user-select: none;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
[data-theme="dark"] .nav-item.active { color: #c7c4ff; }
.nav-item .ic { color: currentColor; opacity: .85; flex: 0 0 auto; }
.nav-item .nav-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .count {
  margin-left: auto; font-size: 12px; font-family: var(--mono);
  color: var(--ink-4); font-weight: 500;
}

.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--hairline); }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: var(--r-sm); cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip .name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip > div { min-width: 0; }
.user-chip .role { font-size: 11px; color: var(--ink-3); font-family: var(--mono); }

/* ── Main column ───────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px; height: 60px; flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -.3px; margin: 0; }
.topbar .crumb { color: var(--ink-3); font-weight: 500; }
.topbar .spacer { flex: 1; }

.screen { flex: 1; overflow-y: auto; min-height: 0; }
.screen-pad { padding: 28px; max-width: 1180px; margin: 0 auto; }
.compact .screen-pad { padding: 20px; }

/* scrollbar */
.screen::-webkit-scrollbar { width: 10px; }
.screen::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 3px solid var(--bg); }
.screen::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

/* ── Search input ──────────────────────────────────────── */
.search {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid transparent;
  color: var(--ink-3); min-width: 220px;
  transition: border-color .12s, background .12s;
}
.search:focus-within { border-color: var(--accent); background: var(--surface); }
.search input {
  border: 0; background: transparent; outline: 0;
  font: inherit; font-size: 14px; color: var(--ink); flex: 1; min-width: 0;
}
.search input::placeholder { color: var(--ink-4); }
.search kbd {
  font-family: var(--mono); font-size: 11px; color: var(--ink-4);
  border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px;
  background: var(--surface);
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-sm);
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.1px;
  border: 1px solid transparent; cursor: pointer; user-select: none;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(.5px); }
.btn .ic { margin: 0 -2px; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 90%, #000); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-soft { background: var(--surface-2); color: var(--ink); }
.btn-soft:hover { background: var(--surface-3); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 8px; }

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }

/* ── Badges / pills ────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap;
  padding: 4px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--ink-2);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-accent { background: var(--accent-tint); color: var(--accent-ink); }
[data-theme="dark"] .badge-accent { color: #c7c4ff; }
.badge-green { background: var(--green-tint); color: var(--green); }
.badge-amber { background: var(--amber-tint); color: var(--amber); }
.badge-red   { background: var(--red-tint);   color: var(--red); }
.badge-blue  { background: var(--blue-tint);  color: var(--blue); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--ink-2); }

/* ── Avatar ────────────────────────────────────────────── */
.avatar {
  border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; color: #fff; flex: 0 0 auto;
  font-size: 12px; letter-spacing: -.2px;
}

/* ── Progress ──────────────────────────────────────────── */
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s cubic-bezier(.2,.7,.2,1); }

/* ── Stat tile ─────────────────────────────────────────── */
.stat {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
}
.stat .k { font-size: 12.5px; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .v { font-size: 27px; font-weight: 700; letter-spacing: -.8px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.stat .d.up { color: var(--green); }
.stat .d.down { color: var(--red); }

/* ── misc type ─────────────────────────────────────────── */
.h-sec { font-size: 13px; font-weight: 700; letter-spacing: -.1px; white-space: nowrap; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.tnum { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.row { display: flex; align-items: center; gap: var(--gap-3); }
.col { display: flex; flex-direction: column; }

/* fade-in on screen switch */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fade { animation: fadeUp .26s cubic-bezier(.2,.7,.2,1); }

/* app integration additions */
@keyframes qz-spin-kf { to { transform: rotate(360deg); } }
.qz-spin {
  display: inline-block; border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: qz-spin-kf .7s linear infinite;
}
.qz-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20,20,28,.38);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: grid; place-items: start center; padding-top: 12vh;
}
[data-theme="dark"] .qz-modal-backdrop { background: rgba(0,0,0,.5); }
.qz-palette {
  width: 100%; max-width: 540px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.qz-palette-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 16px;
  cursor: pointer; border: 0; width: 100%; background: transparent;
  font: inherit; color: inherit; text-align: left;
}
.qz-palette-row.on, .qz-palette-row:hover { background: var(--surface-2); }
