/* =============================================================================
   Language by Yok - IELTS Reading platform
   ============================================================================= */

:root {
  --surface:        #ffffff;
  --page:           #f7f8fa;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --muted:          #898781;
  --line:           rgba(11, 11, 11, 0.10);
  --grid:           #e1e0d9;

  --accent:         #2a78d6;
  --accent-dark:    #1c5cab;
  --accent-wash:    #eaf2fd;

  --good:           #0ca30c;
  --good-ink:       #006300;
  --warning:        #fab219;
  --serious:        #ec835a;
  --critical:       #d03b3b;

  --radius:         10px;
  --shadow:         0 1px 2px rgba(11,11,11,.05), 0 8px 24px rgba(11,11,11,.05);
  --sans:           system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-dark); }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.02rem; }
p  { line-height: 1.6; }

.wrap      { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.wrap-slim { max-width: 720px;  margin: 0 auto; padding: 0 20px; }
.muted     { color: var(--muted); }
.dim       { color: var(--ink-2); }
.small     { font-size: .86rem; }
.tnum      { font-variant-numeric: tabular-nums; }
.center    { text-align: center; }
.right     { text-align: right; }
.row       { display: flex; gap: 12px; align-items: center; }
.row-wrap  { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer    { flex: 1; }
.stack > * + * { margin-top: 14px; }
.hidden    { display: none !important; }

/* ---- site chrome --------------------------------------------------------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 62px; }
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: -.02em; text-decoration: none; color: var(--ink); }
.brand span { color: var(--accent); }
.brand small { display: block; font-weight: 450; font-size: .72rem; color: var(--muted); letter-spacing: 0; }

/* ---- cards --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }

/* ---- buttons & inputs ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 550; line-height: 1;
  padding: 11px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer;
  text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: #f2f4f7; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger  { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .84rem; font-weight: 550; margin-bottom: 6px; color: var(--ink-2); }
input[type=text], input[type=email], input[type=password], select, textarea {
  font: inherit; width: 100%; padding: 11px 12px;
  border: 1px solid #d5d7dc; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.hint { font-size: .8rem; color: var(--muted); margin-top: 6px; }

.notice {
  padding: 12px 14px; border-radius: 8px; font-size: .9rem; line-height: 1.5;
  border: 1px solid var(--line); background: #fff;
}
.notice-warn  { background: #fff8e8; border-color: #f2ddab; }
.notice-error { background: #fdeceb; border-color: #f3c4c2; }
.notice-info  { background: var(--accent-wash); border-color: #c5dcf8; }

/* =============================================================================
   EXAM SCREEN
   ============================================================================= */
body.exam { background: #fff; overflow: hidden; }

.exam-header {
  height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  border-bottom: 1px solid var(--line); background: var(--surface);
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
}
.exam-title { font-weight: 650; font-size: .95rem; min-width: 0; overflow: hidden; }
.exam-title span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-title small { display: block; font-weight: 450; color: var(--muted); font-size: .76rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timer {
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums; font-size: 1.25rem; font-weight: 650;
  padding: 6px 14px; border-radius: 8px; background: #f2f4f7; border: 1px solid var(--line);
}
.timer .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.timer.warn     { background: #fff4de; border-color: #f2ddab; }
.timer.warn .dot { background: var(--warning); }
.timer.danger   { background: #fdeceb; border-color: #f3c4c2; color: var(--critical); }
.timer.danger .dot { background: var(--critical); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.exam-body {
  position: fixed; top: 56px; bottom: 92px; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr 1fr;
}
.pane { overflow-y: auto; padding: 26px 30px 60px; }
.pane-passage { border-right: 1px solid var(--line); background: #fff; }
.pane-questions { background: #fcfcfb; }

.passage-title { font-size: 1.3rem; margin-bottom: 4px; }
.passage-instr {
  font-size: .86rem; color: var(--ink-2); background: var(--accent-wash);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 18px;
}
.passage-body { font-size: 1rem; line-height: 1.72; max-width: 62ch; }
.passage-body p { margin: 0 0 1.05em; }
.passage-body .para-label {
  float: left; margin: 2px 10px 0 -26px; font-weight: 700; color: var(--muted); width: 16px;
}
.passage-body mark { background: #ffeaa0; padding: 1px 0; }

#hl-btn {
  position: absolute; z-index: 50; display: none;
  padding: 6px 10px; font-size: .8rem; border-radius: 6px;
  background: var(--ink); color: #fff; border: 0; cursor: pointer;
}

.qgroup { margin-bottom: 34px; }
.qgroup-head { font-size: 1.02rem; font-weight: 650; margin-bottom: 4px; }
.qgroup-instr { font-size: .9rem; line-height: 1.55; margin-bottom: 10px; }
.qgroup-rubric {
  font-size: .85rem; line-height: 1.7; color: var(--ink-2);
  border-left: 3px solid var(--grid); padding-left: 12px; margin-bottom: 14px;
}
.opt-list {
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: 16px;
  font-size: .9rem;
}
.opt-list div { padding: 8px 12px; display: flex; gap: 10px; }
.opt-list div + div { border-top: 1px solid var(--line); }
.opt-list b { min-width: 26px; color: var(--muted); font-weight: 650; }

.q {
  display: flex; gap: 12px; padding: 12px; border-radius: 8px;
  border: 1px solid transparent; margin-bottom: 6px; scroll-margin-top: 20px;
}
.q.active { border-color: #c5dcf8; background: var(--accent-wash); }
.qnum {
  flex: 0 0 30px; height: 30px; border-radius: 50%; background: #eceef2;
  display: grid; place-items: center; font-weight: 650; font-size: .84rem;
}
.q.answered .qnum { background: var(--accent); color: #fff; }
.qmain { flex: 1; min-width: 0; }
.qtext { line-height: 1.55; margin-bottom: 8px; }
.qtext .gap {
  display: inline-block; min-width: 120px; border-bottom: 1.5px solid var(--ink-2);
  margin: 0 3px;
}
.q input[type=text] { max-width: 320px; }
.q select { max-width: 340px; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid #d5d7dc; border-radius: 999px; padding: 7px 14px; font-size: .88rem;
  background: #fff; line-height: 1;
}
.choice:hover { border-color: var(--accent); }
.choice input { accent-color: var(--accent); margin: 0; }
.choice.mcq { border-radius: 8px; width: 100%; align-items: flex-start; padding: 10px 12px; line-height: 1.45; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }

.flagbox {
  margin-top: 8px; font-size: .8rem; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}

table.qtable { border-collapse: collapse; width: 100%; font-size: .9rem; margin-bottom: 8px; }
table.qtable th, table.qtable td { border: 1px solid var(--grid); padding: 9px 11px; text-align: left; vertical-align: top; }
table.qtable th { background: #f2f4f7; font-weight: 650; }
table.qtable input[type=text] { max-width: 190px; padding: 6px 8px; display: inline-block; }
.summary-box { line-height: 2.1; font-size: .95rem; }
.summary-box select { display: inline-block; width: auto; min-width: 130px; padding: 5px 8px; }

/* ---- footer palette ------------------------------------------------------ */
.exam-footer {
  position: fixed; bottom: 0; left: 0; right: 0; height: 92px; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 16px; overflow-x: auto;
}
.part {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 8px; flex: 0 0 auto; background: #fff;
}
.part.current { border-color: var(--accent); background: var(--accent-wash); }
.part-label { font-size: .78rem; font-weight: 650; white-space: nowrap; }
.part-label small { display: block; font-weight: 450; color: var(--muted); }
.pal { display: flex; gap: 4px; }
.pal button {
  width: 27px; height: 27px; border-radius: 6px; border: 1px solid #d5d7dc;
  background: #fff; font: inherit; font-size: .76rem; cursor: pointer;
  font-variant-numeric: tabular-nums; position: relative; padding: 0;
}
.pal button.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.pal button.cur  { outline: 2px solid var(--ink); outline-offset: 1px; }
.pal button.flag::after {
  content: ''; position: absolute; top: -3px; right: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--warning);
  border: 1.5px solid #fff;
}

/* ---- modal --------------------------------------------------------------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(11,11,11,.5); z-index: 60;
  display: grid; place-items: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; padding: 26px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow);
}

/* =============================================================================
   RESULTS / DASHBOARD
   ============================================================================= */
.hero {
  display: flex; gap: 28px; align-items: center; flex-wrap: wrap;
}
.band-figure { line-height: 1; }
.band-figure .n { font-size: 4.5rem; font-weight: 700; letter-spacing: -.03em; }
.band-figure .l { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.tile .v { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.tile .k { font-size: .78rem; color: var(--muted); margin-top: 3px; }

/* findings */
.finding { border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 14px 16px; background: #fff; }
.finding + .finding { margin-top: 10px; }
.finding.high   { border-left-color: var(--critical); }
.finding.medium { border-left-color: var(--warning); }
.finding.info   { border-left-color: var(--accent); }
.finding.good   { border-left-color: var(--good); }
.finding h4 { margin: 0 0 5px; font-size: .96rem; display: flex; align-items: center; gap: 8px; }
.finding p  { margin: 0 0 8px; font-size: .9rem; line-height: 1.55; color: var(--ink-2); }
.finding .action { font-size: .88rem; line-height: 1.55; background: #f7f8fa; border-radius: 6px; padding: 9px 11px; }
.finding .action b { font-weight: 650; }
.pill {
  font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 4px; background: #eceef2; color: var(--ink-2);
}
.pill.high   { background: #fdeceb; color: #a02a2a; }
.pill.medium { background: #fff4de; color: #8a6100; }
.pill.good   { background: #e8f6e8; color: var(--good-ink); }

/* ---- charts -------------------------------------------------------------- */
.chart { margin-top: 4px; }
.barrow { display: grid; grid-template-columns: 180px 1fr 108px; align-items: center; gap: 12px; padding: 5px 0; font-size: .88rem; }
.barrow .lab { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bartrack { background: #eef0f3; border-radius: 4px; height: 14px; position: relative; }
.barfill  { background: var(--accent); border-radius: 4px; height: 100%; min-width: 2px; }
.barrow .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }

.spark { display: block; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
table.data tbody tr:hover { background: #f7f8fa; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.clickable { cursor: pointer; }

.tag { display: inline-block; font-size: .74rem; padding: 2px 7px; border-radius: 4px; background: #eceef2; color: var(--ink-2); }
.tag.ok   { background: #e8f6e8; color: var(--good-ink); }
.tag.bad  { background: #fdeceb; color: #a02a2a; }

/* review list */
.rev { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: #fff; }
.rev + .rev { margin-top: 8px; }
.rev.wrong   { border-left: 4px solid var(--critical); }
.rev.correct { border-left: 4px solid var(--good); }
.rev-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 6px; }
.rev-head .n { font-weight: 700; }
.rev-q { font-size: .93rem; line-height: 1.5; margin-bottom: 8px; }
.rev-ans { display: flex; gap: 22px; flex-wrap: wrap; font-size: .88rem; margin-bottom: 8px; }
.rev-ans b { font-weight: 650; }
.ansbox { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 7px; border-radius: 4px; background: #f2f4f7; }
.ansbox.ok  { background: #e8f6e8; color: var(--good-ink); }
.ansbox.bad { background: #fdeceb; color: #a02a2a; }
.rev-why { font-size: .87rem; line-height: 1.55; color: var(--ink-2); background: #f7f8fa; border-radius: 6px; padding: 10px 12px; }
.rev-why b { color: var(--ink); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button {
  font: inherit; font-weight: 550; font-size: .92rem; background: none; border: 0;
  padding: 11px 15px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--accent-dark); border-bottom-color: var(--accent); }

@media (max-width: 900px) {
  .exam-body { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .pane-passage { border-right: 0; border-bottom: 1px solid var(--line); }
  .pane { padding: 18px 18px 40px; }
  .barrow { grid-template-columns: 118px 1fr 92px; font-size: .8rem; }
  #chart-grid, .card > div[style*="grid-template-columns:1fr 1fr"] { grid-template-columns: 1fr !important; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
  .band-figure .n { font-size: 3.4rem; }
}

/* Small screens: the clock and the Finish button must never be pushed off. */
@media (max-width: 760px) {
  .exam-header { gap: 8px; padding: 0 10px; }
  .exam-header .spacer { flex: 0 1 auto; }
  .exam-title { flex: 1 1 auto; font-size: .8rem; }
  .exam-title small { display: none; }
  #hl-clear { display: none; }
  .timer { font-size: 1.05rem; padding: 5px 10px; flex: 0 0 auto; }
  #finish-btn { flex: 0 0 auto; white-space: nowrap; }
  .exam-footer { height: 78px; gap: 8px; padding: 0 10px; }
  .pal button { width: 30px; height: 30px; }
  .q { padding: 10px 6px; }
  .choice.mcq { padding: 9px 10px; }
}
@media (max-width: 420px) {
  .exam-title { display: none; }
}
@media print {
  .site-header, .tabs, .btn { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; border-color: #ccc; }
}
