@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,600;6..72,700&display=swap");

:root {
  --forest: #062f2a;
  --forest-deep: #03231f;
  --forest-mid: #0b5147;
  --emerald: #127567;
  --ivory: #f8f3e8;
  --paper: #fffaf1;
  --ink: #17221f;
  --muted: #66756f;
  --line: rgba(6, 47, 42, 0.15);
  --soft: rgba(18, 117, 103, 0.08);
  --gold: #c6aa69;
  --danger: #963e4d;
  --success: #25684d;
  --shadow: 0 28px 80px rgba(1, 23, 20, 0.28);
  --radius-panel: 18px;
  --radius-field: 9px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ivory);
  background: var(--forest-deep);
  font-family: "DM Sans", "Segoe UI", sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 14px;
  top: -60px;
  z-index: 30;
  padding: 10px 14px;
  color: var(--paper);
  background: var(--forest);
}

.skip-link:focus { top: 14px; }

.shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 52px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 18px;
}

.brand h1,
.auth-card h1,
.student-hero h1 {
  margin: 0;
  font-family: "Newsreader", Georgia, serif;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.98;
}

.brand h1 { font-size: clamp(30px, 4vw, 50px); }
.brand p, .student-hero p { margin: 6px 0 0; color: rgba(248, 243, 232, 0.7); }

.teacher-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(248, 243, 232, 0.76);
  font-size: 13px;
}

.portal-nav {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 5px;
  border: 1px solid rgba(248, 243, 232, 0.13);
  border-radius: 12px;
  background: rgba(248, 243, 232, 0.06);
}

.nav-button {
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: rgba(248, 243, 232, 0.7);
  background: transparent;
  font-weight: 600;
  transition: color 180ms var(--ease), background 180ms var(--ease);
}

.nav-button:hover { color: var(--paper); }
.nav-button.active { color: var(--forest); background: var(--ivory); }

.view { animation: reveal 280ms var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.75fr) minmax(500px, 1.25fr);
  gap: 14px;
  align-items: start;
}

.panel {
  color: var(--ink);
  background: var(--paper);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2, .section-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-head p, .hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-body { padding: 20px 22px 24px; }
.stack { display: grid; gap: 15px; }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.row-wide { grid-template-columns: 1.25fr 0.75fr; }

label {
  display: block;
  margin-bottom: 7px;
  color: var(--forest);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid rgba(6, 47, 42, 0.18);
  border-radius: var(--radius-field);
  padding: 12px 13px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease), background 180ms var(--ease);
}

textarea { min-height: 105px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  border-color: var(--emerald);
  background: #fffdf8;
  box-shadow: 0 0 0 3px rgba(18, 117, 103, 0.12);
}

.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(150, 62, 77, 0.1) !important; }

.range-row { display: grid; grid-template-columns: 1fr 64px; align-items: center; gap: 10px; }
input[type="range"] { padding: 0; accent-color: var(--emerald); }
.meter, .count-summary {
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--forest);
  background: var(--soft);
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.count-summary { margin-top: 8px; text-align: left; font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.top-gap { margin-top: 16px; }
.top-gap-small { margin-top: 12px; }
.align-end { align-self: end; }
.button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 700;
  letter-spacing: 0;
  transition: transform 180ms var(--ease), background 180ms var(--ease), box-shadow 180ms var(--ease);
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button-primary { color: var(--paper); background: var(--forest); box-shadow: 0 9px 22px rgba(6, 47, 42, 0.22); }
.button-primary:hover { background: var(--forest-mid); }
.button-secondary { color: var(--forest); border-color: var(--line); background: rgba(6, 47, 42, 0.05); }
.button-secondary:hover { background: rgba(6, 47, 42, 0.09); }
.button-danger { color: var(--danger); border-color: rgba(150, 62, 77, 0.18); background: rgba(150, 62, 77, 0.05); }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: 0.48; transform: none; box-shadow: none; }

.status { min-height: 18px; color: var(--muted); font-size: 12px; }
.status.error { color: var(--danger); font-weight: 600; }
.status.success { color: var(--success); font-weight: 600; }

.empty-state {
  display: grid;
  place-items: center;
  min-height: 380px;
  padding: 42px;
  text-align: center;
  color: var(--muted);
}
.empty-state strong { display: block; margin-bottom: 6px; color: var(--forest); font-size: 18px; }

.editor-header { display: grid; gap: 12px; margin-bottom: 18px; }
.editor-items { display: grid; gap: 10px; }
.editor-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fffdf8;
  overflow: hidden;
}
.editor-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 47, 42, 0.045);
}
.editor-item-head strong { color: var(--forest); font-size: 13px; }
.editor-item-body { display: grid; gap: 12px; padding: 13px; }
.editor-item textarea { min-height: 76px; }
.item-tools { display: flex; gap: 5px; }
.tool-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--forest);
  background: var(--paper);
  font-weight: 700;
}
.tool-button:hover { background: var(--soft); }

.list { display: grid; }
.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-title { margin: 0; color: var(--forest); font-weight: 700; }
.list-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.portal-grid { display: grid; grid-template-columns: 0.72fr 1.28fr; gap: 14px; align-items: start; }
.student-section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.student-section:last-child { border-bottom: 0; }
.student-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.student-heading h3 { margin: 0; color: var(--forest); font-size: 16px; }
.student-heading span { color: var(--muted); font-size: 12px; }
.assignment-row { margin-top: 10px; padding: 12px; border-left: 3px solid rgba(6, 47, 42, 0.18); background: rgba(6, 47, 42, 0.035); }
.assignment-row.submitted { border-left-color: var(--success); }
.assignment-top { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.result-detail { display: grid; gap: 8px; margin-top: 11px; }
.result-line { padding-top: 8px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.45; }
.result-line strong { color: var(--forest); }

.assignment-composer { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: rgba(6, 47, 42, 0.035); }
.share-link { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.share-link input { font-family: Consolas, monospace; font-size: 12px; }

.auth-shell { display: grid; place-items: center; min-height: 100dvh; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 34px; color: var(--ink); background: var(--paper); border-radius: var(--radius-panel); box-shadow: var(--shadow); }
.auth-card h1 { color: var(--forest); font-size: 42px; }
.auth-card > p { margin: 8px 0 24px; color: var(--muted); line-height: 1.5; }

.working-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(3, 35, 31, 0.72);
  backdrop-filter: blur(4px);
}
.working-box { width: min(340px, calc(100% - 32px)); padding: 28px; text-align: center; color: var(--ink); background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); }
.working-mark { width: 44px; height: 44px; margin: 0 auto 15px; border: 3px solid rgba(18, 117, 103, 0.2); border-top-color: var(--emerald); border-radius: 50%; animation: spin 850ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.student-shell { width: min(820px, calc(100% - 28px)); margin: 0 auto; padding: 36px 0 58px; }
.student-hero { margin-bottom: 18px; }
.student-hero h1 { max-width: 720px; font-size: clamp(36px, 7vw, 64px); }
.student-paper { color: var(--ink); background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.student-intro { padding: 25px 28px 22px; border-bottom: 1px solid var(--line); }
.student-intro h2 { margin: 0 0 8px; color: var(--forest); font-size: 20px; }
.student-intro p { margin: 0; line-height: 1.6; }
.example { margin-top: 18px; padding: 14px 16px; border-left: 3px solid var(--gold); background: rgba(198, 170, 105, 0.1); }
.example-label { display: block; margin-bottom: 6px; color: var(--forest); font-size: 11px; font-weight: 700; }
.question-list { display: grid; }
.question { padding: 22px 28px; border-bottom: 1px solid var(--line); }
.question-number { display: block; margin-bottom: 7px; color: var(--emerald); font-size: 12px; font-weight: 700; }
.question-prompt { margin: 0 0 13px; line-height: 1.55; white-space: pre-wrap; }
.choices { display: grid; gap: 8px; }
.choice { display: flex; align-items: flex-start; gap: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.choice:hover { background: var(--soft); }
.choice input { width: auto; margin-top: 3px; accent-color: var(--emerald); }
.student-actions { padding: 20px 28px 26px; }
.submit-confirm { margin-bottom: 14px; padding: 14px; border: 1px solid rgba(198, 170, 105, 0.5); border-radius: 9px; background: rgba(198, 170, 105, 0.1); }
.submit-confirm p { margin: 0 0 12px; line-height: 1.45; }

.result-card { margin-top: 13px; padding: 14px; border-radius: 9px; }
.result-card.correct { background: rgba(37, 104, 77, 0.09); border-left: 3px solid var(--success); }
.result-card.incorrect { background: rgba(150, 62, 77, 0.075); border-left: 3px solid var(--danger); }
.result-card.review { background: rgba(198, 170, 105, 0.11); border-left: 3px solid var(--gold); }
.result-card p { margin: 5px 0 0; font-size: 13px; line-height: 1.5; }
.result-card strong { color: var(--forest); }
.result-summary { padding: 22px 28px; border-bottom: 1px solid var(--line); background: rgba(6, 47, 42, 0.045); }
.result-summary h2 { margin: 0; color: var(--forest); }
.result-summary p { margin: 6px 0 0; color: var(--muted); }

.version {
  position: fixed;
  right: 10px;
  bottom: 9px;
  z-index: 10;
  padding: 5px 8px;
  border: 1px solid rgba(248, 243, 232, 0.18);
  border-radius: 8px;
  color: rgba(248, 243, 232, 0.78);
  background: var(--forest-deep);
  font-size: 11px;
}

@media (max-width: 900px) {
  .workspace, .portal-grid { grid-template-columns: 1fr; }
  .masthead { align-items: flex-start; }
}

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1280px); padding-top: 16px; }
  .masthead { display: grid; }
  .teacher-identity { justify-content: space-between; }
  .portal-nav { overflow-x: auto; }
  .nav-button { white-space: nowrap; }
  .row, .row-wide { grid-template-columns: 1fr; }
  .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
  .auth-card { padding: 26px 20px; }
  .student-shell { padding-top: 24px; }
  .student-intro, .question, .student-actions, .result-summary { padding-left: 18px; padding-right: 18px; }
  .share-link { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
