:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f0f4ff;
  --text: #172033;
  --muted: #606b80;
  --line: #dfe5ef;
  --primary: #2658d9;
  --primary-dark: #1e46ad;
  --danger: #c53030;
  --warning: #9a5b00;
  --ok: #176c3a;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  box-shadow: 0 2px 10px rgba(23, 32, 51, 0.04);
}
.site-header h1 { margin: 0; font-size: 1.35rem; }
.site-header p { margin: 4px 0 0; color: var(--muted); }
.site-footer { margin-top: auto; padding: 16px 24px; color: var(--muted); text-align: center; }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 24px auto 40px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel h2, .panel h3 { margin-top: 0; }
.lead { color: var(--muted); line-height: 1.7; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.choice-card {
  display: block;
  text-align: left;
  padding: 24px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  cursor: pointer;
  min-height: 170px;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.choice-card:hover, .choice-card:focus {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
  outline: none;
}
.choice-card strong { display: block; font-size: 1.25rem; margin-bottom: 8px; }
.choice-card span { color: var(--muted); line-height: 1.65; }

label { display: block; font-weight: 700; margin-bottom: 6px; }
input, select, textarea, button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(38, 88, 217, .18); border-color: var(--primary); }
.form-row { margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
button {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}
button:hover { background: var(--primary-dark); }
button.secondary { background: #e6eaf3; color: var(--text); }
button.secondary:hover { background: #d8deeb; }
button.danger { background: var(--danger); }
button.warning { background: #b46700; }
button:disabled { opacity: .55; cursor: not-allowed; }

.status-pill, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-weight: 700;
}
.pill.ok { color: var(--ok); background: #edf9f2; border-color: #cbe8d6; }
.pill.warn { color: var(--warning); background: #fff7e8; border-color: #f1d29c; }
.pill.danger { color: var(--danger); background: #fff0f0; border-color: #f2c0c0; }
.message {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 12px 0;
  background: var(--panel-soft);
  line-height: 1.6;
}
.message.error { border-color: #f0bbbb; background: #fff0f0; color: var(--danger); }
.message.ok { border-color: #cbe8d6; background: #edf9f2; color: var(--ok); }
.message.warn { border-color: #f1d29c; background: #fff7e8; color: var(--warning); }

.notice-list { line-height: 1.9; }
.countdown {
  text-align: center;
  font-size: clamp(4rem, 15vw, 10rem);
  font-weight: 900;
  color: var(--primary);
  padding: 50px;
}
.exam-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 248, 251, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.timer {
  font-size: 2rem;
  font-weight: 900;
  color: var(--danger);
  text-align: center;
}
.exam-meta { color: var(--muted); line-height: 1.5; }
.exam-meta strong { color: var(--text); }
.passage-box {
  font-size: 1.35rem;
  line-height: 2.1;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 16px;
  user-select: none;
  -webkit-user-select: none;
}
ruby rt { font-size: .62em; color: var(--muted); }
.typing-area { min-height: 230px; font-size: 1.15rem; line-height: 1.85; }
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 132px;
}
.metric span { display: block; color: var(--muted); font-size: .84rem; }
.metric strong { display: block; font-size: 1.25rem; margin-top: 4px; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tab-button { background: #e6eaf3; color: var(--text); }
.tab-button.active { background: var(--primary); color: #fff; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: #f0f4ff; font-size: .92rem; }
tr.suspicious { background: #fff7e8; }
.small { font-size: .9rem; color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.preview-box {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 14px;
  line-height: 2;
  background: #fff;
}
.hidden { display: none !important; }
hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .exam-topbar { grid-template-columns: 1fr; }
  .timer { text-align: left; }
  .passage-box { font-size: 1.15rem; }
}
