:root {
  --ink: #14283c;
  --ink-soft: #3a5168;
  --paper: #f3f6f8;
  --paper-2: #e8eef2;
  --surface: #ffffff;
  --teal: #0f7a6e;
  --teal-deep: #0a5c53;
  --warn: #9a4d1c;
  --danger: #8b2e2e;
  --line: rgba(20, 40, 60, 0.12);
  --shadow: 0 18px 40px rgba(20, 40, 60, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Figtree", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.55;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 122, 110, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(58, 81, 104, 0.12), transparent 50%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(920px, calc(100% - 1.25rem));
  margin: 0 auto;
  padding: 1rem 0 5.5rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(243, 246, 248, 0.92);
  border-bottom: 1px solid var(--line);
  margin: 0 calc(50% - 50vw);
  padding: 0.65rem calc(50vw - 50%);
}

.topbar-inner {
  width: min(920px, calc(100% - 1.25rem));
  margin: 0 auto;
  display: grid;
  gap: 0.55rem;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.progress-wrap {
  display: grid;
  gap: 0.35rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), #1aa394);
  transition: width 0.35s ease;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
  scrollbar-width: thin;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.4rem);
  margin-top: 1rem;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-panel h1,
.section-intro h2,
.result-hero h2 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0.35rem 0 0.75rem;
  font-size: clamp(1.45rem, 5vw, 2.45rem);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--teal-deep);
}

.meta-line {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.lede {
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1.25rem 0 0;
  padding: 0;
}

.meta-grid div {
  background: linear-gradient(180deg, #f7fafb, #eef3f6);
  border-radius: 14px;
  padding: 0.85rem 0.9rem;
}

.meta-grid dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.meta-grid dd {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.dim-head h3 {
  font-family: var(--font-display);
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.dim-head p {
  margin: 0 0 1rem;
  color: var(--ink-soft);
}

.item {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.item.is-missing {
  outline: 2px solid var(--warn);
  outline-offset: 6px;
  border-radius: 12px;
  background: rgba(154, 77, 28, 0.06);
}

.item:first-of-type {
  border-top: 0;
}

.item-num,
.prompt {
  margin: 0 0 0.75rem;
}

.scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.scale-end {
  font-size: 0.75rem;
  color: var(--ink-soft);
  min-width: 5.5rem;
}

.scale-btn {
  width: 2.6rem;
  height: 2.6rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f7fafb;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.scale-btn:hover {
  transform: translateY(-1px);
}

.scale-btn.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.choice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  margin: 0.45rem 0;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice.is-active {
  border-color: var(--teal);
  background: rgba(15, 122, 110, 0.08);
}

.choice input {
  margin-top: 0.2rem;
  min-width: 18px;
  min-height: 18px;
}

.note {
  background: rgba(15, 122, 110, 0.08);
  border-left: 3px solid var(--teal);
  padding: 0.75rem 0.9rem;
  border-radius: 0 12px 12px 0;
}

.consent {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: #f7fafb;
  border: 1px solid var(--line);
}

.identity-box {
  margin-top: 1.1rem;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcfd, #f3f7f9);
}

.identity-box h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.identity-help {
  margin: 0 0 0.9rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.field {
  display: grid;
  gap: 0.3rem;
  margin: 0.65rem 0;
}

.field span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.field input,
.reflection textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  font-size: 16px;
  background: #fff;
}

.field input:focus,
.reflection textarea:focus {
  outline: 2px solid rgba(15, 122, 110, 0.35);
  border-color: var(--teal);
}

.form-error {
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-size: 0.92rem;
}

.identity-chip {
  margin: 0.35rem 0 0.75rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  word-break: break-word;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--teal-deep);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn.danger-ghost {
  background: transparent;
  border: 1px solid rgba(139, 46, 46, 0.35);
  color: var(--danger);
}

.btn.save-btn {
  background: var(--teal);
  color: #fff;
}

.btn.save-btn:hover:not(:disabled) {
  background: var(--teal-deep);
}

.sticky-nav {
  position: sticky;
  bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.save-inline {
  font-size: 0.88rem;
  color: var(--ink-soft);
  align-self: center;
  max-width: min(280px, 100%);
  flex: 1 1 160px;
}

.save-inline.ok {
  color: var(--teal-deep);
  font-weight: 700;
}

.save-inline.warn {
  color: var(--warn);
  font-weight: 700;
}

.save-hint {
  margin: 0.9rem 0 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.req-star {
  color: var(--danger);
  font-weight: 700;
}

.index-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.index-card {
  background: linear-gradient(180deg, #f7fafb, #eef3f6);
  border-radius: 14px;
  padding: 0.9rem;
  display: grid;
  gap: 0.2rem;
}

.index-card span {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.index-card strong {
  font-family: var(--font-display);
  font-size: 1.6rem;
}

.index-card em {
  font-style: normal;
  font-size: 0.85rem;
  color: var(--teal-deep);
  font-weight: 700;
}

.chart-wrap {
  width: min(420px, 100%);
  margin: 0.5rem auto 1rem;
}

.chart-wrap canvas {
  width: 100%;
  height: auto;
  display: block;
}

.bar-row {
  margin: 0.7rem 0;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #147f72, #1aa394);
  border-radius: inherit;
}

.reflection {
  margin: 1rem 0;
}

.reflection textarea {
  resize: vertical;
  background: #fbfcfd;
}

.weeks {
  padding-left: 1.1rem;
}

.weeks li {
  margin: 0.65rem 0;
}

.fineprint {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.fineprint h3 {
  color: var(--ink);
  font-size: 1rem;
  margin-top: 1.1rem;
}

/* Tablet */
@media (max-width: 900px) {
  .meta-grid,
  .index-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-wrap {
    width: min(360px, 100%);
  }

  .scale-btn {
    width: 2.8rem;
    height: 2.8rem;
  }
}

/* Mobile + small tablet */
@media (max-width: 760px) {
  .shell,
  .topbar-inner {
    width: min(100% - 1rem, 920px);
  }

  .shell {
    padding-bottom: 6.5rem;
  }

  .brand-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .scale {
    justify-content: space-between;
  }

  .scale-end {
    min-width: 100%;
    font-size: 0.72rem;
  }

  .scale-end:last-child {
    order: 3;
  }

  .scale-btn {
    flex: 1 1 0;
    max-width: 3.2rem;
  }

  .sticky-nav {
    bottom: 0;
    border-radius: 16px 16px 0 0;
  }

  .sticky-nav .btn {
    flex: 1 1 calc(50% - 0.4rem);
    text-align: center;
  }

  .sticky-nav .save-btn {
    flex: 1 1 100%;
  }

  .bar-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}

/* Phones */
@media (max-width: 520px) {
  .meta-grid,
  .index-cards {
    grid-template-columns: 1fr;
  }

  .tab {
    font-size: 0.78rem;
    padding: 0.38rem 0.7rem;
  }

  .lede {
    font-size: 1rem;
  }
}

@media print {
  .topbar,
  .sticky-nav,
  .actions,
  .btn {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
