:root {
  color-scheme: light dark;
  --bg: #101318;
  --surface: #181d24;
  --surface-2: #202731;
  --surface-3: #2a3441;
  --text: #f4f7fb;
  --muted: #aab5c3;
  --border: #394554;
  --accent: #7cc4ff;
  --accent-strong: #b6deff;
  --success: #73d69b;
  --danger: #ff9090;
  --warning: #ffd081;
  --shadow: 0 20px 45px rgb(0 0 0 / 0.24);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgb(124 196 255 / 0.08), transparent 30rem),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

a {
  color: var(--accent-strong);
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  outline-offset: 3px;
}

.shell {
  width: min(1160px, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header,
.wizard-header {
  border-bottom: 1px solid var(--border);
  background: rgb(16 19 24 / 0.92);
  backdrop-filter: blur(14px);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.brand small {
  color: var(--muted);
}

.brand.compact > span:last-child {
  display: block;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgb(124 196 255 / 0.55);
  border-radius: 12px;
  background: rgb(124 196 255 / 0.12);
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.text-link {
  font-weight: 650;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.home-main {
  padding-block: 4.5rem 5rem;
}

.hero {
  max-width: 780px;
  margin-bottom: 4rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 14ch;
  margin: 0;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero > p:last-child {
  max-width: 690px;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-heading h2,
.privacy-note h2 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: -0.025em;
}

.section-heading > p {
  margin: 0;
  color: var(--muted);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
}

.template-card,
.empty-state,
.privacy-note,
.recent-list a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.template-card {
  display: flex;
  min-height: 300px;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.5rem;
}

.template-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.35rem;
}

.template-card p {
  margin: 0.2rem 0;
  color: var(--muted);
}

.template-card .filename {
  margin-top: 0.8rem;
  color: #8390a0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.77rem;
  overflow-wrap: anywhere;
}

.start-form {
  display: grid;
  gap: 0.85rem;
}

.start-form label,
.answer-field {
  display: grid;
  gap: 0.45rem;
}

.start-form label > span,
.answer-field > span {
  font-weight: 750;
}

.start-form small {
  color: var(--muted);
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0f1318;
  color: var(--text);
}

input {
  min-height: 46px;
  padding: 0.65rem 0.8rem;
}

textarea {
  min-height: 180px;
  resize: vertical;
  padding: 0.9rem 1rem;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(124 196 255 / 0.14);
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.button-primary {
  background: var(--accent-strong);
  color: #08131d;
}

.button-secondary,
.button-quiet {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.button-quiet {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
}

.button-success {
  background: var(--success);
  color: #07180f;
}

.notice,
.empty-state,
.privacy-note {
  padding: 1.25rem 1.4rem;
}

.notice-error {
  border: 1px solid rgb(255 144 144 / 0.5);
  background: rgb(255 144 144 / 0.1);
  color: #ffd4d4;
}

.empty-state p,
.privacy-note p {
  color: var(--muted);
}

.privacy-note,
.recent-section {
  margin-top: 3rem;
}

.recent-list {
  display: grid;
  gap: 0.75rem;
}

.recent-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.2rem;
  color: var(--text);
  text-decoration: none;
}

.recent-list a:hover {
  border-color: var(--accent);
}

.recent-list small {
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.wizard-page {
  overflow: hidden;
}

.wizard-header {
  display: grid;
  min-height: 72px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
}

.wizard-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.wizard-title span {
  color: var(--muted);
  font-size: 0.83rem;
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.wizard-layout {
  display: grid;
  height: calc(100vh - 72px);
  grid-template-columns: 300px minmax(0, 1fr);
}

.toc {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: #12171d;
}

.toc-header,
.toc-footer {
  padding: 1rem;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-weight: 850;
}

.toc nav {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 0.7rem;
}

.section-button {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.75rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.section-button:hover {
  background: var(--surface);
  color: var(--text);
}

.section-button.active {
  border-color: rgb(124 196 255 / 0.45);
  background: rgb(124 196 255 / 0.11);
  color: var(--text);
}

.section-button strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-button span {
  font-size: 0.78rem;
}

.toc-footer {
  border-top: 1px solid var(--border);
}

.overall-progress {
  display: grid;
  gap: 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
}

progress::-webkit-progress-bar {
  background: var(--surface-3);
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.question-area {
  overflow-y: auto;
  padding: 1rem clamp(1rem, 4vw, 4rem) 4rem;
}

.question-toolbar {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto 0.8rem;
  max-width: 900px;
}

.save-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.save-status.saving {
  color: var(--warning);
}

.save-status.saved {
  color: var(--success);
}

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

.question-card,
.finish-panel {
  max-width: 900px;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.question-card {
  --question-context-height: 7rem;
  --active-question-height: 10rem;
  --answer-height: 13rem;
  padding: clamp(1.1rem, 3vw, 2rem);
}

.question-position {
  display: flex;
  height: 1.5rem;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.question-position > span:first-child {
  flex: 0 0 auto;
}

.question-position > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.question-context {
  height: var(--question-context-height);
  margin: 1.25rem 0;
  overflow-y: auto;
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
  scrollbar-gutter: stable;
}

.question-context p {
  margin: 0.45rem 0;
}

.question-context:empty {
  visibility: hidden;
}

.active-question {
  height: var(--active-question-height);
  margin: 1.3rem 0 1.6rem;
  overflow-y: auto;
  border: 2px solid rgb(124 196 255 / 0.72);
  border-radius: 12px;
  padding: clamp(1rem, 3vw, 1.5rem);
  background:
    linear-gradient(135deg, rgb(124 196 255 / 0.16), transparent 65%),
    #101820;
  scrollbar-gutter: stable;
}

.active-question-kicker {
  margin: 0 0 0.4rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.active-question h1 {
  margin: 0;
  font-size: clamp(1.45rem, 4vw, 2.35rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.answer-field textarea {
  height: var(--answer-height);
  min-height: var(--answer-height);
  max-height: var(--answer-height);
  resize: none;
}

.input-hint {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.question-navigation {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.finish-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1.25rem;
}

.finish-panel h2,
.finish-panel p {
  margin: 0;
}

.finish-panel p {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
}

.mobile-only {
  display: none;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 100;
  max-width: min(420px, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  background: #05080b;
  box-shadow: var(--shadow);
}

.toast.copy-success {
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  z-index: 250;
  border-color: rgb(79 209 139 / 0.8);
  padding: 1rem 1.4rem;
  background: #07150e;
  color: #dff9e9;
  font-size: 1rem;
  font-weight: 850;
  text-align: center;
  animation: copy-toast-drop 2.4s ease-out forwards;
}

@keyframes copy-toast-drop {
  0% {
    opacity: 0;
    transform: translate(-50%, -70%);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
  72% {
    opacity: 1;
    transform: translate(-50%, -10%);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 85%);
  }
}

.help-dialog,
.finish-dialog {
  width: min(620px, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.help-dialog::backdrop,
.finish-dialog::backdrop {
  background: rgb(0 0 0 / 0.72);
  backdrop-filter: blur(3px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.2rem;
}

.dialog-header h2 {
  margin: 0;
}

.dialog-body {
  padding: 1.2rem;
}

.finish-dialog {
  width: min(720px, calc(100% - 2rem));
}

.dialog-kicker {
  margin: 0 0 0.25rem;
  color: var(--success);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.finish-dialog .dialog-header h2 {
  margin: 0;
}

.finish-dialog-body {
  display: grid;
  gap: 0;
  padding: 0 1.25rem;
}

.finish-dialog-section {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1.35rem 0;
}

.finish-dialog-section + .finish-dialog-section {
  border-top: 1px solid var(--border);
}

.finish-step {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid rgb(79 209 139 / 0.5);
  border-radius: 999px;
  background: rgb(79 209 139 / 0.1);
  color: var(--success);
  font-weight: 900;
}

.finish-dialog-section h3,
.finish-dialog-section p {
  margin: 0;
}

.finish-dialog-section p {
  margin-top: 0.45rem;
  color: var(--muted);
}

.resume-link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.6rem;
  margin-top: 1rem;
}

.resume-link-box input {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.72rem 0.8rem;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82rem;
}

.finish-dialog-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
}

.shortcut-list {
  display: grid;
  gap: 1rem;
  margin: 0;
}

.shortcut-list > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
}

.shortcut-list dt {
  font-weight: 800;
}

.shortcut-list dd {
  margin: 0;
  color: var(--muted);
}

kbd,
code {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.08rem 0.3rem;
  background: #0b0f14;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.9em;
}

.noscript {
  position: fixed;
  inset: 1rem;
  z-index: 1000;
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 2rem;
  background: var(--bg);
}

@media (max-width: 900px) {
  .wizard-page {
    overflow: auto;
  }

  .wizard-header {
    grid-template-columns: auto 1fr auto;
  }

  .wizard-title {
    align-items: flex-start;
    overflow: hidden;
    text-align: left;
  }

  .wizard-title strong,
  .wizard-title span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .wizard-header .brand strong,
  .header-actions .button:first-child {
    display: none;
  }

  .wizard-layout {
    display: block;
    height: auto;
  }

  .toc {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(340px, 90vw);
    transform: translateX(-105%);
    transition: transform 160ms ease;
    box-shadow: var(--shadow);
  }

  .toc.open {
    transform: translateX(0);
  }

  .mobile-only {
    display: inline-flex;
  }

  .question-area {
    min-height: calc(100vh - 72px);
  }
}

@media (max-width: 620px) {
  .home-main {
    padding-top: 3rem;
  }

  .header-inner .text-link {
    display: none;
  }

  .template-card {
    min-height: 0;
  }

  .question-area {
    padding-inline: 0.7rem;
  }

  .question-card {
    padding: 1rem;
  }

  .question-navigation,
  .finish-panel,
  .finish-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .finish-actions {
    width: 100%;
  }

  .resume-link-box {
    grid-template-columns: 1fr;
  }

  .finish-dialog-section {
    grid-template-columns: 1fr;
  }

  .shortcut-list > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Static-site runtime states. */
[hidden] {
  display: none !important;
}

.template-grid[aria-busy="true"] {
  opacity: 0.7;
}

.loading-state,
.empty-state,
.runtime-note {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--surface);
  color: var(--muted);
}

.runtime-note strong {
  color: var(--text);
}

.resume-warning {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.button[aria-busy="true"] {
  cursor: progress;
  opacity: 0.75;
}
