@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@500;600;700&family=Quicksand:wght@500;600;700&display=swap');

:root {
  --pink: #FFD1E3;
  --pink-dark: #FF9FC4;
  --blue: #BEE3F8;
  --blue-dark: #7FC7EA;
  --purple: #D9CCF5;
  --purple-dark: #B79CEB;
  --yellow: #FFF3B0;
  --yellow-dark: #FFE066;
  --green: #CDEAC0;
  --green-dark: #9FDB8B;
  --cream: #FFFBF5;
  --ink: #3B3355;
  --muted: #8B86A6;
  --danger: #FF8FA3;
  --danger-dark: #F05C7E;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow-soft: 0 10px 24px rgba(89, 70, 150, 0.12);
  --font-exam: Arial, 'Helvetica Neue', Helvetica, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Quicksand', 'Segoe UI', sans-serif;
  background: linear-gradient(160deg, #FDF6FF 0%, #F0FBFF 45%, #FFF9F0 100%);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Fredoka', 'Quicksand', sans-serif; margin: 0; }

/* ---------- floating background decor ---------- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-decor .blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
  animation: floaty 9s ease-in-out infinite;
}
.bg-decor .blob.b1 { width: 160px; height: 160px; background: var(--pink); top: 8%; left: 6%; animation-delay: 0s; }
.bg-decor .blob.b2 { width: 110px; height: 110px; background: var(--blue); top: 65%; left: 3%; animation-delay: 1.5s; }
.bg-decor .blob.b3 { width: 140px; height: 140px; background: var(--yellow); top: 15%; right: 7%; animation-delay: 0.8s; }
.bg-decor .blob.b4 { width: 120px; height: 120px; background: var(--green); bottom: 8%; right: 10%; animation-delay: 2.2s; }
.bg-decor .blob.b5 { width: 90px; height: 90px; background: var(--purple); bottom: 25%; left: 45%; animation-delay: 1.1s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-18px) translateX(10px); }
}

.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 70px; position: relative; z-index: 1; }
.container:has(#screen-exam.active) { max-width: 1680px; padding: 10px 20px 12px; }

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== HOME SCREEN ===================== */
.hero {
  position: relative;
  background: radial-gradient(ellipse at top, #4b4376 0%, #342c5c 65%, #241f45 100%);
  border-radius: var(--radius-lg);
  padding: 46px 20px 110px;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.hero-stars { position: absolute; inset: 0; pointer-events: none; }
.hero-stars svg { position: absolute; width: 14px; height: 14px; color: #fff; opacity: 0.8; animation: twinkle 2.4s ease-in-out infinite; }
.hero-stars svg:nth-child(1) { top: 14%; left: 12%; animation-delay: 0s; }
.hero-stars svg:nth-child(2) { top: 24%; left: 82%; width: 10px; height: 10px; animation-delay: 0.6s; }
.hero-stars svg:nth-child(3) { top: 65%; left: 6%; width: 9px; height: 9px; animation-delay: 1.1s; }
.hero-stars svg:nth-child(4) { top: 10%; left: 48%; width: 11px; height: 11px; animation-delay: 1.6s; }
.hero-stars svg:nth-child(5) { top: 58%; left: 90%; animation-delay: 0.3s; }
.hero-stars svg:nth-child(6) { top: 75%; left: 40%; width: 8px; height: 8px; animation-delay: 1.9s; }

@keyframes twinkle { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }

.neon-logo {
  font-size: clamp(3rem, 9vw, 5rem);
  font-weight: 700;
  letter-spacing: 6px;
  color: #fff;
  -webkit-text-stroke: 2px #241f45;
  text-shadow:
    0 0 4px #fff,
    0 0 14px var(--pink-dark),
    0 0 26px var(--blue-dark),
    0 0 40px var(--purple-dark),
    0 3px 0 rgba(0,0,0,0.3);
  animation: neonPulse 3.2s ease-in-out infinite;
  position: relative;
  z-index: 2;
}

@keyframes neonPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.18); }
}

.hero-sub {
  color: #E7E1FF;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  margin-top: 6px;
  position: relative;
  z-index: 2;
}

.hero-mascots {
  position: absolute;
  left: 0; right: 0; bottom: -18px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 28px;
  z-index: 2;
}

.mascot { animation: bob 3.4s ease-in-out infinite; filter: drop-shadow(0 8px 10px rgba(0,0,0,0.18)); }
.mascot svg { width: 100%; display: block; }
.mascot-owl { width: 130px; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 22px;
  margin-top: 56px;
}

.mode-card {
  border-radius: var(--radius-lg);
  padding: 24px 22px 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  border: 3px solid rgba(255,255,255,0.6);
  position: relative;
}

.card-pink { background: linear-gradient(160deg, #FFE7F1 0%, var(--pink) 100%); }
.card-blue { background: linear-gradient(160deg, #E6F5FF 0%, var(--blue) 100%); }
.card-purple { background: linear-gradient(160deg, #F1EBFF 0%, var(--purple) 100%); }

.card-illustration { width: 100px; height: 76px; }
.card-illustration svg { width: 100%; height: 100%; }

.card-chip {
  display: inline-block;
  background: rgba(255,255,255,0.75);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 4px 14px;
  border-radius: 999px;
}

.mode-card h3 { font-size: 1.25rem; color: var(--ink); }
.mode-card p { margin: 0; color: #5B5579; font-size: 0.88rem; min-height: 40px; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-family: 'Fredoka', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
  box-shadow: 0 6px 14px rgba(89, 70, 150, 0.18);
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-start {
  background: linear-gradient(135deg, var(--purple-dark), var(--pink-dark));
  color: #fff;
  margin-top: 6px;
}

.btn-primary { background: linear-gradient(135deg, var(--blue-dark), var(--purple-dark)); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 2px solid var(--purple); }
.btn-submit { background: linear-gradient(135deg, var(--green-dark), #6FC26B); color: #fff; }
.btn-exit { background: #fff; color: var(--danger-dark); border: 2px solid var(--danger); }
.btn-danger { background: linear-gradient(135deg, var(--danger-dark), #E0426A); color: #fff; }

/* ===================== PRACTICE SCREEN ===================== */
.exam-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 2px solid var(--purple);
  border-radius: 14px;
  padding: 6px 18px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow-soft);
}

.exam-title { font-family: 'Fredoka', sans-serif; font-size: 0.92rem; color: var(--ink); }

.tabs { display: flex; gap: 6px; }
.tab-btn {
  padding: 4px 13px;
  border: 2px solid var(--purple);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
}
.tab-btn.active { background: linear-gradient(135deg, var(--purple-dark), var(--pink-dark)); color: #fff; border-color: transparent; }

.timer-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #FFF3B0, #FFE066);
  padding: 4px 13px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(255, 193, 7, 0.3);
}
.timer-icon { font-size: 0.9rem; }
.timer {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #7A5B00;
}
.timer.warning { color: #C9660A; }
.timer.danger { color: var(--danger-dark); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.task-panel { display: none; }

.split-panel.active {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}

.pane {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 150px);
  max-height: 1300px;
  min-height: 480px;
  font-family: var(--font-exam);
}

.pane p { font-size: 0.95rem; line-height: 1.6; }

.pane-question { border: 3px solid var(--blue); overflow-y: auto; }
.pane-editor { border: 3px solid var(--green); overflow: hidden; padding: 0; }

.type-badge {
  display: inline-block;
  background: var(--blue);
  color: #1D5E82;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
  align-self: flex-start;
  font-family: 'Fredoka', sans-serif;
  letter-spacing: 0.5px;
}

.chart-svg { width: 100%; height: auto; max-width: 100%; display: block; margin: 12px auto; }

.prompt-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.prompt-table th, .prompt-table td {
  border: 1px solid var(--blue);
  padding: 8px 12px;
  text-align: center;
  font-size: 0.88rem;
}
.prompt-table th { background: #EAF6FF; }

.pie-legend-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 4px; }
.pie-legend-grid span { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.pie-legend-grid i { width: 10px; height: 10px; display: inline-block; border-radius: 2px; }

.editor-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }

textarea.essay-input {
  width: 100%;
  flex: 1;
  min-height: 0;
  padding: 20px 20px 8px 20px;
  border: none;
  border-radius: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  font-family: var(--font-exam);
  resize: none;
  background: transparent;
  color: var(--ink);
}
textarea.essay-input:focus { outline: none; }

.word-count {
  flex-shrink: 0;
  align-self: flex-end;
  font-size: 0.75rem;
  font-weight: 600;
  color: #B3B0C9;
  padding: 4px 20px 10px 0;
}

.exam-actions-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

.exam-actions-bar .btn {
  padding: 7px 20px;
  font-size: 0.85rem;
  box-shadow: none;
}

/* ===================== MODAL ===================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(59, 51, 85, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 30px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  border: 4px solid var(--purple);
  animation: popIn 0.2s ease;
}

@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-mascot { width: 84px; margin: 0 auto 10px; }
.modal-mascot svg { width: 100%; display: block; }
.modal-card h3 { margin-bottom: 8px; color: var(--ink); }
.modal-card p { color: #5B5579; font-size: 0.92rem; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ===================== RESULT SCREEN ===================== */
.loading-box { text-align: center; padding: 60px 20px; color: var(--muted); }

.spinner {
  width: 44px; height: 44px;
  border: 5px solid var(--purple);
  border-top-color: var(--pink-dark);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.result-card {
  background: #fff;
  border: 3px solid var(--blue);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.result-card h2 { margin-top: 0; }

.band-overall { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }

.band-overall .band-number {
  font-family: 'Fredoka', sans-serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--purple-dark), var(--pink-dark));
  border-radius: 50%;
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.criterion-item { border: 2px solid var(--blue); border-radius: var(--radius-md); padding: 14px; background: #F8FCFF; }
.criterion-item .label { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.criterion-item .score { font-family: 'Fredoka', sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--purple-dark); margin: 4px 0; }
.criterion-item .comment { font-size: 0.88rem; color: var(--ink); }

.feedback-section { margin-top: 18px; }
.feedback-section h4 { margin-bottom: 8px; }
.feedback-section ul { margin: 0; padding-left: 20px; }
.feedback-section li { margin-bottom: 6px; }

.error-box {
  background: #FFF0F3;
  border: 2px solid var(--danger);
  color: var(--danger-dark);
  padding: 18px;
  border-radius: var(--radius-md);
}

.result-actions { display: flex; justify-content: center; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

.criterion-item .weight {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--purple);
  color: var(--purple-dark);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}

.note-box {
  background: #FFF9E5;
  border: 2px dashed var(--yellow-dark);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 0.88rem;
  color: #6b5200;
  margin-bottom: 20px;
}

.word-count-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

/* ===================== DETAIL SCREEN ===================== */
:root {
  --hl-task-bg: #FFE066;
  --hl-task-border: #C98F00;
  --hl-coherence-bg: #A7E8F0;
  --hl-coherence-border: #1D94A8;
  --hl-lexical-bg: #E3C9FF;
  --hl-lexical-border: #8A4FD1;
  --hl-grammar-bg: #FFC8A2;
  --hl-grammar-border: #D96A1F;
  --hl-positive-bg: #CDEAC0;
  --hl-positive-border: #3F9142;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  background: #fff;
  border: 2px solid var(--purple);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
}

.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; font-weight: 600; color: var(--ink); }
.dot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; border: 2px solid rgba(0,0,0,0.15); }
.dot-task { background: var(--hl-task-bg); }
.dot-coherence { background: var(--hl-coherence-bg); }
.dot-lexical { background: var(--hl-lexical-bg); }
.dot-grammar { background: var(--hl-grammar-bg); }
.dot-positive { background: var(--hl-positive-bg); }

.detail-panel { display: none; }
.detail-panel.active { display: block; animation: fadeIn 0.25s ease; }

.essay-display {
  background: #fff;
  border: 3px solid var(--purple);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 20px;
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 1rem;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

mark.hl {
  padding: 2px 4px;
  border-radius: 5px;
  cursor: pointer;
  transition: transform 0.12s;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.hl:hover { transform: scale(1.03); }
mark.hl-task { background: var(--hl-task-bg); }
mark.hl-coherence { background: var(--hl-coherence-bg); }
mark.hl-lexical { background: var(--hl-lexical-bg); }
mark.hl-grammar { background: var(--hl-grammar-bg); }
mark.hl-positive { background: var(--hl-positive-bg); }

.annotation-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }

.annotation-card {
  background: #fff;
  border-left: 7px solid var(--muted);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: background 0.15s;
}
.annotation-card:hover { background: #FBFAFF; }
.annotation-card.anno-task { border-left-color: var(--hl-task-border); }
.annotation-card.anno-coherence { border-left-color: var(--hl-coherence-border); }
.annotation-card.anno-lexical { border-left-color: var(--hl-lexical-border); }
.annotation-card.anno-grammar { border-left-color: var(--hl-grammar-border); }
.annotation-card.anno-positive { border-left-color: var(--hl-positive-border); }

.annotation-cat { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 4px; }
.annotation-quote { font-style: italic; color: var(--ink); margin-bottom: 6px; }
.annotation-issue { font-size: 0.9rem; color: #4A4568; margin-bottom: 4px; }
.annotation-suggestion { font-size: 0.9rem; color: #2F8F3B; font-weight: 600; }

@keyframes flashFade { from { outline-color: rgba(255, 99, 71, 0.9); } to { outline-color: rgba(255, 99, 71, 0); } }
.flash { outline: 3px solid rgba(255, 99, 71, 0.9); outline-offset: 3px; animation: flashFade 1.1s ease forwards; }

@media (max-width: 760px) {
  .split-panel.active { grid-template-columns: 1fr; }
  .pane, .pane-question { height: 48vh; max-height: 440px; min-height: 320px; }
  .mascot-owl { width: 92px; }
  .exam-topbar { flex-direction: column; align-items: stretch; text-align: center; }
  .band-overall { flex-direction: column; text-align: center; }
}
