:root {
  /* Pre-dawn defaults; overridden live by JS */
  --sky-bg: #06070c;
  --sky-bg-2: #0b0a18;
  --sky-fg: #f4eee4;
  --sky-fg-dim: #9a9385;
  --sky-muted: #5a5344;
  --sky-accent: #ffb84a;
  --sky-indigo: #2a1b5e;
  --sky-line: rgba(244, 238, 228, 0.08);
  --sun: #ffcf5a;
  --stone: #060608;

  --grain-opacity: 0.22;
  --breath: 24s;

  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --sans: 'Source Sans 3', system-ui, sans-serif;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;

  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; }

html, body {
  height: 100%;
  background: var(--sky-bg);
  color: var(--sky-fg);
  font-family: var(--sans);
  overflow: hidden;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: background 4s var(--ease), color 4s var(--ease);
}

/* ----- Atmospheric layers ----- */
.sky {
  position: fixed; inset: 0;
  background: var(--sky-bg);
  transition: background 4s var(--ease);
  z-index: 0;
}
@keyframes breathe {
  0%, 100% { filter: brightness(1) saturate(1); }
  50%      { filter: brightness(1.08) saturate(1.08); }
}

.grain {
  position: fixed; inset: -10%;
  pointer-events: none;
  z-index: 3;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.85'/></svg>");
  animation: grain-drift 14s steps(8) infinite;
}
@keyframes grain-drift {
  0%   { transform: translate(0,0) }
  25%  { transform: translate(-3%,2%) }
  50%  { transform: translate(2%,-2%) }
  75%  { transform: translate(-1%,-3%) }
  100% { transform: translate(0,0) }
}

.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(ellipse 90% 90% at 50% 50%, transparent 40%, rgba(0,0,0,0.55) 100%);
}

/* Horizon line */
.horizon {
  position: fixed; left: 0; right: 0; top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--sky-line) 20%, var(--sky-line) 80%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

/* ----- Layout ----- */
.frame {
  position: relative;
  z-index: 4;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-columns: 1fr;
  padding: 28px 40px;
  gap: 16px;
}

/* Explicit row pinning — immune to hidden siblings shifting auto-placement */
.frame > .chrome         { grid-row: 1; }
.frame > .offline-banner { grid-row: 2; }
.frame > .locations-bar  { grid-row: 3; }
.frame > .main           { grid-row: 4; }
.frame > .footer         { grid-row: 5; }

/* Location pills bar — hidden when empty, shown for multi-location rule sets */
.locations-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 0;
}
.locations-bar:empty { display: none; }
.loc-pill {
  background: transparent;
  border: 1px solid var(--sky-line);
  border-radius: 20px;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  white-space: nowrap;
}
.loc-pill:hover {
  border-color: var(--sky-fg-dim);
  color: var(--sky-fg);
}
.loc-pill.active {
  border-color: var(--sky-accent);
  color: var(--sky-accent);
  background: color-mix(in oklab, var(--sky-accent) 8%, transparent);
}

/* Top chrome */
.chrome {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 14px;
}
.brand-mark {
  width: 3px; height: 44px;
  background: var(--sky-fg);
  opacity: 0.9;
  position: relative;
}
.brand-mark::before {
  content: ''; position: absolute; left: 50%; top: -8px; transform: translateX(-50%);
  width: 18px; height: 1px; background: var(--sky-fg); opacity: 0.55;
}
.brand-mark::after {
  content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  width: 18px; height: 1px; background: var(--sky-fg); opacity: 0.55;
}
.wordmark {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--sky-fg);
}
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sky-muted);
}

.chrome-center {
  display: flex; align-items: center; gap: 20px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  color: var(--sky-muted);
  text-transform: uppercase;
}
.chrome-center .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 12px var(--sun); }

.chrome-right {
  display: flex; justify-content: flex-end; gap: 18px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--sky-muted);
  text-transform: uppercase;
}
.chrome-right span b { color: var(--sky-fg); font-weight: 500; margin-left: 8px; }
.info-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  color: var(--sky-muted);
  font-family: var(--serif);
  font-size: 12px;
  font-style: italic;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.info-btn:hover {
  border-color: var(--sky-fg);
  color: var(--sky-fg);
}
/* ---- Module tooltip buttons ---- */
.side-head-row,
.log-head-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.tip-btn {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: transparent;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1;
  cursor: default;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}
.tip-btn:hover,
.tip-btn:focus { border-color: var(--sky-fg-dim); color: var(--sky-fg); outline: none; }

.tip-bubble {
  display: none;
  position: absolute;
  z-index: 60;
  width: 210px;
  background: rgba(6, 8, 16, 0.97);
  border: 1px solid rgba(255,255,255,0.11);
  padding: 11px 13px;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.65;
  color: rgba(185, 180, 165, 0.88);
  pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.tip-btn:hover .tip-bubble,
.tip-btn:focus .tip-bubble { display: block; }

.orb-tip {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}

.tip-bubble.tip-right {
  left: calc(100% + 9px);
  top: 50%;
  transform: translateY(-50%);
}
.tip-bubble.tip-left {
  right: calc(100% + 9px);
  top: 50%;
  transform: translateY(-50%);
}
.tip-bubble.tip-up {
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 240px;
  width: max-content;
}

.login-link {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sky-muted);
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 2px 8px;
  transition: border-color 0.15s, color 0.15s;
}
.login-link:hover {
  border-color: var(--sky-fg);
  color: var(--sky-fg);
}

/* Main — three columns, the orb is the center */
.main {
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  gap: 40px;
  align-items: stretch;
  min-height: 0;
}

/* Side panels */
.side {
  display: flex; flex-direction: column; gap: 22px;
  padding-top: 20px;
}
.side-head {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--sky-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--sky-line);
}

.reading {
  display: flex; flex-direction: column; gap: 3px;
}
.reading-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--sky-muted);
}
.reading-val {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--sky-fg);
}
.reading-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--sky-fg-dim);
  margin-top: 2px;
}

/* ----- The Orb (Eye direction) ----- */
.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.orb-wrap {
  position: relative;
  width: min(62vh, 560px);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}

/* Perimeter tick ring */
.orb-ticks {
  position: absolute; inset: 0;
  border-radius: 50%;
}

/* Outer soft halo */
.orb-halo {
  position: absolute; inset: 3%;
  border-radius: 50%;
  border: 1px solid rgba(244, 238, 228, 0.06);
}
.orb-halo::before {
  content: '';
  position: absolute; inset: -1px;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: color-mix(in oklab, var(--sky-accent) 70%, transparent);
  border-right-color: color-mix(in oklab, var(--sky-accent) 25%, transparent);
  transform: rotate(-18deg);
  opacity: 0.9;
}
.orb-halo::after {
  content: '';
  position: absolute; inset: 6%;
  border-radius: 50%;
  border: 1px solid rgba(244, 238, 228, 0.04);
}

/* The sky window */
.orb {
  position: relative;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 120px 0 rgba(0,0,0,0.7),
    inset 0 0 120px 0 rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  background:
    radial-gradient(ellipse 90% 55% at 50% 100%, var(--sky-accent) 0%, color-mix(in oklab, var(--sky-accent) 55%, #000) 22%, transparent 58%),
    linear-gradient(180deg,
      color-mix(in oklab, var(--sky-bg-2) 85%, #000) 0%,
      var(--sky-indigo) 38%,
      color-mix(in oklab, var(--sky-indigo) 60%, var(--sky-accent)) 72%,
      color-mix(in oklab, var(--sky-accent) 50%, #000) 100%);
  animation: breathe var(--breath) ease-in-out infinite;
}

/* Horizon inside the orb */
.orb-horizon {
  position: absolute; left: 6%; right: 6%; top: 72%;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--sky-accent) 70%, transparent), transparent);
  opacity: 0.55;
}
.orb-earth { display: none; }

/* Sun marker */
.sun {
  position: absolute;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow:
    0 0 22px 3px color-mix(in oklab, var(--sun) 90%, transparent),
    0 0 55px 14px color-mix(in oklab, var(--sun) 40%, transparent);
  transform: translate(-50%, -50%);
  transition: top 1.6s var(--ease), left 1.6s var(--ease), opacity 2s var(--ease);
  z-index: 3;
}

/* Center readout */
.readout {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.readout-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--sky-fg-dim);
  margin-bottom: 14px;
}
.readout-time {
  font-family: var(--mono);
  font-weight: 300;
  font-size: clamp(52px, 7vw, 96px);
  letter-spacing: 0.02em;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 2px 40px rgba(0,0,0,0.45);
}
.readout-sub {
  margin-top: 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sky-fg-dim);
}
.readout-sub b { color: var(--sky-fg); font-weight: 500; }

/* Arc tick marks (inside orb) */
.orb-scale {
  position: absolute; inset: 0;
  pointer-events: none;
}
.orb-scale .tick {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--sky-muted);
  transform: translate(-50%, -50%);
}

/* Rules list (right column) */
.rules {
  display: flex; flex-direction: column;
  gap: 0;
}
.rule {
  position: relative;
  padding: 14px 0;
  border-bottom: 1px solid var(--sky-line);
  display: grid;
  grid-template-columns: 10px 1fr auto auto auto auto auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  transition: background 0.4s var(--ease), padding 0.3s var(--ease);
}
.rule:hover { padding-left: 6px; }
.rule-bar {
  width: 2px; height: 22px; background: var(--sky-muted); opacity: 0.6;
  transition: background 0.4s var(--ease), opacity 0.4s var(--ease), height 0.4s var(--ease);
}
.rule.next .rule-bar { background: var(--sun); opacity: 1; height: 28px; box-shadow: 0 0 10px var(--sun); }
.rule.paused .rule-bar { background: var(--sky-muted); opacity: 0.25; }

.rule-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rule-name {
  font-size: 15px; color: var(--sky-fg); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rule-meta {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em;
  color: var(--sky-muted); text-transform: uppercase;
}
.rule-time {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 300;
  color: var(--sky-fg);
  letter-spacing: 0.04em;
  text-align: right;
}
.rule.paused .rule-meta::after { content: ' · paused'; color: #ffb84a; opacity: 0.7; }

/* Delete button — appears on hover */
.rule-delete {
  background: transparent;
  border: none;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}
.rule:hover .rule-delete { opacity: 1; }
.rule-delete:hover { color: #d88a8a; }

/* Expiry badge */
.rule-expiry {
  display: inline-block;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--sky-muted);
  border: 1px solid currentColor;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
  opacity: 0.6;
}
.rule-expiry.urgent {
  color: #e0a050;
  opacity: 1;
}

/* Renew button */
.rule-renew {
  background: transparent;
  border: none;
  color: #e0a050;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}
.rule:hover .rule-renew { opacity: 1; }
.rule-renew:hover { color: var(--sun); }
/* Selected rule */
.rule.selected {
  padding-left: 8px;
  background: color-mix(in oklab, var(--sky-accent) 5%, transparent);
}
.rule.selected .rule-bar { background: var(--sky-accent); opacity: 1; height: 32px; box-shadow: 0 0 14px var(--sky-accent); }
.rule.selected .rule-name { color: var(--sky-fg); }

/* Per-rule edit button */
.rule-edit {
  background: transparent;
  border: none;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}
.rule:hover .rule-edit { opacity: 1; }
.rule-edit:hover { color: var(--sky-fg); }

/* Per-rule fire button */
.rule-fire {
  background: transparent;
  border: none;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}
.rule:hover .rule-fire { opacity: 1; }
.rule.selected .rule-fire { opacity: 1; color: var(--sky-accent); }
.rule-fire:hover { color: var(--sun); }

/* Orbital rule rings overlay (sits behind the orb) */
.rule-rings-overlay {
  position: absolute;
  inset: -14%;
  pointer-events: none;
  z-index: 1;
}
.rule-rings-svg {
  width: 100%; height: 100%;
  overflow: visible;
}

/* Bottom bar */
.footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 24px;
  padding-top: 12px;
  border-top: 1px solid var(--sky-line);
}
.log {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--sky-fg-dim);
}
.log-head {
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--sky-muted);
  margin-bottom: 4px;
}
.log-row { display: grid; grid-template-columns: 50px 90px 1fr; gap: 10px; align-items: baseline; }
.log-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .ok { color: #9fd28a; }
.log-row .err { color: #d88a8a; }
.log-row .pending { color: var(--sky-fg-dim); }
.log-legend {
  opacity: 0.4;
  font-size: 10px;
  letter-spacing: 0.06em;
  padding-top: 6px;
  border-top: 1px solid var(--sky-line);
  margin-top: 4px;
}

.controls {
  display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap;
}
.controls-right {
  display: flex; gap: 10px; margin-left: 8px; padding-left: 8px;
  border-left: 1px solid var(--sky-line);
}
.btn-coffee {
  border-color: rgba(212, 168, 75, 0.35);
  color: #d4a84b;
  text-decoration: none;
}
.btn-coffee:hover { border-color: #d4a84b; background: rgba(212,168,75,0.08); }
.btn-feedback { opacity: 0.7; }
.btn-feedback:hover { opacity: 1; }
.btn {
  background: transparent;
  border: 1px solid var(--sky-line);
  color: var(--sky-fg);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 18px;
  cursor: pointer;
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease), background 0.4s var(--ease);
  backdrop-filter: blur(4px);
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--sky-fg); color: var(--sky-fg); background: color-mix(in oklab, var(--sky-fg) 6%, transparent); }
.btn.primary { border-color: var(--sky-fg); }
.btn.confirming { border-color: #d88a8a; color: #d88a8a; }

.status-right {
  display: flex; flex-direction: column; gap: 4px;
  align-items: flex-end;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--sky-fg-dim);
}
.status-right .kv { display: grid; grid-template-columns: auto auto; gap: 10px; }
.status-right .kv span:first-child { color: var(--sky-muted); letter-spacing: 0.18em; text-transform: uppercase; font-size: 10.5px; }
.status-right .kv span:last-child { color: var(--sky-fg); }

/* Field arc + gnomon SVG — always hidden (direction tweak removed) */
.field-arc { display: none; position: absolute; inset: 0; pointer-events: none; }
#gnomonSvg { display: none; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ----- Offline banner ----- */
.offline-banner {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d88a8a;
  background: rgba(216,138,138,0.07);
  border-bottom: 1px solid rgba(216,138,138,0.2);
  padding: 7px 24px;
  text-align: center;
}
.offline-banner:empty { display: none; }

/* Small screens */
@media (max-width: 1080px) {
  .main { grid-template-columns: 1fr; }
  .side { display: none; }
  .orb-wrap { width: min(86vw, 480px); }
}

/* Subtle entry */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.rise { animation: rise 1.2s var(--ease) both; }
.rise.d1 { animation-delay: 0.1s; }
.rise.d2 { animation-delay: 0.2s; }
.rise.d3 { animation-delay: 0.3s; }
.rise.d4 { animation-delay: 0.4s; }

/* ----- Readout context label ("fires in") ----- */
.readout-context {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--sky-muted);
  margin-bottom: 2px;
  min-height: 14px;
  transition: color 0.6s;
}

/* ----- Countdown urgency states ----- */
#readoutTime[data-urgency="soon"] { color: var(--sun); }
#readoutTime[data-urgency="urgent"] {
  color: #ff9a3a;
  animation: urgency-pulse 2s ease-in-out infinite;
}
#readoutTime[data-urgency="critical"] {
  color: #ff4a4a;
  animation: urgency-pulse 0.6s ease-in-out infinite;
  text-shadow: 0 0 24px rgba(255,74,74,0.4);
}
@keyframes urgency-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ----- Rule toggle (pause/resume) ----- */
.rule-toggle {
  background: transparent;
  border: none;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  cursor: pointer;
  padding: 4px 2px;
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  white-space: nowrap;
}
.rule:hover .rule-toggle { opacity: 1; }
.rule-toggle:hover { color: var(--sky-fg); }
.rule.paused .rule-toggle { opacity: 0.7; color: #ffb84a; }
.rule.paused .rule-name { opacity: 0.45; }
.rule.paused .rule-meta { opacity: 0.35; }
.rule.paused .rule-time { opacity: 0.35; }

/* ----- Rules show-all button ----- */
.rules-show-all {
  background: transparent;
  border: none;
  color: var(--sky-muted);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s;
}
.rules-show-all:hover { color: var(--sky-fg); }

/* ----- Empty state ----- */
.rule-empty {
  padding: 14px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rule-empty-title {
  font-size: 13px;
  color: var(--sky-fg-dim);
  font-weight: 400;
}
.rule-empty-desc {
  font-size: 11.5px;
  color: var(--sky-muted);
  line-height: 1.6;
  max-width: 260px;
}

/* ---- Status badges (logs page) ---- */
.badge {
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-family: var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: inline-block;
}
.badge-success  { background: rgba(92,184,138,0.15); color: #5cb88a; }
.badge-failed   { background: rgba(224,112,112,0.15); color: #e07070; }
.badge-pending  { background: rgba(180,180,60,0.12);  color: #b4b43c; }
.badge-retrying { background: rgba(200,140,60,0.15);  color: #c88c3c; }

/* ---- Utility pages (logs, add-rule) ---- */
body.page-mode {
  overflow: auto;
}
.page-frame {
  position: relative;
  z-index: 4;
  min-height: 100vh;
  padding: 28px 40px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.page-chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--sky-line);
}
.page-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--sky-muted);
}
.back-link {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sky-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--sky-fg); }

/* Logs table */
.logs-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.logs-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--sky-muted);
  border-bottom: 1px solid var(--sky-line);
  font-weight: 400;
}
.logs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid color-mix(in oklab, var(--sky-line) 60%, transparent);
  color: var(--sky-fg-dim);
  vertical-align: middle;
}
.logs-table tr:hover td { background: color-mix(in oklab, var(--sky-fg) 3%, transparent); }
.logs-table .rule-col { color: var(--sky-fg); font-size: 12px; font-weight: 400; font-family: var(--sans); }
.logs-table .code-col { color: var(--sky-fg); font-family: var(--mono); }
.logs-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sky-muted);
  margin-bottom: 8px;
}

/* Add-rule form */
.rule-form {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--sky-muted);
}
.form-input {
  background: transparent;
  border: 1px solid var(--sky-line);
  color: var(--sky-fg);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.3s var(--ease);
  width: 100%;
}
.form-input:focus { border-color: color-mix(in oklab, var(--sky-fg) 50%, transparent); }
.form-input::placeholder { color: var(--sky-muted); font-size: 11px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--sky-fg-dim);
  opacity: 0.7;
}
.solar-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--sky-accent);
  opacity: 0.8;
  min-height: 16px;
  margin-top: 2px;
  letter-spacing: 0.06em;
}
.trigger-pills { display: flex; gap: 8px; }
.trigger-pill {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 16px;
  border: 1px solid var(--sky-line);
  color: var(--sky-fg-dim);
  cursor: pointer;
  transition: all 0.3s var(--ease);
  background: transparent;
}
.trigger-pill.on {
  color: var(--sky-fg);
  border-color: var(--sky-fg);
  background: color-mix(in oklab, var(--sky-fg) 10%, transparent);
}
.form-divider {
  border: none;
  border-top: 1px solid var(--sky-line);
  margin: 4px 0;
}
.form-actions { display: flex; gap: 12px; align-items: center; }
.form-error {
  font-family: var(--mono);
  font-size: 11px;
  color: #e07070;
  min-height: 16px;
}

/* ---- Welcome overlay ---- */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: rgba(4, 5, 10, 0.82);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  padding: 32px 24px;
  overflow-y: auto;
}
.welcome-overlay.active { display: flex; }
.welcome-overlay[data-first-visit] { cursor: default; }

.welcome-card {
  max-width: 680px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: rise 0.8s var(--ease) both;
  margin: auto;
}

.welcome-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.welcome-brand .wordmark {
  font-size: 18px;
  letter-spacing: 0.48em;
  color: rgba(220, 215, 200, 0.9);
}

.welcome-headline {
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.2;
  color: rgba(220, 215, 200, 0.95);
  letter-spacing: 0.01em;
}

.welcome-sub {
  font-size: 15px;
  color: rgba(190, 185, 170, 0.85);
  line-height: 1.7;
  max-width: 520px;
  border-left: 2px solid rgba(255,255,255,0.12);
  padding-left: 16px;
}

.welcome-steps {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
  border: 1px solid rgba(255,255,255,0.10);
}
.welcome-step {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid rgba(255,255,255,0.10);
}
.welcome-step:last-child { border-right: none; }
.welcome-step-num {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.4em;
  color: #d4a84b;
  opacity: 0.9;
}
.welcome-step-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(210, 205, 190, 0.9);
}
.welcome-step-body {
  font-size: 12.5px;
  color: rgba(170, 165, 150, 0.8);
  line-height: 1.6;
}

.welcome-works-with {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: rgba(140, 135, 120, 0.7);
  text-transform: uppercase;
}
.welcome-works-with span {
  color: rgba(180, 175, 160, 0.8);
  margin-right: 10px;
}

.welcome-divider {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: rgba(140, 135, 120, 0.55);
  display: flex;
  align-items: center;
  gap: 14px;
}
.welcome-divider::before,
.welcome-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.welcome-guide {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}
.welcome-guide-item {
  background: rgba(4, 5, 10, 0.5);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.welcome-guide-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(210, 205, 190, 0.75);
}
.welcome-guide-body {
  font-size: 12px;
  color: rgba(155, 150, 135, 0.75);
  line-height: 1.6;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons inside overlays — fixed colors, never inherit sky palette */
.welcome-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.22);
  color: rgba(210, 205, 190, 0.88);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  text-decoration: none;
  display: inline-block;
}
.welcome-btn:hover {
  border-color: rgba(255,255,255,0.55);
  color: rgba(230, 225, 215, 1);
  background: rgba(255,255,255,0.05);
}
.welcome-btn-primary {
  border-color: rgba(212, 168, 75, 0.65);
  color: #d4a84b;
}
.welcome-btn-primary:hover {
  border-color: #d4a84b;
  background: rgba(212, 168, 75, 0.1);
  color: #e0b85a;
}

.welcome-reopen-hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: rgba(120, 115, 100, 0.65);
  margin-top: -8px;
}
.welcome-reopen-hint span {
  font-style: italic;
  font-family: var(--serif);
  color: rgba(150, 145, 130, 0.8);
}

/* ---- Feedback overlay ---- */
.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 91;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 5, 10, 0.78);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 24px;
}
.feedback-overlay.active { display: flex; }

.feedback-card {
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: rise 0.5s var(--ease) both;
}
.feedback-head {
  font-family: var(--serif);
  font-weight: 300;
  font-size: 26px;
  color: rgba(220, 215, 200, 0.95);
  letter-spacing: 0.01em;
}
.feedback-sub {
  font-size: 13px;
  color: rgba(170, 165, 150, 0.8);
  line-height: 1.6;
  margin-top: -10px;
}
.feedback-options {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid rgba(255,255,255,0.09);
}
.feedback-opt {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: rgba(4, 5, 10, 0.5);
  text-decoration: none;
  transition: background 0.15s;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.feedback-opt:first-child { border-top: none; }
.feedback-opt:hover { background: rgba(255,255,255,0.05); }
.feedback-opt-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}
.feedback-opt-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(210, 205, 190, 0.9);
  margin-bottom: 4px;
}
.feedback-opt-desc {
  font-size: 11.5px;
  color: rgba(150, 145, 130, 0.75);
  line-height: 1.5;
}
.feedback-opt-coffee .feedback-opt-title { color: #d4a84b; }
