/*
   Iris, a small warm room for music
   local fonts only, nothing fetched, no monospace cosplay
 */
:root {
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
  --radius: 24px;
  --radius-sm: 14px;
  --max: 760px;
  --lens-hi: #cfb6e6;
  --lens-mid: #8f6fb5;
  --lens-lo: #5d4382;
  --glint: #ffffff;
}

/* - four moods ------------------------------------------------------------ */

body.phase-dawn {
  --paper: #fbf1ec;
  --paper-2: #f6e4de;
  --card: rgba(255, 253, 251, .82);
  --card-solid: #fffdfb;
  --ink: #2e2230;
  --ink-soft: #6b5a68;
  --muted: #93828f;
  --line: rgba(74, 52, 74, .13);
  --line-strong: rgba(74, 52, 74, .24);
  --iris: #7a5fa8;
  --iris-soft: #b7a3d4;
  --accent: #cd7c62;
  --good: #4f8a6b;
  --bad: #b4534a;
  --petal-a: #c9a6d8;
  --petal-b: #8f6fb5;
  --heart: #f4c98a;
  --glow: rgba(205, 124, 98, .16);
}

body.phase-day {
  --paper: #f8f4ec;
  --paper-2: #f1eadf;
  --card: rgba(255, 254, 252, .86);
  --card-solid: #fffefc;
  --ink: #272130;
  --ink-soft: #5f5566;
  --muted: #8d8494;
  --line: rgba(60, 50, 70, .12);
  --line-strong: rgba(60, 50, 70, .22);
  --iris: #6d5da6;
  --iris-soft: #b6aadb;
  --accent: #c47a4f;
  --good: #4a8266;
  --bad: #ac4f46;
  --petal-a: #c3b0e0;
  --petal-b: #7d69b0;
  --heart: #f0c078;
  --glow: rgba(109, 93, 166, .13);
}

body.phase-dusk {
  --paper: #fbf1e6;
  --paper-2: #f6e3d2;
  --card: rgba(255, 251, 246, .84);
  --card-solid: #fffbf6;
  --ink: #30242c;
  --ink-soft: #6d5b60;
  --muted: #9b868c;
  --line: rgba(88, 58, 54, .14);
  --line-strong: rgba(88, 58, 54, .26);
  --iris: #85568f;
  --iris-soft: #c6a2c8;
  --accent: #c96c45;
  --good: #57855f;
  --bad: #b04f3f;
  --petal-a: #d9b3c4;
  --petal-b: #9c6a9a;
  --heart: #f2b46a;
  --glow: rgba(201, 108, 69, .16);
}

body.phase-night {
  --paper: #171520;
  --paper-2: #1d1a28;
  --card: rgba(40, 36, 54, .62);
  --card-solid: #221f2e;
  --ink: #ece8f4;
  --ink-soft: #b9b1c9;
  --muted: #8b829c;
  --line: rgba(214, 204, 236, .13);
  --line-strong: rgba(214, 204, 236, .26);
  --iris: #b7a1ef;
  --iris-soft: #6b5c96;
  --accent: #e2a06f;
  --good: #7fc9a0;
  --bad: #ef8b7f;
  --petal-a: #a58ede;
  --petal-b: #6a4f9e;
  --heart: #f6cf94;
  --glow: rgba(183, 161, 239, .14);
  --lens-hi: #dcc6f5;
  --lens-mid: #a98ce0;
  --lens-lo: #6b4c9e;
}

/* - base ------------------------------------------------------------ */

* { box-sizing: border-box; }

/* any element with the hidden attribute stays gone, whatever a class says.
   components like .ghost.as-link otherwise set display and win over the UA rule */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .6s var(--ease), color .6s var(--ease);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.wash {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 12% -10%, var(--paper-2) 0%, transparent 62%),
    radial-gradient(90% 70% at 96% 4%, var(--glow) 0%, transparent 58%),
    radial-gradient(100% 90% at 50% 118%, var(--paper-2) 0%, transparent 66%);
  transition: background .6s var(--ease);
}

.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
  background-image:
    radial-gradient(1.4px 1.4px at 18% 22%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.2px 1.2px at 72% 12%, rgba(255,255,255,.42), transparent),
    radial-gradient(1.6px 1.6px at 88% 34%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.1px 1.1px at 34% 8%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.3px 1.3px at 58% 26%, rgba(255,255,255,.4), transparent),
    radial-gradient(1px 1px at 8% 46%, rgba(255,255,255,.3), transparent);
  background-repeat: no-repeat;
}
body.phase-night .stars { opacity: 1; }

/* - topbar ------------------------------------------------------------ */

.topbar {
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 11px; }

.mark { display: grid; place-items: center; filter: drop-shadow(0 2px 8px var(--glow)); }

.wordmark {
  font-family: var(--serif);
  font-size: 23px;
  letter-spacing: .035em;
  color: var(--ink);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* - stage / panels ------------------------------------------------------------ */

.stage {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 26px 22px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stage.has-subview { justify-content: flex-start; }

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise .55s var(--ease) both;
}

.panel.hidden { display: none !important; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* - hero ------------------------------------------------------------ */

.hero {
  text-align: center;
  padding: 18px 0 4px;
}

.eye {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  margin: 0 0 22px;
  cursor: pointer;
  transition: transform .2s var(--ease);
  display: inline-grid;
  place-items: center;
  filter: drop-shadow(0 10px 34px var(--glow));
}
.eye:hover { transform: translateY(-1px); }
.eye:focus-visible { outline: 2px solid var(--iris); outline-offset: 6px; border-radius: 50%; }
.eye svg { display: block; overflow: visible; }
.eye-rim { fill: none; stroke: var(--line-strong); stroke-width: 1.2; opacity: .5; }
.eye-petal { fill: var(--petal-b); opacity: .1; }
.eye-iris { fill: var(--iris); opacity: .9; }
.eye-pupil { fill: var(--ink); opacity: .82; }
.eye-glint { fill: #fff; opacity: .8; }

#eyePupil {
  transition: transform .32s var(--ease);
  transform-origin: 60px 60px;
}

.greeting {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(30px, 5.4vw, 44px);
  line-height: 1.14;
  letter-spacing: -.015em;
  margin: 0 0 12px;
  min-height: 1.2em;
  text-wrap: balance;
}

.greeting .cursor {
  display: inline-block;
  width: 2px;
  height: .92em;
  margin-left: 2px;
  vertical-align: -.08em;
  background: var(--accent);
  animation: blink 1.05s steps(2, start) infinite;
  border-radius: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

.sub {
  margin: 0 auto;
  max-width: 46ch;
  color: var(--ink-soft);
  font-size: 15.5px;
  text-wrap: pretty;
}

/* - cards ------------------------------------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(14px) saturate(1.05);
  box-shadow:
    0 1px 0 rgba(255,255,255,.5) inset,
    0 14px 40px -26px rgba(40, 26, 44, .5);
  animation: fadeIn .5s var(--ease) both;
}
body.phase-night .card { box-shadow: 0 18px 46px -30px rgba(0,0,0,.9); }

.link-card { max-width: 620px; margin: 0 auto; width: 100%; }

.field-label {
  display: block;
  font-size: 12.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.row.tight { gap: 8px; }
.row.end { justify-content: flex-end; align-items: center; margin-top: 20px; }

input[type="text"], input[type="url"] {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: var(--card-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .3s;
}
body.phase-night input[type="text"], body.phase-night input[type="url"] { background: rgba(20,18,28,.55); }
input::placeholder { color: var(--muted); opacity: .8; }
input:focus-visible {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--iris) 16%, transparent);
}

/* - buttons ------------------------------------------------------------ */

button { font: inherit; color: inherit; cursor: pointer; }

.primary {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 13px 22px;
  background: linear-gradient(160deg, var(--iris), color-mix(in srgb, var(--iris) 74%, var(--accent)));
  color: #fff;
  font-weight: 560;
  letter-spacing: .01em;
  white-space: nowrap;
  box-shadow: 0 8px 22px -12px color-mix(in srgb, var(--iris) 70%, transparent);
  transition: transform .16s var(--ease), box-shadow .2s var(--ease), filter .2s;
}
.primary:hover { transform: translateY(-1px); filter: brightness(1.05); }
.primary:active { transform: translateY(0) scale(.985); }
.primary:disabled { opacity: .55; cursor: default; transform: none; filter: none; }
.primary.big { padding: 15px 28px; font-size: 16.5px; }

.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: background .2s, border-color .2s, color .2s;
}
.ghost:hover { background: color-mix(in srgb, var(--iris) 8%, transparent); border-color: var(--iris-soft); color: var(--ink); }
.ghost.small { padding: 6px 12px; font-size: 12.5px; }

.error {
  margin: 10px 0 0;
  color: var(--bad);
  font-size: 14px;
}

.tip {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 1.4em;
  transition: opacity .35s var(--ease);
}

.whisper {
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14.5px;
  color: var(--muted);
  margin: 22px 0 0;
  min-height: 1.4em;
}

/* - setup: found card ------------------------------------------------------------ */

.found-card { display: block; }

.eyebrow {
  display: block;
  font-size: 11.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 9px;
}

.found-card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(21px, 3.4vw, 27px);
  line-height: 1.22;
  margin: 0 0 6px;
  text-wrap: balance;
}

.found-meta { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; }

.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.card-head .field-label { margin-bottom: 0; }

.presets { display: flex; flex-wrap: wrap; gap: 7px; }

.pill {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--ink-soft);
  transition: all .18s var(--ease);
}
.pill:hover { border-color: var(--iris-soft); color: var(--ink); }
.pill.on {
  background: color-mix(in srgb, var(--iris) 16%, transparent);
  border-color: var(--iris);
  color: var(--ink);
  font-weight: 520;
}

.mini {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* - track chips ------------------------------------------------------------ */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  max-height: 268px;
  overflow-y: auto;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.chips::-webkit-scrollbar { width: 8px; }
.chips::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.tchip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--card-solid);
  border-radius: 999px;
  padding: 7px 13px 7px 9px;
  font-size: 13px;
  color: var(--ink-soft);
  transition: all .16s var(--ease);
}
body.phase-night .tchip { background: rgba(20,18,28,.5); }
.tchip:hover { border-color: var(--line-strong); color: var(--ink); }

.tchip .n {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  transition: all .16s var(--ease);
}

.tchip .t {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 34ch;
}

.tchip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--iris) 14%, var(--card-solid));
  border-color: var(--iris-soft);
  color: var(--ink);
}
.tchip[aria-pressed="true"] .n {
  background: var(--iris);
  color: #fff;
}

.tchip.seen { opacity: .62; }
.tchip.seen .n::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 2px var(--card-solid);
}

.manual { margin-top: 14px; }
.manual summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--muted);
  list-style: none;
  transition: color .2s;
}
.manual summary::-webkit-details-marker { display: none; }
.manual summary::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  margin-right: 9px;
  vertical-align: 1px;
  transition: transform .2s var(--ease);
}
.manual[open] summary::before { transform: rotate(45deg) translateX(-1px); }
.manual summary:hover { color: var(--ink-soft); }
.manual input { margin-top: 10px; width: 100%; }

/* - prefix / segmented ------------------------------------------------------------ */

.suffix-sample {
  display: grid;
  place-items: center;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--iris) 9%, transparent);
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.split {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  margin: 22px 0 4px;
  align-items: start;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  border: 1px solid var(--line);
}

.seg {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 13px;
  color: var(--ink-soft);
  transition: all .18s var(--ease);
}
.seg:hover { color: var(--ink); }
.seg[aria-checked="true"] {
  background: var(--card-solid);
  color: var(--ink);
  font-weight: 540;
  box-shadow: 0 2px 8px -4px rgba(40,26,44,.4);
}
body.phase-night .seg[aria-checked="true"] { background: rgba(60,54,78,.9); }

/* - review ------------------------------------------------------------ */

.ready-card { background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--iris) 5%, var(--card))); }

.review {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 22px;
  margin: 4px 0 0;
  font-size: 14px;
}
.review dt { color: var(--muted); white-space: nowrap; }
.review dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* - run ------------------------------------------------------------ */

.run-head { text-align: center; padding: 8px 0 0; }
.run-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 4vw, 32px);
  margin: 0 0 8px;
}

.run-card { display: flex; flex-direction: column; align-items: center; }

.ring-wrap { position: relative; display: grid; place-items: center; margin: 6px 0 18px; }
.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-fg {
  fill: none;
  stroke: var(--iris);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset .4s var(--ease);
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--iris) 55%, transparent));
}

.ring-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.ring-pct { font-family: var(--serif); font-size: 31px; font-variant-numeric: tabular-nums; }
.ring-sub { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.run-stats {
  display: flex;
  gap: 30px;
  justify-content: center;
  width: 100%;
  padding: 4px 0 14px;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stat-v { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat-k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.now {
  width: 100%;
  text-align: center;
  font-size: 14px;
  color: var(--ink-soft);
  min-height: 1.5em;
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
}

.activity {
  width: 100%;
  max-height: 224px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding: 6px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.activity::-webkit-scrollbar { width: 8px; }
.activity::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

.act {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 6px;
  font-size: 13px;
  color: var(--ink-soft);
  border-radius: 10px;
  animation: fadeIn .35s var(--ease) both;
}
.act .marker {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--iris-soft);
  transform: translateY(-1px);
}
.act .txt { overflow-wrap: anywhere; }

.act.kind-saved { color: var(--ink); }
.act.kind-saved .marker { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 15%, transparent); }
.act.kind-error { color: var(--bad); }
.act.kind-error .marker { background: var(--bad); }
.act.kind-warn { color: var(--accent); }
.act.kind-warn .marker { background: var(--accent); }

/* - done ------------------------------------------------------------ */

.done-card { text-align: left; }

.done-card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(25px, 4.2vw, 33px);
  line-height: 1.16;
  margin: 0 0 10px;
  text-wrap: balance;
}
.done-card .sub { margin: 0 0 18px; max-width: none; }

.saved {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}
.saved li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  animation: fadeIn .4s var(--ease) both;
}
.saved li:nth-child(odd) { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.saved li svg { flex: none; opacity: .8; }
.saved .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.failures { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.failures summary {
  cursor: pointer;
  font-size: 13.5px;
  color: var(--bad);
  list-style: none;
}
.failures summary::-webkit-details-marker { display: none; }
.failures summary::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
  margin-right: 9px;
  vertical-align: 1px;
  transition: transform .2s var(--ease);
}
.failures[open] summary::before { transform: rotate(45deg) translateX(-1px); }
.failures ul {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.failures li {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--bad) 7%, transparent);
  border-left: 2px solid var(--bad);
  border-radius: 0 8px 8px 0;
  padding: 7px 11px;
  overflow-wrap: anywhere;
}

/* - footer ------------------------------------------------------------ */

.foot {
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 22px 44px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
}
.foot p { margin: 0 0 8px; text-wrap: pretty; }
.foot-links { display: flex; gap: 9px; justify-content: center; align-items: center; }
.foot a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 1px;
  transition: color .2s, border-color .2s;
}
.foot a:hover { color: var(--accent); border-color: var(--accent); }

/* - toast ------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 18px);
  background: var(--card-solid);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13.5px;
  box-shadow: 0 16px 44px -22px rgba(40,26,44,.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
  z-index: 20;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* - the mark -------------------------------------------------------------- */

.mark img {
  display: block;
  border-radius: 50%;
  box-shadow: 0 2px 10px -3px color-mix(in srgb, var(--ink) 40%, transparent);
  transition: transform .5s var(--ease);
}
.brand:hover .mark img { transform: rotate(-8deg) scale(1.04); }

/* - app install chip ------------------------------------------------------ */

.ghost.icon-only { padding: 7px 13px; font-size: 12.5px; }
#installBtn {
  border-color: var(--iris-soft);
  color: var(--iris);
  background: color-mix(in srgb, var(--iris) 8%, transparent);
}
#installBtn:hover { background: color-mix(in srgb, var(--iris) 16%, transparent); }

/* - naming block ---------------------------------------------------------- */

.segmented.naming { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.segmented.naming .seg { padding: 10px 12px; }

.prefix-block { margin-top: 14px; animation: fadeIn .3s var(--ease) both; }

/* - standalone app shell -------------------------------------------------- */

@media (display-mode: standalone) {
  .topbar { padding-top: max(18px, env(safe-area-inset-top)); }
  .foot { padding-bottom: max(28px, env(safe-area-inset-bottom)); }
  .install-hint { display: none; }
}

/* - truthful-host banner -------------------------------------------------- */

.remote-warn {
  max-width: var(--max);
  margin: 0 auto 4px;
  padding: 12px 22px 0;
}
.remote-warn-inner {
  border: 1px solid color-mix(in srgb, var(--bad) 42%, transparent);
  background: color-mix(in srgb, var(--bad) 8%, var(--card));
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}
.remote-warn-inner strong { display: block; margin-bottom: 3px; font-weight: 620; }

/* - views & tabs ------------------------------------------------------- */

.view { display: flex; flex-direction: column; gap: 18px; }
.view.hidden { display: none; }

.view-head { padding: 6px 2px 2px; }
.view-head h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(25px, 4.4vw, 34px);
  line-height: 1.15;
  margin: 0 0 6px;
}
.view-head .sub { margin: 0; max-width: none; }

.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  max-width: var(--max);
  width: 100%;
  margin: 8px auto 0;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.2);
}

.tab {
  appearance: none;
  border: 0;
  background: none;
  border-radius: 14px;
  padding: 7px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.tab svg { transition: transform .25s var(--ease); }
.tab:hover { color: var(--ink-soft); }
.tab.on { color: var(--iris); background: color-mix(in srgb, var(--iris) 9%, transparent); }
.tab.on svg { transform: translateY(-1px); }
.tab:focus-visible { outline: 2px solid var(--iris); outline-offset: -2px; }

/* - library ------------------------------------------------------------ */

.row.between { justify-content: space-between; align-items: center; gap: 12px; }
.row.end .mini { margin-right: auto; }

.inline-stat { display: flex; flex-direction: column; gap: 1px; }
.inline-stat strong { font-size: 17px; font-variant-numeric: tabular-nums; font-weight: 560; }
.inline-stat span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.mini-input {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--card-solid);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  max-width: 190px;
}
body.phase-night .mini-input { background: rgba(20,18,28,.55); }
.mini-input:focus-visible { outline: none; border-color: var(--iris); }

.lib-list, .history-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 440px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.lib-list::-webkit-scrollbar, .history-list::-webkit-scrollbar { width: 8px; }
.lib-list::-webkit-scrollbar-thumb, .history-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 8px;
}

.lib-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  animation: fadeIn .3s var(--ease) both;
}
.lib-row:nth-child(odd) { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.lib-row .badge {
  flex: none;
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--iris) 14%, transparent);
  color: var(--ink-soft);
}
.lib-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lib-row .meta { flex: none; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty-note { text-align: center; padding: 18px 0 6px; }

/* - history ------------------------------------------------------------ */

.hist-row {
  display: flex;
  align-items: baseline;
  gap: 11px;
  padding: 11px 10px;
  border-radius: 10px;
  animation: fadeIn .3s var(--ease) both;
}
.hist-row:nth-child(odd) { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.hist-row .when { flex: none; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 74px; }
.hist-row .what { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .count { flex: none; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.hist-row .count.bad { color: var(--bad); }

/* - settings ----------------------------------------------------------- */

.danger { border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: var(--bad); color: var(--bad); }

.mini.warn { color: var(--bad); }
#prefixNote.warn { color: var(--bad); }

.support-card { background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--accent) 6%, var(--card))); }
.support-card h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 21px;
  margin: 0 0 8px;
}
.support-card .mini { max-width: 46ch; }

.primary.as-link {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* - responsive: phone first, then a real desktop layout ---------------- */

@media (max-width: 899px) {
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-width: none;
    margin: 0;
    border-radius: 0;
  }
  .stage { padding-bottom: 88px; }
  .foot { padding-bottom: 96px; }
}

@media (max-width: 620px) {
  .topbar { padding-top: 18px; }
  .stage { padding-top: 20px; }
  .card { padding: 19px; border-radius: 20px; }
  .row { flex-direction: column; }
  .row.end { flex-direction: row; }
  .suffix-sample { display: none; }
  .split { grid-template-columns: 1fr; gap: 16px; }
  .segmented {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    width: 100%;
  }
  .segmented:has(.seg:nth-child(3):last-child) { grid-template-columns: repeat(3, 1fr); }
  .seg { padding: 8px 4px; text-align: center; }
  .chips { max-height: 220px; }
  .tchip .t { max-width: 22ch; }
  .run-stats { gap: 22px; }
  .review { grid-template-columns: 1fr; gap: 2px 0; }
  .review dd { margin-bottom: 8px; }
  .inline-stat strong { font-size: 15.5px; }
  .mini-input { max-width: 100%; }
  .card-head { align-items: center; }
  .lib-row .meta { display: none; }
  .hist-row { flex-wrap: wrap; gap: 3px 10px; }
  .hist-row .what { flex-basis: 100%; white-space: normal; }
  .tabbar { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 400px) {
  .card { padding: 16px; }
  .tab span { font-size: 9.5px; }
  .review { font-size: 13px; }
}

/* ---- desktop: side rail, wide canvas, two-column work areas ---------- */

@media (min-width: 900px) {
  :root { --max: 1140px; }

  body { padding-left: 94px; }

  .topbar { padding: 26px 26px 0; }
  .stage { padding: 30px 26px 40px; }
  .foot { padding: 26px 26px 44px; }
  .remote-warn { padding: 12px 26px 0; }

  /* nav becomes a left rail instead of a bottom bar */
  .tabbar {
    position: fixed;
    left: 0; top: 0; bottom: 0; right: auto;
    width: 94px;
    max-width: none;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    gap: 6px;
    padding: 20px 12px;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--paper) 90%, transparent);
    backdrop-filter: blur(14px);
  }

  .tab {
    padding: 13px 4px 11px;
    gap: 5px;
    border-radius: 16px;
    font-size: 9.5px;
    letter-spacing: .07em;
  }
  .tab svg { width: 21px; height: 21px; }
  .tab.on svg { transform: none; }

  /* home: hero beside the link card */
  #panel-link:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
    align-items: center;
    gap: 20px 56px;
    padding: 30px 0;
  }
  #panel-link .hero { text-align: left; padding: 0; }
  #panel-link .eye { margin: 0 0 26px; }
  #panel-link .sub { margin: 0; max-width: 34ch; }
  #panel-link .link-card { max-width: none; width: 100%; }
  #panel-link .whisper { grid-column: 1; margin: 0; text-align: left; }
  .greeting { font-size: clamp(34px, 3.4vw, 46px); }

  /* setup: tracks on the left, the rest on the right */
  #panel-setup:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(0, 1.32fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  #panel-setup > .found-card,
  #panel-setup > .ready-card { grid-column: 1 / -1; }
  #panel-setup .chips { max-height: 420px; }

  /* settings: two columns of cards */
  #view-settings:not(.hidden) {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
  }
  #view-settings > .view-head { grid-column: 1 / -1; }

  /* library and history get the full width */
  .lib-list { max-height: 560px; }
  .history-list { max-height: 620px; }
  .lib-row, .hist-row { font-size: 14px; padding: 11px 12px; }

  .card { padding: 26px; }
  .view-head { padding: 8px 2px 4px; }
  .view { gap: 20px; }

  .segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .seg { padding: 8px 6px; text-align: center; white-space: nowrap; }
}

@media (min-width: 1280px) {
  :root { --max: 1240px; }
  body { padding-left: 104px; }
  .tabbar { width: 104px; padding: 24px 14px; }
  .tab { font-size: 10px; }
}

@media (display-mode: standalone) {
  .tabbar { padding-bottom: calc(7px + env(safe-area-inset-bottom)); }
}

@media (min-width: 900px) and (display-mode: standalone) {
  .tabbar { padding-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* - track durations --------------------------------------------------- */

.tchip .dur {
  flex: none;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-left: 2px;
}
.tchip[aria-pressed="true"] .dur { color: color-mix(in srgb, var(--ink) 58%, transparent); }

.chips-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.chips-tools .mini { margin: 8px 0 0; }
.chips-tools .mini-input { margin-top: 8px; }

/* - library row actions ---------------------------------------------- */

.row-acts { flex: none; display: flex; gap: 2px; opacity: 0; transition: opacity .18s var(--ease); }
.lib-row:hover .row-acts,
.lib-row:focus-within .row-acts { opacity: 1; }

@media (hover: none) {
  .row-acts { opacity: 1; }
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.icon-btn.del:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.icon-btn.armed { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.icon-btn:focus-visible { outline: 2px solid var(--iris); outline-offset: 1px; }

/* - theme segmented --------------------------------------------------- */

.segmented.theme { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
.segmented.theme .seg { padding: 9px 6px; }

.ghost.as-link {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* - browser mode ------------------------------------------------------- */

.browser-note { display: none; }
body.browser-mode .browser-note { display: block; }

body.browser-mode .helper-only { display: none !important; }

/* tabs that need a server to mean anything */
body.browser-mode .tab[data-view="library"],
body.browser-mode .tab[data-view="history"] { display: none; }
body.browser-mode .tabbar { grid-template-columns: repeat(2, 1fr); }

body.browser-mode #view-library,
body.browser-mode #view-history { display: none !important; }

/* the parts of settings that only exist with a helper */
body.browser-mode #setPrefix,
body.browser-mode #setSample,
body.browser-mode #setReveal,
body.browser-mode #setSave,
body.browser-mode #setDir,
body.browser-mode #archiveForget,
body.browser-mode #setFormat,
body.browser-mode #setQuality { display: none; }

@media (min-width: 1280px) {
  body.browser-mode .tabbar { grid-template-columns: repeat(2, 1fr); }
}

/* - honesty about what a browser can reach ---------------------------- */

.mode-note {
  display: none;
  margin: 14px 0 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 3%, transparent);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}
body.browser-mode .mode-note { display: block; }
.mode-note strong { display: block; margin-bottom: 3px; color: var(--ink); font-weight: 600; }

/* - connect flow ------------------------------------------------------- */

.connect-card { max-width: 620px; margin: 0 auto; width: 100%; }
.connect-card h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.16;
  margin: 0 0 10px;
}
.connect-card > .sub { margin: 0 0 22px; }

.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.steps[hidden] { display: none !important; }

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 38px;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--iris) 14%, transparent);
  color: var(--iris);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.steps strong { display: block; font-weight: 580; font-size: 14.5px; margin-bottom: 2px; }
.steps span { display: block; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }

.code-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 22px;
  letter-spacing: .38em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--card-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 18px;
}
body.phase-night .code-input { background: rgba(20,18,28,.55); }
.code-input:focus-visible {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--iris) 16%, transparent);
}

.connect-foot {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.connect-foot .mini { margin: 0; }

@media (max-width: 620px) {
  .steps li { padding-left: 33px; }
  .code-input { font-size: 19px; letter-spacing: .3em; }
}

/* - connect: local app handoff ---------------------------------------- */

.open-app {
  margin: 0 0 22px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--iris) 26%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--iris) 6%, transparent);
  text-align: center;
}
.open-app[hidden] { display: none !important; }
.open-app .mini { margin: 10px 0 0; }

.pair-block {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.pair-block[hidden] { display: none !important; }
.pair-block .mini { margin: 0 0 10px; }

.steps code {
  font-family: var(--sans);
  font-size: 12.5px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  padding: 1px 5px;
  border-radius: 5px;
}
