:root {
  --paper: #f3f1ea;
  --ink: #0a0a0a;
  --ink-60: rgba(10, 10, 10, 0.6);
  --ink-40: rgba(10, 10, 10, 0.4);
  --ink-25: rgba(10, 10, 10, 0.25);
  --line: rgba(10, 10, 10, 0.85);
  --klein: #1d2bd4;
  --klein-deep: #0a17b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* keep the hidden attribute authoritative over display rules below */
[hidden] {
  display: none !important;
}

html,
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
}

/* Klein blue haze bleeding up from the bottom */
.haze {
  position: fixed;
  left: -15%;
  right: -15%;
  bottom: -20%;
  height: 82vh;
  background:
    radial-gradient(52% 55% at 32% 95%, rgba(29, 43, 212, 0.85), transparent 70%),
    radial-gradient(60% 62% at 78% 100%, rgba(10, 23, 184, 0.8), transparent 72%),
    radial-gradient(130% 80% at 50% 118%, rgba(29, 43, 212, 0.55), transparent 74%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.frame {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  padding: 34px 22px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- masthead ---- */
.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
}

.brand h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.eyebrow {
  margin-top: 7px;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--ink-40);
  font-weight: 600;
}

.mark {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.mark .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  transition: background 0.3s ease;
}

.mark[data-status="WATCH"] .dot { background: var(--ink-40); }
.mark[data-status="HANDOVER"] .dot {
  background: var(--ink);
  box-shadow: 0 0 0 3px rgba(10, 10, 10, 0.12);
}

/* ---- 2 x 3 grid with thin black lines ---- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.cell {
  position: relative;
  appearance: none;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 18px 16px 16px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: background 0.18s ease;
}

.cell:hover { background: rgba(10, 10, 10, 0.03); }

.cell.is-active {
  background: rgba(29, 43, 212, 0.06);
}

.cell-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 700;
  color: var(--ink-60);
}

.cell-value {
  margin-top: auto;
  font-size: 40px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.cell-value .unit {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

.cell-value.is-word {
  font-size: 30px;
  text-transform: lowercase;
}

.cell-sub {
  margin-top: 10px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-40);
}

/* ---- frosted glass detail panel ---- */
.panel {
  margin-top: 26px;
  border-radius: 18px;
  padding: 24px 22px 22px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 18px 50px rgba(10, 23, 120, 0.18);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink-25);
}

.panel-figure {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.figure-now {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.figure-sep { color: var(--ink-40); font-size: 24px; font-weight: 300; }
.figure-max { font-size: 22px; font-weight: 600; color: var(--ink-60); }

.panel-status {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.panel-rows {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
}

.panel-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid rgba(10, 10, 10, 0.1);
}

.panel-row:last-child { border-bottom: none; }

.panel-row dt {
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--ink-60);
}

.panel-row dd {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.panel-foot {
  margin-top: 14px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-40);
}

.panel.is-error .panel-status { font-size: 20px; }

/* ---- handover: light entry in the panel ---- */
.handover-zone {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-25);
}

.handover-prepare {
  appearance: none;
  background: transparent;
  border: none;
  padding: 2px 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--ink-60);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 0.18s ease;
}

.handover-prepare:hover { color: var(--ink); }
.prepare-arrow { font-size: 12px; color: var(--klein); font-weight: 600; }

/* ---- handover: frosted action sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.18);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 5;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  max-width: 460px;
  margin: 0 auto;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  padding: 12px 22px calc(24px + env(safe-area-inset-bottom)) 22px;
  background: rgba(243, 241, 234, 0.72);
  border-top: 1px solid var(--line);
  border-left: 1px solid rgba(255, 255, 255, 0.5);
  border-right: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -20px 60px rgba(10, 23, 120, 0.22);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  animation: sheet-up 0.22s ease;
}

@keyframes sheet-up {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--ink-25);
  margin: 0 auto 12px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink-25);
}

.sheet-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.sheet-meta {
  margin-top: 6px;
  font-size: 10.5px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: var(--ink-40);
}

/* token usage folded into the meta — one shade lighter, never red */
.meta-tokens {
  color: rgba(10, 10, 10, 0.32);
}

/* hideable stage · message error line — light grey, not red, up to two lines */
.handover-error {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--ink-60);
  word-break: break-word;
}

.sheet-close {
  appearance: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 16px;
  color: var(--ink-60);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.18s ease, background 0.18s ease;
}

.sheet-close:hover { color: var(--ink); background: rgba(29, 43, 212, 0.06); }

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.handover-btn {
  appearance: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  cursor: pointer;
  transition: background 0.18s ease, opacity 0.18s ease;
}

.handover-btn:hover { background: rgba(29, 43, 212, 0.08); }
.handover-btn:disabled { opacity: 0.45; cursor: default; }

.handover-out {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 14px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  padding: 14px 14px;
}

.handover-out.is-error { color: var(--ink-60); }

.handover-saved {
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  color: var(--ink-60);
  word-break: break-word;
}
