/*
 * The setup walkthrough and health page (see setup.js). The app's own stone
 * and amber, with three more lights for checks: green for good, amber for
 * worth a look, red for needs fixing. Calm on purpose: a check that passes
 * is quiet, and only what needs doing stands out.
 */
:root {
  --ok: #4a6630;
  --ok-wash: rgb(106 140 75 / 0.14);
  --warn: #a86a17;
  --warn-wash: rgb(233 162 59 / 0.14);
  --bad: #b91c1c;
  --bad-wash: rgb(220 38 38 / 0.11);
}
html.dark {
  --ok: #b8d49a;
  --ok-wash: rgb(156 191 122 / 0.14);
  --warn: #f4b860;
  --warn-wash: rgb(244 184 96 / 0.12);
  --bad: #f87171;
  --bad-wash: rgb(248 113 113 / 0.12);
}

body.setup-open { overflow: hidden; }
.setup {
  position: fixed; inset: 0; z-index: 48;
  display: grid; grid-template-columns: 280px minmax(0, 1fr);
  background: var(--canvas);
}
.setup[hidden] { display: none; }
.setup::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: var(--ambient);
}
.setup > * { position: relative; }

/* --- the rail ------------------------------------------------------------- */

.setup-rail {
  display: flex; flex-direction: column; gap: 22px;
  padding: 26px 20px 22px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-right: 1px solid var(--hairline);
}
.setup-rail .logo { font-size: var(--fs-md); gap: 10px; }
.setup-rail .logo-mark { width: 26px; height: 26px; }
.setup-progress { height: 3px; border-radius: var(--r-pill); background: var(--hairline); overflow: hidden; }
.setup-progress i {
  display: block; height: 100%; width: calc(var(--done, 0) * 100%);
  background: linear-gradient(90deg, var(--amber-400), var(--amber-600));
  transition: width 500ms var(--ease-editorial);
}
.setup-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.setup-step button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: var(--r-sm);
  background: none; box-shadow: none; color: var(--muted);
  font-size: var(--fs-md); font-weight: 500; text-align: left;
}
.setup-step button:hover:not(:disabled) { background: var(--hover-wash); color: var(--text-strong); }
.setup-step button:active:not(:disabled) { transform: none; }
.step-mark {
  width: 26px; height: 26px; flex: none; display: grid; place-items: center;
  border-radius: 50%; font-size: var(--fs-xs); font-weight: 600;
  border: 1px solid var(--hairline-strong, var(--hairline)); color: var(--muted); background: var(--surface);
  transition: background 220ms var(--ease-editorial), color 220ms var(--ease-editorial), border-color 220ms var(--ease-editorial);
}
.step-mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.setup-step.current button { color: var(--text-strong); background: var(--surface); box-shadow: var(--elev-1); }
.setup-step.current .step-mark { background: var(--select-bg); border-color: transparent; color: var(--select-fg); }
.setup-step.seen .step-mark { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-wash); }
.setup-skip { margin-top: auto; align-self: flex-start; }

/* --- the page ------------------------------------------------------------- */

.setup-main { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
.setup-body { overflow: auto; padding: 56px clamp(24px, 6vw, 72px) 40px; }
.setup-body > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.setup-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px clamp(24px, 6vw, 72px);
  border-top: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  backdrop-filter: blur(16px);
}
.setup-foot .primary { min-width: 140px; justify-content: center; }

.setup-head { margin-bottom: 30px; animation: rise 420ms var(--ease-editorial) both; }
.setup-kicker {
  margin: 0 0 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--muted);
}
.setup-head h1 {
  margin: 0; font-size: var(--fs-2xl); line-height: 1.08;
  letter-spacing: -0.035em; font-weight: 650; color: var(--text-strong);
}
.setup-sub { margin: 14px 0 0; max-width: 60ch; font-size: var(--fs-lg); line-height: 1.6; color: var(--muted); }
.small { font-size: var(--fs-sm); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .setup-head, .setup .check, .verdict { animation: none !important; } }

/* --- welcome --------------------------------------------------------------- */

.setup-card {
  padding: 22px 24px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--elev-1);
}
.field { display: grid; gap: 10px; font-size: var(--fs-md); font-weight: 600; color: var(--text-strong); }
.field input { font-size: var(--fs-lg); padding: 12px 14px; }
.name-card .muted { margin: 10px 0 0; }
.tour { list-style: none; padding: 0; margin: 22px auto 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tour li {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px;
  border-radius: var(--r-md); border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.tour strong { display: block; font-size: var(--fs-md); color: var(--text-strong); }
.tour li span:not(.tour-icon) { display: block; font-size: var(--fs-sm); color: var(--muted); margin-top: 3px; line-height: 1.45; }
.tour-icon, .kind-icon, .check-icon {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--hairline); color: var(--text);
}
.tour-icon svg, .kind-icon svg, .check-icon svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

/* --- libraries ------------------------------------------------------------- */

.kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.kind {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--elev-1);
  transition: border-color 260ms var(--ease-editorial), box-shadow 260ms var(--ease-editorial);
}
.kind.done { border-color: color-mix(in srgb, var(--ok) 35%, var(--hairline)); }
.kind-head { display: flex; gap: 12px; align-items: flex-start; }
.kind-head strong { display: block; font-size: var(--fs-md); color: var(--text-strong); }
.kind-head span:not(.kind-icon) { display: block; font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; line-height: 1.45; }
.kind > button { margin-top: auto; justify-content: center; }
.kind-folders { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.kind-folders li {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 2px 8px; align-items: center;
  padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--hairline);
}
.kind-folders code {
  background: none; border: 0; padding: 0; font-size: var(--fs-xs); color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left;
}
.kind-count { grid-column: 2; font-size: var(--fs-xs); color: var(--muted); }
.kind-folders li.scanning .kind-count { color: var(--text); }
.mini-state { width: 16px; height: 16px; display: grid; place-items: center; color: var(--ok); }
.mini-state svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.browser {
  margin-top: 16px; border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--hairline);
  box-shadow: var(--elev-3);
  animation: rise 300ms var(--ease-editorial) both;
}
.browser[hidden] { display: none; }
.browser-head { display: grid; gap: 6px; padding: 16px 18px 12px; border-bottom: 1px solid var(--hairline); }
.browser-head strong { font-size: var(--fs-md); color: var(--text-strong); }
.browser-path { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-xs); }
.browser-list { list-style: none; margin: 0; padding: 6px; max-height: 300px; overflow: auto; }
button.browser-row {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: var(--r-sm); background: none; box-shadow: none; text-align: left;
  font-size: var(--fs-md); font-weight: 400; color: var(--text);
}
button.browser-row:hover:not(:disabled) { background: var(--hover-wash); }
button.browser-row:active:not(:disabled) { transform: none; }
.browser-row svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.browser-row.up { color: var(--muted); }
.browser-row.up svg { stroke: var(--muted); }
.empty-folder { padding: 10px 12px; }
.browser-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-top: 1px solid var(--hairline); background: var(--surface-2);
}
.browser-foot > span { margin-right: auto; }

/* --- verdicts and checks --------------------------------------------------- */

.verdict {
  display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px;
  padding: 20px 22px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--elev-2);
  animation: rise 360ms var(--ease-editorial) both;
}
.verdict strong { display: block; font-size: var(--fs-lg); letter-spacing: -0.015em; color: var(--text-strong); }
.verdict p { margin: 5px 0 0; font-size: var(--fs-md); line-height: 1.55; color: var(--muted); max-width: 60ch; }
.verdict-icon {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); color: var(--muted);
}
.verdict-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.verdict.ok { border-color: color-mix(in srgb, var(--ok) 30%, var(--hairline)); background: linear-gradient(120deg, var(--ok-wash), transparent 60%), var(--surface); }
.verdict.ok .verdict-icon { background: var(--ok-wash); color: var(--ok); }
.verdict.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--hairline)); background: linear-gradient(120deg, var(--warn-wash), transparent 60%), var(--surface); }
.verdict.warn .verdict-icon { background: var(--warn-wash); color: var(--warn); }
.verdict.bad { border-color: color-mix(in srgb, var(--bad) 35%, var(--hairline)); background: linear-gradient(120deg, var(--bad-wash), transparent 60%), var(--surface); }
.verdict.bad .verdict-icon { background: var(--bad-wash); color: var(--bad); }

.checks {
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--elev-1);
}
.setup .check {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 15px 18px;
  animation: rise 320ms var(--ease-editorial) both;
}
.setup .check + .setup .check { border-top: 1px solid var(--hairline); }
.check-text { display: grid; gap: 3px; min-width: 0; }
.check-text strong { font-size: var(--fs-md); font-weight: 600; color: var(--text-strong); }
.check-detail { font-size: var(--fs-sm); line-height: 1.45; color: var(--muted); }
.check-right { display: flex; align-items: center; gap: 12px; }
.check-value {
  font-family: "Geist Mono", ui-monospace, monospace; font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-strong); white-space: nowrap;
}
.check-state {
  width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface-2); color: var(--muted);
}
.check-state svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.setup .check.ok .check-state { background: var(--ok-wash); color: var(--ok); }
.setup .check.warn .check-state { background: var(--warn-wash); color: var(--warn); }
.setup .check.bad .check-state { background: var(--bad-wash); color: var(--bad); }
.setup .check.warn .check-icon { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.setup .check.bad .check-icon { background: var(--bad-wash); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.setup .check.run .check-detail { color: var(--text); }
.setup .check.info .check-icon { background: var(--surface-2); border-color: var(--hairline); color: var(--muted); }

.spin {
  width: 14px; height: 14px; border-radius: 50%; display: block;
  border: 2px solid color-mix(in srgb, var(--accent-text) 25%, transparent);
  border-top-color: var(--accent-text);
  animation: spin 800ms linear infinite;
}
.verdict-icon .spin { width: 20px; height: 20px; }
@keyframes spin { to { transform: rotate(360deg); } }

.meter { display: block; height: 6px; margin-top: 6px; max-width: 360px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.meter i {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: var(--ok); transition: width 900ms var(--ease-editorial);
}
.meter.tight i { background: #e9a23b; }
.meter.slow i { background: var(--bad); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 500; border: 1px solid var(--hairline); background: var(--surface-2); color: var(--muted);
}
.tag svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.tag.yes { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: var(--ok-wash); }

.check-fix {
  grid-column: 2 / -1; margin-top: 2px; padding: 14px 16px;
  border-radius: var(--r-md); background: var(--warn-wash);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
}
.setup .check.bad .check-fix { background: var(--bad-wash); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.fix-title { margin: 0 0 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-strong); }
.check-fix ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: var(--fs-sm); line-height: 1.5; color: var(--text); }
.fix-link {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 12px;
  padding: 7px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600;
  background: var(--surface); border: 1px solid var(--hairline); color: var(--text-strong); text-decoration: none;
}
.fix-link:hover { border-color: color-mix(in srgb, var(--text) 30%, transparent); }
.fix-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.rerun { margin-top: 16px; }

/* --- screens ----------------------------------------------------------------- */

.screens-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.screen {
  display: flex; flex-direction: column; gap: 10px; padding: 22px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--hairline); box-shadow: var(--elev-1);
  animation: rise 360ms var(--ease-editorial) both;
}
.screen strong { font-size: var(--fs-md); color: var(--text-strong); }
.screen p { margin: 0; font-size: var(--fs-sm); line-height: 1.55; color: var(--muted); }
.screen > button { margin-top: auto; align-self: flex-start; }
.big-address {
  display: block; margin-top: 10px; padding: 10px 12px; font-size: var(--fs-md); font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: var(--r-sm); color: var(--text-strong);
}

.health-link { margin: -6px 0 14px; font-size: var(--fs-sm); }

/* --- smaller screens ------------------------------------------------------- */

@media (max-width: 900px) {
  .kinds { grid-template-columns: 1fr; }
  .tour, .screens-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .setup { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .setup-rail { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--hairline); }
  .setup-rail .logo { margin-right: auto; }
  .setup-progress { order: 3; flex-basis: 100%; }
  .setup-steps { order: 4; flex-basis: 100%; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; }
  .setup-step button { flex-direction: column; gap: 4px; padding: 6px 2px; font-size: var(--fs-xs); justify-content: center; text-align: center; }
  .setup-step.current button { box-shadow: none; background: none; }
  .setup-skip { margin: 0; order: 2; padding: 6px 10px; font-size: var(--fs-sm); }
  .setup-body { padding: 28px 18px 28px; }
  .setup-foot { padding: 12px 16px; }
  .setup .check { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 14px; }
  .check-fix { grid-column: 1 / -1; }
  .check-value { font-size: var(--fs-xs); }
  .tour-icon, .kind-icon, .check-icon { width: 32px; height: 32px; }
}
