/* ==========================================================================
   Osiris — order desk
   Dark slate, light header band, rounded cards. Mobile first; the desktop
   layout is the same components on a wider grid.
   ========================================================================== */

:root {
  --bg:        #232b36;
  --bg-deep:   #1b222b;
  --surface:   #333d4a;
  --surface-2: #3d4854;
  --raised:    #4a5768;
  --line:      #46515f;

  --header:    #b8c4d0;
  --header-ink:#1f272f;

  --ink:       #eef2f6;
  --ink-2:     #b9c4d0;
  --ink-3:     #8996a5;
  --ink-4:     #6b7686;

  --accent:    #8fa3bd;
  --ok:        #4ea87a;
  --ok-bg:     #22402f;
  --warn:      #d9a441;
  --warn-bg:   #4a3a1c;
  --danger:    #c0575f;
  --danger-bg: #6e2f33;
  --info:      #6f8fc4;

  --chip-progress-bg: #f5e6b8;
  --chip-progress-ink:#5c4a12;
  --chip-idle-bg:     #f2d4da;
  --chip-idle-ink:    #7a2f3a;
  --chip-done-bg:     #cfe9d8;
  --chip-done-ink:    #1e5136;

  --r-lg: 20px;
  --r:    14px;
  --r-sm: 10px;

  --ui: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --shell-max: 1180px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* Marking messages means a lot of tapping; accidental double-tap zoom on
     mobile made that miserable. */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 6px; border: 2px solid var(--bg); }

/* ---------------------------------------------------------------- header */

.masthead {
  background: var(--header);
  color: var(--header-ink);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: 20px 20px 18px;
}
.masthead-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wordmark {
  font-size: 30px;
  font-weight: 400;
  letter-spacing: 0.34em;
  margin: 0;
  color: var(--header-ink);
  text-transform: uppercase;
  line-height: 1;
}

.status-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill .pip {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(78, 168, 122, 0.6);
  animation: pulse 2.4s var(--ease) infinite;
}
.status-pill.is-down .pip { background: var(--danger); animation: none; }
.status-pill.is-busy .pip { background: var(--warn); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(78, 168, 122, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(78, 168, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(78, 168, 122, 0); }
}

/* ---------------------------------------------------------------- gate */

.gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg-deep);
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border-radius: var(--r-lg);
  padding: 32px 28px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.gate-mark {
  color: var(--ink);
  font-size: 26px;
  text-align: center;
  margin: 0 0 6px;
}
.gate-sub {
  text-align: center;
  color: var(--ink-4);
  font-size: 13.5px;
  margin: 0 0 22px;
}
.gate-form { margin-top: 6px; }
.gate-form .btn { margin-top: 6px; }
.gate-foot {
  text-align: center;
  color: var(--ink-4);
  font-size: 12px;
  margin: 18px 0 0;
}

.page-switch {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 6px 30px 6px 14px;
  background: rgba(255, 255, 255, 0.55) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%231f272f' stroke-width='3' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>") no-repeat right 11px center;
  color: var(--header-ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.whoami-btn {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--header-ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.whoami-btn:hover { background: rgba(255, 255, 255, 0.68); }

/* ---------------------------------------------------------------- tabs */

.tabs {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  padding: 0 14px;
}
.tab {
  flex: 1;
  appearance: none;
  background: none;
  border: 0;
  padding: 15px 8px 13px;
  color: var(--ink-4);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: color 0.18s var(--ease);
  white-space: nowrap;
}
.tab:hover { color: var(--ink-2); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab::after {
  content: "";
  position: absolute;
  left: 50%; right: 50%; bottom: 0;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: left 0.22s var(--ease), right 0.22s var(--ease);
}
.tab[aria-selected="true"]::after { left: 12%; right: 12%; }

.tab-count {
  display: inline-block;
  margin-left: 3px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- shell */

.shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 20px 16px 130px;
}

.panel { display: none; }
.panel[data-active] { display: block; animation: rise 0.26s var(--ease); }

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

.section-title {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 4px 0 16px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .grow { flex: 1; min-width: 160px; }

/* ---------------------------------------------------------------- fields */

.input {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--ink);
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.input::placeholder { color: var(--ink-4); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
textarea.input { resize: vertical; min-height: 74px; line-height: 1.55; }

.field { display: block; margin-bottom: 14px; }
.field > .label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.field .hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink-4);
}

.switch {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.16s var(--ease);
}
.switch:hover { background: var(--surface-2); }
.switch input { margin: 3px 0 0; width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.switch .switch-note { display: block; font-size: 12px; color: var(--ink-4); margin-top: 2px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.16s var(--ease), opacity 0.16s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #1a212a; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #a3b5cc; }
.btn-danger { background: var(--danger-bg); color: #f0b8bd; }
.btn-danger:hover:not(:disabled) { background: #813a3f; }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); }
.btn-sm { padding: 8px 13px; font-size: 13px; }
.btn-block { width: 100%; }

.btn.is-busy { pointer-events: none; opacity: 0.75; }
.btn.is-busy::before {
  content: "";
  width: 13px; height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

.card {
  background: var(--surface);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 13px;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.card.is-open { background: var(--surface-2); }
.card.is-entering { animation: rise 0.3s var(--ease); }
.card.is-leaving { opacity: 0; transform: translateX(-10px); transition: all 0.24s var(--ease); }

.card-head {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  user-select: none;
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-sub { font-size: 12px; color: var(--ink-4); margin-top: 3px; }

.caret {
  flex: none;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  transition: transform 0.24s var(--ease);
}
.card.is-open .caret { transform: rotate(180deg); }

.card-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s var(--ease);
}
.card.is-open .card-body { grid-template-rows: 1fr; }
.card-body > .card-body-inner { overflow: hidden; min-height: 0; }
.card.is-open .card-body > .card-body-inner { padding-top: 14px; }

.card-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.card-actions .btn { flex: 1; min-width: 96px; }

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex: none;
}
.chip-progress { background: var(--chip-progress-bg); color: var(--chip-progress-ink); }
.chip-idle     { background: var(--chip-idle-bg);     color: var(--chip-idle-ink); }
.chip-done     { background: var(--chip-done-bg);     color: var(--chip-done-ink); }
.chip-revision { background: #f6dcc0; color: #7a4614; }
.chip-failed   { background: #f2c9cd; color: #7a2129; }
.chip-muted    { background: var(--raised); color: var(--ink-2); }

/* ---------------------------------------------------------------- tags */

.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  background: var(--bg-deep);
  color: var(--ink-4);
  white-space: nowrap;
}
.tag-ok      { color: #8fc4a6; }
.tag-error   { color: #f0a6ac; background: var(--danger-bg); cursor: pointer; }
.tag-error:hover { background: #813a3f; color: #fff; }
.tag-warn[data-act] { cursor: pointer; }
.tag-warn[data-act]:hover { background: var(--warn-bg); color: #f5dcae; }
.tag-idle    { color: var(--ink-4); }
.tag-warn    { color: #e0b473; }
.tag-working { color: var(--accent); }

.tag-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.1s var(--ease) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------------------------------------------------------------- progress */

.progress {
  background: var(--bg-deep);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.progress-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 13px;
  color: var(--ink-2);
}
.progress-stage { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-pct { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 12px; }

.progress-track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #b7c8dc);
  transition: width 0.5s var(--ease);
}
.progress-fill.is-indeterminate {
  width: 38% !important;
  animation: slide 1.5s var(--ease) infinite;
}
@keyframes slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.progress-fill.is-failed { background: var(--danger); }
.progress-fill.is-done   { background: var(--ok); }

.progress-steps {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}
.progress-steps .dot {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-2);
  transition: background 0.35s var(--ease);
}
.progress-steps .dot.is-done { background: var(--ok); }
.progress-steps .dot.is-active { background: var(--accent); }

/* ---------------------------------------------------------------- chat */

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 9px;
}
.chat-freshness {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  color: var(--ink-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  flex: none;
  transition: background 0.16s var(--ease), transform 0.12s var(--ease);
}
.chat-refresh:hover { background: var(--surface-2); color: var(--ink); }
.chat-refresh:active { transform: scale(0.96); }
.chat-refresh.is-spinning { pointer-events: none; opacity: 0.7; }
.chat-refresh.is-spinning svg { animation: spin 0.9s linear infinite; }

.chat {
  background: var(--bg-deep);
  border-radius: var(--r);
  padding: 14px 12px;
  max-height: 52vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.chat-day {
  display: block;
  width: fit-content;
  margin: 12px auto 10px;
  padding: 3px 13px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-4);
  font-size: 11px;
  font-weight: 600;
}

.msg {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin-bottom: 7px;
  position: relative;
}
.msg.out { flex-direction: row-reverse; }

.msg-check {
  flex: none;
  width: 21px; height: 21px;
  border-radius: 6px;
  border: 2px solid var(--ink-4);
  background: transparent;
  cursor: pointer;
  align-self: center;
  display: grid;
  place-items: center;
  padding: 0;
  transition: all 0.16s var(--ease);
  opacity: 0.5;
}
.msg:hover .msg-check { opacity: 1; }
.msg-check svg { width: 12px; height: 12px; opacity: 0; transform: scale(0.5); transition: all 0.16s var(--ease); }
.msg-check[aria-pressed="true"] {
  opacity: 1;
  background: var(--marker, var(--accent));
  border-color: var(--marker, var(--accent));
}
.msg-check[aria-pressed="true"] svg { opacity: 1; transform: none; color: #141a21; }
.msg.out .msg-check { visibility: hidden; }

.bubble {
  max-width: min(560px, 76%);
  padding: 10px 14px;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14.5px;
  line-height: 1.5;
  cursor: pointer;
  transition: box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
.msg.in  .bubble { border-bottom-left-radius: 5px; }
.msg.out .bubble { border-bottom-right-radius: 5px; background: var(--raised); cursor: default; }
.msg.in .bubble:hover { background: var(--surface-2); }

.msg.is-marked .bubble {
  box-shadow: inset 3px 0 0 0 var(--marker, var(--accent)),
              0 0 0 1px var(--marker, var(--accent));
}
.msg.is-marked::after {
  content: attr(data-marker);
  position: absolute;
  top: -6px; left: 32px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--marker, var(--accent));
  color: #141a21;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.bubble-meta { font-size: 11px; color: var(--ink-4); margin-top: 4px; }
.bubble-media { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bubble-media img {
  width: 92px; height: 92px;
  object-fit: cover;
  border-radius: 9px;
  background: var(--surface-2);
  cursor: zoom-in;
  transition: transform 0.18s var(--ease);
}
.bubble-media img:hover { transform: scale(1.04); }
.media-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  font-size: 11px;
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- markers */

.marker-bar {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  padding: 11px 0 13px;
}
.marker-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.marker-pill .swatch {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--marker);
  flex: none;
}
.marker-pill[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--marker);
  color: var(--ink);
}
.marker-pill .n {
  font-size: 11px;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.marker-pill.add { color: var(--ink-3); font-weight: 500; }

.marker-x {
  display: inline-grid;
  place-items: center;
  width: 17px; height: 17px;
  margin: -2px -5px -2px 1px;
  border-radius: 50%;
  color: var(--ink-4);
  cursor: pointer;
  transition: background 0.14s var(--ease), color 0.14s var(--ease);
}
.marker-x:hover { background: var(--danger-bg); color: #f0b8bd; }

/* ---------------------------------------------------------------- lyrics */

.lyrics-tools {
  display: flex;
  gap: 7px;
  margin: 10px 0 7px;
  flex-wrap: wrap;
}
.lyrics-tools .input { flex: 1; min-width: 110px; padding: 8px 11px; font-size: 13px; }
.lyrics-tools .btn { flex: none; }

.lyrics-box {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  min-height: 180px;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

#rev-lyrics-wrap.is-muted { opacity: 0.45; pointer-events: none; }

/* ---------------------------------------------------------------- modal */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 14, 19, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex;
  flex-direction: column;
  transform: translateY(28px);
  transition: transform 0.3s var(--ease);
  box-shadow: 0 -14px 44px rgba(0, 0, 0, 0.42);
}
.scrim.is-open .modal { transform: none; }

.modal-grip {
  width: 38px; height: 4px;
  border-radius: 3px;
  background: var(--raised);
  margin: 10px auto 2px;
  flex: none;
}
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 10px;
  flex: none;
}
.modal-title { font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -0.01em; }
.modal-close {
  border: 0;
  background: var(--surface);
  width: 32px; height: 32px;
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.16s var(--ease);
}
.modal-close:hover { background: var(--surface-2); }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  flex: none;
}
.modal-foot .btn { flex: 1; }

/* ---------------------------------------------------------------- admin */

.admin-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.admin-tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 8px 14px 10px;
  color: var(--ink-4);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.16s var(--ease), border-color 0.16s var(--ease);
}
.admin-tab:hover { color: var(--ink-2); }
.admin-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.admin-card {
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 14px 15px;
  margin-bottom: 10px;
}
.admin-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.admin-card-head strong { flex: 1; font-size: 14.5px; }

.admin-problems {
  margin: 0 0 10px;
  padding-left: 18px;
  color: #e0b473;
  font-size: 12.5px;
  line-height: 1.6;
}
.admin-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}
.col-grid .field { margin-bottom: 0; }
.col-grid .input { text-align: center; text-transform: uppercase; }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column-reverse;
  gap: 9px;
  width: min(430px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  animation: toast-in 0.3s var(--ease);
}
.toast.is-out { animation: toast-out 0.26s var(--ease) forwards; }
.toast-ok    { background: var(--ok-bg);     box-shadow: inset 3px 0 0 var(--ok),     0 10px 30px rgba(0,0,0,.4); }
.toast-error { background: var(--danger-bg); box-shadow: inset 3px 0 0 var(--danger), 0 10px 30px rgba(0,0,0,.4); }
.toast-warn  { background: var(--warn-bg);   box-shadow: inset 3px 0 0 var(--warn),   0 10px 30px rgba(0,0,0,.4); }
.toast .toast-x {
  margin-left: auto;
  background: none;
  border: 0;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 0 2px;
}
.toast .toast-x:hover { opacity: 1; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------------------------------------------------------------- fab */

.fab-row {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}
.fab-row > * { pointer-events: auto; }

.fab {
  width: 54px; height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.36);
  transition: transform 0.16s var(--ease), background 0.16s var(--ease);
}
.fab:hover { background: var(--raised); }
.fab:active { transform: scale(0.93); }
.fab.is-spinning svg { animation: spin 0.9s linear infinite; }

.fab-primary {
  margin-left: auto;
  width: auto;
  height: 54px;
  padding: 0 8px 0 22px;
  border-radius: 999px;
  gap: 12px;
  display: flex;
  align-items: center;
  background: var(--header);
  color: var(--header-ink);
  font-size: 15px;
  font-weight: 500;
}
.fab-primary .plus {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  flex: none;
}
.fab-primary:hover { background: #c6d1dc; }

/* ---------------------------------------------------------------- misc */

.empty {
  text-align: center;
  padding: 54px 22px;
  color: var(--ink-4);
  /* Inside the board grid this would otherwise be squeezed into one column. */
  grid-column: 1 / -1;
}
.empty h3 { color: var(--ink-2); font-size: 16px; font-weight: 500; margin: 0 0 7px; }
.empty p { margin: 0 auto 18px; max-width: 320px; font-size: 14px; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--surface);
  border-radius: var(--r-sm);
  margin-bottom: 9px;
  cursor: pointer;
  transition: background 0.16s var(--ease), transform 0.12s var(--ease);
}
.list-row:hover { background: var(--surface-2); }
.list-row:active { transform: scale(0.995); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .row-title { font-weight: 600; font-size: 14.5px; }
.list-row .row-sub {
  font-size: 12px;
  color: var(--ink-4);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-row.is-selected { box-shadow: inset 0 0 0 1px var(--accent); background: var(--surface-2); }

/* Locked while a link or an add is in flight, so a second click cannot land. */
.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.4);
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-deep);
  padding: 13px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  max-height: 300px;
  overflow-y: auto;
}
.muted { color: var(--ink-4); }
.small { font-size: 12px; }
.stack > * + * { margin-top: 10px; }

.note {
  padding: 10px 13px;
  border-radius: var(--r-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--ink-2);
}
.note-warn { background: var(--warn-bg); color: #f0d5a1; }
.note-error { background: var(--danger-bg); color: #f2bdc1; }
.note-info { background: #2a3950; color: #b8cbe8; }

.feed { max-height: 260px; overflow-y: auto; }
.feed-line {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  animation: rise 0.24s var(--ease);
}
.feed-line:last-child { border-bottom: 0; }
.feed-line time { flex: none; width: 58px; color: var(--ink-4); font-size: 11px; padding-top: 1px; }
.feed-line.is-warn span  { color: #e8c179; }
.feed-line.is-error span { color: #eda3a9; }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-card { height: 62px; margin-bottom: 13px; }
.board-grid > .skeleton-card { margin-bottom: 0; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(8, 11, 15, 0.9);
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease);
  cursor: zoom-out;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--r); }

/* ---------------------------------------------------------------- desktop */

@media (min-width: 860px) {
  :root { --shell-max: 1120px; }

  .shell { padding: 28px 32px 132px; }
  .masthead { padding: 28px 32px 24px; border-radius: 0 0 26px 26px; }
  .wordmark { font-size: 34px; }

  .tabs-inner { padding: 0 32px; }
  .tab { flex: 0 0 auto; padding: 16px 30px 14px; font-size: 14.5px; }
  .tab::after { left: 22px; right: 22px; transform: scaleX(0); transform-origin: center;
                transition: transform 0.22s var(--ease); }
  .tab[aria-selected="true"]::after { transform: scaleX(1); }

  .section-title { font-size: 23px; margin: 6px 0 18px; }

  /* The name box has no business spanning a 1100px screen. */
  .toolbar .grow { flex: 0 1 380px; min-width: 260px; }

  .board-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    align-items: start;
  }
  .board-grid .card { margin-bottom: 0; }
  /* An expanded card needs the full width for the progress bar and buttons. */
  .card.is-open { grid-column: 1 / -1; }

  .card { padding: 18px 20px; }
  .card-actions .btn { flex: 0 1 auto; min-width: 128px; }

  /* Centre the dialog rather than docking it to the bottom edge. */
  .scrim { align-items: center; padding: 24px; }
  .modal { border-radius: var(--r-lg); max-height: 84vh; max-width: 620px; transform: scale(0.97); }
  .scrim.is-open .modal { transform: none; }
  .modal-grip { display: none; }
  .modal-head { padding: 20px 26px 12px; }
  .modal-body { padding: 4px 26px 22px; }
  .modal-foot { padding: 16px 26px; }
  .modal-foot .btn { flex: 0 1 auto; min-width: 120px; }
  .modal-foot .btn:last-child { margin-left: auto; }

  .chat { max-height: 44vh; padding: 16px 18px; }
  .bubble { max-width: 74%; }

  .toasts { left: auto; right: 28px; transform: none; bottom: 28px; width: 400px; }

  .fab-row { padding: 0 32px; bottom: 26px; }

  .empty { padding: 64px 22px; }
  .list-row { padding: 14px 18px; }
}

@media (min-width: 1240px) {
  /* Wide screens were leaving a lot of dead margin. */
  :root { --shell-max: 1260px; }
  .board-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1600px) {
  :root { --shell-max: 1400px; }
  .board-grid { grid-template-columns: repeat(4, 1fr); }
}

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