/* torchy: a quiet icon rail beside grouped settings rows; every row leads with a plain line icon. */

@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f2f2f7;
  --panel: #ffffff;
  --glass: rgb(255 255 255 / 0.86);
  --line: #e5e5ea;
  --edge: rgb(20 20 30 / 0.06);
  --fill: #f2f2f7;
  --fill-hover: #e9e9ee;
  --text: #1c1c1e;
  --muted: #6b6b73;
  --faint: #8e8e93;
  --accent: #f2600f;
  --accent-ink: #c2410c;
  --accent-soft: #fff0e5;
  --btn: #c2410c;
  --on-btn: #ffffff;
  --track: #e3e3e8;
  --knob: #ffffff;
  --check-ring: #8e8e93;
  --segment-on: #ffffff;
  --avatar-bg: #1c1c1e;
  --avatar-fg: #ffffff;
  --ok: #18794e;
  --danger: #c9252d;
  --danger-soft: #fdecec;
  --on-danger: #ffffff;
  --warn: #cc7a00;
  --toast: #1c1c1e;
  --on-toast: #f5f5f7;
  --shadow: 0 1px 2px rgb(20 20 30 / 0.04), 0 6px 18px -8px rgb(20 20 30 / 0.1);
  --float: 0 1px 2px rgb(20 20 30 / 0.05), 0 18px 40px -16px rgb(20 20 30 / 0.22);
  --knob-shadow: 0 1px 1px rgb(0 0 0 / 0.08), 0 2px 6px rgb(0 0 0 / 0.16);
  --radius: 16px;
  --radius-sm: 10px;
  --inset: 64px;
  --lead: 44px;
  --font:
    "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%238e8e93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
  --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='m5.5 12.5 4 4 9-9'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ground: #0e0e10;
    --panel: #1c1c1f;
    --glass: rgb(36 36 40 / 0.86);
    --line: #2e2e33;
    --edge: rgb(255 255 255 / 0.06);
    --fill: #2a2a2e;
    --fill-hover: #333338;
    --text: #f2f2f5;
    --muted: #a1a1a8;
    --faint: #7c7c84;
    --accent: #ff7a2e;
    --accent-ink: #ff9a5c;
    --accent-soft: rgb(255 122 46 / 0.15);
    --btn: #ff7a2e;
    --on-btn: #1a0b02;
    --track: #3a3a3f;
    --knob: #f5f5f7;
    --check-ring: #7c7c84;
    --segment-on: #4a4a50;
    --avatar-bg: #2e2e33;
    --avatar-fg: #f2f2f5;
    --ok: #4cc38a;
    --danger: #ff6b6b;
    --danger-soft: rgb(255 107 107 / 0.12);
    --on-danger: #1f0505;
    --warn: #c97700;
    --toast: #f2f2f5;
    --on-toast: #1c1c1e;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 22px -10px rgb(0 0 0 / 0.6);
    --float: 0 1px 2px rgb(0 0 0 / 0.5), 0 20px 44px -14px rgb(0 0 0 / 0.75);
    --knob-shadow: 0 1px 2px rgb(0 0 0 / 0.4);
    --check-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%231a0b02' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='m5.5 12.5 4 4 9-9'/%3E%3C/svg%3E");
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--text);
  font: 16px / 1.45 var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--accent);
}

::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
}

* {
  scrollbar-color: var(--faint) transparent;
  scrollbar-width: thin;
}

:focus-visible {
  outline: 2px solid var(--accent-ink);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

code {
  font-family: var(--mono);
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: var(--fill);
}

h1,
h2,
p,
ol {
  margin: 0;
}

[hidden] {
  display: none !important;
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 40;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}
.skip:focus {
  top: 10px;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ---------- Top bar (phones, and signed-out pages) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 60px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 1.1875rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.logo {
  display: block;
  flex: none;
}

.topnav {
  display: flex;
  gap: 4px;
}
.topnav a {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--muted);
  transition:
    background-color 140ms linear,
    color 140ms linear;
}
.topnav a:hover {
  background: var(--fill-hover);
  color: var(--text);
}
.topnav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
body:not(.signed-in) [data-auth="in"] {
  display: none;
}
body:not(.signed-in) .topbar {
  display: none;
}

/* ---------- Shell: an icon rail floating at the left edge, centered top to bottom ---------- */

.shell {
  min-height: 100dvh;
  padding: 20px 48px 20px 132px;
}

.dock {
  position: fixed;
  top: 50%;
  left: 24px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 68px;
  padding: 10px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow:
    0 0 0 1px var(--edge),
    var(--float);
  transform: translateY(-50%);
}

.dock-sections,
.dock-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.dock-link {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  transition:
    background-color 180ms linear,
    color 180ms linear,
    transform 320ms var(--spring);
}
.dock-link:hover {
  background: var(--fill);
  color: var(--text);
}
.dock-link:active {
  transform: scale(0.9);
}
.dock-link[aria-current="page"] {
  background: var(--text);
  color: var(--panel);
}
.dock-glyph {
  width: 22px;
  height: 22px;
  transition: transform 320ms var(--spring);
}
.dock-link:hover .dock-glyph {
  transform: scale(1.14);
}
.dock-brand .logo {
  transition: transform 420ms var(--spring);
}
.dock-brand:hover {
  background: transparent;
}
.dock-brand:hover .logo {
  transform: rotate(-10deg) scale(1.12);
}
.dock-server .avatar {
  width: 38px;
  height: 38px;
  font-size: 1rem;
  transition: transform 320ms var(--spring);
}
.dock-server:hover {
  background: transparent;
}
.dock-server:hover .avatar {
  transform: scale(1.1);
}

/* The name bubble that slides out to the right on hover or keyboard focus. */
.dock-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 16px);
  z-index: 1;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--toast);
  color: var(--on-toast);
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--float);
  opacity: 0;
  pointer-events: none;
  transform: translate(-8px, -50%) scale(0.96);
  transform-origin: left center;
  transition:
    opacity 140ms linear,
    transform 260ms var(--spring);
}
.dock-label::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -4px;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: inherit;
  transform: translateY(-50%) rotate(45deg);
}
.dock-link:hover .dock-label,
.dock-link:focus-visible .dock-label {
  opacity: 1;
  transform: translate(0, -50%) scale(1);
}
.dock-short {
  display: none;
}

.stage {
  min-width: 0;
  max-width: 1000px;
  margin: 0 auto;
  padding: 26px 0 72px;
}
.stage:has(.split) {
  max-width: 1220px;
}

.stage-body.enter {
  animation: enter 360ms var(--ease);
}
@keyframes enter {
  from {
    transform: translateY(8px);
  }
}

.page-head {
  margin: 0 0 30px;
}
.title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 1.0625rem;
  overflow-wrap: anywhere;
}

/* ---------- Groups and rows ---------- */

.groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  min-width: 0;
}

.group-label {
  margin: 0 0 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.panel {
  container-type: inline-size;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow:
    0 0 0 1px var(--edge),
    var(--shadow);
  overflow: clip;
}

.group-note {
  max-width: 72ch;
  margin-top: 8px;
  padding: 0 16px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 20px;
}
.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: var(--inset);
  height: 1px;
  background: var(--line);
}
.row + .row-buttons::before {
  display: none;
}

/* Row icons are plain line glyphs: no fill behind them and no motion. */
.tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--muted);
}
.tile .icon {
  width: 24px;
  height: 24px;
}
.tile.tone-danger {
  color: var(--danger);
}
.tile.tone-warn {
  color: var(--warn);
}

.row-text {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.row-label {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
label.row-label {
  cursor: pointer;
}
.row-help {
  max-width: 68ch;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.row.is-disabled .row-label {
  color: var(--muted);
}

.row-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  margin-left: auto;
}

.row-status {
  color: var(--ok);
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 160ms linear;
}
.row-status.show {
  opacity: 1;
}

.row-value {
  flex: none;
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* A label with its control stacked below it. */
.row-field {
  align-items: flex-start;
}
.row-body {
  display: grid;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.row-body > .row-label {
  margin: 3px 0 -2px;
}

/* A label on the left, a compact control on the right. */
.row-pair .row-control {
  flex: 0 0 300px;
}
.row-pair .input-number {
  flex-basis: 110px;
}
/* In a narrow panel the control drops below its label, lined up with the label text. */
@container (max-width: 640px) {
  .row-pair {
    flex-wrap: wrap;
  }
  .row-pair .row-text {
    flex-basis: calc(100% - var(--lead));
  }
  .row-pair .row-control {
    flex-basis: calc(100% - var(--lead));
    margin-left: var(--lead);
  }
  .row-pair .input-number {
    flex-basis: 110px;
  }
}

.row-buttons {
  min-height: 0;
  padding: 4px 20px 18px var(--inset);
}
.panel > .error {
  padding: 0 20px 18px var(--inset);
}

/* Links that open a server. */
.row-link,
.is-gone {
  --inset: 80px;
  color: var(--text);
  text-decoration: none;
}
.row-link {
  transition: background-color 120ms linear;
}
.row-link:hover {
  background: var(--fill);
}
.row-link:focus-visible {
  border-radius: var(--radius);
  outline-offset: -3px;
}
.chevron {
  width: 18px;
  height: 18px;
  margin-left: auto;
  color: var(--faint);
}
.is-gone {
  opacity: 0.6;
}

/* Channel rows with a round check at the right edge. */
.row-check {
  min-height: 64px;
  cursor: pointer;
  transition: background-color 120ms linear;
}
.row-check:hover {
  background: color-mix(in srgb, var(--fill) 60%, transparent);
}
.check {
  appearance: none;
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 2px solid var(--check-ring);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition:
    background-color 160ms linear,
    border-color 160ms linear;
}
.check:checked {
  border-color: var(--accent);
  background: var(--accent) var(--check-mark) center / 16px no-repeat;
}
.check:disabled {
  cursor: progress;
  opacity: 0.6;
}

/* Moderation cases. */
.row-case {
  align-items: flex-start;
}
.row-case .row-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.case-action {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.case-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.danger-zone .row-label {
  color: var(--danger);
}

/* ---------- Avatar ---------- */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-weight: 700;
  object-fit: cover;
}

/* ---------- Personas ---------- */

.persona-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.persona-calls {
  display: block;
  margin-top: 2px;
  font-size: 0.8125rem;
}
.persona-main {
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}
.row.is-off > .avatar {
  opacity: 0.45;
}

/* ---------- Switch ---------- */

.switch {
  position: relative;
  display: inline-block;
  flex: none;
  width: 51px;
  height: 31px;
}
.switch input {
  position: absolute;
  inset: -8px -6px;
  z-index: 1;
  width: calc(100% + 12px);
  height: calc(100% + 16px);
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--track);
  transition: background-color 200ms linear;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--knob);
  box-shadow: var(--knob-shadow);
  transition:
    transform 260ms var(--ease),
    width 200ms var(--ease);
}
.switch input:checked + .switch-track {
  background: var(--accent);
}
.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}
.switch input:active:not(:disabled) + .switch-track::after {
  width: 33px;
}
.switch input:checked:active:not(:disabled) + .switch-track::after {
  transform: translateX(14px);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent-ink);
  outline-offset: 3px;
}
.switch input:disabled {
  cursor: not-allowed;
}
.switch input:disabled + .switch-track {
  opacity: 0.45;
}
.switch[aria-busy="true"] input {
  cursor: progress;
}
.switch[aria-busy="true"] .switch-track {
  animation: busy 900ms ease-in-out infinite alternate;
}
@keyframes busy {
  to {
    opacity: 0.55;
  }
}

/* ---------- Inputs ---------- */

.input,
.textarea,
.select {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--fill);
  transition:
    background-color 140ms linear,
    border-color 140ms linear,
    box-shadow 140ms linear;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
.input:hover,
.textarea:hover,
.select:hover {
  background: var(--fill-hover);
}
.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.input:disabled,
.textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.5;
}
.select {
  appearance: none;
  padding-right: 40px;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  cursor: pointer;
  text-overflow: ellipsis;
}
.input-code {
  font-family: var(--mono);
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.input-code::placeholder {
  letter-spacing: 0.14em;
}
.input-number {
  font-variant-numeric: tabular-nums;
}

.file-input {
  max-width: 100%;
  color: var(--muted);
  font-size: 0.9375rem;
}
.file-input::file-selector-button {
  min-height: 40px;
  margin-right: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--fill);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.file-input::file-selector-button:hover {
  background: var(--fill-hover);
}

.thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--fill);
  object-fit: cover;
}
.thumb-wide {
  width: min(100%, 340px);
  height: auto;
  aspect-ratio: 17 / 6;
  border-radius: var(--radius-sm);
}

/* Segmented choices: real radios drawn as a pill control. */
.segmented {
  display: flex;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 12px;
  background: var(--fill);
}
.segmented legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.segment {
  position: relative;
  flex: 1;
  min-width: 0;
}
.segment input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.segment > span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  transition:
    background-color 160ms linear,
    color 160ms linear,
    box-shadow 160ms linear;
}
.segment .icon {
  width: 18px;
  height: 18px;
}
.segment input:hover + span {
  color: var(--text);
}
.segment input:checked + span {
  background: var(--segment-on);
  color: var(--text);
  font-weight: 650;
  box-shadow:
    0 1px 2px rgb(0 0 0 / 0.08),
    0 2px 8px -2px rgb(0 0 0 / 0.12);
}
.segment input:focus-visible + span {
  outline: 2px solid var(--accent-ink);
  outline-offset: 1px;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.token {
  min-height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background-color 140ms linear;
}
.token:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

/* ---------- Welcome: settings beside a sticky preview ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  min-width: 0;
}
@media (min-width: 1180px) {
  .split {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }
  .split-side {
    position: sticky;
    top: 20px;
  }
}

.preview {
  display: flex;
  gap: 12px;
  padding: 18px 16px;
}
.preview-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--fill);
  object-fit: cover;
}
.preview-body {
  flex: 1;
  min-width: 0;
}
.preview-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
}
.preview-badge {
  padding: 1px 5px;
  border-radius: 4px;
  background: #5865f2;
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.preview-text {
  margin-top: 2px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-text:empty::before {
  content: "Nothing is posted.";
  color: var(--muted);
}
.preview-image {
  display: block;
  max-width: min(100%, 320px);
  margin-top: 10px;
  border-radius: var(--radius-sm);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--btn);
  color: var(--on-btn);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 140ms linear,
    transform 120ms var(--ease);
}
.btn .icon {
  width: 18px;
  height: 18px;
}
.btn:hover {
  background: color-mix(in srgb, var(--btn) 88%, var(--text));
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-quiet {
  background: var(--fill);
  color: var(--text);
}
.btn-quiet:hover {
  background: var(--fill-hover);
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}
.btn-block {
  width: 100%;
}
.btn-large {
  min-height: 52px;
  font-size: 1.0625rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

/* The save bar floats at the bottom of the screen while a long form scrolls. */
.form-bar {
  position: sticky;
  bottom: 16px;
  z-index: 4;
  justify-self: start;
  display: flex;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 0;
  padding: 8px;
  border-radius: 26px;
  background: var(--glass);
  box-shadow:
    0 0 0 1px var(--edge),
    var(--float);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
}
.form-bar .error {
  flex-basis: 100%;
  padding: 0 0 6px 10px;
}

.saved-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-size: 0.875rem;
  font-weight: 600;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition:
    opacity 160ms linear,
    max-width 260ms var(--ease),
    margin 260ms var(--ease);
}
.saved-note .icon {
  width: 16px;
  height: 16px;
}
.saved-note.show {
  max-width: 260px;
  margin: 0 12px 0 14px;
  opacity: 1;
}
.saved-note.dirty {
  color: var(--muted);
}
.saved-note.dirty .icon {
  display: none;
}
.saved-note.dirty::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--danger);
  font-size: 0.9375rem;
  font-weight: 550;
}
.error:empty {
  display: none;
}
.error::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  background: currentColor;
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.5v5.5M12 16.6v.01'/%3E%3C/g%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* ---------- Empty states ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 24px;
  text-align: center;
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--muted);
}
.empty-icon .icon {
  width: 26px;
  height: 26px;
}
.empty.tone-danger .empty-icon {
  background: var(--danger-soft);
  color: var(--danger);
}
.empty-title {
  font-weight: 650;
}
.empty-text {
  max-width: 42ch;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* ---------- Sign up and log in: a soft card over the illustrated sky ---------- */

.auth {
  --auth-art: url("/img/auth-light.svg");
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 32px 16px;
  background:
    var(--auth-art) center / cover no-repeat,
    #fde9dc;
}
@media (prefers-color-scheme: dark) {
  .auth {
    --auth-art: url("/img/auth-dark.svg");
    background-color: #1d1729;
  }
}
.auth > .group {
  width: min(100%, 420px);
}

.auth-card {
  display: grid;
  gap: 22px;
  width: min(100%, 420px);
  padding: 30px 26px 24px;
  border-radius: 30px;
  background: var(--glass);
  box-shadow:
    0 0 0 1px var(--edge),
    var(--float);
  backdrop-filter: saturate(1.4) blur(18px);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  animation: card-in 520ms var(--ease);
}
@keyframes card-in {
  from {
    transform: translateY(14px) scale(0.98);
  }
}

.auth-head {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}
.auth-mark {
  display: block;
  animation: bob 3.6s ease-in-out infinite;
}
.auth-mark .logo {
  filter: drop-shadow(0 10px 14px color-mix(in srgb, var(--accent) 35%, transparent));
  transition: transform 420ms var(--spring);
}
.auth-mark:hover .logo {
  transform: rotate(-8deg) scale(1.08);
}
@keyframes bob {
  50% {
    transform: translateY(-5px);
  }
}
.auth .title {
  font-size: 1.875rem;
}

/* Inside the card the rows lose their panel, so the card itself is the only surface. */
.auth-card .groups {
  gap: 16px;
}
.auth-card .panel {
  background: transparent;
  box-shadow: none;
  overflow: visible;
}
.auth-card .row {
  min-height: 0;
  padding: 6px 0;
}
.auth-card .row + .row::before {
  display: none;
}
.auth-card .steps {
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.auth-card .step-num {
  background: var(--panel);
}
.auth-actions {
  display: grid;
  gap: 12px;
}
.auth-switch {
  color: var(--muted);
  text-align: center;
}

.steps {
  display: grid;
  gap: 12px;
  padding: 16px;
  list-style: none;
}
.step {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.8125rem;
  font-weight: 700;
  transform: translateY(-1px);
}

/* ---------- Loading ---------- */

.skeleton {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: var(--fill);
  animation: pulse 1.2s ease-in-out infinite alternate;
}
.tile.skeleton {
  border-radius: 8px;
  background: var(--fill);
}
.avatar.skeleton {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.skeleton-line {
  width: 46%;
}
.skeleton-short {
  width: 28%;
  height: 11px;
  margin-top: 6px;
}
@keyframes pulse {
  to {
    opacity: 0.45;
  }
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--toast);
  color: var(--on-toast);
  font-size: 0.9375rem;
  font-weight: 550;
  box-shadow: var(--float);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition:
    opacity 200ms linear,
    transform 320ms var(--ease);
}
.toast .icon {
  width: 18px;
  height: 18px;
  color: var(--ok);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.bad {
  background: var(--danger);
  color: var(--on-danger);
}
.toast.bad .icon {
  display: none;
}

/* ---------- Hover motion: springy and small, only where a pointer can hover ---------- */

.row-link > .avatar,
.brand .logo,
.topnav a,
.token,
.btn .icon {
  transition:
    background-color 200ms linear,
    color 160ms linear,
    transform 360ms var(--spring);
}
.btn {
  transition:
    background-color 140ms linear,
    box-shadow 200ms linear,
    transform 260ms var(--spring);
}
.chevron {
  transition:
    color 160ms linear,
    transform 260ms var(--spring);
}

@media (hover: hover) {
  .row-link:hover > .avatar {
    transform: rotate(-6deg) scale(1.08);
  }
  .row-link:hover .chevron {
    color: var(--muted);
    transform: translateX(3px);
  }
  .btn:hover:not(:disabled) {
    box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--btn) 70%, transparent);
    transform: translateY(-2px);
  }
  .btn-quiet:hover:not(:disabled),
  .btn-danger:hover:not(:disabled) {
    box-shadow: none;
  }
  .btn:hover:not(:disabled) .icon {
    transform: scale(1.14);
  }
  .token:hover {
    transform: translateY(-2px);
  }
  .check:hover:not(:checked) {
    border-color: var(--accent);
  }
  .segment input:hover:not(:checked) + span {
    background: color-mix(in srgb, var(--segment-on) 55%, transparent);
  }
  .switch:hover input:not(:disabled) + .switch-track::after {
    box-shadow:
      var(--knob-shadow),
      0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent);
  }
  .topnav a:hover {
    transform: scale(1.08);
  }
  .brand:hover .logo {
    transform: rotate(-10deg) scale(1.1);
  }
}
.btn:active:not(:disabled) {
  box-shadow: none;
  transform: scale(0.97);
}

/* ---------- Desktop: the dock carries the brand, so the top bar goes ---------- */

@media (min-width: 861px) {
  body.signed-in .topbar {
    display: none;
  }
}

/* ---------- Phones and narrow windows: the dock becomes a bottom tab bar ---------- */

@media (max-width: 860px) {
  .shell {
    min-height: 0;
    padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }
  .stage {
    padding: 10px 0 48px;
  }
  .shell:has(.has-sections) .stage {
    padding-bottom: calc(112px + env(safe-area-inset-bottom));
  }

  .dock:not(.has-sections) {
    display: none;
  }
  .dock.has-sections {
    top: auto;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    width: auto;
    max-width: 520px;
    margin: 0 auto;
    padding: 6px;
    background: var(--glass);
    transform: none;
    backdrop-filter: saturate(1.6) blur(16px);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
  }
  .dock-brand,
  .dock-server,
  .dock-foot,
  .dock-label {
    display: none;
  }
  .dock-sections {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    padding: 0;
    border: 0;
  }
  .dock-sections .dock-link {
    gap: 2px;
    width: auto;
    height: 56px;
    padding: 6px 2px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
  }
  .dock-sections .dock-link:hover {
    background: transparent;
  }
  .dock-sections .dock-link[aria-current="page"] {
    background: var(--fill);
    color: var(--text);
  }
  .dock-short {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-bar {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  body.signed-in .toast {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .auth {
    background-position: 16% center;
  }
  .auth-card {
    padding: 26px 20px 22px;
  }
  .topbar {
    height: 56px;
    padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }
  .title {
    font-size: 2.25rem;
  }
  .subtitle {
    font-size: 1rem;
  }
  .page-head {
    margin-bottom: 24px;
  }
  .row {
    --inset: 56px;
    --lead: 42px;
    gap: 14px;
    min-height: 68px;
    padding: 12px 14px;
  }
  .row-link,
  .is-gone {
    --inset: 72px;
  }
  .row-label {
    font-size: 1rem;
  }
  .row-help {
    font-size: 0.875rem;
  }
  .panel > .error {
    padding: 0 14px 14px 56px;
  }
  .row-buttons {
    padding: 4px 14px 14px 56px;
  }
  .segment > span {
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.8125rem;
  }
}

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