:root {
  --bg: #e8ebe6;
  --shell: #f7f4ee;
  --ink: #1c2a24;
  --muted: #5f6f67;
  --line: #d5d9d2;
  --accent: #0f6b5c;
  --accent-soft: #d8efe9;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --ok: #067647;
  --ok-soft: #e3f6ec;
  --card: #ffffff;
  --shadow: 0 18px 40px rgba(28, 42, 36, 0.12);
  --radius: 18px;
  font-family: "SF Pro Text", "PingFang TC", "Noto Sans TC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, #f4f7f2 0%, var(--bg) 55%),
    var(--bg);
  color: var(--ink);
}

body {
  display: flex;
  justify-content: center;
  padding: 16px 12px 32px;
}

.phone-shell {
  width: min(100%, 430px);
  min-height: calc(100vh - 48px);
  background: var(--shell);
  border: 1px solid rgba(28, 42, 36, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(10px);
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.app-header__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.brand__eyebrow {
  display: block;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 700;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.user-chip a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.app-main {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.progress-block {
  margin-top: 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.progress-bar {
  height: 10px;
  background: #e1e6e1;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, #0f6b5c, #2a9d8f);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(28, 42, 36, 0.04);
}

.card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.card p,
.lead {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

.field input:focus {
  outline: 2px solid rgba(15, 107, 92, 0.25);
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(15, 107, 92, 0.35);
}

.btn--danger {
  background: var(--danger);
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.alert--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chapter-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.chapter-link__num {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}

.chapter-link__title {
  font-weight: 700;
  line-height: 1.35;
}

.chapter-link__meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.question-text {
  font-size: 1.08rem;
  line-height: 1.55;
  font-weight: 700;
  margin: 0 0 16px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  position: relative;
}

.option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  min-height: 56px;
  padding: 14px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
  line-height: 1.45;
}

.option input:checked + label {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option__key {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #eef2ef;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.option.is-correct label {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.option.is-wrong label {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option.is-locked label {
  cursor: default;
}

.reveal {
  margin-top: 14px;
  border-radius: 14px;
  padding: 14px;
  background: #f3f6f3;
  border: 1px solid var(--line);
}

.reveal h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.reveal p {
  margin: 0 0 10px;
  color: var(--ink);
  line-height: 1.5;
  font-size: 0.92rem;
}

.reveal blockquote {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.source-ref {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}

.score-hero {
  text-align: center;
  padding: 28px 12px 8px;
}

.score-hero .score {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th,
.table td {
  text-align: left;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form input {
  flex: 1;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: auto;
  padding-top: 8px;
}

.inline-form input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

.search-hit {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.search-hit:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.search-hit__body {
  margin: 8px 0 12px;
  line-height: 1.55;
  font-size: 0.92rem;
  color: var(--ink);
}

.search-hit__actions {
  display: flex;
  justify-content: flex-end;
}

.search-hit__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid rgba(15, 107, 92, 0.18);
}

.search-hit__link::after {
  content: "→";
  font-weight: 800;
}

.search-hit mark {
  background: #fff3bf;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.float-dock {
  position: fixed;
  right: max(14px, calc(50vw - 215px + 14px));
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.float-dock.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.float-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 52px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(28, 42, 36, 0.92);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(28, 42, 36, 0.22);
  backdrop-filter: blur(8px);
  flex-direction: column;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.float-btn--top {
  background: rgba(15, 107, 92, 0.95);
}

.float-btn span[aria-hidden="true"] {
  font-size: 1rem;
  line-height: 1;
}

.float-btn__text {
  line-height: 1.1;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-card {
  display: block;
  padding: 18px 16px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 8px 24px rgba(28, 42, 36, 0.04);
}

.menu-card__kicker {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}

.menu-card__title {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.menu-card__desc {
  display: block;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.toc h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.toc-list a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.passage {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 12px;
  scroll-margin-top: 96px;
}

.passage--target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.15);
}

.passage__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.passage__top {
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
}

.passage__body {
  line-height: 1.65;
  font-size: 0.95rem;
  color: var(--ink);
}

.passage__body mark {
  background: #fff3bf;
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.chapter-body {
  display: flex;
  flex-direction: column;
}
