:root {
  color-scheme: light;
  --survey-header-height: 0px;
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-alt: #eef3f0;
  --surface-warm: #fff8ed;
  --text: #18211d;
  --muted: #657269;
  --line: #d9e0da;
  --accent: #1d7758;
  --accent-dark: #12583f;
  --accent-soft: #dff1ea;
  --gold: #b9822f;
  --gold-soft: #faecd2;
  --shadow: 0 18px 46px rgba(30, 45, 38, 0.1);
  --shadow-soft: 0 10px 24px rgba(30, 45, 38, 0.07);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-padding-top: 88px;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(223, 241, 234, 0.78), rgba(243, 245, 241, 0) 420px),
    linear-gradient(135deg, rgba(250, 236, 210, 0.58), rgba(250, 236, 210, 0) 46%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 20px rgba(29, 119, 88, 0.18);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
}

.app-shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.start-view,
.done-view {
  min-height: calc(100vh - 64px);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 28px;
}

.intro,
.done-view {
  width: min(860px, 100%);
  max-width: 860px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(40px, 5vw, 68px);
}

h2 {
  font-size: 24px;
}

.summary,
.done-view p:not(.eyebrow) {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
  overflow-wrap: anywhere;
  margin-left: auto;
  margin-right: auto;
}

.intro-notes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
  max-width: 960px;
}

.intro-notes article {
  display: grid;
  gap: 8px;
  min-width: 0;
  min-height: 124px;
  padding: 16px;
  border: 1px solid rgba(29, 119, 88, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
  text-align: left;
}

.intro-notes strong {
  color: var(--text);
  font-size: 16px;
}

.intro-notes span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.intro-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.intro-metrics span {
  min-width: 0;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(29, 119, 88, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.start-form {
  display: grid;
  justify-self: center;
  gap: 12px;
  width: min(420px, 100%);
  max-width: 420px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.start-form button {
  min-height: 52px;
  font-size: 17px;
}

.start-form p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.survey-view {
  display: grid;
  gap: 18px;
}

.survey-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -32px -16px 0;
  padding: 22px 16px 16px;
  border-bottom: 1px solid rgba(217, 224, 218, 0.72);
  background: rgba(243, 245, 241, 0.88);
  backdrop-filter: blur(18px);
}

.survey-header h2 {
  max-width: 900px;
  font-size: 24px;
  line-height: 1.48;
}

.done-actions,
.survey-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(24, 33, 29, 0.08);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.survey-form {
  display: grid;
  gap: 16px;
  padding-bottom: 72px;
}

.answers-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.answer-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.answer-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f9fbf8);
}

.answer-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 30px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.word-count {
  color: var(--muted);
  font-size: 12px;
}

.answer-content {
  max-height: 600px;
  overflow: auto;
  padding: 18px;
}

.markdown-body {
  color: #25302b;
  font-size: 15px;
  line-height: 1.82;
}

.markdown-body p {
  margin: 0 0 14px;
}

.markdown-body p:last-child,
.markdown-body ul:last-child {
  margin-bottom: 0;
}

.markdown-body strong {
  color: #111a16;
  font-weight: 800;
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef3f0;
  color: #12583f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  margin: 18px 0 10px;
  color: var(--accent-dark);
  line-height: 1.35;
}

.markdown-body h3 {
  font-size: 17px;
}

.markdown-body h4,
.markdown-body h5 {
  font-size: 16px;
}

.markdown-body ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.markdown-body li {
  margin: 6px 0;
}

fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

legend {
  padding: 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.choice-grid,
.tag-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
}

.annotation-panel {
  display: grid;
  grid-template-columns: 1.05fr 1.2fr;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-soft);
}

.comment-field {
  grid-column: 1 / -1;
}

.choice-grid label,
.tag-grid label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.choice-grid label:has(input:checked),
.tag-grid label:has(input:checked) {
  border-color: rgba(29, 119, 88, 0.35);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(29, 119, 88, 0.1);
}

.choice-grid input,
.tag-grid input {
  width: auto;
  height: auto;
}

.comment-field {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.survey-footer {
  position: sticky;
  bottom: 0;
  z-index: 8;
  justify-content: space-between;
  margin-top: -50px;
  padding: 64px 0 20px;
  background: linear-gradient(180deg, rgba(243, 245, 241, 0), rgba(243, 245, 241, 0.98) 44%);
  pointer-events: none;
}

.survey-footer button {
  pointer-events: auto;
}

.done-view {
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.done-status {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.done-status.success {
  border-color: rgba(29, 119, 88, 0.22);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.done-status.error {
  border-color: rgba(178, 69, 63, 0.24);
  background: #fff1ef;
  color: #9f352f;
}

.admin-shell {
  width: min(1100px, calc(100vw - 32px));
}

.admin-view {
  align-content: start;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1fr);
  gap: 16px;
}

.admin-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.admin-card h2 {
  font-size: 20px;
}

.admin-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-log-card {
  grid-column: 1 / -1;
}

.admin-log-card pre {
  min-height: 180px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #17201c;
  color: #dff1ea;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 920px) {
  .start-form,
  .answers-list,
  .annotation-panel {
    grid-template-columns: 1fr;
  }

  .intro-notes {
    grid-template-columns: 1fr;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .answer-card {
    min-height: 260px;
  }

  .answer-content {
    max-height: 360px;
  }

  .survey-header {
    display: grid;
    margin-left: -16px;
    margin-right: -16px;
  }

  .comment-field {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  body {
    background:
      linear-gradient(180deg, rgba(223, 241, 234, 0.86), rgba(243, 245, 241, 0) 300px),
      var(--bg);
  }

  button {
    min-height: 48px;
    border-radius: 8px;
  }

  .app-shell {
    width: 100%;
    max-width: 540px;
    padding: 18px 12px;
    overflow: visible;
  }

  .start-view {
    min-height: calc(100svh - 36px);
    align-content: start;
    gap: 18px;
    padding-top: 14px;
  }

  .intro,
  .done-view {
    max-width: none;
    text-align: left;
  }

  .eyebrow {
    margin-bottom: 8px;
    font-size: 12px;
  }

  h1 {
    font-size: 34px;
    line-height: 1.15;
  }

  h2 {
    font-size: 20px;
  }

  .summary {
    margin: 14px 0 0;
    font-size: 16px;
    line-height: 1.7;
  }

  .intro-notes {
    gap: 10px;
    margin-top: 18px;
  }

  .intro-notes article {
    min-height: auto;
    padding: 14px;
    border-radius: 10px;
  }

  .intro-notes strong {
    font-size: 15px;
  }

  .intro-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 8px;
    margin-top: 16px;
  }

  .intro-metrics span {
    justify-content: center;
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .start-form {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    width: 100%;
    max-width: none;
    padding: 12px;
    border-radius: 12px;
  }

  .start-form button {
    min-height: 54px;
    font-size: 17px;
  }

  .survey-view {
    gap: 12px;
    padding-top: calc(var(--survey-header-height) + 10px);
  }

  .survey-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-height: min(36svh, 280px);
    margin: 0;
    padding: 14px 12px 12px;
    box-shadow: 0 10px 24px rgba(30, 45, 38, 0.08);
    overflow: auto;
  }

  .survey-header h2 {
    font-size: 19px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .progress-track {
    height: 6px;
  }

  .survey-form {
    gap: 12px;
    padding-bottom: 88px;
  }

  .answers-list {
    gap: 12px;
  }

  .answer-card {
    min-height: auto;
    border-radius: 10px;
    overflow: visible;
  }

  .answer-card header {
    min-height: 50px;
    padding: 10px 12px;
  }

  .answer-label {
    min-width: 70px;
    min-height: 28px;
    font-size: 14px;
  }

  .answer-content {
    max-height: none;
    overflow: visible;
    padding: 14px;
  }

  .markdown-body {
    font-size: 15px;
    line-height: 1.78;
  }

  .annotation-panel {
    position: relative;
    padding: 12px;
    border-radius: 10px;
  }

  .choice-grid,
  .tag-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .choice-grid label,
  .tag-grid label {
    justify-content: center;
    min-height: 42px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 14px;
  }

  .comment-field {
    padding: 12px;
  }

  .survey-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin-top: 0;
    padding: 12px;
    background: rgba(243, 245, 241, 0.96);
    box-shadow: 0 -8px 24px rgba(30, 45, 38, 0.1);
    backdrop-filter: blur(14px);
  }

  .survey-footer button {
    flex: 1;
  }

  .done-view {
    min-height: calc(100svh - 36px);
    padding: 22px;
    border-radius: 12px;
  }

  .done-actions {
    display: grid;
  }
}
