:root {
  color-scheme: dark;
  --bg: #070b12;
  --surface: #101722;
  --surface-strong: #172231;
  --surface-soft: #0c121c;
  --text: #eef5ff;
  --muted: #93a5ba;
  --line: #263548;
  --accent: #43c7ff;
  --accent-strong: #8be0ff;
  --success: #57d68d;
  --danger: #ff7d8d;
  --shadow: 0 18px 48px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% -10%, rgba(67, 199, 255, .14), transparent 36rem),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

input:not([type="checkbox"]),
.button {
  min-height: 42px;
}

.hero {
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 18, .88);
  backdrop-filter: blur(14px);
}

.hero__inner {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  align-items: end;
  gap: 36px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -.04em;
}

h2 {
  margin-bottom: 7px;
  font-size: 1.45rem;
}

h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: .01em;
}

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

.progress-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(23, 34, 49, .95), rgba(12, 18, 28, .95));
  box-shadow: var(--shadow);
}

.progress-card__copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.progress__bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 180ms ease;
}

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 70px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 34px;
}

.shell--checklist {
  grid-template-columns: 230px minmax(0, 1fr);
}

.workspace-panel[hidden],
.progress-card[hidden] {
  display: none;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
}

#category-nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface);
  color: var(--text);
}

.nav-link__count {
  font-variant-numeric: tabular-nums;
  font-size: .78rem;
}

.remaining-toggle {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 20px;
  padding: 12px 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}

.toast {
  position: fixed;
  z-index: 20;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 94%, #000);
  box-shadow: 0 12px 30px rgb(0 0 0 / .25);
  color: var(--text);
  font-size: .9rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .25s ease, transform .25s ease;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-saving="true"] {
  border-color: var(--accent-strong);
}

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.account-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.ally-code-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 1rem; }
.ally-code-form label { white-space: nowrap; }
.ally-code-form input { width: 126px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); font: inherit; }
.ally-code-form .button { min-height: 42px; font-size: inherit; }
.workspace-tabs { grid-column: 1 / -1; justify-self: center; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 610px); padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(12, 18, 28, .82); box-shadow: 0 10px 28px rgba(0, 0, 0, .16); }
.workspace-tab { min-height: 42px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; transition: background 120ms ease, color 120ms ease; }
.workspace-tab:hover, .workspace-tab:focus-visible { color: var(--text); background: rgba(255, 255, 255, .05); outline: 0; }
.workspace-tab[aria-selected="true"] { color: #092232; background: linear-gradient(135deg, var(--accent), var(--accent-strong)); box-shadow: 0 5px 14px rgba(67, 199, 255, .2); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.token-dialog { width: min(520px, calc(100% - 32px)); color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); padding: 0; }
.token-dialog::backdrop { background: rgba(0, 0, 0, .65); }
.token-dialog__card { padding: 28px; }
.token-dialog__card h2 { margin: 4px 0 10px; }
.token-dialog__value { display: grid; gap: 7px; margin: 20px 0; font-weight: 700; }
.token-dialog__value input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--text); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }
.token-dialog__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.login__card { width: min(400px, 100%); display: grid; gap: 14px; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.login__card label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.login__card input { width: 100%; padding: 10px 12px; color: var(--text); border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }

.error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  color: var(--danger);
  background: rgba(255, 125, 141, .08);
}

.audit {
  margin: 0 0 42px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(23, 34, 49, .9), rgba(12, 18, 28, .9));
  box-shadow: var(--shadow);
}

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

.audit h2 {
  margin-bottom: 6px;
}

.audit__copy,
.audit-squad__purpose {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(67, 199, 255, .5);
  border-radius: 9px;
  background: rgba(67, 199, 255, .12);
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  background: rgba(67, 199, 255, .22);
}

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

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

.button--secondary:hover,
.button--secondary:focus-visible {
  background: var(--surface-strong);
  color: var(--text);
}

.audit > .muted {
  margin: 18px 0 0;
  font-size: .86rem;
}

.audit__summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 18px;
}

.audit-metric {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(7, 11, 18, .42);
}

.audit-metric strong,
.audit-metric span {
  display: block;
}

.audit-metric strong {
  font-size: 1.35rem;
}

.audit-metric span {
  margin-top: 2px;
  color: var(--muted);
  font-size: .76rem;
}

.audit-metric--success strong,
.audit-unit--ready .audit-unit__headline > strong {
  color: var(--success);
}

.audit-metric--attention strong,
.audit-unit--attention .audit-unit__headline > strong {
  color: var(--accent-strong);
}

.audit-metric--danger strong {
  color: var(--danger);
}

.audit__squads {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.audit-squad {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(7, 11, 18, .38);
}

.audit-squad h3 {
  margin-bottom: 3px;
}

.audit-squad__purpose {
  font-size: .82rem;
}

.audit-unit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.audit-unit__headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.audit-unit__metric {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .8rem;
  text-align: right;
  white-space: nowrap;
}

.audit-unit__metric-addition {
  color: #f4c95d;
  font-size: 1rem;
}

.audit-unit__metric small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
}

.audit-unit__details,
.audit-unit__goal,
.audit-unit__findings {
  color: var(--muted);
  font-size: .79rem;
  line-height: 1.4;
}

.audit-unit__details {
  display: block;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.audit-unit__goal,
.audit-unit__findings {
  display: block;
  margin-top: 3px;
}

.audit-unit__goal::before {
  content: "Focus: ";
  color: var(--text);
}

.audit-unit__findings {
  color: var(--accent-strong);
}

.category {
  scroll-margin-top: 24px;
  margin-bottom: 42px;
}

.category__header {
  margin-bottom: 17px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.category__title-row,
.section__title-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.category__title-row h2 {
  margin-bottom: 0;
}

.category__description,
.section__description {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.section {
  margin-top: 22px;
  padding: 18px 20px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 23, 34, .82);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .14);
}

.section__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 8px;
}

.section__count {
  color: var(--muted);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.title-delete {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 24px;
  margin: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: #ee6d76;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
}

.category__title-row:hover .title-delete,
.category__title-row:focus-within .title-delete,
.section__title-row:hover .title-delete,
.section__title-row:focus-within .title-delete {
  opacity: .78;
}

.title-delete:hover {
  color: #ff9198;
  opacity: 1;
}

.title-delete:focus-visible {
  outline: 2px solid rgba(238, 109, 118, .6);
  outline-offset: 1px;
  opacity: 1;
}

.title-delete:disabled {
  cursor: wait;
  opacity: .42;
}

.title-delete svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.inline-creator {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.category > .inline-creator {
  margin: 20px 0 2px;
}

.inline-creator input:not([type="checkbox"]) {
  min-width: 0;
  flex: 1 1 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
}

.inline-creator input:not([type="checkbox"]):focus {
  outline: 2px solid rgba(67, 199, 255, .45);
  outline-offset: 1px;
}

/* A pending checklist item should read as part of its list, not as a separate form. */
.inline-creator--item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  min-height: 48px;
  margin-top: 0;
  padding: 12px 2px;
  border-top: 1px solid var(--line);
}

.inline-creator--item input:not([type="checkbox"]) {
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 0 0 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  line-height: 1.45;
}

.inline-creator--item input:not([type="checkbox"])::placeholder {
  color: var(--muted);
  opacity: .78;
}

.inline-creator--item input:not([type="checkbox"]):hover,
.inline-creator--item input:not([type="checkbox"]):focus {
  border-bottom-color: var(--accent);
  outline: 0;
}

.item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: start;
  min-height: 48px;
  padding: 12px 2px;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.item:first-of-type {
  border-top: 0;
}

.item:hover .item__text {
  color: var(--accent-strong);
}

.item__checkbox {
  -webkit-appearance: none;
  appearance: none;
  display: grid;
  place-content: center;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  /* Mirrors the compact cyan control from the original checklist, without
     relying on Safari's native checkbox rendering. */
  border: 1px solid #6d737b;
  border-radius: 2px;
  background: #303132;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.item__checkbox::after {
  content: "";
  width: 8px;
  height: 4px;
  border: solid #092232;
  border-width: 0 0 2px 2px;
  opacity: 0;
  transform: rotate(-45deg) translate(1px, -1px);
}

.item__checkbox:checked {
  border-color: #43c7ff;
  background: #43c7ff;
}

.item__checkbox:checked::after {
  opacity: 1;
}

.item__checkbox:focus-visible {
  outline: 2px solid rgba(67, 199, 255, .55);
  outline-offset: 2px;
}

.item__checkbox:disabled {
  cursor: wait;
}

.item__checkbox--placeholder:disabled {
  cursor: default;
}

.item__body {
  min-width: 0;
  cursor: pointer;
}

.item__text {
  display: block;
  line-height: 1.45;
  transition: color 120ms ease;
}

.item__note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.4;
}

.item__note:empty {
  display: none;
}

.item__delete {
  display: grid;
  place-items: center;
  align-self: start;
  width: 30px;
  height: 24px;
  margin: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: #ee6d76;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease;
}

.item:hover .item__delete,
.item:focus-within .item__delete {
  opacity: .78;
}

.item__delete:hover {
  color: #ff9198;
  opacity: 1;
}

.item__delete:focus-visible {
  outline: 2px solid rgba(238, 109, 118, .6);
  outline-offset: 1px;
  opacity: 1;
}

.item__delete:disabled {
  cursor: wait;
  opacity: .42;
}

.item__delete svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.item:has(.item__checkbox:checked) .item__text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.empty {
  padding: 30px 0;
  color: var(--muted);
}

@media (max-width: 780px) {
  .hero__inner,
  .shell {
    width: min(100% - 26px, 680px);
  }

  .hero__inner {
    grid-template-columns: 1fr;
    gap: 22px;
    padding-top: 28px;
  }

  .shell {
    grid-template-columns: 1fr;
    padding-top: 18px;
  }

  .sidebar {
    position: static;
  }

  #category-nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .nav-link {
    flex: 0 0 auto;
    width: auto;
  }

  .remaining-toggle {
    margin-top: 10px;
  }

  .audit__header {
    align-items: stretch;
    flex-direction: column;
  }

  .audit__summary,
  .audit__squads {
    grid-template-columns: 1fr;
  }

  .audit-unit__headline {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .audit-unit__metric {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .progress__bar,
  .item__text {
    transition: none;
  }
}
