:root {
  color-scheme: light;
  --bg: #f3efe7;
  --bg-alt: #e8dfd1;
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --text: #16212d;
  --muted: #617082;
  --border: rgba(22, 33, 45, 0.12);
  --shadow: 0 18px 48px rgba(43, 31, 17, 0.12);
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --warning: #d97706;
  --card-radius: 24px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111c;
  --bg-alt: #0f1722;
  --panel: rgba(13, 21, 33, 0.8);
  --panel-strong: rgba(18, 26, 40, 0.95);
  --text: #eff5fb;
  --muted: #99a8ba;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --warning: #f59e0b;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--text);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 183, 77, 0.24), transparent 30%),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
  background-attachment: fixed;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 14px;
  padding-bottom: 24px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.field-label {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
}

.toolbar {
  display: grid;
  gap: 14px;
  padding: 16px;
  margin-bottom: 12px;
}

.toolbar-row {
  display: grid;
  gap: 12px;
}

.toolbar-bottom {
  grid-template-columns: 1fr auto auto;
  align-items: end;
}

.control-group {
  display: grid;
  gap: 8px;
}

.theme-group {
  max-width: 180px;
  margin-left: auto;
}

.segmented,
.page-size-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.page-size-group {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segment,
.page-size,
.button {
  min-height: 46px;
  padding: 0 14px;
  border-radius: 16px;
  font-weight: 700;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.segment,
.page-size {
  background: rgba(127, 140, 153, 0.11);
  color: var(--text);
}

.segment.is-active,
.page-size.is-active {
  background: var(--accent);
  color: #fff;
}

.segment[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.segment:active,
.page-size:active,
.button:active {
  transform: scale(0.98);
}

.segment:disabled,
.page-size:disabled,
.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.search-row,
.jump-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-row input,
.jump-row input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.button-ghost {
  background: rgba(127, 140, 153, 0.1);
}

.stage {
  display: grid;
  gap: 12px;
  touch-action: pan-y;
}

.focus-wrap,
.list-wrap {
  display: grid;
  gap: 12px;
}

.focus-hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.question-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.question-card.is-focus {
  border-color: rgba(15, 118, 110, 0.24);
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 0;
}

.question-title h3 {
  margin: 8px 0 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.question-meta {
  display: inline-flex;
  align-items: start;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(127, 140, 153, 0.12);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.type {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.question-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.question-text {
  margin: 0;
  font-size: clamp(1.05rem, 4vw, 1.2rem);
  line-height: 1.72;
  font-weight: 700;
}

.question-text .inline-rich-image,
.option-text .inline-rich-image {
  display: block;
  width: min(100%, 360px);
  margin: 12px 0;
  border-radius: 16px;
}

.media-frame {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.06);
}

.media-frame img,
.media-frame video {
  display: block;
  width: 100%;
}

.media-frame video {
  max-height: 64vh;
}

.media-link {
  padding: 14px;
  display: flex;
  justify-content: center;
}

.options {
  display: grid;
  gap: 10px;
}

.option-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
}

.option-tag {
  width: fit-content;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.option-text {
  white-space: pre-wrap;
  line-height: 1.65;
}

.option-card img {
  width: 100%;
  border-radius: 16px;
  display: block;
}

.answer-box {
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(127, 140, 153, 0.08);
}

.answer-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.answer-value {
  display: grid;
  gap: 10px;
  font-size: 1rem;
  line-height: 1.55;
}

.answer-choice {
  font-size: 1.05rem;
}

.answer-content {
  line-height: 1.65;
}

.answer-content .inline-rich-image {
  display: block;
  width: min(100%, 360px);
  margin: 0;
  border-radius: 16px;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.details {
  border-top: 1px solid var(--border);
  padding: 0 16px 16px;
}

.details summary {
  cursor: pointer;
  list-style: none;
  padding-top: 14px;
  color: var(--accent-strong);
  font-weight: 800;
}

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

.details-body {
  padding-top: 12px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.empty-state {
  padding: 20px;
}

.empty-state h3 {
  margin: 0 0 8px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.floating-actions {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 40;
  display: grid;
  gap: 10px;
  align-items: end;
}

.fab {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  font-size: 28px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

:root[data-theme="dark"] .fab {
  background: rgba(18, 26, 40, 0.95);
}

.fab-favorite {
  font-size: 24px;
}

@media (min-width: 760px) {
  .toolbar-row {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: end;
  }
  .toolbar-bottom {
    grid-template-columns: 1fr auto auto;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .hero {
    padding: 16px;
  }

  .toolbar-bottom {
    grid-template-columns: 1fr auto;
    align-items: end;
  }

  .theme-group {
    max-width: none;
    margin-left: 0;
  }

  .toolbar-bottom {
    grid-template-columns: 1fr;
  }

  .floating-actions {
    right: 10px;
    bottom: 10px;
  }
}
