:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #eef2ee;
  --ink: #171a18;
  --muted: #66706b;
  --line: #d8ded8;
  --accent: #176b63;
  --accent-strong: #11564f;
  --warm: #b85538;
  --fresh: #2d6fb7;
  --fresh-soft: #e8f1fb;
  --danger-soft: #fff1ec;
  --button-text: #ffffff;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --app-height: 100dvh;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  min-height: var(--app-height);
  margin: 0 auto;
  padding: 24px;
}

.screen {
  min-height: calc(var(--app-height) - 48px);
}

.preamble-screen,
.transition-screen,
.terminal-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.entry-screen,
.rewrite-screen,
.compare-screen,
.result-screen,
.final-screen {
  padding: 42px 0;
}

.preamble-copy {
  max-width: 560px;
  margin: 0 0 28px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1.18;
}

.preamble-mark {
  color: var(--accent);
  font-weight: 700;
}

.preamble-mark.warm {
  color: var(--warm);
}

.prompt-copy,
.terminal-copy {
  margin: 0 0 22px;
  color: var(--ink);
  font-size: 19px;
  line-height: 1.45;
}

.sub-copy {
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(184, 85, 56, 0.28);
  border-radius: var(--radius);
  color: #7a2f1d;
  background: var(--danger-soft);
  font-size: 15px;
  line-height: 1.4;
}

.entry-form,
.rewrite-form {
  width: 100%;
}

.text-input,
.comment-input {
  display: block;
  width: 100%;
  min-height: 150px;
  max-height: 50vh;
  resize: none;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.52;
}

.comment-input {
  min-height: 96px;
  max-height: 240px;
  margin-top: 22px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

.text-input:focus,
.comment-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 99, 0.12);
}

.text-input::placeholder,
.comment-input::placeholder {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 16px;
  opacity: 1;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.actions.right {
  justify-content: flex-end;
}

.actions.split {
  justify-content: space-between;
  align-items: center;
}

.choice-row,
.final-actions {
  flex-wrap: wrap;
}

.button {
  min-width: 128px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--button-text);
  background: var(--accent);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
}

.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.button.secondary {
  color: var(--accent);
  background: transparent;
  border-color: var(--line);
}

.button.secondary:hover {
  color: var(--accent-strong);
  background: var(--surface-soft);
  border-color: var(--line);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.icon-button {
  min-width: 48px;
  width: 48px;
  padding: 0;
  flex: 0 0 48px;
}

.word-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  color: #ffffff;
  background: var(--warm);
  white-space: nowrap;
}

.word-chip.inline {
  margin: 0 1px;
  padding: 1px 5px;
}

.new-word-chip {
  display: inline;
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--fresh);
  background: var(--fresh-soft);
}

.version-block,
.summary-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.version-block {
  padding: 14px;
}

.context-block {
  margin-bottom: 18px;
  background: var(--surface-soft);
}

.version-label,
.summary-index,
.choice-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.version-label,
.summary-index {
  margin-bottom: 8px;
}

.version-text {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.52;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.pair-grid {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.pair-grid.vertical {
  grid-template-columns: 1fr;
}

.compare-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.compare-input-row .comment-input {
  margin-top: 0;
}

.result-comment {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 16px;
  line-height: 1.5;
}

.final-choice-list {
  display: grid;
  gap: 12px;
  max-width: 440px;
  margin-top: 20px;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0 18px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.summary-list {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.summary-item {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.summary-item .version-block {
  padding: 0;
  border: 0;
  background: transparent;
}

.choice-note {
  padding-top: 2px;
  color: var(--accent);
}

@media (min-width: 721px) {
  .app-shell {
    padding: 32px;
  }

  .screen {
    min-height: calc(var(--app-height) - 64px);
  }

  .preamble-copy {
    font-size: 42px;
  }

  .text-input,
  .version-text {
    font-size: 20px;
  }
}

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

  .screen {
    min-height: calc(var(--app-height) - 40px);
  }

  .entry-screen,
  .rewrite-screen,
  .compare-screen,
  .result-screen,
  .final-screen {
    padding: 28px 0;
  }

  .preamble-copy {
    font-size: 30px;
  }

  .actions.split,
  .choice-row,
  .final-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compare-input-row {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
    flex-basis: auto;
  }

  .button {
    width: 100%;
  }
}

@media (max-height: 620px) {
  .preamble-screen,
  .transition-screen,
  .terminal-screen {
    justify-content: flex-start;
    padding-top: 48px;
  }
}

.knowledge-shell {
  min-height: auto;
  padding-top: 32px;
  padding-bottom: 56px;
  color: var(--ink);
}

.knowledge-block {
  margin: 0 0 48px;
}

.knowledge-block:last-child {
  margin-bottom: 0;
}

.knowledge-title {
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.knowledge-copy,
.accordion-copy {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
}

.knowledge-copy:last-child,
.accordion-copy:last-child {
  margin-bottom: 0;
}

.knowledge-copy em,
.accordion-copy em {
  font-style: italic;
}

.knowledge-pair {
  margin-top: 0;
}

.knowledge-pair .version-block {
  background: var(--surface-soft);
}

.knowledge-hook {
  margin: 18px 0 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}

.knowledge-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.skeleton-line {
  width: 72%;
  height: 16px;
  margin: 8px 0;
  border-radius: 4px;
  background: var(--line);
}

.skeleton-line.wide {
  width: 94%;
}

.skeleton-line.short {
  width: 42%;
}

.skeleton-copy {
  margin: 0 0 16px;
}

.knowledge-feedback {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.feedback-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

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

.clarity-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 36px;
}

.clarity-label {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.clarity-controls,
.card-clarity {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.clarity-pill {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
}

.clarity-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-soft);
}

.clarity-pill.is-clear {
  border-color: var(--accent);
  color: var(--button-text);
  background: var(--accent);
}

.clarity-pill.is-unclear {
  border-color: var(--ink);
  color: var(--button-text);
  background: var(--ink);
}

.question-box,
.card-form {
  margin-top: 14px;
}

.question-toggle {
  min-width: 0;
}

.knowledge-feedback-input {
  min-height: 84px;
  margin-top: 0;
}

.compact-actions {
  margin-top: 10px;
}

.thanks-note {
  margin: 0;
  color: var(--accent);
  font-size: 15px;
  line-height: 1.45;
}

.benefit-list {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.benefit-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.benefit-original,
.benefit-expanded,
.benefit-note {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.benefit-arrow {
  margin: 8px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
}

.benefit-note {
  margin-top: 8px;
  color: var(--muted);
  font-style: italic;
}

.personal-example {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.personal-arrow {
  color: var(--muted);
}

.knowledge-link-row {
  margin: 0 0 20px;
}

.knowledge-link {
  color: var(--accent);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
}

.knowledge-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

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

.accordion-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.accordion-card.is-open {
  background: var(--surface-soft);
}

.accordion-header {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
}

.accordion-chevron {
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease;
}

.accordion-card.is-open .accordion-panel {
  grid-template-rows: 1fr;
}

.accordion-panel-inner {
  overflow: hidden;
  padding: 0 14px;
}

.accordion-card.is-open .accordion-panel-inner {
  padding-bottom: 14px;
}

.card-clarity {
  margin: 0 0 12px;
}

.knowledge-final-actions {
  display: grid;
  gap: 12px;
}

.knowledge-final-actions > .button,
.final-action-wrap > .button,
.final-action-link {
  width: 100%;
}

.final-action-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.final-inline-form {
  display: grid;
  gap: 12px;
}

.email-input {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 16px;
}

.email-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 99, 0.12);
}

.email-input::placeholder {
  color: var(--muted);
  opacity: 1;
}

@media (max-width: 620px) {
  .knowledge-shell {
    padding: 24px 16px 44px;
  }

  .clarity-row {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: start;
  }

  .clarity-controls,
  .card-clarity {
    flex-wrap: wrap;
  }
}
