/* Be QA Engineer
   Layout: a test-run console. One reading column; cards and lists styled like test cases with status pills.
   Bottom tab bar on phones, top tabs on wider screens. */
:root {
  --paper: #f3f5f6;
  --surface: #ffffff;
  --sunken: #e9edf0;
  --ink: #13202a;
  --muted: #566571;
  --line: #d6dde2;
  --accent: #2341c4;
  --accent-ink: #ffffff;
  --accent-soft: #e6eafb;
  --mark: #ffe58a;
  --pass: #1d7a46;
  --pass-soft: #e2f3e8;
  --warn: #8a5800;
  --warn-soft: #fdf0d6;
  --fail: #b42a2a;
  --fail-soft: #fbe6e4;
  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body: "BeQA Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "BeQA Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1418; --surface: #162027; --sunken: #111a20; --ink: #e4ebef; --muted: #93a2ac; --line: #28353d;
    --accent: #8aa2ff; --accent-ink: #0e1418; --accent-soft: #1f2850; --mark: #6b5712;
    --pass: #5fcf8c; --pass-soft: #143323; --warn: #f2c066; --warn-soft: #352a12; --fail: #ff8a80; --fail-soft: #3a1a19;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1418; --surface: #162027; --sunken: #111a20; --ink: #e4ebef; --muted: #93a2ac; --line: #28353d;
  --accent: #8aa2ff; --accent-ink: #0e1418; --accent-soft: #1f2850; --mark: #6b5712;
  --pass: #5fcf8c; --pass-soft: #143323; --warn: #f2c066; --warn-soft: #352a12; --fail: #ff8a80; --fail-soft: #3a1a19;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); }
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1:focus { outline: none; }
p { margin: 0; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.label { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--mono); font-size: .78rem; letter-spacing: .02em; color: var(--muted); font-variant-numeric: tabular-nums; }
.lede { color: var(--muted); max-width: 60ch; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .9rem; }
.note { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }
.icon { width: 22px; height: 22px; flex: none; }
kbd { font-family: var(--mono); font-size: .7rem; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; opacity: .6; }

/* ---------- header and navigation ---------- */
#app { max-width: 780px; margin: 0 auto; }
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding-block: 12px; background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; margin-right: auto; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font: 600 13px var(--mono); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.12rem; }
.tabs { display: flex; gap: 2px; }
.tabs button {
  display: flex; align-items: center; gap: 6px; border: 0; background: none;
  padding: 7px 12px; border-radius: 999px; color: var(--muted); font-size: .92rem; font-weight: 500;
}
.tabs button .icon { width: 18px; height: 18px; }
.tabs button:hover { color: var(--ink); background: var(--sunken); }
.tabs button[aria-current="page"] { background: var(--ink); color: var(--paper); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.icon-btn[aria-current="page"] { color: var(--accent); border-color: var(--accent); }

.main { display: flex; flex-direction: column; gap: 28px; padding-block: 24px 64px; }

@media (max-width: 720px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    justify-content: space-around; gap: 0;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .tabs button { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: .72rem; border-radius: 10px; flex: 1; }
  .tabs button .icon { width: 22px; height: 22px; }
  .tabs button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .tabs.is-hidden-mobile { display: none; }
  .main { padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px)); }
  .in-session .main { padding-bottom: 48px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 9px 18px; font-weight: 600; font-size: .92rem; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.danger { color: var(--fail); border-color: var(--fail); }
.btn.lg { padding: 12px 22px; font-size: 1rem; }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
.back { align-self: flex-start; background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; font-size: .92rem; }

/* ---------- page heads and blocks ---------- */
.hero, .page-head { display: flex; flex-direction: column; gap: 12px; }
.hero h1 { font-size: clamp(2rem, 6.5vw, 3rem); font-weight: 800; letter-spacing: -.02em; }
.page-head h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; letter-spacing: -.015em; }
.muted-h { color: var(--muted); font-weight: 700; font-size: .55em; letter-spacing: 0; display: block; margin-top: 4px; }
.hero .actions { margin-top: 6px; }
.block { display: flex; flex-direction: column; gap: 14px; }
.block-head { display: flex; flex-direction: column; gap: 4px; }
.block-head h2 { font-size: 1.3rem; }
.block-head p { color: var(--muted); font-size: .94rem; }

.strip { display: flex; flex-wrap: wrap; gap: 12px 32px; padding-block: 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.strip div { display: flex; flex-direction: column; gap: 2px; }
.strip strong { font-family: var(--display); font-size: 1.7rem; line-height: 1; }
.strip small { font-size: .6em; color: var(--muted); }

.notice { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; font-size: .92rem; }
.moved { flex-direction: column; align-items: flex-start; gap: 12px; border: 1px solid var(--accent); }
.moved-text { display: flex; flex-direction: column; gap: 2px; }

/* ---------- meters ---------- */
.meter { position: relative; display: block; height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.meter i, .meter b { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.meter b { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.meter i { background: var(--accent); z-index: 1; transition: width .3s; }
.meter.thin { height: 4px; }

/* ---------- topics and weak spots ---------- */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.topic {
  text-align: left; display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  transition: border-color .15s, transform .15s;
}
.topic:hover { border-color: var(--accent); transform: translateY(-1px); }
.topic-name { font-family: var(--display); font-weight: 700; font-size: 1.08rem; }
.topic-desc { color: var(--muted); font-size: .86rem; line-height: 1.45; flex: 1; }
.weak { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.weak-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px auto; gap: 14px; align-items: center; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 13px 16px; }
.weak-row:first-child { border-top: 0; }
.weak-row:hover { background: var(--accent-soft); }
.weak-name { font-weight: 600; }
.weak-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.weak-bar i { display: block; height: 100%; background: var(--fail); border-radius: 99px; }

/* ---------- flashcard ---------- */
.session-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flash {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: clamp(20px, 5vw, 32px); display: flex; flex-direction: column; gap: 18px; min-width: 0;
}
.flash-meta { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.flash-q { font-size: clamp(1.4rem, 4.5vw, 1.9rem); font-weight: 700; letter-spacing: -.01em; }
.flash-a { border-top: 2px dashed var(--line); padding-top: 18px; }
.flash-a, .prose, .card-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aside { background: var(--sunken); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: .94rem; }
.aside.warn { background: var(--warn-soft); }
.aside ul { margin: 0; padding-left: 1.2em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-family: var(--mono); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; background: var(--sunken); color: var(--muted); border: 1px solid transparent; }
.chip.ghost { background: none; border-color: var(--line); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.toggle { cursor: pointer; text-transform: none; letter-spacing: 0; font-family: var(--body); font-size: .88rem; padding: 6px 12px; border-color: var(--line); background: var(--surface); }
.chip.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.timer { font-size: 1rem; padding: 2px 10px; border-radius: 99px; background: var(--sunken); color: var(--ink); }
.timer.over { background: var(--fail-soft); color: var(--fail); }

.answer-bar { display: flex; flex-direction: column; gap: 10px; }
.rates { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rates.three { grid-template-columns: repeat(3, 1fr); }
.rate {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px 6px;
}
.rate b { font-weight: 600; }
.rate span { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.rate-again { border-bottom: 3px solid var(--fail); }
.rate-hard { border-bottom: 3px solid var(--warn); }
.rate-good { border-bottom: 3px solid var(--pass); }
.rate-easy { border-bottom: 3px solid var(--accent); }
.rate:hover { background: var(--sunken); }
@media (max-width: 420px) { .rate kbd { display: none; } }

/* ---------- prose (lessons, answers, tasks) ---------- */
.prose { max-width: 68ch; }
.prose h3, .flash-a h3, .card-body h3 { font-size: 1.15rem; margin-top: 8px; }
.prose ul, .prose ol, .flash-a ul, .flash-a ol, .card-body ul, .card-body ol, .hints ul { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 5px; }
strong { font-weight: 600; }
mark { background: var(--mark); color: inherit; padding: 0 3px; border-radius: 3px; }
code { font-family: var(--mono); font-size: .86em; background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }
pre.code { margin: 0; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font-size: .84rem; line-height: 1.55; }
pre.code code { background: none; padding: 0; font-size: inherit; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 420px; font-size: .92rem; }
.table-wrap th, .table-wrap td { text-align: left; padding: 9px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.table-wrap th { border-top: 0; font-family: var(--mono); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.history { min-width: 0 !important; }
.history .num { font-variant-numeric: tabular-nums; }

/* ---------- panels, forms ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.panel h2 { font-size: 1.2rem; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 16px; }
.field-row { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 600; }
.inline-actions { display: flex; gap: 16px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; background: var(--sunken); border-radius: 999px; padding: 3px; align-self: flex-start; }
.seg button { border: 0; background: none; padding: 7px 16px; border-radius: 999px; color: var(--muted); font-weight: 500; font-size: .92rem; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.seg.wide { align-self: stretch; display: flex; }
.seg.wide button { flex: 1; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
textarea, .search, select, .field input:not([type="checkbox"]) {
  width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
select { width: auto; min-width: 120px; padding-right: 28px; }
.steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.confirm { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .92rem; }
.hints { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 10px; }
.hints[open] > summary { margin-bottom: 10px; }
.hints summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.hints textarea { min-height: 90px; margin-bottom: 10px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters .search { flex: 1 1 240px; }
.count { margin-bottom: -4px; }
.callout { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; background: var(--accent-soft); border-color: transparent; }
.callout > div:first-child { flex: 1 1 260px; display: flex; flex-direction: column; gap: 4px; }
.callout p { color: var(--muted); }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.setting > div { flex: 1 1 240px; min-width: 0; }
.switch { width: 22px; height: 22px; accent-color: var(--accent); }
.file-btn { position: relative; overflow: hidden; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.about p { max-width: 62ch; }

.ai-mode { border-color: var(--accent); }
.ai-mode .steps { color: var(--ink); gap: 12px; }
.copy-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mono-input { flex: 1 1 220px; min-width: 0; font-family: var(--mono); font-size: .85rem; border: 1px solid var(--line); background: var(--sunken); color: var(--ink); border-radius: 10px; padding: 9px 12px; }
.ai-mode a { color: var(--accent); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 15px 18px; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--accent-soft); }
.row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-main b { font-weight: 600; }
.row-main span { color: var(--muted); font-size: .88rem; }
.pill { font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; white-space: nowrap; border: 1px solid var(--line); color: var(--muted); flex: none; }
.pill.pass { background: var(--pass-soft); color: var(--pass); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.fail { background: var(--fail-soft); color: var(--fail); border-color: transparent; }
@media (max-width: 520px) {
  .row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .weak-row { grid-template-columns: minmax(0, 1fr) auto; }
  .weak-bar { grid-column: 1 / -1; grid-row: 2; }
}

.cards-list { display: flex; flex-direction: column; gap: 8px; }
.card-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.card-item summary { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; cursor: pointer; list-style: none; font-weight: 500; }
.card-item summary::-webkit-details-marker { display: none; }
.card-item summary .pill { margin-top: 2px; }
.card-item[open] summary { border-bottom: 1px solid var(--line); }
.card-body { padding: 16px; }

.terms { display: flex; flex-direction: column; margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.term { padding: 13px 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 200px) 1fr; gap: 4px 18px; }
.term:first-child { border-top: 0; }
.term dt { font-weight: 600; }
.term dd { margin: 0; color: var(--muted); font-size: .94rem; min-width: 0; }
.tag { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-top: 2px; font-weight: 400; }
@media (max-width: 520px) { .term { grid-template-columns: 1fr; } }

/* ---------- bug hunt sandbox ---------- */
.sandbox { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--surface); max-width: 460px; }
.sandbox-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.sandbox .err { color: var(--fail); font-size: .85rem; min-height: 1.2em; }
.sandbox-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.sandbox-status { font-size: .92rem; color: var(--pass); min-height: 1.4em; }
.accounts { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
