﻿:root {
  --bg-1: #040507;
  --bg-2: #11141a;
  --ink-1: #f4f6fb;
  --ink-2: #d7dde8;
  --muted: #97a1b4;
  --panel: rgba(18, 21, 27, 0.84);
  --panel-strong: #181c23;
  --line: rgba(186, 198, 221, 0.16);
  --accent: #9ec5ff;
  --accent-2: #6d95d8;
  --accent-bright: #5da4ff;
  --warm: #d8a85d;
  --ok: #79d59a;
  --error: #ff8989;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  --glow-cool: rgba(158, 197, 255, 0.14);
  --glow-warm: rgba(216, 168, 93, 0.12);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink-1);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 680px at 12% -8%, rgba(83, 103, 140, 0.2) 0%, var(--bg-1) 52%, transparent 90%),
    radial-gradient(980px 560px at 95% 4%, rgba(120, 144, 178, 0.16) 0%, var(--bg-2) 42%, transparent 88%),
    linear-gradient(180deg, #030406 0%, #101319 100%);
  background-attachment: fixed;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
  filter: blur(18px);
}

body::before {
  width: 300px;
  height: 300px;
  left: -120px;
  top: 24%;
  border-radius: 50%;
  background: var(--glow-cool);
}

body::after {
  width: 360px;
  height: 360px;
  right: -140px;
  top: 58%;
  border-radius: 42% 58% 51% 49% / 39% 41% 59% 61%;
  background: var(--glow-warm);
}

.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 26px 42px;
}

.landing-shell {
  min-height: 100vh;
}

.landing-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 26px 56px;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 26px;
}

.landing-logo {
  width: clamp(190px, 26vw, 320px);
  max-width: 100%;
  height: auto;
}

.landing-link {
  color: var(--ink-1);
  text-decoration: none;
  font-weight: 700;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 430px);
  gap: 28px;
  align-items: start;
}

.landing-copy {
  padding: 36px 0 12px;
}

.landing-kicker {
  margin: 0 0 14px;
  color: var(--accent-bright);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.landing-copy h1 {
  margin: 0 0 16px;
  font-family: "Fraunces", "Iowan Old Style", "Georgia", serif;
  font-size: clamp(2.7rem, 6vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
}

.landing-lede {
  max-width: 720px;
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: clamp(1.04rem, 1.7vw, 1.18rem);
  line-height: 1.7;
}

.landing-points {
  display: grid;
  gap: 12px;
}

.landing-point {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(18, 22, 29, 0.92) 0%, rgba(10, 13, 18, 0.82) 100%);
  color: var(--ink-2);
}

.landing-auth {
  position: sticky;
  top: 24px;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  min-height: 114px;
  padding: 30px 12px;
  border: 1px solid rgba(186, 198, 221, 0.12);
  border-radius: 18px;
  background: rgba(10, 13, 18, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  z-index: 25;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
}

.topbar-brand {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.topbar-logo {
  display: block;
  width: clamp(180px, 27vw, 315px);
  max-width: 100%;
  height: auto;
}

.topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.auth-panel {
  margin-bottom: 14px;
}

.auth-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.auth-grid {
  align-items: end;
}

.auth-actions {
  align-items: center;
  gap: 10px;
}

.auth-signed-in {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-user-email {
  color: var(--ink-2);
  font-size: 0.96rem;
}

.app-account {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-user-email {
  color: var(--ink-2);
  font-size: 0.92rem;
}

.topbar-title {
  margin: 0;
  font-family: "Fraunces", "Iowan Old Style", "Georgia", serif;
  font-size: clamp(1.08rem, 1.85vw, 1.42rem);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-align: center;
  white-space: nowrap;
}

.topbar-subtitle {
  margin: 0;
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
}

.app-menu {
  position: relative;
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 50px;
  height: 50px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(24, 29, 37, 0.94) 0%, rgba(14, 18, 24, 0.9) 100%);
  box-shadow: var(--shadow);
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--ink-1);
}

.menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: min(320px, calc(100vw - 28px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(16, 20, 27, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
  z-index: 20;
}

.menu-panel[hidden] {
  display: none;
}

.menu-section + .menu-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.menu-section {
  position: relative;
}

.menu-label {
  display: block;
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffffff;
}

.menu-item {
  width: 100%;
  justify-content: flex-start;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(186, 198, 221, 0.12);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(31, 37, 47, 0.96) 0%, rgba(20, 24, 31, 0.96) 100%);
  color: #ffffff;
  box-shadow: none;
}

.menu-item:first-of-type {
  margin-top: 0;
}

.menu-item:hover {
  filter: brightness(1.05);
}

.menu-subtoggle {
  margin-top: 0;
}

.theme-preset-panel {
  position: absolute;
  top: 0;
  left: calc(100% + 12px);
  width: min(320px, calc(100vw - 56px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 20, 27, 0.98);
  backdrop-filter: blur(14px);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
  z-index: 25;
}

.theme-preset-panel[hidden] {
  display: none;
}

.menu-import {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.menu-section select {
  margin-top: 0;
}

.theme-preset-list {
  display: grid;
  gap: 8px;
}

.theme-preset-item {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(186, 198, 221, 0.12);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(31, 37, 47, 0.96) 0%, rgba(20, 24, 31, 0.96) 100%);
  color: #ffffff;
  box-shadow: none;
  text-align: left;
}

.theme-preset-item.active {
  border-color: rgba(158, 197, 255, 0.4);
  background: linear-gradient(180deg, rgba(51, 74, 109, 0.96) 0%, rgba(27, 37, 54, 0.96) 100%);
}

.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex: 0 0 14px;
}

@media (max-width: 860px) {
  .theme-preset-panel {
    position: static;
    width: 100%;
    margin-top: 10px;
  }
}

.history-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(24, 29, 37, 0.94) 0%, rgba(14, 18, 24, 0.9) 100%);
  box-shadow: var(--shadow);
}

.history-btn svg {
  width: 21px;
  height: 21px;
  stroke: #ffffff;
  stroke-width: 2.15;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-btn:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
  filter: none;
}

.topbar-status {
  margin: 0;
  text-align: right;
  color: #ffffff;
  position: absolute;
  right: 12px;
  top: 50%;
  z-index: 1;
  width: 220px;
  max-width: 220px;
  transform: translateY(-50%);
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.panel {
  position: relative;
  overflow: hidden;
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  animation: panel-in 320ms ease both;
}

.cover-card {
  margin: 0 0 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(22, 26, 33, 0.74) 0%, rgba(14, 18, 24, 0.56) 100%);
}

.cover-card-head {
  width: 100%;
  text-align: center;
}

.cover-card-head h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--ink-1);
}

.cover-card-head .hint {
  margin: 6px 0 0;
}

.book-cover-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 230px);
  aspect-ratio: 2 / 3;
  margin: 14px auto 12px;
  overflow: hidden;
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(26, 31, 39, 0.94) 0%, rgba(15, 19, 25, 0.98) 100%);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.book-cover-preview.empty {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.book-cover-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-upload {
  width: auto;
  min-width: 0;
  margin: 0;
}

.cover-card .row {
  justify-content: center;
}

.app-footer {
  margin: 34px 0 0;
  padding: 12px 4px 0;
  text-align: center;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.72);
}

.app-footer a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.app-footer a:hover,
.app-footer a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.faq-shell {
  max-width: 960px;
}

.faq-intro {
  margin: 0 0 18px;
  color: var(--ink-2);
  line-height: 1.6;
}

.faq-list {
  display: grid;
  gap: 14px;
}

.faq-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 92%, #ffffff 8%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  font-weight: 800;
  color: var(--ink-1);
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  float: right;
  color: color-mix(in srgb, var(--accent) 76%, var(--warm) 24%);
  font-size: 1rem;
  line-height: 1;
}

.faq-item[open] summary::after {
  content: "-";
}

.faq-answer {
  padding: 0 18px 18px;
  color: var(--ink-2);
  line-height: 1.7;
}

.faq-answer p {
  margin: 0 0 10px;
}

.faq-answer p:last-child {
  margin-bottom: 0;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-bright) 55%, var(--warm) 100%);
  opacity: 0.88;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

h2 {
  margin: 0 0 10px;
  font-family: "Fraunces", "Georgia", serif;
  font-size: 1.2rem;
  color: var(--ink-1);
}

label {
  display: block;
  margin: 10px 0 5px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--ink-2);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(186, 198, 221, 0.18);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink-1);
  background: var(--panel-strong);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #9ec5ff;
  box-shadow: 0 0 0 3px rgba(158, 197, 255, 0.16);
}

input[readonly] {
  background: color-mix(in srgb, var(--panel-strong) 82%, #808080 18%);
  color: var(--muted);
  cursor: default;
}

input[readonly]:focus {
  border-color: rgba(186, 198, 221, 0.18);
  box-shadow: none;
}

input::placeholder,
textarea::placeholder {
  color: #7f889a;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.run-analysis-row {
  justify-content: center;
}

.get-started-actions {
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.inline-lock-hint {
  margin: 0;
  flex: 1 1 260px;
}

.get-started-tools {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.spread {
  justify-content: space-between;
}

button,
.file-import {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(140deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 100ms ease, filter 100ms ease;
}

button:hover,
.file-import:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.file-import.disabled {
  opacity: 0.45;
  filter: saturate(0.7);
  cursor: not-allowed;
  pointer-events: none;
}

button:active,
.file-import:active {
  transform: translateY(0);
}

button.ghost {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 86%, #ffffff 14%) 0%, var(--panel-strong) 100%);
  color: var(--ink-1);
  border: 1px solid var(--line);
}

button.danger {
  background: linear-gradient(180deg, #d94848 0%, #aa2f2f 100%);
  color: #fff;
}

.file-import {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.file-import input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  background: color-mix(in srgb, var(--panel-strong) 58%, #9aa3b2 42%);
  color: color-mix(in srgb, var(--muted) 82%, #cfd6e2 18%);
  border-color: color-mix(in srgb, var(--line) 55%, #aab4c5 45%);
  opacity: 0.72;
  box-shadow: none;
}

.disabled-field-label {
  color: color-mix(in srgb, var(--muted) 88%, #cbd4e0 12%);
  opacity: 0.72;
}

.hint,
.status {
  color: var(--muted);
  margin: 6px 0;
}

.status.error {
  color: var(--error);
}

.status.ok {
  color: var(--ok);
}

.status.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-1);
}

.inline-analysis-status {
  margin: 0;
  min-height: 20px;
  display: inline-flex;
  align-items: center;
}

.run-analysis-btn {
  padding: 12px 18px;
  font-size: 1.2em;
  background: linear-gradient(140deg, #2fbe66 0%, #1f954f 100%);
  box-shadow: 0 10px 24px rgba(47, 190, 102, 0.24);
}

.run-analysis-btn:hover {
  filter: brightness(1.05);
}

.status-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, var(--ink-1) 24%, transparent 76%);
  border-top-color: var(--ink-1);
  border-radius: 50%;
  animation: status-spin 0.8s linear infinite;
}

.status-stop {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-1);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  flex: 0 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-stop::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

.status-stop:hover {
  transform: none;
  filter: brightness(1.08);
  background: rgba(255, 255, 255, 0.14);
}

.status-stop:active {
  transform: none;
}

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

code {
  padding: 0.1em 0.34em;
  border-radius: 5px;
  background: var(--panel-strong);
  color: var(--ink-1);
}

.chapter-list {
  display: grid;
  gap: 9px;
}

.chapter-item {
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel);
}

.chapter-item strong {
  color: var(--ink-1);
}

.chapter-item .meta {
  color: var(--muted);
  font-size: 0.87rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 9px;
}

.card {
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 12px;
  padding: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 92%, #ffffff 8%) 0%, var(--panel-strong) 100%);
}

.card .k {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.card .v {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--ink-1);
}

.chart {
  margin-top: 12px;
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 13px;
  padding: 10px;
  min-height: 180px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 94%, #ffffff 6%) 0%, var(--panel-strong) 100%);
}

.arc-chart-wrap {
  position: relative;
  padding-bottom: 20px;
}

.arc-act-label {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
  white-space: nowrap;
}

.analysis-block {
  margin-top: 12px;
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 12px;
  padding: 11px;
  background: var(--panel);
}

.metrics-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 10, 15, 0.58);
  backdrop-filter: blur(10px);
  z-index: 60;
}

.metrics-modal[hidden] {
  display: none;
}

.metrics-dialog {
  width: min(860px, 100%);
  max-height: min(82vh, 920px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.42);
}

.metrics-dialog h3 {
  margin: 0;
  color: var(--ink-1);
}

.metrics-modal-content {
  margin-top: 14px;
}

.chapter-breakdown-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(4, minmax(96px, 0.9fr));
  gap: 10px 12px;
  align-items: center;
}

.chapter-breakdown-head {
  color: color-mix(in srgb, var(--accent) 72%, var(--warm) 28%);
  font-weight: 800;
  letter-spacing: 0.01em;
  padding-bottom: 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
}

.chapter-breakdown-head:nth-child(4) .help-q::after,
.chapter-breakdown-head:nth-child(5) .help-q::after {
  left: auto;
  right: 0;
}

.chapter-breakdown-row {
  display: contents;
}

.chapter-breakdown-label {
  font-weight: 700;
  color: var(--ink-1);
}

.chapter-breakdown-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.chapter-breakdown-link:hover,
.chapter-breakdown-link:focus-visible,
.chapter-breakdown-link.is-active {
  color: color-mix(in srgb, var(--accent) 78%, var(--warm) 22%);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.chapter-breakdown-label .chapter-breakdown-link.is-active {
  text-decoration-thickness: 2px;
}

.chapter-breakdown-caret {
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  transition: transform 140ms ease;
}

.chapter-breakdown-caret.is-open {
  transform: rotate(90deg);
}

.chapter-breakdown-inline-detail {
  grid-column: 1 / -1;
  margin: 2px 0 12px;
  padding: 12px 0 0 24px;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
}

.chapter-breakdown-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.chapter-breakdown-detail-grid > div {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-strong) 88%, #ffffff 12%);
}

.chapter-breakdown-detail-label {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 72%, var(--warm) 28%);
}

.chapter-breakdown-detail-grid p {
  margin: 0;
  color: var(--ink-1);
  line-height: 1.5;
}

#outlineModalText {
  min-height: 420px;
  resize: vertical;
}

#outlineModalText.is-editing {
  border-color: rgba(47, 190, 102, 0.45);
  box-shadow: 0 0 0 3px rgba(47, 190, 102, 0.14);
}

.analysis-block h3 {
  margin: 0 0 8px;
  color: var(--ink-1);
}

.analysis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.analysis-head .hint {
  margin: 4px 0 0;
}

.analysis-block ul {
  margin: 0;
  padding-left: 20px;
}

.outline-metric-item {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
}

.outline-metric-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.outline-metric-label {
  color: color-mix(in srgb, var(--accent) 72%, var(--warm) 28%);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.outline-assessment-divider {
  list-style: none;
  margin: 14px 0 8px;
  padding: 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, transparent 22%);
}

.outline-assessment-footer {
  margin: 10px 0 0;
  text-align: right;
  color: var(--muted);
  font-size: 0.84rem;
}

.chapter-breakdown-cta {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.3em;
  padding: 0.14em 0.52em;
  border-radius: 999px;
  font-weight: 800;
  line-height: 1.1;
  color: #12161d;
}

.score-good {
  background: #7fda93;
}

.score-mid {
  background: #d7de73;
}

.score-warn {
  background: #efb35e;
}

.score-bad {
  background: #e57f7f;
}

.score-out-of {
  color: var(--muted);
}

.story-grade-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
  min-width: 4.8em;
  text-align: center;
  padding: 0.12em 0.4em;
  border-radius: 999px;
  color: #12161d;
  font-weight: 800;
}

.ai-report {
  line-height: 1.5;
}

.ai-report-menu {
  position: relative;
  flex-shrink: 0;
}

.ai-report-toggle {
  width: 42px;
  height: 42px;
  padding: 0 10px;
  box-shadow: none;
}

.ai-report-menu-panel {
  left: auto;
  right: 0;
  width: min(320px, calc(100vw - 56px));
}

.ai-report-menu-item {
  width: 100%;
  justify-content: flex-start;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(186, 198, 221, 0.12);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(31, 37, 47, 0.96) 0%, rgba(20, 24, 31, 0.96) 100%);
  color: #ffffff;
  box-shadow: none;
  text-align: left;
}

.ai-report-menu-item:first-of-type {
  margin-top: 0;
}

.ai-report-menu-item.active {
  border-color: rgba(158, 197, 255, 0.4);
  background: linear-gradient(180deg, rgba(51, 74, 109, 0.96) 0%, rgba(27, 37, 54, 0.96) 100%);
}

.report-body {
  white-space: pre-wrap;
}

.chat-thread {
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 12px;
  padding: 11px;
  min-height: 120px;
  max-height: 340px;
  overflow: auto;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 94%, #ffffff 6%) 0%, var(--panel-strong) 100%);
}

.chat-msg {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(186, 198, 221, 0.14);
}

.chat-msg .role {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--ink-1);
  margin-bottom: 4px;
}

.chat-msg.user {
  background: color-mix(in srgb, var(--panel-strong) 88%, #ffffff 12%);
}

.chat-msg.assistant {
  background: var(--panel);
}

.chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: 0.8rem;
  margin-right: 6px;
  margin-bottom: 6px;
}

.chip.active {
  background: #1d5fc4;
  color: #fff;
  border-color: #1d5fc4;
}

.char-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
  margin-right: 8px;
}

.char-pick-box {
  width: 14px;
  height: 14px;
  margin: 0;
  vertical-align: middle;
}

.warn-text {
  color: #ff9a9a;
  font-weight: 700;
}

.help-q {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: help;
  background: var(--panel-strong);
  vertical-align: text-top;
}

.help-q::after {
  content: attr(data-help-text);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  transform: none;
  width: min(280px, 70vw);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-strong) 96%, #ffffff 4%);
  color: var(--ink-1);
  font-size: 0.77rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 120ms ease, visibility 120ms ease;
  z-index: 30;
}

.help-q:hover::after,
.help-q:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.mono {
  font-family: "Consolas", "Menlo", monospace;
  letter-spacing: 0.03em;
}

.act-timeline {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 6px;
  margin: 10px 0 12px;
  padding: 8px;
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 92%, #ffffff 8%) 0%, var(--panel-strong) 100%);
  min-height: 72px;
}

.act-timeline-bands {
  display: flex;
  grid-template-columns: none;
  gap: 6px;
}

.act-graph-wrap {
  position: relative;
  margin: 8px 0 10px;
  border: 1px solid rgba(186, 198, 221, 0.16);
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-strong) 92%, #ffffff 8%) 0%, var(--panel-strong) 100%);
  height: 170px;
  overflow: visible;
}

.act-graph {
  width: 100%;
  height: 100%;
}

.act-segment {
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink-1);
  padding: 20px 6px 6px;
}

.act-1 { background: rgba(109, 149, 216, 0.16); }
.act-2 { background: rgba(216, 168, 93, 0.16); }
.act-3 { background: rgba(121, 213, 154, 0.16); }

.act-timeline .moment {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  text-align: center;
}

.act-timeline .moment span {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-1);
  white-space: nowrap;
}

.act-timeline .moment small {
  display: block;
  font-size: 0.66rem;
  color: var(--muted);
}

.act-point {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.act-point.edge-left {
  transform: translate(-18%, -50%);
}

.act-point.edge-right {
  transform: translate(-82%, -50%);
}

.act-point-btn {
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.act-pop {
  display: none;
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translate(-50%, -100%);
  width: min(320px, 72vw);
  background: #181d25;
  border: 1px solid rgba(186, 198, 221, 0.2);
  border-radius: 10px;
  padding: 8px 9px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  text-align: left;
}

.act-pop p {
  margin: 6px 0 0;
  color: #d2dbea;
  font-size: 0.84rem;
}

.act-point:hover .act-pop {
  display: block;
}

.act-point.edge-left .act-pop {
  left: 0;
  transform: translate(0, -100%);
}

.act-point.edge-right .act-pop {
  left: auto;
  right: 0;
  transform: translate(0, -100%);
}

@media (max-width: 860px) {
  .app {
    padding: 14px 14px 30px;
  }

  .landing-page {
    padding: 14px 14px 36px;
  }

  .landing-nav {
    padding-bottom: 18px;
  }

  .landing-hero {
    grid-template-columns: 1fr;
  }

  .landing-copy {
    padding-top: 8px;
  }

  .landing-auth {
    position: static;
  }

  .auth-panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    top: 0;
    min-height: 0;
  }

  .topbar-left {
    width: 100%;
  }

  .topbar-brand {
    position: static;
    order: -1;
    width: 100%;
    padding: 2px 48px 0;
    transform: none;
    justify-content: center;
  }

  .topbar-logo {
    width: min(270px, 78vw);
  }

  .topbar-title,
  .topbar-subtitle {
    white-space: normal;
  }

  .topbar-status {
    width: 100%;
    text-align: left;
  }

  .topbar-right {
    width: 100%;
    align-items: flex-start;
  }

  .panel {
    padding: 13px;
  }
}
