:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #647086;
  --soft: #f5f7fb;
  --paper: #ffffff;
  --line: rgba(23, 32, 51, .12);
  --teal: #167a7f;
  --blue: #315fbd;
  --coral: #e4654f;
  --gold: #d69b2d;
  --plum: #6d4aa1;
  --mint: #dff5ef;
  --shadow: 0 24px 70px rgba(23, 32, 51, .14);
  --shadow-soft: 0 12px 35px rgba(23, 32, 51, .09);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(22, 122, 127, .16), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(228, 101, 79, .12), transparent 30rem),
    linear-gradient(135deg, #fbfcff 0%, #f3f6fa 46%, #f9fbf8 100%);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 16px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: white;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 12px 28px rgba(22, 122, 127, .28);
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

#main-nav { display: grid; gap: 6px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  color: #3f4b60;
  transition: background .2s ease, color .2s ease, transform .2s ease;
}
.nav-link:hover { background: rgba(22, 122, 127, .08); transform: translateX(2px); }
.nav-link.active { background: #172033; color: white; box-shadow: var(--shadow-soft); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }

.nav-foot {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.76);
}
.mini-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}
.progress-shell {
  height: 9px;
  margin: 10px 0 8px;
  border-radius: 999px;
  background: rgba(23, 32, 51, .09);
  overflow: hidden;
}
.progress-shell span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width .4s ease;
}
.nav-foot small { color: var(--muted); }

.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 8;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand.compact { padding: 0; }
.brand.compact .brand-mark { width: 38px; height: 38px; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}

main {
  min-width: 0;
  padding: 34px clamp(18px, 4vw, 56px) 56px;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  animation: pageIn .42s ease both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  padding: clamp(28px, 6vw, 72px);
  color: white;
  background:
    linear-gradient(125deg, rgba(12, 22, 38, .96), rgba(31, 69, 87, .92) 55%, rgba(106, 74, 161, .82)),
    url("../assets/images/image_03_53c87d6fa389.jpg") center/cover;
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -38% 42%;
  height: 70%;
  background: radial-gradient(circle, rgba(255,255,255,.2), transparent 65%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: rgba(255,255,255,.88);
  font-size: 13px;
  font-weight: 700;
}
h1, h2, h3 {
  margin: 0;
  letter-spacing: 0;
}
h1, .display {
  max-width: 820px;
  margin-top: 20px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(42px, 7vw, 86px);
  line-height: .96;
}
.hero-copy {
  max-width: 780px;
  margin: 22px 0 0;
  color: rgba(255,255,255,.82);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.55;
}
.hero-actions, .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 0;
  border-radius: 14px;
  background: #172033;
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(23,32,51,.16);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.button:hover { transform: translateY(-2px); box-shadow: 0 18px 34px rgba(23,32,51,.2); }
.button.light { background: white; color: #172033; }
.button.ghost { background: rgba(255,255,255,.12); color: white; border: 1px solid rgba(255,255,255,.22); }
.button.subtle { background: #eef4f6; color: #23414a; box-shadow: none; }
.button.small { min-height: 34px; padding: 7px 11px; border-radius: 11px; font-size: 13px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.kpi {
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.72);
  border: 1px solid rgba(255,255,255,.72);
  box-shadow: var(--shadow-soft);
}
.hero .kpi { background: rgba(255,255,255,.13); color: white; border-color: rgba(255,255,255,.18); box-shadow: none; }
.kpi strong { display:block; font-size: 28px; line-height: 1; }
.kpi span { display:block; margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.hero .kpi span { color: rgba(255,255,255,.72); }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 38px 0 18px;
}
.section-head h2 {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(28px, 4vw, 46px);
}
.section-head p {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.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)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.card {
  position: relative;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.78);
  box-shadow: var(--shadow-soft);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(22,122,127,.25); }
.card h3 { font-size: 18px; line-height: 1.25; }
.card p { color: var(--muted); line-height: 1.6; margin: 10px 0 0; }
.card.compact { padding: 15px; }
.card.accent { border-top: 4px solid var(--teal); }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef4f6;
  color: #31515b;
  font-size: 12px;
  font-weight: 800;
}
.tag.warn { background: #fff1df; color: #86550d; }
.tag.prof { background: #eaf7f4; color: #126168; }
.tag.exp { background: #f0edff; color: #594199; }
.tag.ext { background: #f8eced; color: #944538; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}
.search {
  min-width: min(100%, 320px);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 0 14px;
  outline: none;
}
.search:focus { border-color: rgba(22,122,127,.5); box-shadow: 0 0 0 4px rgba(22,122,127,.09); }

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}
.timeline::before {
  content:"";
  position:absolute;
  top: 8px;
  bottom: 8px;
  left: 19px;
  width: 2px;
  background: linear-gradient(var(--teal), var(--gold), var(--coral));
  opacity: .45;
}
.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
}
.timeline-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: white;
  border: 2px solid rgba(22,122,127,.35);
  box-shadow: var(--shadow-soft);
  z-index: 1;
  color: var(--teal);
  font-weight: 900;
}

.study-step {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
}
.step-num {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #172033;
  color: white;
  font-weight: 900;
}
.complete-toggle {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}
.complete-toggle.done { background: var(--teal); color: white; border-color: var(--teal); }

body.graph-mode {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}
body.graph-mode .page {
  animation: none;
  transform: none;
}
.graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  align-items: stretch;
  gap: 16px;
}
.graph-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}
.graph-current {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
}
.graph-current strong {
  max-width: min(680px, 48vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}
.button[disabled] {
  opacity: .45;
  pointer-events: none;
}
.graph-expand,
.graph-exit,
.graph-back {
  min-height: 46px;
  border-radius: 16px;
}
.graph-exit {
  background: linear-gradient(135deg, var(--coral), #b84737);
  box-shadow: 0 14px 34px rgba(228,101,79,.24);
}
.graph-stage {
  min-height: 580px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(rgba(255,255,255,.88), rgba(255,255,255,.78)),
    radial-gradient(circle at 30% 25%, rgba(22,122,127,.18), transparent 22rem),
    radial-gradient(circle at 75% 70%, rgba(214,155,45,.14), transparent 24rem);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.graph-svg { width: 100%; height: 100%; min-height: 580px; }
.graph-node circle {
  filter: drop-shadow(0 10px 16px rgba(23,32,51,.18));
  transition: transform .2s ease, opacity .2s ease;
}
.graph-node:hover circle { transform: scale(1.05); }
.graph-node text { font-size: 17px; font-weight: 900; pointer-events: none; fill: #172033; }
.graph-edge { stroke: rgba(49,95,189,.35); stroke-width: 2; }
.graph-info {
  min-height: 0;
  overflow: auto;
}
.graph-info .tag-row .tag {
  min-height: 34px;
  text-align: left;
}
.graph-layout.immersive {
  position: fixed;
  inset: 0;
  z-index: 100;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 18px;
  gap: 14px;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 18% 16%, rgba(22,122,127,.18), transparent 26rem),
    radial-gradient(circle at 84% 14%, rgba(214,155,45,.18), transparent 22rem),
    linear-gradient(135deg, #f7fbff, #edf5ef 55%, #fff8f1);
}
.graph-layout.immersive .graph-topbar {
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(23,32,51,.13);
}
.graph-layout.immersive .graph-stage {
  min-height: 0;
  height: 100%;
  border-radius: 28px;
  background:
    linear-gradient(rgba(255,255,255,.74), rgba(255,255,255,.62)),
    radial-gradient(circle at 28% 28%, rgba(22,122,127,.18), transparent 18rem),
    radial-gradient(circle at 78% 72%, rgba(214,155,45,.16), transparent 18rem);
}
.graph-layout.immersive .graph-svg {
  min-height: 0;
  height: 100%;
}
.graph-layout.immersive .graph-info {
  max-height: 100%;
  border-radius: 24px;
  background: rgba(255,255,255,.84);
  backdrop-filter: blur(18px);
}

.layer-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.layer-tabs button {
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--muted);
  font-weight: 800;
}
.layer-tabs button.active { background: #172033; color: white; }

.quiz-card .option {
  width: 100%;
  display: block;
  margin-top: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  text-align: left;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.quiz-card .option:hover { transform: translateX(3px); border-color: rgba(22,122,127,.45); }
.quiz-card .option.correct { background: #eaf7f4; border-color: rgba(22,122,127,.45); }
.quiz-card .option.wrong { background: #fff0ee; border-color: rgba(228,101,79,.45); }
.answer-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: 14px;
  background: #f5f7fb;
  color: #364258;
  line-height: 1.55;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(23,32,51,.34);
  backdrop-filter: blur(4px);
  animation: fade .2s ease both;
}
.detail-drawer {
  position: fixed;
  z-index: 21;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(620px, calc(100vw - 32px));
  overflow: auto;
  padding: 22px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.8);
  animation: drawerIn .26s ease both;
}
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer-top {
  display:flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 18px;
}
.close-button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}
.transcript-line {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.55;
}
.transcript-line time {
  display: inline-block;
  min-width: 84px;
  color: var(--teal);
  font-weight: 900;
}

.empty {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255,255,255,.62);
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .mobile-bar { display: flex; }
  .side-nav {
    position: fixed;
    inset: 64px auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-104%);
    transition: transform .24s ease;
    box-shadow: var(--shadow);
  }
  body.menu-open .side-nav { transform: translateX(0); }
  main { padding-top: 24px; }
  .kpi-grid, .grid.four, .grid.three, .grid.two, .graph-layout { grid-template-columns: 1fr; }
  .graph-stage, .graph-svg { min-height: 560px; }
  .graph-current strong { max-width: 48vw; }
  .graph-layout.immersive {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) minmax(160px, 26vh);
    padding: 12px;
    height: 100dvh;
    max-height: 100dvh;
  }
  .graph-layout.immersive .graph-stage {
    min-height: 0;
    height: auto;
  }
  .graph-layout.immersive .graph-info {
    max-height: none;
    min-height: 0;
  }
}

@media (max-width: 620px) {
  main { padding-inline: 14px; }
  .hero { border-radius: 20px; padding: 24px; }
  .section-head { display: block; }
  .timeline-item, .study-step { grid-template-columns: 1fr; }
  .timeline::before { display: none; }
  .graph-topbar {
    display: grid;
    grid-template-columns: minmax(70px, auto) minmax(0, 1fr) minmax(70px, auto);
    gap: 8px;
    padding: 8px;
    border-radius: 18px;
  }
  .graph-back,
  .graph-expand,
  .graph-exit {
    min-height: 42px;
    padding: 9px 11px;
    font-size: 13px;
    border-radius: 14px;
    white-space: nowrap;
  }
  .graph-current .tag { display: none; }
  .graph-current strong {
    max-width: 100%;
    font-size: 14px;
    line-height: 1.15;
  }
  .graph-stage {
    min-height: 62vh;
    border-radius: 20px;
  }
  .graph-svg { min-height: 62vh; }
  .graph-node text { font-size: 20px; }
  .graph-info {
    padding: 16px;
    border-radius: 18px;
  }
  .graph-info h3 { font-size: 20px; }
  .graph-info .row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .graph-layout.immersive {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) minmax(145px, 28dvh);
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    gap: 10px;
    min-height: 100dvh;
    max-height: 100dvh;
    background:
      linear-gradient(180deg, rgba(247,251,255,.98), rgba(238,247,241,.98)),
      radial-gradient(circle at 15% 12%, rgba(22,122,127,.16), transparent 18rem);
  }
  .graph-layout.immersive .graph-stage {
    height: auto;
    min-height: 0;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(23,32,51,.15);
  }
  .graph-layout.immersive .graph-svg {
    min-height: 0;
    height: 100%;
  }
  .graph-layout.immersive .graph-node text {
    font-size: 20px;
    font-weight: 950;
  }
  .graph-layout.immersive .graph-edge {
    stroke-width: 3;
  }
  .graph-layout.immersive .graph-info {
    max-height: none;
    min-height: 0;
    padding: 14px;
    border-radius: 22px 22px 18px 18px;
    box-shadow: 0 -10px 36px rgba(23,32,51,.10);
  }
  .graph-layout.immersive .graph-info h3 {
    font-size: 18px;
    margin-bottom: 6px;
  }
  .graph-layout.immersive .graph-info p {
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 10px;
  }
  .graph-layout.immersive .graph-info .tag-row {
    gap: 6px;
  }
  .graph-layout.immersive .graph-info .tag-row:last-child {
    max-height: 58px;
    overflow: auto;
    padding-bottom: 2px;
  }
  .graph-layout.immersive .graph-info .row-actions {
    display: none;
  }
  .detail-drawer {
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    padding: 18px;
    border-radius: 22px;
  }
}
