/* ── App shell chrome ───────────────────────────────────────────────────── */

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

.cos-app {
  width: 100%; height: 100dvh;
  background: var(--bg); color: var(--text);
  font-family: var(--f-sans);
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.cos-header {
  flex-shrink: 0;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 5px;
  position: relative; z-index: 30;
}
.cos-header__row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 30px;
}
.cos-header__brand {
  display: flex; align-items: baseline; gap: 6px;
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted);
}
.cos-header__brand b { color: var(--accent); font-weight: 600; text-shadow: 0 0 8px var(--accent-glow); }
.cos-header__tabname {
  font-family: var(--f-sans); font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text); line-height: 1.05;
}
.cos-header__actions { display: flex; align-items: center; gap: 6px; }

/* Beachfront pill */
.bf-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px 0 8px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-2); cursor: pointer;
}
.bf-pill .dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 6px currentColor; flex-shrink: 0; }
.bf-pill[data-status="green"]  .dot { background: var(--good);  color: var(--good); }
.bf-pill[data-status="yellow"] .dot { background: var(--warn);  color: var(--warn); }
.bf-pill[data-status="red"]    .dot { background: var(--bad);   color: var(--bad); }
.bf-pill[data-status="unknown"] .dot { background: var(--muted); color: var(--muted); }

/* Icon button (gear) */
.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Tab hairline accent */
.tab-hairline {
  height: 1px;
  background: linear-gradient(to right, var(--accent), transparent 65%);
  opacity: 0.40;
}

/* ── Scroll surface ──────────────────────────────────────────────────────── */
.cos-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 14px 16px 100px;
  -webkit-overflow-scrolling: touch;
}
/* PTR (pull-to-refresh indicator) */
.ptr {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; margin: -8px 0 4px;
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.ptr.visible { opacity: 0.7; }
.ptr .spin { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
.cos-tabs {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px max(18px, env(safe-area-inset-bottom));
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-top: 1px solid var(--border-soft);
}
.cos-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0 2px; background: transparent; border: 0; cursor: pointer;
  color: var(--muted); font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  touch-action: manipulation;
}
.cos-tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; transition: color .15s; }
/* All tabs use Today's accent (CMC blue) as the constant active indicator */
.cos-tab[aria-selected="true"] { color: oklch(0.62 0.20 262); }
.cos-tab[aria-selected="true"] svg { filter: drop-shadow(0 0 4px oklch(0.62 0.20 262 / 0.45)); }

/* ── Bottom sheets ───────────────────────────────────────────────────────── */
.sheet-scrim {
  position: absolute; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.42);
  display: flex; align-items: flex-end;
  animation: scrim .25s ease both;
}
@keyframes scrim { from { background: rgba(0,0,0,0); } }
.sheet {
  width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--bg-elev);
  border-top-left-radius: var(--r-xl); border-top-right-radius: var(--r-xl);
  border: 1px solid var(--border-soft); border-bottom: 0;
  max-height: 88dvh; display: flex; flex-direction: column;
  animation: sheet-in .32s cubic-bezier(0.16, 1, 0.3, 1) both;
  overflow: hidden;
}
@keyframes sheet-in { from { transform: translateY(24%); opacity: 0.5; } }
.sheet__grab { width: 38px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 4px; flex-shrink: 0; }
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 18px 8px; flex-shrink: 0;
}
.sheet__head h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; color: var(--text); }
.sheet__close {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); border: 0; cursor: pointer;
  color: var(--muted); font-size: 16px; display: flex; align-items: center; justify-content: center;
}
.sheet__body { padding: 8px 18px 32px; overflow-y: auto; flex: 1; }

/* System sheet — row list */
.sys-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 0; border-top: 1px solid var(--border-soft);
}
.sys-row:first-child { border-top: 0; }
.sys-row__label { font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.sys-row__value { font-family: var(--f-mono); font-size: 11px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }

/* ── Setup screen ────────────────────────────────────────────────────────── */
.setup {
  position: fixed; inset: 0; z-index: 70;
  background: oklch(0.155 0.013 252); /* always Today-dark regardless of tab */
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 0 28px;
}
.setup__logo {
  font-family: var(--f-mono); color: oklch(0.62 0.20 262);
  font-size: 12px; letter-spacing: 0.30em; text-transform: uppercase;
  text-shadow: 0 0 12px oklch(0.62 0.20 262 / 0.45);
  text-align: center; margin-bottom: 28px;
}
.setup__title {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  color: oklch(0.97 0 0); text-align: center; margin-bottom: 8px;
}
.setup__sub { font-size: 14px; color: oklch(0.55 0.012 252); text-align: center; margin-bottom: 28px; line-height: 1.5; max-width: 320px; }
.setup__input {
  width: 100%; max-width: 360px; height: 50px;
  border-radius: var(--r-md); border: 1px solid oklch(0.30 0.012 252);
  background: oklch(0.205 0.014 252); color: oklch(0.97 0 0);
  font-family: var(--f-mono); font-size: 14px; letter-spacing: 0.08em; padding: 0 14px;
  margin-bottom: 12px; outline: none;
}
.setup__input:focus { border-color: oklch(0.62 0.20 262); }
.setup__btn {
  width: 100%; max-width: 360px; height: 50px;
  background: oklch(0.62 0.20 262); color: #fff;
  border: 0; border-radius: var(--r-md); font-family: var(--f-mono);
  font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  font-weight: 700; cursor: pointer; box-shadow: 0 0 20px oklch(0.62 0.20 262 / 0.35);
  touch-action: manipulation;
}
.setup__btn:active { opacity: 0.85; }
.setup__foot {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: oklch(0.40 0.012 252); text-align: center; margin-top: 28px;
}
