:root {
  --canvas: #f7f9f8;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --ink: #10201d;
  --ink-soft: #364843;
  --muted: #687873;
  --line: #d8e1de;
  --line-strong: #bccbc7;
  --teal: #08786d;
  --teal-dark: #045d55;
  --teal-soft: #e3f1ee;
  --amber: #a86111;
  --amber-soft: #fff4df;
  --coral: #c44e48;
  --coral-dark: #943933;
  --coral-soft: #fff0ee;
  --night: #0d211d;
  --night-soft: #19312c;
  --shadow: 0 20px 60px rgba(16, 32, 29, 0.08);
  --shadow-tight: 0 8px 24px rgba(16, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
}

body.locked .console-shell {
  display: none;
}

body:not(.locked) .login-gate {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(13, 117, 108, 0.2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}

.login-panel {
  width: min(390px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand,
.header-brand,
.header-actions,
.action-heading,
.rail-heading,
.primary-actions,
.modal-header,
.modal-actions,
.episode-header,
.episode-brand,
.safety-strip,
.console-footer,
.baseline-meta,
.button,
.icon-button {
  display: flex;
  align-items: center;
}

.login-brand {
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 7px;
  background: var(--ink);
  color: white;
  font-size: 18px;
  font-weight: 900;
}

.login-brand h1 {
  margin: 0 0 3px;
  font-size: 25px;
  line-height: 1.1;
}

.login-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.login-panel > label,
.notes-field,
.conditional-fields > label,
.dark-label {
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 750;
}

input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

.system-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.button {
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 18px;
  font-weight: 850;
  letter-spacing: 0;
}

.button svg,
.icon-button svg,
.rail-heading svg,
.safety-strip svg,
.text-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.button.primary {
  background: var(--teal);
  color: white;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.login-panel .button {
  width: 100%;
  margin-top: 16px;
}

.console-shell {
  width: min(1380px, calc(100% - 56px));
  min-height: 100vh;
  margin: 0 auto;
}

.console-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.header-brand {
  gap: 11px;
}

.header-brand > div {
  display: grid;
  gap: 2px;
}

.header-brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.header-brand span:not(.brand-mark) {
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  gap: 8px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
  color: var(--muted);
  font-size: 12px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #56a99f;
  box-shadow: 0 0 0 4px rgba(8, 120, 109, 0.09);
}

.sync-status.is-offline .sync-dot {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(168, 97, 17, 0.09);
}

.sync-status.is-syncing .sync-dot {
  animation: sync-pulse 1.1s ease-in-out infinite;
}

.icon-button {
  width: auto;
  min-width: 38px;
  height: 38px;
  gap: 7px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  padding: 0 11px;
  font-size: 12px;
  font-weight: 750;
}

.icon-button:hover {
  color: var(--teal);
  border-color: #b8cbc6;
}

.command-surface {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 354px;
  column-gap: 52px;
  padding: 34px 0 24px;
}

.action-zone {
  min-width: 0;
  padding-right: 2px;
}

.action-heading {
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
}

.section-label {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.action-heading h1 {
  margin: 0;
  padding-left: 18px;
  border-left: 5px solid var(--coral);
  font-size: clamp(36px, 4.2vw, 62px);
  line-height: 1.02;
  font-weight: 900;
}

.guidance-state {
  min-width: 104px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid #bdd8d2;
  border-left: 3px solid var(--teal);
  border-radius: 5px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.guidance-focus {
  max-width: 800px;
  margin: 19px 0 7px 23px;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.58;
}

.guidance-rationale {
  max-width: 800px;
  margin: 0 0 0 23px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.action-steps {
  margin: 25px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.action-step {
  display: grid;
  grid-template-columns: 28px 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 84px;
  border-bottom: 1px solid var(--line);
}

.step-index {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.step-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #c7dad5;
  border-radius: 7px;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.step-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.step-copy strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.3;
}

.step-copy p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.step-time {
  min-width: 62px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
  text-align: right;
}

.primary-actions {
  gap: 12px;
  margin-top: 22px;
}

.primary-actions .button {
  flex: 1;
  min-height: 50px;
}

.episode-button {
  border-color: var(--coral);
  background: var(--coral);
  color: white;
}

.episode-button:hover {
  border-color: var(--coral-dark);
  background: var(--coral-dark);
}

.decision-rail {
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.rail-section {
  padding: 0 0 21px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 21px;
}

.rail-heading {
  gap: 9px;
  margin-bottom: 14px;
}

.rail-heading svg {
  color: var(--teal);
}

.avoid-section .rail-heading svg {
  color: var(--coral);
}

.rail-heading h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: 0;
}

.avoid-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.avoid-list li {
  position: relative;
  padding-left: 17px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.avoid-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 6px;
  height: 6px;
  background: var(--coral);
  border-radius: 50%;
}

.baseline-section p,
.next-section p,
.review-prompt p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.65;
}

.baseline-meter {
  height: 6px;
  margin: 14px 0 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e0e8e5;
}

.baseline-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal);
  border-radius: inherit;
  transition: width 260ms ease;
}

.baseline-meta {
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.review-prompt {
  margin: 0 0 24px;
  padding: 14px;
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
}

.review-prompt strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  border: 0;
  background: transparent;
  color: var(--amber);
  padding: 0;
  font-size: 13px;
  font-weight: 850;
}

.safety-strip {
  grid-column: 1 / -1;
  gap: 11px;
  margin-top: 26px;
  padding: 12px 14px;
  border-top: 1px solid #e6b5b1;
  border-bottom: 1px solid #e6b5b1;
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.safety-strip p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.console-footer {
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 20, 17, 0.52);
  backdrop-filter: blur(6px);
}

.modal-sheet {
  width: min(720px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  background: var(--surface);
  border-radius: 7px;
  box-shadow: 0 24px 80px rgba(5, 18, 15, 0.24);
}

.checkin-sheet {
  padding: 24px;
}

.modal-header {
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}

.modal-header h2 {
  margin: 0;
  font-size: 25px;
}

.form-section {
  min-width: 0;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.form-section legend {
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.choice-row {
  display: grid;
  gap: 7px;
}

.choice-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-row.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.choice-row label,
.toggle-grid label {
  display: block;
  min-width: 0;
}

.choice-row input,
.toggle-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-row span,
.toggle-grid span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.choice-row input:checked + span,
.toggle-grid input:checked + span {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.metric-grid,
.conditional-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-control {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfc;
}

.metric-control > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 800;
}

.metric-control output {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.disclosure-check {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin: 2px 0 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfc;
}

.disclosure-check input {
  margin-top: 3px;
  accent-color: var(--teal);
}

.disclosure-check span {
  display: grid;
  gap: 3px;
}

.disclosure-check strong {
  font-size: 13px;
}

.disclosure-check small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.baseline-change-fields {
  padding: 14px;
  border-left: 3px solid var(--amber);
  background: #fffaf1;
}

.notes-field {
  margin-top: 4px;
}

.modal-actions {
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.episode-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--night);
  color: white;
}

.episode-console {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.episode-header {
  justify-content: space-between;
  margin-bottom: 36px;
}

.episode-brand {
  gap: 9px;
  font-size: 14px;
  font-weight: 850;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff6f67;
  box-shadow: 0 0 0 6px rgba(255, 111, 103, 0.12);
}

.icon-button.dark {
  border-color: #36504a;
  background: var(--night-soft);
  color: white;
}

.episode-timer-view {
  text-align: center;
}

.episode-caption,
.episode-summary {
  margin: 0;
  color: #a8bbb6;
  font-size: 13px;
  line-height: 1.6;
}

.episode-timer {
  margin: 20px 0 8px;
  font-size: clamp(72px, 12vw, 126px);
  line-height: 1;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.episode-timer-view h2,
.episode-finish-form h2 {
  margin: 24px 0 10px;
  font-size: clamp(27px, 5vw, 40px);
}

.episode-timer-view > p:last-of-type {
  max-width: 520px;
  margin: 0 auto;
  color: #c6d4d0;
  line-height: 1.65;
}

.episode-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 38px 0 30px;
  padding: 0;
  list-style: none;
}

.episode-progress li {
  padding-top: 11px;
  border-top: 3px solid #35504a;
  color: #78908a;
  font-size: 12px;
  font-weight: 800;
}

.episode-progress li.active,
.episode-progress li.complete {
  border-color: #5fc2b4;
  color: white;
}

.episode-finish {
  width: min(300px, 100%);
  margin: 0 auto;
  border-color: #536d67;
  background: transparent;
  color: white;
}

.episode-finish:hover {
  background: var(--night-soft);
}

.episode-finish-form {
  display: grid;
  gap: 18px;
}

.section-label.coral {
  color: #ff938d;
}

.dark-control {
  border-color: #35504a;
  background: var(--night-soft);
}

.dark-control > span {
  color: #d8e3e0;
}

.dark-control output {
  color: #7ed3c7;
}

.dark-grid span,
.dark-choices span {
  border-color: #35504a;
  background: var(--night-soft);
  color: #c5d2cf;
}

.dark-grid input:checked + span,
.dark-choices input:checked + span {
  border-color: #6bc7ba;
  background: #183c36;
  color: white;
}

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

.impact-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #35504a;
  border-radius: 6px;
  background: var(--night-soft);
  color: #d7e2df;
  font-size: 13px;
  font-weight: 750;
}

.impact-grid input {
  accent-color: #6bc7ba;
}

.dark-fieldset legend,
.dark-label {
  color: #cbd8d4;
}

.dark-label textarea {
  border-color: #35504a;
  background: var(--night-soft);
  color: white;
}

.episode-save {
  width: 100%;
  background: #58b8aa;
  color: #081714;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  max-width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 11px 15px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@keyframes sync-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.mode-stabilize .guidance-state,
.mode-reassess .guidance-state {
  border-left-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.mode-progress .guidance-state {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: #8e510d;
}

@media (max-width: 920px) {
  .console-shell {
    width: min(100% - 32px, 780px);
  }

  .command-surface {
    grid-template-columns: 1fr;
    padding-top: 30px;
  }

  .decision-rail {
    margin-top: 34px;
    padding: 26px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .safety-strip {
    margin-top: 12px;
  }
}

@media (max-width: 620px) {
  .console-shell {
    width: calc(100% - 24px);
  }

  .console-header {
    min-height: 66px;
    gap: 8px;
  }

  .header-brand .brand-mark {
    width: 34px;
    height: 34px;
  }

  .sync-status {
    display: none;
  }

  #todayLabel {
    display: none;
  }

  .header-actions {
    gap: 4px;
  }

  .icon-button {
    width: 38px;
    padding: 0;
  }

  .icon-button > span {
    display: none;
  }

  .command-surface {
    padding-top: 24px;
  }

  .action-heading {
    display: grid;
    gap: 15px;
  }

  .action-heading h1 {
    padding-left: 13px;
    border-left-width: 4px;
    font-size: 38px;
  }

  .guidance-state {
    width: fit-content;
  }

  .guidance-focus {
    margin: 16px 0 6px 17px;
    font-size: 16px;
  }

  .guidance-rationale {
    margin-left: 17px;
  }

  .action-step {
    grid-template-columns: 24px 40px minmax(0, 1fr);
    gap: 10px;
    min-height: 92px;
    padding: 9px 0;
  }

  .step-icon {
    width: 38px;
    height: 38px;
  }

  .step-time {
    grid-column: 3;
    text-align: left;
  }

  .primary-actions {
    position: sticky;
    z-index: 8;
    bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 8px;
    margin: 14px -12px 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(247, 249, 248, 0.96);
    backdrop-filter: blur(14px);
    box-shadow: 0 -8px 28px rgba(16, 32, 29, 0.06);
  }

  .primary-actions .episode-button {
    order: 0;
  }

  .primary-actions .button {
    min-height: 48px;
    padding-inline: 10px;
    font-size: 13px;
  }

  .console-footer {
    align-items: flex-start;
    display: grid;
  }

  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .modal-sheet {
    width: 100%;
    max-height: 94vh;
    border-radius: 7px 7px 0 0;
  }

  .checkin-sheet {
    padding: 20px 16px 24px;
  }

  .metric-grid,
  .conditional-fields {
    grid-template-columns: 1fr;
  }

  .choice-row.four,
  .toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .modal-actions {
    position: sticky;
    bottom: -24px;
    margin-left: -16px;
    margin-right: -16px;
    padding: 12px 16px 24px;
    background: var(--surface);
  }

  .modal-actions .button.primary {
    flex: 1;
  }

  .episode-overlay {
    padding: 16px;
  }

  .episode-header {
    margin-bottom: 22px;
  }

  .episode-timer {
    margin-top: 16px;
    font-size: 76px;
  }

  .episode-progress {
    margin-top: 28px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
