:root{
  --ink: #12151c;
  --surface: #1b202a;
  --surface-2: #232a36;
  --text: #eceef2;
  --text-dim: #9aa3b2;
  --amber: #f2b705;
  --teal: #3ed6b0;
  --danger: #ff6b6b;
  --radius: 14px;
}

*{box-sizing:border-box;}

html,body{
  margin:0;
  padding:0;
  background:var(--ink);
  color:var(--text);
  font-family:'Inter', sans-serif;
  -webkit-font-smoothing:antialiased;
}

.grain{
  position:fixed; inset:0;
  pointer-events:none;
  opacity:0.03;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index:0;
}

.topbar{
  display:flex; justify-content:space-between; align-items:center;
  padding:22px 32px;
  position:relative; z-index:1;
}
.brand{
  font-family:'Newsreader', serif;
  font-size:20px; font-weight:600;
  display:flex; align-items:center; gap:8px;
}
.brand-mark{ color:var(--amber); }

.key-btn{
  background:var(--surface);
  border:1px solid #313a49;
  color:var(--text-dim);
  padding:9px 16px;
  border-radius:100px;
  font-size:13px;
  font-family:'Inter', sans-serif;
  cursor:pointer;
  transition:all .15s ease;
}
.key-btn:hover{ color:var(--text); border-color:var(--amber); }

main{ max-width:1080px; margin:0 auto; padding:0 32px; position:relative; z-index:1; }

.hero{ padding:56px 0 40px; max-width:720px; }
.eyebrow{
  font-family:'IBM Plex Mono', monospace;
  font-size:12px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--teal);
  margin:0 0 14px;
}
.hero h1{
  font-family:'Newsreader', serif;
  font-weight:500;
  font-size:52px;
  line-height:1.08;
  margin:0 0 20px;
  letter-spacing:-.01em;
}
.highlight-wrap{ position:relative; display:inline-block; color:var(--amber); font-style:italic; }
.highlight-wrap .stroke{
  position:absolute; left:-4px; right:-4px; bottom:-6px; width:calc(100% + 8px); height:20px;
}
.highlight-wrap .stroke path{
  fill:none; stroke:var(--amber); stroke-width:6; stroke-linecap:round;
  opacity:.45;
  stroke-dasharray:320; stroke-dashoffset:320;
  animation:draw 1.1s .3s ease forwards;
}
@keyframes draw{ to{ stroke-dashoffset:0; } }

.sub{ color:var(--text-dim); font-size:17px; line-height:1.6; max-width:560px; }

.workspace{
  display:grid; grid-template-columns:1fr 1fr; gap:24px;
  padding-bottom:64px;
}
@media (max-width:860px){ .workspace{ grid-template-columns:1fr; } .hero h1{ font-size:38px; } }

.panel{
  background:var(--surface);
  border:1px solid #262d3a;
  border-radius:var(--radius);
  padding:24px;
  display:flex; flex-direction:column;
}
.panel-head{
  display:flex; justify-content:space-between; align-items:center;
  margin-bottom:18px;
}
.panel-head h2{
  font-family:'Newsreader', serif; font-weight:500; font-size:19px; margin:0;
}

.mode-toggle{ display:flex; background:var(--surface-2); border-radius:100px; padding:3px; }
.mode-btn{
  border:none; background:transparent; color:var(--text-dim);
  font-family:'Inter', sans-serif; font-size:13px; padding:6px 14px;
  border-radius:100px; cursor:pointer;
}
.mode-btn.active{ background:var(--ink); color:var(--text); }

.mode-body.hidden{ display:none; }

.record-btn{
  width:100%;
  display:flex; align-items:center; justify-content:center; gap:10px;
  background:var(--ink);
  border:1px solid #313a49;
  color:var(--text);
  padding:16px;
  border-radius:100px;
  font-size:15px; font-weight:500;
  cursor:pointer;
  margin-bottom:10px;
  transition:border-color .15s ease;
}
.record-btn:hover{ border-color:var(--amber); }
.record-btn .dot{
  width:10px; height:10px; border-radius:50%;
  background:var(--danger);
}
.record-btn.recording .dot{ animation:pulse 1s infinite; }
.record-btn.recording{ border-color:var(--danger); }
@keyframes pulse{ 0%,100%{ opacity:1; transform:scale(1);} 50%{ opacity:.4; transform:scale(1.3);} }

.hint{ color:var(--text-dim); font-size:13px; line-height:1.5; margin:0 0 14px; }

textarea{
  width:100%; min-height:160px; resize:vertical;
  background:var(--ink);
  border:1px solid #262d3a;
  border-radius:10px;
  color:var(--text);
  font-family:'IBM Plex Mono', monospace;
  font-size:13px; line-height:1.6;
  padding:14px;
  margin-bottom:16px;
}
textarea:focus{ outline:2px solid var(--teal); outline-offset:1px; }

.generate-btn{
  background:var(--amber);
  color:#1a1500;
  border:none;
  padding:14px;
  border-radius:100px;
  font-family:'Inter', sans-serif;
  font-weight:600; font-size:15px;
  cursor:pointer;
  transition:opacity .15s ease, transform .1s ease;
}
.generate-btn:hover{ opacity:.9; }
.generate-btn:active{ transform:scale(.98); }
.generate-btn:disabled{ opacity:.35; cursor:not-allowed; }

.ghost-btn{
  background:transparent; border:1px solid #313a49; color:var(--text-dim);
  padding:14px 18px; border-radius:100px; cursor:pointer; font-family:'Inter', sans-serif;
}

.error{ color:var(--danger); font-size:13px; margin:10px 0 0; min-height:16px; }

.empty-state, .loading-state{
  flex:1;
  display:flex; align-items:center; justify-content:center;
  text-align:center;
  color:var(--text-dim);
  font-size:14px;
  padding:40px 20px;
}
.loading-state{ flex-direction:column; gap:16px; }
.hidden{ display:none !important; }

.spinner{
  width:28px; height:28px; border-radius:50%;
  border:3px solid #313a49; border-top-color:var(--amber);
  animation:spin .8s linear infinite;
}
@keyframes spin{ to{ transform:rotate(360deg); } }

.results h3{
  font-family:'Newsreader', serif; font-weight:500; font-size:24px; margin:0 0 20px;
}

.block-label{
  font-family:'IBM Plex Mono', monospace;
  font-size:11px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--teal); margin:0 0 10px;
}
.result-block{ margin-bottom:26px; }

#summaryList{ margin:0; padding-left:18px; color:var(--text); line-height:1.7; font-size:14px; }
#summaryList li{ margin-bottom:6px; }

.term-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:520px){ .term-grid{ grid-template-columns:1fr; } }

/* Exam readiness */
.readiness-row{ display:flex; align-items:center; gap:12px; margin-bottom:14px; }
.readiness-bar{
  flex:1; height:10px; border-radius:100px; background:var(--surface-2);
  overflow:hidden;
}
.readiness-fill{
  height:100%; width:0%; border-radius:100px;
  background:var(--danger);
  transition:width .6s ease;
}
.readiness-fill.mid{ background:var(--amber); }
.readiness-fill.good{ background:var(--teal); }
.readiness-fill.low{ background:var(--danger); }
.readiness-score{ font-family:'IBM Plex Mono', monospace; font-size:15px; font-weight:500; min-width:44px; text-align:right; }

.readiness-cols{ display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.mini-label{ font-size:12px; font-weight:600; margin:0 0 6px; }
.mini-label.good{ color:var(--teal); }
.mini-label.bad{ color:var(--amber); }
.mini-list{ margin:0; padding-left:16px; font-size:13px; color:var(--text-dim); line-height:1.6; }

/* Knowledge gaps */
.gap-cols{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; }
@media (max-width:600px){ .gap-cols{ grid-template-columns:1fr; } .readiness-cols{ grid-template-columns:1fr; } }
.mini-label.dot-red{ color:#ff8a8a; }
.mini-label.dot-yellow{ color:var(--amber); }
.mini-label.dot-green{ color:var(--teal); }
.gap-empty{ list-style:none; margin-left:-16px; color:#565f6e; font-style:italic; }

/* Memory tricks */
.tricks-list{ display:flex; flex-direction:column; gap:10px; }
.trick-card{
  background:var(--surface-2);
  border:1px solid #2c3444; border-left:3px solid var(--teal);
  border-radius:8px;
  padding:12px 14px;
}
.trick-concept{ font-weight:600; font-size:13px; margin-bottom:4px; }
.trick-text{ font-size:13px; color:var(--text-dim); line-height:1.5; }


.term-card{
  background:var(--surface-2);
  border:1px solid #2c3444;
  border-radius:10px;
  padding:12px 14px;
  cursor:pointer;
  perspective:600px;
}
.term-card .term{ font-weight:600; font-size:14px; position:relative; display:inline-block; }
.term-card .def{
  margin-top:6px; font-size:13px; color:var(--text-dim); line-height:1.5;
  max-height:0; overflow:hidden; transition:max-height .25s ease;
}
.term-card.open .def{ max-height:200px; margin-top:8px; }

.quiz-item{
  background:var(--surface-2);
  border:1px solid #2c3444;
  border-radius:10px;
  padding:14px;
  margin-bottom:10px;
  cursor:pointer;
}
.quiz-item .q{ font-size:14px; font-weight:500; }
.quiz-item .a{
  margin-top:8px; font-size:13px; color:var(--amber);
  max-height:0; overflow:hidden; transition:max-height .25s ease;
}
.quiz-item .explain{
  margin-top:6px; font-size:12px; color:var(--text-dim); line-height:1.5;
}
.quiz-item.open .a{ max-height:400px; margin-top:8px; }
.quiz-item .reveal-hint{ font-size:11px; color:var(--text-dim); margin-top:4px; }

footer{
  text-align:center; color:var(--text-dim); font-size:12px;
  padding:30px; font-family:'IBM Plex Mono', monospace;
}

.modal{
  position:fixed; inset:0; background:rgba(10,12,16,.7);
  display:flex; align-items:center; justify-content:center;
  z-index:10;
}
.modal-card{
  background:var(--surface); border:1px solid #313a49; border-radius:var(--radius);
  padding:26px; width:100%; max-width:400px;
}
.modal-card h3{ font-family:'Newsreader', serif; font-weight:500; margin:0 0 10px; }
.modal-card p{ color:var(--text-dim); font-size:13px; line-height:1.6; margin:0 0 16px; }
.modal-card a{ color:var(--teal); }
.modal-card input{
  width:100%; background:var(--ink); border:1px solid #262d3a; border-radius:10px;
  padding:12px; color:var(--text); font-family:'IBM Plex Mono', monospace; margin-bottom:16px;
}
.modal-actions{ display:flex; gap:10px; justify-content:flex-end; }
