:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #182033;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #047857;
  --warn: #b45309;
  --shadow: 0 18px 45px rgba(15, 23, 42, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 12px; padding: 10px 14px; background: var(--primary); color: white; cursor: pointer; font-weight: 700; }
button:hover { background: var(--primary-dark); }
button.secondary { background: #eef2ff; color: #1e3a8a; }
button.secondary:hover { background: #dbeafe; }
button.ghost { background: transparent; color: var(--primary); }
button.danger { background: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: white; color: var(--text); }
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-weight: 700; margin: 12px 0 7px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 900; letter-spacing: -.02em; }
.logo { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: white; display:flex; align-items:center; justify-content:center; font-weight:900; }
.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.small-card { background: white; border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top left, #dbeafe, transparent 38%), radial-gradient(circle at bottom right, #ede9fe, transparent 40%), var(--bg); }
.login-card { width: min(440px, 100%); }
.login-title { margin: 0 0 6px; font-size: 32px; letter-spacing: -.04em; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; background: #eef2ff; color: #1e3a8a; font-weight: 700; font-size: 13px; }
.pill.green { background: #ecfdf5; color: var(--ok); }
.pill.orange { background: #fff7ed; color: var(--warn); }
.error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; padding: 10px 12px; border-radius: 12px; margin: 12px 0; }
.success { color: #065f46; background: #ecfdf5; border: 1px solid #a7f3d0; padding: 10px 12px; border-radius: 12px; margin: 12px 0; }
.tabs { display:flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { border: 1px solid var(--line); color: var(--text); background: white; }
.tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.folder { min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform .15s ease, border-color .15s ease; }
.folder:hover { transform: translateY(-2px); border-color: #bfdbfe; }
.folder .icon { font-size: 42px; }
.exam-list { display: grid; gap: 12px; }
.exam-item { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.exam-title { font-weight: 900; font-size: 18px; margin-bottom: 5px; }
.exam-meta { display:flex; gap:8px; flex-wrap:wrap; }
.timer { padding: 10px 14px; background: #111827; color: #fff; border-radius: 14px; font-weight: 900; letter-spacing: .03em; }
.progress { height: 9px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 15px 0; }
.progress > div { height: 100%; background: var(--primary); width: 0%; transition: width .25s ease; }
.question-card { max-width: 920px; margin: 0 auto; }
.prompt { font-size: 20px; line-height: 1.55; font-weight: 800; margin: 8px 0 16px; }
.passage { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); padding: 16px; border-radius: 14px; line-height: 1.7; margin: 14px 0; }
.answer-row { display: grid; gap: 8px; margin: 13px 0; }
.order-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.order-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.order-controls { display:flex; gap:6px; }
.order-controls button { padding: 8px 10px; }
.navbar-question { display:flex; justify-content: space-between; align-items:center; gap: 12px; margin-top: 18px; }
.result-item { border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 14px 0; background: #fff; }
.result-item.ok { border-color: #a7f3d0; background: #f0fdf4; }
.result-item.no { border-color: #fecaca; background: #fff7f7; }
.result-prompt { font-size: 17px; line-height: 1.55; font-weight: 800; margin: 12px 0; }
.result-gap-passage { font-size: 17px; }
.result-gap-answer { display: inline-block; padding: 0 4px; color: var(--ok); border-bottom: 2px solid #86efac; }
.result-answer-list { display: grid; gap: 10px; margin: 14px 0 0; padding-left: 28px; }
.result-answer-list li { padding: 10px 12px; line-height: 1.55; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.result-review-list { display: grid; gap: 12px; margin-top: 14px; }
.result-review-row { padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.result-review-question { font-weight: 800; line-height: 1.55; }
.result-paragraph-text { margin-top: 8px; color: #374151; line-height: 1.65; white-space: pre-wrap; }
.result-comparison { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; line-height: 1.5; }
.result-comparison.correct { color: var(--ok); }
.result-comparison.incorrect { color: var(--danger); }
.result-check, .result-cross { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-weight: 900; flex: 0 0 24px; }
.result-check { background: var(--ok); }
.result-cross { background: var(--danger); }
.result-comparison del { color: #991b1b; }
.student-answer-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.correct-answer-label { margin-left: 4px; color: var(--muted); font-size: 13px; font-weight: 700; }
.result-comparison.incorrect strong { color: var(--ok); }
.script { white-space: pre-wrap; background: white; border: 1px dashed #cbd5e1; padding: 12px; border-radius: 12px; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.admin-section { margin-bottom: 20px; }
.kv { display:grid; grid-template-columns: 170px 1fr; gap: 8px; margin: 8px 0; }
.audio-note { padding: 10px 12px; border-radius: 12px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; margin: 10px 0; }
footer { color: var(--muted); font-size: 13px; margin-top: 25px; }
@media (max-width: 820px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .exam-item, .topbar-inner, .navbar-question { flex-direction: column; align-items: stretch; }
  .timer { text-align: center; }
  .order-item { grid-template-columns: 1fr; }
  .result-comparison { align-items: flex-start; }
}

/* Inline dropdowns for Reading gap-fill questions */
.inline-gap-passage { font-size: 17px; }
.inline-gap-select {
  width: auto;
  min-width: 150px;
  max-width: 260px;
  display: inline-block;
  margin: 0 6px;
  padding: 6px 28px 6px 10px;
  vertical-align: middle;
  border-color: #bfdbfe;
  background-color: #fff;
  color: var(--text);
}

.question-editor {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}
.question-editor-title { font-size: 18px; font-weight: 900; color: #1e3a8a; margin-bottom: 8px; }
.question-answer-editor { margin-top: 16px; padding: 14px; border: 1px solid #bfdbfe; border-radius: 12px; background: #eff6ff; }
.question-answer-title { font-weight: 900; color: #1e40af; }
.admin-editor-banner { display: grid; gap: 4px; padding: 14px 16px; margin-bottom: 16px; border-radius: 12px; }
.admin-editor-banner.reading { color: #14532d; background: #f0fdf4; border: 1px solid #bbf7d0; }
.admin-editor-banner.listening { color: #1e3a8a; background: #eff6ff; border: 1px solid #bfdbfe; }
.admin-editor-banner span { font-size: 14px; }
.question-editor textarea {
  min-height: 92px;
  resize: vertical;
  font-family: inherit;
}
.admin-question-card details .script {
  white-space: normal;
}
.inline-gap-passage .inline-gap-select {
  min-width: 150px;
  width: auto;
  display: inline-block;
  margin: 0 4px;
  padding: 6px 10px;
}
