/* ============================================================
   ANVIL — Runbook & how-to knowledge base
   Cloud-suite aesthetic: atmospheric dual theme + frosted glass
   ============================================================ */

/* ---------- Theme tokens ---------- */
:root {
  /* Night (default) — moonlit anvil over dark prairie */
  --bg-0: #0b1120;
  --bg-1: #131c30;
  --bg-2: #1e293b;
  --ink: #f8fafc;
  --ink-soft: #cbd5e1;
  --ink-faint: #94a3b8;

  --beacon: #f59e0b;
  --beacon-bright: #fbbf24;
  --beacon-ink: #1a1206;

  --accent-cool: #38bdf8;

  /* Panels kept translucent so the scenic sky shows through */
  --glass: rgba(15, 23, 42, 0.46);
  --glass-strong: rgba(15, 23, 42, 0.74);
  --glass-hi: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-strong: rgba(255, 255, 255, 0.2);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.8);

  --danger: #f87171;
  --amber-wash: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(251, 191, 36, 0.4);

  /* Scene colors */
  --sky-top: #070b16;
  --sky-mid: #111b31;
  --sky-horizon: #2a3952;
  --cloud-lit: #cbd5ec;
  --cloud-mid: #8b97b4;
  --cloud-shadow: #39435f;
  --butte: #2b2638;
  --butte-2: #191826;
  --grass: #19222f;
  --grass-fore: #0e141d;
  --scene-haze: rgba(60, 78, 110, 0.55);
  --star-opacity: 1;
  --sun-opacity: 0;
  --moon-opacity: 1;

  --radius: 16px;
  --radius-sm: 10px;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;

  --rail-w: 260px;
  --deck-w: 360px;
}

/* Twilight — golden dusk anvil, matches the prairie photo */
html.twilight {
  --bg-0: #1c2540;
  --bg-1: #2a3357;
  --bg-2: #3a4063;
  --ink: #f8fafc;
  --ink-soft: #dbe2f0;
  --ink-faint: #aeb8d0;

  --glass: rgba(26, 30, 54, 0.44);
  --glass-strong: rgba(26, 30, 54, 0.72);
  --glass-hi: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-border-strong: rgba(255, 255, 255, 0.26);
  --shadow: 0 18px 50px -22px rgba(20, 12, 40, 0.6);

  --sky-top: #243253;
  --sky-mid: #50567f;
  --sky-horizon: #edb07a;
  --cloud-lit: #ffd9a6;
  --cloud-mid: #e9b98e;
  --cloud-shadow: #7c6f96;
  --butte: #a4654b;
  --butte-2: #6f4038;
  --grass: #8a7c52;
  --grass-fore: #4f5236;
  --scene-haze: rgba(240, 170, 110, 0.32);
  --star-opacity: 0.22;
  --sun-opacity: 1;
  --moon-opacity: 0;
}

/* Day — bright azure sky, sunlit white anvil, green prairie */
html.day {
  --bg-0: #e0f2fe;
  --bg-1: #eff6ff;
  --bg-2: #f8fafc;
  --ink: #1e293b;
  --ink-soft: #334155;
  --ink-faint: #64748b;

  --beacon: #d97706;
  --beacon-bright: #f59e0b;
  --beacon-ink: #ffffff;

  --accent-cool: #0284c7;

  --glass: rgba(255, 255, 255, 0.5);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-hi: rgba(255, 255, 255, 0.52);
  --glass-border: rgba(255, 255, 255, 0.72);
  --glass-border-strong: rgba(148, 163, 184, 0.45);
  --shadow: 0 18px 50px -24px rgba(30, 58, 95, 0.35);

  --danger: #dc2626;
  --amber-wash: rgba(245, 158, 11, 0.16);
  --amber-border: rgba(217, 119, 6, 0.4);

  --sky-top: #3fa0dd;
  --sky-mid: #8ad0f2;
  --sky-horizon: #eaf7ff;
  --cloud-lit: #ffffff;
  --cloud-mid: #e6eef7;
  --cloud-shadow: #b7c5d9;
  --butte: #c67d58;
  --butte-2: #9c5c41;
  --grass: #8fae5f;
  --grass-fore: #5f7e3f;
  --scene-haze: rgba(255, 255, 255, 0.35);
  --star-opacity: 0;
  --sun-opacity: 1;
  --moon-opacity: 0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--bg-0);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Scenic backdrop: anvil cloud over prairie ---------- */
.scenic-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.scenic-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    var(--sky-top) 0%,
    var(--sky-mid) 46%,
    var(--sky-horizon) 72%,
    var(--sky-horizon) 100%);
  transition: background 0.6s ease;
}
.scenic-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.scenic-scene path,
.scenic-scene ellipse,
.scenic-scene circle,
.scenic-scene rect { transition: fill 0.6s ease; }

/* Twinkling stars (night, faint at twilight) */
.scenic-stars {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 62%;
  opacity: var(--star-opacity);
  transition: opacity 0.6s ease;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 28% 32%, #fff, transparent),
    radial-gradient(1.6px 1.6px at 44% 12%, #fff, transparent),
    radial-gradient(1px 1px at 58% 26%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 72% 16%, #fff, transparent),
    radial-gradient(1.2px 1.2px at 84% 30%, #fff, transparent),
    radial-gradient(1px 1px at 20% 44%, #fff, transparent),
    radial-gradient(1.3px 1.3px at 66% 40%, #fff, transparent),
    radial-gradient(1px 1px at 92% 22%, #fff, transparent),
    radial-gradient(1.1px 1.1px at 38% 48%, #fff, transparent);
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: calc(var(--star-opacity) * 0.55); } to { opacity: var(--star-opacity); } }

/* Sun / moon */
.celestial {
  position: absolute;
  top: 12%; right: 16%;
  width: 120px; height: 120px;
  display: grid;
  place-items: center;
  transition: opacity 0.6s ease;
}
.celestial--sun { opacity: var(--sun-opacity); }
.celestial--moon { opacity: var(--moon-opacity); }
.celestial__glow {
  position: absolute;
  width: 220px; height: 220px;
  border-radius: 50%;
  filter: blur(26px);
}
.celestial__disc {
  position: relative;
  width: 86px; height: 86px;
  border-radius: 50%;
}
.celestial--sun .celestial__glow { background: radial-gradient(circle, rgba(255,214,120,0.75), transparent 70%); }
.celestial--sun .celestial__disc { background: radial-gradient(circle at 38% 34%, #fff6d8, #ffcf6b 55%, #f6a93a); box-shadow: 0 0 50px rgba(255,190,90,0.6); }
.celestial--moon .celestial__glow { background: radial-gradient(circle, rgba(226,232,240,0.5), transparent 70%); }
.celestial--moon .celestial__disc { background: radial-gradient(circle at 36% 32%, #ffffff, #dbe4f0 55%, #aab6c9); box-shadow: 0 0 36px rgba(203,213,236,0.5); }

/* ---------- App shell (3-panel grid) ---------- */
.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--deck-w) 1fr;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 16px 16px;
  transition: grid-template-columns 0.35s ease;
}

/* ---------- Topbar + Breadcrumb ---------- */
.topbar {
  flex: none;
  padding: 14px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover {
  border-color: var(--glass-border-strong);
  transform: translateY(-1px) rotate(30deg);
}
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crumb__home {
  font-family: var(--font-ui);
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  padding: 4px 2px;
  background: linear-gradient(120deg, var(--ink), var(--beacon-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.crumb__sep { color: var(--ink-faint); font-size: 1rem; }
.crumb__drop { position: relative; }
.crumb__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.crumb__btn:hover { border-color: var(--glass-border-strong); }
.crumb__caret { font-size: 0.7rem; color: var(--ink-faint); }
.crumb__menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 220px;
  max-height: 340px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border-strong);
  background: var(--glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}
.crumb__menu li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.crumb__menu li:hover { background: var(--glass-hi); color: var(--ink); }
.crumb__menu li.is-active {
  background: linear-gradient(120deg, rgba(245,158,11,0.18), var(--glass-hi));
  color: var(--ink);
  font-weight: 600;
}
.crumb__emoji { font-size: 1rem; }

/* Shared glass surface */
.rail, .deck, .canvas {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ============ LEFT RAIL ============ */
.rail {
  padding: 18px 16px;
  gap: 18px;
}
.rail__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand__emblem {
  width: 46px; height: 36px;
  flex: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.brand__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  background: linear-gradient(120deg, var(--ink), var(--beacon-bright));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand__version {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--beacon-bright);
  -webkit-text-fill-color: var(--beacon-bright);
  vertical-align: middle;
  opacity: 0.85;
}
html.day .brand__version { color: var(--beacon); -webkit-text-fill-color: var(--beacon); }
.brand__tagline {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* Workspace navigation */
.rail__workspaces {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail__labelrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ws-add {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--beacon-bright);
  cursor: pointer;
  transition: all 0.15s ease;
}
html.day .ws-add { color: var(--beacon); }
.ws-add:hover { border-color: var(--amber-border); }
.ws-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.ws-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.86rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.ws-card:hover { border-color: var(--glass-border-strong); color: var(--ink); }
.ws-card.is-active {
  border-color: var(--beacon);
  background: linear-gradient(120deg, rgba(245,158,11,0.16), var(--glass-hi));
  color: var(--ink);
  font-weight: 600;
}
.ws-card__icon { font-size: 1.1rem; flex: none; }
.ws-card__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-card__count {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.22);
  color: inherit;
}
html.day .ws-card__count { background: rgba(148,163,184,0.25); }

/* Workspace row with hover-revealed edit/delete */
.ws-row { position: relative; display: flex; align-items: center; }
.ws-row .ws-card { padding-right: 56px; }
.ws-row__act {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}
.ws-row:hover .ws-row__act,
.ws-row:focus-within .ws-row__act { opacity: 0.85; }
.ws-row__act:hover { background: var(--glass-hi); opacity: 1; }
.ws-row__act:nth-of-type(2) { right: 30px; }
.ws-row__act:last-child { right: 6px; }
.ws-row__act--danger:hover { background: rgba(248,113,113,0.18); }

/* Scope toggle */
.scope-toggle {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink-soft);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  transition: all 0.15s ease;
}
.scope-toggle:hover { border-color: var(--glass-border-strong); color: var(--ink); }
.scope-toggle.is-global {
  border-color: var(--amber-border);
  color: var(--beacon-bright);
  background: var(--amber-wash);
}
html.day .scope-toggle.is-global { color: var(--beacon); }

.rail__filters {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rail__label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  font-weight: 600;
}
.tag-filters {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tag-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-hi);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.tag-pill:hover {
  border-color: var(--glass-border-strong);
  color: var(--ink);
}
.tag-pill.is-active {
  background: linear-gradient(120deg, var(--beacon), var(--beacon-bright));
  border-color: transparent;
  color: var(--beacon-ink);
  font-weight: 600;
}
.tag-pill__count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0,0,0,0.22);
  color: inherit;
}
.tag-pill.is-active .tag-pill__count {
  background: rgba(0,0,0,0.18);
}
.tag-pill--sub {
  font-weight: 600;
}
.tag-pill--sub .tag-pill__glyph { color: var(--beacon-bright); margin-right: 2px; }
html.day .tag-pill--sub .tag-pill__glyph { color: var(--beacon); }
.tag-pill--sub.is-active .tag-pill__glyph { color: var(--beacon-ink); }

/* Utility strip */
.rail__utility {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
}
.backup-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  color: var(--ink-faint);
}
.backup-status__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--beacon-bright);
  box-shadow: 0 0 10px var(--beacon-bright);
}
.rail__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:hover {
  border-color: var(--glass-border-strong);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn--ghost { background: var(--glass-hi); }
.btn--beacon {
  background: linear-gradient(120deg, var(--beacon), var(--beacon-bright));
  border-color: transparent;
  color: var(--beacon-ink);
  box-shadow: 0 8px 20px -8px var(--beacon);
}
.btn--beacon:hover { filter: brightness(1.06); }
.btn--kiosk {
  border-color: var(--amber-border);
  color: var(--beacon-bright);
}
.btn--danger {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}
.btn--danger:hover { background: rgba(248, 113, 113, 0.12); }
.btn--tiny {
  font-size: 0.72rem;
  padding: 5px 10px;
}
.btn kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  opacity: 0.8;
}

.theme-toggle {
  display: none;
}

/* ---------- Modals (settings / about) ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 9, 18, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal__card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--glass-strong);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--glass-border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border);
}
.modal__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.modal__close {
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  line-height: 1;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--glass-hi);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.modal__close:hover { border-color: var(--glass-border-strong); }

.settings-content { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-divider { height: 1px; background: var(--glass-border); }
.settings-row__label { font-weight: 700; font-size: 0.9rem; }
.settings-row__desc { font-size: 0.78rem; color: var(--ink-faint); line-height: 1.4; }
.settings-privacy {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-faint);
  line-height: 1.4;
}
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.settings-actions .btn { flex: 1 1 auto; }
.settings-actions--compact .btn { flex: 1 1 140px; }

/* Encrypted cloud sync */
.cloud-data-field { display: flex; flex-direction: column; gap: 5px; margin-top: 4px; }
.cloud-data-field__label { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); }
.cloud-phrase-entry { display: flex; gap: 6px; }
.cloud-data-field__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}
.cloud-data-field__input:focus { outline: none; border-color: var(--beacon); }
.cloud-phrase-entry__toggle {
  flex: none;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink-soft);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.cloud-phrase-entry__toggle:hover { border-color: var(--glass-border-strong); color: var(--ink); }
.cloud-phrase-output {
  margin: 0;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--amber-border);
  background: var(--amber-wash);
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--ink-soft);
}
.cloud-remember-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.cloud-data-status {
  margin: 2px 0 0;
  min-height: 1em;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--ink-faint);
}
.cloud-data-status--info { color: var(--accent-cool); }
.cloud-data-status--success { color: var(--beacon-bright); }
html.day .cloud-data-status--success { color: var(--beacon); }
.cloud-data-status--error { color: var(--danger); }

.theme-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.theme-chip {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theme-chip:hover { border-color: var(--glass-border-strong); transform: translateY(-1px); }
.theme-chip.is-active {
  border-color: var(--beacon);
  background: var(--amber-wash);
  color: var(--beacon-bright);
  box-shadow: 0 0 0 1px var(--beacon) inset;
}
html.day .theme-chip.is-active { color: var(--beacon); }

.about-content { padding: 18px; text-align: center; }
.about-content__name {
  margin: 4px 0 2px;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.about-content__version {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--beacon-bright);
}
html.day .about-content__version { color: var(--beacon); }
.about-content__description {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ============ MIDDLE DECK ============ */
.deck { padding: 16px; gap: 14px; }
.deck__top {
  display: flex;
  gap: 10px;
  align-items: center;
}
.search {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}
.search__icon {
  position: absolute;
  left: 12px;
  font-size: 0.85rem;
  opacity: 0.6;
  pointer-events: none;
}
.search__input {
  width: 100%;
  padding: 10px 40px 10px 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.88rem;
}
.search__input:focus {
  outline: none;
  border-color: var(--beacon);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
.search__kbd {
  position: absolute;
  right: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
  color: var(--ink-faint);
}
.search__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.search__clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  background: var(--glass-hi);
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.search__clear:hover { color: var(--ink); border-color: var(--beacon); }
.deck-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
}
.deck-empty__text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--ink-faint);
  overflow-wrap: anywhere;
}
.deck__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.deck__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

/* Runbook card */
.card {
  text-align: left;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover {
  border-color: var(--glass-border-strong);
  transform: translateY(-2px);
}
.card.is-active {
  border-color: var(--beacon);
  background: linear-gradient(120deg, rgba(245, 158, 11, 0.14), var(--glass-hi));
}
.card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
}
.verified-badge {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent-cool);
  border: 1px solid rgba(56, 189, 248, 0.3);
  white-space: nowrap;
}
.card__preview {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tag-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink-soft);
}

/* ============ RIGHT CANVAS ============ */
.canvas { position: relative; }
.reader, .editor {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 30px 40px;
}

/* Reader */
.reader__head { margin-bottom: 22px; }
.reader__titlebar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.reader__title {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.2;
}
.reader__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.reader__submeta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
.reader__timestamp {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--ink-faint);
}
.reader__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Callouts */
.callout {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 22px;
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.callout__title {
  margin: 0 0 10px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout--tools {
  border-color: rgba(56, 189, 248, 0.28);
  background: linear-gradient(120deg, rgba(56, 189, 248, 0.08), var(--glass-hi));
}
.callout--gotchas {
  border-color: var(--amber-border);
  background: linear-gradient(120deg, var(--amber-wash), var(--glass-hi));
}
.callout--gotchas .callout__title { color: var(--beacon-bright); }
html.day .callout--gotchas .callout__title { color: var(--beacon); }

.tools-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tools-list li {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--ink);
}
.gotchas-list {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gotchas-list li {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* Steps */
.steps { margin-bottom: 22px; }
.steps__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.steps__title {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink-soft);
}
.steps__list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  transition: all 0.15s ease;
}
.step.is-done { opacity: 0.55; }
.step.is-done .step__text { text-decoration: line-through; }
.step__check {
  flex: none;
  appearance: none;
  -webkit-appearance: none;
  width: 24px; height: 24px;
  margin-top: 2px;
  border-radius: 7px;
  border: 2px solid var(--glass-border-strong);
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.step__check:checked {
  background: linear-gradient(120deg, var(--beacon), var(--beacon-bright));
  border-color: transparent;
}
.step__check:checked::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 6px; height: 11px;
  border: solid var(--beacon-ink);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
.step__body {
  flex: 1 1 auto;
  min-width: 0;
}
.step__num {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--beacon-bright);
  margin-right: 8px;
}
html.day .step__num { color: var(--beacon); }
.step__text {
  font-size: 1rem;
  line-height: 1.55;
}
.step__thumb {
  margin-top: 10px;
  max-width: 180px;
  max-height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  cursor: zoom-in;
  display: block;
  object-fit: cover;
}

.kiosk-exit {
  position: sticky;
  bottom: 0;
  margin-top: 10px;
}

/* ============ EDITOR ============ */
.editor { gap: 0; }
.editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.editor__title { margin: 0; font-size: 1.4rem; font-weight: 800; }
.editor__actions { display: flex; gap: 8px; }
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field__label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field__label small {
  text-transform: none;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0;
}
.field__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-hi);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  resize: vertical;
}
.field__input:focus {
  outline: none;
  border-color: var(--beacon);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
.field__input.mono { font-family: var(--font-mono); font-size: 0.85rem; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 14px;
}
.field-row--even { grid-template-columns: 1fr 1fr; }
.field--narrow { margin-bottom: 16px; }
.editor__footer {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

/* ============ EMPTY STATE ============ */
.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--ink-faint);
  gap: 10px;
}
.empty__emblem { width: 110px; color: var(--beacon-bright); }
.empty__title { margin: 6px 0 0; font-size: 1.3rem; font-weight: 700; color: var(--ink-soft); }
.empty__text { margin: 0; max-width: 340px; font-size: 0.92rem; line-height: 1.5; }

/* ============ KIOSK / WORKBENCH MODE ============ */
.shell.is-kiosk .topbar { display: none; }
.app.is-kiosk {
  grid-template-columns: 0 0 1fr;
}
.app.is-kiosk .rail,
.app.is-kiosk .deck {
  opacity: 0;
  pointer-events: none;
}
.app.is-kiosk .reader {
  font-size: 1.2em;
}
.app.is-kiosk .reader__title { font-size: 2rem; }
.app.is-kiosk .step__text { font-size: 1.2em; }
.app.is-kiosk .reader,
.app.is-kiosk .editor {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ============ LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(8, 12, 22, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox__img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}
.lightbox__close {
  position: absolute;
  top: 20px; right: 28px;
  font-size: 2.4rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border-strong);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Scrollbars ---------- */
.rail__filters::-webkit-scrollbar,
.deck__list::-webkit-scrollbar,
.reader::-webkit-scrollbar,
.editor::-webkit-scrollbar { width: 8px; }
.rail__filters::-webkit-scrollbar-thumb,
.deck__list::-webkit-scrollbar-thumb,
.reader::-webkit-scrollbar-thumb,
.editor::-webkit-scrollbar-thumb {
  background: var(--glass-border-strong);
  border-radius: 999px;
}

/* ============ RESPONSIVE ============ */

/* Tablet: collapse rail to a slim auto width */
@media (max-width: 1100px) {
  :root { --deck-w: 320px; }
  .app { grid-template-columns: 220px 300px 1fr; }
}

/* Mobile: glass stack. Panels become scrollable sections. */
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-auto-rows: min-content;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  .rail, .deck {
    height: auto;
  }
  .rail__filters { max-height: 160px; }
  .deck__list { max-height: 50vh; }
  .canvas { min-height: 70vh; }
  .reader, .editor { padding: 20px; }

  /* On mobile, viewing a runbook hides the rail + deck for focus */
  .app.is-viewing .rail,
  .app.is-viewing .deck { display: none; }
  .app.is-kiosk { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
