:root {
  --red: #852d27;
  --red-deep: #521c19;
  --red-light: #b4503d;
  --gold: #c7a15a;
  --gold-soft: #ead8ad;
  --paper: #fbf6e9;
  --paper-deep: #efe3c7;
  --ink: #2d2621;
  --muted: #75695d;
  --green: #496d60;
  --sky: #5ba8bd;
  --orange: #e28b45;
  --purple: #8b72b8;
  --shadow: 0 18px 50px rgba(65, 38, 22, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(199,161,90,.13), transparent 24rem),
    radial-gradient(circle at 92% 22%, rgba(91,168,189,.12), transparent 20rem),
    radial-gradient(circle at 20% 72%, rgba(226,139,69,.11), transparent 19rem),
    linear-gradient(90deg, rgba(82,28,25,.035) 1px, transparent 1px),
    #f4eedf;
  background-size: auto, auto, auto, 32px 32px, auto;
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
}
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  color: white;
  background: rgba(82, 28, 25, .97);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 8px 25px rgba(30, 14, 10, .18);
}
.site-header::after {
  content: "";
  position: absolute;
  inset: auto 0 -9px;
  height: 7px;
  background: repeating-linear-gradient(90deg, transparent 0 12px, var(--gold) 12px 15px);
  opacity: .35;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  text-decoration: none;
}
.brand-seal {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 50% 50% 46% 50%;
  font-size: 22px;
  font-weight: 700;
  box-shadow: inset 0 0 0 4px rgba(199,161,90,.12);
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .14em; }
.brand small { margin-top: 2px; color: #decda8; font-size: 10px; letter-spacing: .08em; }
nav { display: flex; gap: 8px; }
.nav-btn {
  padding: 9px 14px;
  color: #eadfc9;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
}
.nav-btn.active { color: var(--red-deep); background: var(--gold-soft); }

.hero {
  min-height: 520px;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 40px;
  align-items: center;
  padding: 70px max(24px, calc((100vw - 1180px) / 2));
  color: white;
  background:
    linear-gradient(105deg, rgba(55,18,16,.95), rgba(112,37,31,.76)),
    url("/assets/youth-map.jpg") center 48% / cover;
  overflow: hidden;
  position: relative;
}
.hero::before, .hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(234,216,173,.18);
  border-radius: 50%;
}
.hero::before { width: 360px; height: 360px; left: -180px; bottom: -180px; }
.hero::after { width: 520px; height: 520px; right: -210px; top: -280px; }
.hero-copy, .hero-card { position: relative; z-index: 1; }
.eyebrow { color: var(--gold); font-size: 13px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; }
.hero h1 {
  margin: 18px 0;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 1.12;
  letter-spacing: .08em;
}
.hero h1 span { color: var(--gold-soft); }
.hero-copy > p:not(.eyebrow) { max-width: 560px; color: #eadfd1; line-height: 1.9; }
.primary-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 22px;
  color: white;
  background: var(--red);
  border: 1px solid var(--red);
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(82,28,25,.18);
  text-decoration: none;
  transition: .2s ease;
}
.hero .primary-btn { margin-top: 20px; color: var(--red-deep); background: var(--gold-soft); border-color: var(--gold-soft); }
.primary-btn:hover { transform: translateY(-2px); filter: brightness(1.06); }
.hero-card {
  max-width: 380px;
  justify-self: end;
  padding: 20px 35px 32px;
  text-align: center;
  border: 1px solid rgba(234,216,173,.45);
  background: rgba(54,18,16,.45);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 0 45px rgba(199,161,90,.08);
}
.hero-guide { width: 175px; height: 190px; margin: -65px auto -5px; object-fit: contain; object-position: top; filter: drop-shadow(0 12px 12px rgba(20,10,5,.22)); }
.hero-card p { margin: 26px 0 8px; color: var(--gold-soft); letter-spacing: .22em; }
.hero-card strong, .hero-card small { display: block; }
.hero-card strong { font-size: 25px; letter-spacing: .12em; }
.hero-card small { margin-top: 12px; color: #dccdbd; }
.moon {
  position: absolute;
  top: 32px;
  right: 44px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: 0 0 35px rgba(234,216,173,.32);
}
.roof { position: relative; height: 30px; margin: auto; background: var(--red-light); border-bottom: 5px solid var(--gold); }
.roof::before {
  content: "";
  position: absolute;
  left: -34px;
  right: -34px;
  top: -18px;
  height: 30px;
  background: var(--gold);
  clip-path: polygon(9% 55%, 50% 0, 91% 55%, 100% 100%, 0 100%);
}
.roof::after {
  content: "";
  position: absolute;
  left: 15px; right: 15px; bottom: -32px; height: 26px;
  background: repeating-linear-gradient(90deg, var(--red-light) 0 13px, var(--gold) 13px 17px);
}
.roof-large { width: 210px; }

.official-resources {
  display: grid;
  grid-template-columns: 1.45fr repeat(5, 1fr);
  max-width: 1180px;
  margin: -28px auto 0;
  position: relative;
  z-index: 2;
  background: var(--paper);
  border: 1px solid #d9c398;
  box-shadow: var(--shadow);
}
.official-resources > div, .official-resources a { min-height: 76px; padding: 16px 18px; border-right: 1px solid #e1d3b7; }
.official-resources > div { display: grid; align-content: center; color: white; background: var(--red); }
.official-resources > div span { color: var(--gold-soft); font-size: 11px; letter-spacing: .16em; }
.official-resources > div strong { margin-top: 4px; }
.official-resources a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--red-deep);
  font-weight: 700;
  text-decoration: none;
  transition: .2s;
}
.official-resources a:hover { color: white; background: var(--red-light); }
.official-resources b { color: var(--gold); }

.explorer-strip {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 25px;
  align-items: center;
  max-width: 1080px;
  min-height: 150px;
  margin: 42px auto -22px;
  padding: 18px 28px 18px 18px;
  overflow: hidden;
  color: #493629;
  background: linear-gradient(115deg, #fff6d4, #fffdf4 60%, #dff2ec);
  border: 2px dashed #d4ad62;
  border-radius: 28px 8px 28px 8px;
  box-shadow: 0 14px 30px rgba(65,38,22,.1);
}
.explorer-strip img { align-self: end; width: 185px; height: 140px; object-fit: contain; object-position: bottom; }
.explorer-strip span { color: var(--orange); font-size: 12px; font-weight: 700; letter-spacing: .18em; }
.explorer-strip strong { display: block; margin: 6px 0; color: var(--red); font-size: 24px; }
.explorer-strip p { margin: 0; color: var(--muted); line-height: 1.7; }
.explorer-badges { display: grid; gap: 8px; }
.explorer-badges b { padding: 8px 13px; color: white; background: var(--sky); border-radius: 99px; font-size: 13px; text-align: center; transform: rotate(-2deg); }
.explorer-badges b:nth-child(2) { background: var(--orange); transform: rotate(2deg); }
.explorer-badges b:nth-child(3) { background: var(--green); transform: rotate(-1deg); }

.journey-wrap {
  display: grid;
  grid-template-columns: 210px minmax(0, 920px);
  gap: 34px;
  max-width: 1200px;
  margin: 55px auto 90px;
  padding: 0 24px;
}
.journey-nav {
  position: sticky;
  top: 100px;
  align-self: start;
  display: grid;
  gap: 5px;
  padding: 22px;
  border: 1px solid #dfcfaa;
  background: rgba(251,246,233,.78);
  box-shadow: var(--shadow);
}
.journey-nav p { margin: 0 0 10px; color: var(--red); font-weight: 700; letter-spacing: .2em; }
.journey-nav a {
  padding: 10px 12px;
  color: var(--muted);
  border-left: 2px solid #dfcfaa;
  text-decoration: none;
}
.journey-nav a:hover, .journey-nav a.active { color: var(--red); border-color: var(--red); background: #f2e6cc; }
.journey-nav span { margin-top: 15px; color: var(--green); font-size: 12px; }

.homework-form { min-width: 0; }
.paper-section {
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: auto 1000px;
  margin-bottom: 30px;
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid #dcc9a0;
  border-radius: 2px var(--radius) 2px var(--radius);
  background: linear-gradient(135deg, rgba(255,253,246,.98), rgba(251,246,233,.98));
  box-shadow: var(--shadow);
}
.paper-section::before {
  content: "";
  position: absolute;
  left: 10px; right: 10px; top: 10px; bottom: 10px;
  pointer-events: none;
  border: 1px solid rgba(199,161,90,.23);
}
#pre { border-top: 8px solid var(--sky); }
#task1 { border-top: 8px solid var(--green); }
#task2 { border-top: 8px solid var(--orange); }
#task3 { border-top: 8px solid var(--purple); }
#post { border-top: 8px solid var(--gold); }
.section-heading {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 26px;
}
.section-heading p, .section-heading h2 { margin: 0; }
.section-heading p { color: var(--muted); font-size: 13px; letter-spacing: .18em; }
.section-heading h2 { margin-top: 5px; color: var(--red-deep); font-size: clamp(23px, 3vw, 34px); letter-spacing: .08em; }
.chapter {
  display: grid;
  place-items: center;
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  color: var(--paper);
  background: var(--red);
  border: 5px double var(--gold-soft);
  border-radius: 50%;
  font-size: 23px;
}
.chapter-wide {
  flex-basis: auto;
  width: auto;
  min-width: 104px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 16px;
  letter-spacing: .08em;
}
.task-intro { position: relative; z-index: 1; margin: -6px 0 25px; color: var(--muted); line-height: 1.85; }
.exact-brief {
  position: relative;
  z-index: 1;
  margin: 0 0 24px;
  padding: 20px 22px;
  color: #4b4036;
  background: linear-gradient(135deg, #fff8df, #f5e5bf);
  border: 1px solid #d5bb7e;
  border-left: 7px solid var(--orange);
  border-radius: 4px 18px 18px 4px;
  box-shadow: inset 0 1px white;
}
.exact-brief strong { display: inline-block; margin-bottom: 7px; color: var(--red); font-size: 17px; }
.exact-brief p { margin: 5px 0; line-height: 1.9; }
.exact-brief ol { margin: 8px 0 0; padding-left: 24px; line-height: 1.9; }
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 28px; }
.task-top { align-items: start; margin-bottom: 24px; }
.task-top .exact-brief { height: 100%; margin: 0; }
.brief-list { margin-top: 0; padding-left: 24px; line-height: 1.9; }

.qr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 0 0 24px; }
.qr-grid figure {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  align-items: center;
  margin: 0;
  padding: 12px;
  background: white;
  border: 2px dashed #d7b967;
  border-radius: 16px;
  box-shadow: 0 8px 18px rgba(65,38,22,.08);
}
.qr-grid img { display: block; width: 112px; aspect-ratio: 1; object-fit: contain; border-radius: 9px; }
.qr-grid figcaption { display: grid; gap: 5px; }
.qr-grid strong { color: var(--red); font-size: 16px; }
.qr-grid span { color: var(--muted); font-size: 12px; line-height: 1.5; }

label { display: grid; gap: 8px; color: var(--red-deep); font-weight: 700; }
input, textarea, select {
  width: 100%;
  color: var(--ink);
  background: rgba(255,253,247,.8);
  border: 1px solid #d8c8a7;
  border-radius: 7px;
  outline: none;
}
input, select { height: 43px; padding: 0 12px; }
textarea { min-height: 80px; padding: 12px; line-height: 1.7; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--red-light); box-shadow: 0 0 0 3px rgba(180,80,61,.1); }
input::placeholder, textarea::placeholder { color: #aa9c89; }
.form-grid { display: grid; gap: 20px; margin: 18px 0; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.notice { margin-top: 20px; padding: 12px 14px; color: var(--muted); background: #f1e7d0; border-left: 3px solid var(--gold); font-size: 13px; }
.counter { float: right; color: var(--green); font-size: 12px; font-weight: 400; }

.level-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 26px; }
.level-guide {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 3px;
  padding: 12px 16px;
  color: #5b4937;
  background: linear-gradient(90deg, #fff3c7, #eef7e9);
  border: 2px dashed #d5ae58;
  border-radius: 14px;
}
.level-guide strong { flex: 0 0 auto; color: var(--red); font-size: 17px; }
.level-guide span { line-height: 1.6; }
.level-card {
  display: grid;
  gap: 8px;
  min-height: 225px;
  height: auto;
  padding: 18px;
  text-align: left;
  color: var(--ink);
  background: rgba(255,253,247,.72);
  border: 1px solid #d8c8a7;
  border-radius: 12px;
  transition: .2s;
}
.level-card:hover { transform: translateY(-3px); border-color: var(--red-light); }
.level-card.selected { color: white; background: var(--red); border-color: var(--red); box-shadow: 0 10px 25px rgba(82,28,25,.18); }
.level-card strong { color: var(--red); font-size: 18px; }
.level-card.selected strong, .level-card.selected ul { color: white; }
.level-card span { color: var(--gold); font-size: 11px; letter-spacing: .16em; }
.level-card ul { display: grid; gap: 8px; margin: 3px 0 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.level-card li { padding-left: 2px; }
.level-card:nth-child(1) { border-top: 5px solid var(--green); }
.level-card:nth-child(2) { border-top: 5px solid var(--orange); }
.level-card:nth-child(3) { border-top: 5px solid var(--purple); }
.level-card.selected:nth-child(1) { background: var(--green); }
.level-card.selected:nth-child(2) { background: #b66535; }
.level-card.selected:nth-child(3) { background: #665080; }

.reference-card {
  align-self: start;
  padding: 0;
  overflow: hidden;
  color: var(--red-deep);
  background: white;
  border: 1px solid #d8c8a7;
  border-radius: 9px;
  box-shadow: 0 10px 22px rgba(65,38,22,.1);
  transition: .2s ease;
}
.reference-card:hover { transform: translateY(-3px) rotate(1deg); border-color: var(--red-light); }
.reference-card img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: center top; }
.reference-card span { display: block; padding: 11px; color: white; background: var(--red); font-weight: 700; text-align: center; }
.kid-tip {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 15px;
  align-items: center;
  max-width: 580px;
  margin: -10px 0 24px;
  padding: 10px 18px 10px 8px;
  color: var(--muted);
  background: #e7f4ee;
  border: 2px dashed #9bbfb2;
  border-radius: 18px 18px 18px 3px;
}
.kid-tip img { width: 76px; height: 76px; object-fit: contain; object-position: bottom; }
.kid-tip p { margin: 0; line-height: 1.65; }
.kid-tip strong { display: block; color: var(--green); }
.kid-tip.guide-tip { background: #eee8f7; border-color: #b8a4d2; }
.kid-tip.guide-tip strong { color: var(--purple); }
.ai-card { margin: 22px 0; border: 1px solid #ccb57c; background: #f2e7cc; border-radius: 9px; }
.ai-card summary { display: flex; justify-content: space-between; gap: 15px; padding: 15px 18px; color: var(--red-deep); cursor: pointer; font-weight: 700; }
.ai-card summary small { color: var(--muted); font-weight: 400; }
.ai-body { padding: 0 18px 18px; color: var(--muted); line-height: 1.75; }
.ai-body p { padding-left: 13px; border-left: 2px solid var(--gold); }
.copy-btn, .ghost-btn {
  padding: 9px 14px;
  color: var(--red);
  background: transparent;
  border: 1px solid var(--red-light);
  border-radius: 7px;
}
.ai-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ai-launch, .slides-btn {
  padding: 10px 16px;
  color: white;
  background: var(--purple);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 7px 15px rgba(75,54,104,.18);
}
.slides-btn {
  display: block;
  margin: 25px auto 0;
  color: var(--red-deep);
  background: #f2d98e;
  border: 1px solid #d2af55;
}
.route-explorer {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.45fr .85fr;
  gap: 0;
  overflow: hidden;
  margin: 0 0 24px;
  background: #fffaf0;
  border: 1px solid #d9c398;
  border-radius: 18px;
  box-shadow: 0 12px 25px rgba(65,38,22,.09);
}
.route-explorer img { width: 100%; height: 240px; object-fit: cover; }
.route-explorer div { display: grid; align-content: center; padding: 24px; background: linear-gradient(145deg, #fff4cf, #f3d99b); }
.route-explorer strong { color: var(--red); font-size: 22px; }
.route-explorer p { line-height: 1.8; }
.route-explorer a { color: var(--red); font-weight: 700; }
.reflection { padding-top: 4px; }
.checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin-top: 22px;
  padding: 15px;
  border-top: 1px dashed #cfb987;
  border-bottom: 1px dashed #cfb987;
}
.checklist strong { color: var(--red); margin-right: 8px; }
.checklist label { display: flex; flex-direction: row; align-items: center; color: var(--muted); font-size: 13px; font-weight: 400; }
.checklist input { width: 17px; height: 17px; accent-color: var(--red); }
.submit-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;
  padding: 28px 34px;
  color: white;
  background: var(--red-deep);
  border-top: 4px solid var(--gold);
  box-shadow: var(--shadow);
}
.submit-section p, .submit-section h2 { margin: 0; }
.submit-section p { color: var(--gold-soft); font-size: 12px; letter-spacing: .12em; }
.submit-section h2 { margin-top: 7px; }
.submit-btn { background: var(--gold); border-color: var(--gold); color: var(--red-deep); }

.hidden { display: none !important; }
.teacher-view { min-height: calc(100vh - 72px); padding: 50px max(24px, calc((100vw - 1280px) / 2)); }
.teacher-login {
  max-width: 480px;
  margin: 60px auto;
  padding: 48px;
  text-align: center;
  background: var(--paper);
  border: 1px solid #dbc79e;
  box-shadow: var(--shadow);
}
.teacher-login .brand-seal { margin: auto; color: var(--red); }
.teacher-login h1 { color: var(--red-deep); }
.teacher-login p, .teacher-login small { color: var(--muted); }
.teacher-login form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 25px 0; }
.dashboard { max-width: 1280px; margin: auto; }
.dashboard-head, .dashboard-actions, .card-head, .results-head, .filters {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.dashboard-head { margin-bottom: 25px; }
.dashboard-head h1 { margin: 3px 0 0; color: var(--red-deep); font-size: 36px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi-card, .dashboard-card { background: var(--paper); border: 1px solid #ddcba5; box-shadow: var(--shadow); }
.kpi-card { padding: 22px; border-top: 4px solid var(--red); }
.kpi-card span { color: var(--muted); font-size: 13px; }
.kpi-card strong { display: block; margin-top: 8px; color: var(--red-deep); font-size: 32px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 18px; margin-bottom: 18px; }
.dashboard-card { padding: 24px; }
.card-head { margin-bottom: 20px; }
.card-head h2 { margin: 0; color: var(--red-deep); font-size: 20px; }
.card-head span { color: var(--muted); font-size: 12px; }
.bar-row { display: grid; grid-template-columns: 68px 1fr 42px; gap: 10px; align-items: center; margin: 14px 0; font-size: 13px; }
.bar-track { height: 10px; overflow: hidden; background: #eadfc7; border-radius: 99px; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--red-light)); border-radius: inherit; }
.stack-row { margin: 15px 0; }
.stack-label { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 13px; }
.stack-bar { display: flex; overflow: hidden; height: 15px; background: #eadfc7; border-radius: 99px; }
.stack-bar span:nth-child(1) { background: var(--green); }
.stack-bar span:nth-child(2) { background: var(--gold); }
.stack-bar span:nth-child(3) { background: var(--red-light); }
.legend { display: flex; gap: 15px; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 50%; }
.legend i:nth-of-type(1) { background: var(--green); }
.legend i:nth-of-type(2) { background: var(--gold); }
.legend i:nth-of-type(3) { background: var(--red-light); }
.filters input { width: 230px; }
.filters select { width: 125px; }
.results-table { overflow-x: auto; }
.results-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th, .results-table td { padding: 13px 10px; text-align: left; border-bottom: 1px solid #e5d9c0; }
.results-table th { color: var(--red-deep); background: #f1e7d0; }
.results-table td { color: var(--muted); }
.level-tag { padding: 3px 8px; color: var(--red); background: #f1dfca; border-radius: 99px; white-space: nowrap; }
.view-work, .delete-work { padding: 6px 8px; color: var(--red); background: transparent; border: 0; text-decoration: underline; }
.delete-work { color: #8f7765; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

dialog {
  max-width: min(900px, 92vw);
  max-height: 88vh;
  padding: 38px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--gold);
  box-shadow: 0 25px 90px rgba(40,20,15,.35);
}
dialog::backdrop { background: rgba(42,20,17,.72); backdrop-filter: blur(3px); }
#imageDialog { padding: 15px; }
#imageDialog img { display: block; width: 100%; height: auto; border: 1px solid #d8c8a7; }
.slide-dialog { width: min(1100px, 94vw); }
#slideGallery { display: grid; gap: 18px; max-height: 80vh; overflow: auto; padding: 20px 8px; }
.slide-item { display: grid; gap: 7px; }
.slide-item span { color: var(--red); font-weight: 700; }
.slide-controls { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; padding: 10px; background: rgba(251,246,233,.94); }
.slide-controls button { padding: 10px 15px; color: white; background: var(--red); border: 0; border-radius: 7px; }
.slide-controls button:last-child { justify-self: end; }
.slide-controls button:disabled { opacity: .35; }
.image-retrying { min-height: 120px; opacity: .45; background: linear-gradient(100deg, #efe3ca, #fff9e9, #efe3ca); }
.dialog-close { position: absolute; top: 7px; right: 9px; width: 30px; height: 30px; color: white; background: var(--red); border: 0; border-radius: 50%; }
.work-detail h2 { color: var(--red-deep); }
.work-detail h3 { margin-top: 25px; padding-bottom: 7px; color: var(--red); border-bottom: 1px solid #d8c8a7; }
.work-detail p { white-space: pre-wrap; line-height: 1.75; }
.work-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.work-meta span { padding: 5px 9px; background: #eee1c7; border-radius: 99px; font-size: 12px; }

#toast {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: 25px;
  transform: translate(-50%, 120px);
  padding: 12px 20px;
  color: white;
  background: var(--red-deep);
  border: 1px solid var(--gold);
  border-radius: 7px;
  opacity: 0;
  transition: .25s;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

.voice-wrap { position: relative; display: block; }
.voice-wrap textarea, .voice-wrap input { padding-right: 104px; }
.voice-btn {
  padding: 7px 11px;
  color: var(--red);
  background: #fff4cd;
  border: 1px solid #d7b967;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.voice-wrap > .voice-btn { position: absolute; right: 8px; bottom: 8px; }
.voice-btn.listening { color: white; background: #d64e43; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(214,78,67,.12); } }

.floating-ai {
  position: fixed;
  z-index: 19;
  right: 20px;
  bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 15px 6px 4px;
  color: white;
  background: linear-gradient(135deg, var(--purple), #5d4c85);
  border: 2px solid #ead8ad;
  border-radius: 999px;
  box-shadow: 0 15px 35px rgba(53,35,73,.28);
}
.floating-ai img { width: 48px; height: 48px; object-fit: contain; object-position: top; background: white; border-radius: 50%; }
.ai-dialog { width: min(760px, 94vw); padding: 0; overflow: hidden; border-radius: 20px; }
.ai-dialog-head { display: flex; gap: 18px; align-items: center; padding: 20px 28px; color: white; background: linear-gradient(135deg, #6f568c, #443762); }
.ai-dialog-head img { width: 80px; height: 85px; object-fit: contain; object-position: top; background: #fff4dc; border-radius: 50%; }
.ai-dialog-head h2, .ai-dialog-head p { margin: 3px 0; }
.ai-dialog-head span { color: #f2d98e; font-size: 11px; letter-spacing: .15em; }
.ai-dialog-head span.connected { color: #bcebc8; }
.role-tabs { display: flex; gap: 7px; padding: 12px 18px; overflow-x: auto; background: #f2e7cc; }
.role-tabs button { padding: 8px 12px; white-space: nowrap; color: var(--red); background: white; border: 1px solid #d7c18e; border-radius: 99px; }
.role-tabs button.active { color: white; background: var(--red); }
.chat-messages { display: grid; gap: 12px; min-height: 260px; max-height: 46vh; overflow: auto; padding: 20px; background: #fffaf0; }
.chat-message { max-width: 84%; padding: 12px 15px; border-radius: 16px; line-height: 1.7; white-space: pre-wrap; }
.chat-message.ai { justify-self: start; background: #eee2f5; border-bottom-left-radius: 3px; }
.chat-message.user { justify-self: end; color: white; background: var(--red-light); border-bottom-right-radius: 3px; }
.chat-message small { display: block; margin-bottom: 3px; opacity: .65; font-size: 10px; }
.speak-message { display: block; margin-top: 8px; padding: 4px 8px; color: #5d4c85; background: rgba(255,255,255,.7); border: 1px solid #cbb9dc; border-radius: 99px; font-size: 11px; }
.chat-compose { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 15px 18px 18px; background: #f2e7cc; }
.chat-compose textarea { min-height: 65px; }
.chat-voice { align-self: end; height: 42px; }
.chat-compose .primary-btn { align-self: end; height: 42px; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero-card { display: none; }
  .journey-wrap { grid-template-columns: 1fr; }
  .journey-nav { position: static; display: flex; overflow-x: auto; }
  .journey-nav p, .journey-nav span { display: none; }
  .journey-nav a { white-space: nowrap; border-left: 0; border-bottom: 2px solid #dfcfaa; }
  .level-picker, .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .level-guide { grid-column: 1 / -1; }
  .level-card:last-child { grid-column: 1 / -1; }
  .chart-grid { grid-template-columns: 1fr; }
  .results-head { align-items: flex-start; flex-direction: column; }
  .official-resources { grid-template-columns: repeat(3, 1fr); margin: 0; max-width: none; }
  .official-resources > div { grid-column: 1 / -1; }
  .explorer-strip { margin-left: 20px; margin-right: 20px; }
}

@media (max-width: 700px) {
  .site-header { height: 64px; padding: 0 14px; }
  .brand small { display: none; }
  .brand-seal { width: 36px; height: 36px; font-size: 18px; }
  .hero {
    min-height: 430px;
    padding: 50px 22px;
    background:
      linear-gradient(105deg, rgba(55,18,16,.96), rgba(112,37,31,.82)),
      url("/assets/youth-map-mobile.jpg") center 48% / cover;
  }
  .hero h1 { font-size: 42px; }
  .official-resources { grid-template-columns: repeat(2, 1fr); }
  .official-resources a { min-height: 58px; padding: 12px; font-size: 13px; }
  .explorer-strip { grid-template-columns: 90px 1fr; gap: 12px; margin: 22px 12px 0; padding: 14px; }
  .explorer-strip img { width: 90px; height: 105px; }
  .explorer-strip strong { font-size: 18px; }
  .explorer-strip p { font-size: 12px; }
  .explorer-badges { display: none; }
  .journey-wrap { margin-top: 22px; padding: 0 12px; }
  .paper-section { padding: 25px 18px; }
  .task-layout, .form-grid.two, .form-grid.three, .level-picker, .kpi-grid { grid-template-columns: 1fr; }
  .level-card:last-child { grid-column: auto; }
  .level-guide { display: grid; gap: 3px; }
  .reference-card { display: grid; grid-template-columns: 120px 1fr; align-items: stretch; width: 100%; }
  .reference-card img { height: 90px; aspect-ratio: auto; }
  .reference-card span { display: grid; place-items: center; }
  .qr-grid { grid-template-columns: 1fr; }
  .qr-grid figure { grid-template-columns: 105px 1fr; }
  .qr-grid img { width: 105px; }
  .ai-card summary { display: grid; }
  .submit-section, .dashboard-head { align-items: stretch; flex-direction: column; }
  .teacher-view { padding: 25px 12px; }
  .teacher-login { padding: 30px 20px; }
  .teacher-login form { grid-template-columns: 1fr; }
  .filters { width: 100%; flex-direction: column; align-items: stretch; }
  .filters input, .filters select { width: 100%; }
  .route-explorer { grid-template-columns: 1fr; }
  .route-explorer img { height: 190px; }
  .chat-compose { grid-template-columns: 1fr 1fr; }
  .chat-compose textarea { grid-column: 1 / -1; }
  .floating-ai span { display: none; }
  .floating-ai { right: 12px; bottom: 12px; padding: 3px; }
}
