:root {
  color-scheme: light;
  --bg: #f6f1e8;
  --surface: #fffdf8;
  --ink: #181715;
  --muted: #706b63;
  --line: #ded6c8;
  --accent: #006c67;
  --accent-strong: #004f4b;
  --danger: #9a2d21;
  --header: #151515;
  --header-ink: #f7f3eb;
  --shadow: 0 8px 24px rgb(24 23 21 / 9%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 20px) 18px 20px;
  background: var(--header);
  color: var(--header-ink);
}

.eyebrow {
  margin: 0 0 3px;
  color: #69c7b9;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.count-pill {
  min-width: 76px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid rgb(247 243 235 / 35%);
  border-radius: 999px;
  color: var(--header-ink);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 8px 12px;
  background: #242220;
  box-shadow: 0 4px 14px rgb(24 23 21 / 12%);
}

.tab-button {
  min-width: 0;
  min-height: 40px;
  border: 1px solid rgb(247 243 235 / 18%);
  border-radius: 8px;
  background: transparent;
  color: rgb(247 243 235 / 78%);
  font-size: 0.9rem;
  font-weight: 800;
}

.tab-button.is-active {
  border-color: #69c7b9;
  background: #69c7b9;
  color: #10100f;
}

.app-shell {
  width: min(100%, 840px);
  margin: 0 auto;
  padding: 14px 12px calc(env(safe-area-inset-bottom) + 28px);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.controls {
  position: sticky;
  top: 56px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(112px, 0.42fr) minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  background: var(--bg);
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

select {
  padding: 0 32px 0 10px;
}

input[type="search"] {
  padding: 0 12px;
}

select:focus,
input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 108 103 / 16%);
}

.status {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.status[hidden] {
  display: none;
}

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

.dialogue-list {
  display: grid;
  gap: 10px;
}

.dialogue-card {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialogue-meta {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialogue-ja,
.dialogue-ko {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.dialogue-ja {
  color: var(--ink);
  font-family: "Yu Gothic", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  font-size: 1.04rem;
  line-height: 1.62;
}

.dialogue-ko {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.55;
}

.scroll-sentinel {
  min-height: 32px;
}

.scroll-sentinel[hidden] {
  display: none;
}

.quiz {
  display: grid;
  gap: 12px;
}

.quiz.is-answered {
  gap: 8px;
}

.quiz-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 2px 0;
}

.quiz-mode,
.quiz-score {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.prompt-card {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quiz.is-answered .prompt-card {
  gap: 5px;
  padding: 10px 12px;
}

.prompt-label {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.quiz-prompt {
  margin: 0;
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.quiz.is-answered .quiz-prompt {
  font-size: 0.94rem;
  line-height: 1.35;
}

.quiz.is-answered .prompt-label,
.quiz.is-answered .prompt-card .dialogue-meta {
  display: none;
}

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

.quiz.is-answered .choices {
  gap: 6px;
}

.choice-button {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 58px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}

.quiz.is-answered .choice-button {
  gap: 4px;
  min-height: 0;
  padding: 8px 10px;
}

.choice-button:not(:disabled):active {
  border-color: var(--accent);
  background: #edf8f5;
}

.choice-button:disabled {
  opacity: 1;
}

.choice-button.is-correct {
  border-color: #157347;
  background: #e9f7ef;
}

.choice-button.is-wrong {
  border-color: var(--danger);
  background: #faece9;
}

.choice-button.is-selected {
  box-shadow: 0 0 0 3px rgb(0 108 103 / 12%);
}

.choice-text {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.quiz.is-answered .choice-text {
  font-size: 0.88rem;
  line-height: 1.28;
}

.choice-detail {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.quiz.is-answered .choice-detail {
  font-size: 0.78rem;
  line-height: 1.24;
}

.quiz-feedback {
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 800;
}

.quiz.is-answered .quiz-feedback {
  padding: 7px 10px;
  font-size: 0.82rem;
}

.quiz-feedback[hidden] {
  display: none;
}

.quiz-feedback.is-correct {
  background: #e9f7ef;
  color: #146c43;
}

.quiz-feedback.is-wrong {
  background: #faece9;
  color: var(--danger);
}

.next-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.quiz.is-answered .next-button {
  min-height: 38px;
  font-size: 0.9rem;
}

.next-button[hidden] {
  display: none;
}

.next-button:active {
  background: var(--accent-strong);
}

@media (min-width: 700px) {
  .app-header {
    padding-right: max(28px, env(safe-area-inset-right));
    padding-left: max(28px, env(safe-area-inset-left));
  }

  .app-shell {
    padding-right: 18px;
    padding-left: 18px;
  }

  .tabs {
    padding-right: max(18px, env(safe-area-inset-right));
    padding-left: max(18px, env(safe-area-inset-left));
  }

  .dialogue-card {
    padding: 16px 18px;
  }

  .quiz {
    gap: 14px;
  }
}
