/* Earshot. Layout only; the look (tokens, cards, buttons) comes from the shared ui.css loaded after this. */

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; -webkit-font-smoothing: antialiased; line-height: 1.5; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
.mono { font-family: var(--mono); }
.i { width: 16px; height: 16px; flex: none; }
.small { font-size: 0.8125rem; }
[hidden] { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn.block { width: 100%; }
.icon-btn { display: grid; place-items: center; border: none; background: transparent; cursor: pointer; flex: none; }
.seg { display: inline-flex; flex-wrap: wrap; }
.seg button { cursor: pointer; font-family: inherit; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 10; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 20px;
  background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-c);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; background: var(--muted-bg); border: 1px solid var(--border-c); }

/* ---------- page ---------- */
.wrap { max-width: 1000px; margin: 0 auto; padding: 40px 20px 80px; display: flex; flex-direction: column; gap: 20px; }
.hero { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.1; letter-spacing: -0.035em; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.pad { padding: 18px 20px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h3 { font-size: 0.9rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ---------- status ---------- */
.status { position: sticky; top: 64px; z-index: 5; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.status-top { display: flex; align-items: center; gap: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); flex: none; }
.dot.tx { background: var(--blue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 25%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.dot.rx { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); animation: pulse 1.2s ease-in-out infinite; }
.dot.wait { background: var(--yellow); animation: pulse 1.2s ease-in-out infinite; }
.dot.bad { background: var(--danger); }
.dot.good { background: var(--success); }
@keyframes pulse { 50% { opacity: 0.45; } }
.status-text { flex: 1; min-width: 0; }
.st-title { font-weight: 600; font-size: 0.95rem; }
.st-detail { font-size: 0.8125rem; overflow-wrap: anywhere; }
.st-pct { font-size: 0.8125rem; color: var(--muted-fg); }
.bar { height: 4px; border-radius: 4px; background: var(--muted-bg); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--foreground); transition: width 0.15s linear; }
.pipes { display: flex; flex-direction: column; gap: 6px; }
.pipe { display: flex; flex-wrap: wrap; gap: 4px; }
.pipe span {
  font-size: 0.72rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; color: var(--muted-fg);
  border: 1px solid var(--border-c); transition: background 0.15s, color 0.15s;
}
.pipe span.done { color: var(--foreground); }
.pipe span.on { background: var(--primary-bg); color: var(--primary-fg); border-color: transparent; }
.pipe span.fail { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border-c)); }

/* ---------- spectrogram ---------- */
.scope { overflow: hidden; --b1: #3b82f6; --b2: #22c55e; --b3: #f59e0b; --b4: #ec4899; }
.scope-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px 6px; }
.chans { display: flex; gap: 10px; font-size: 0.72rem; color: var(--muted-fg); }
.chans span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }
.chans span.on { color: var(--foreground); }
.scope-view { position: relative; height: 260px; padding: 0 34px 0 38px; }
#wf { display: block; width: 100%; height: 100%; }
.axis { position: absolute; inset: 0 auto 0 0; width: 38px; border-right: 1px solid var(--border-c); }
.axis span { position: absolute; right: 6px; transform: translateY(-50%); font: 500 9.5px/1 var(--mono); color: var(--muted-fg); }
.spec-view { position: relative; padding: 0 16px 6px; }
#spec { display: block; width: 100%; height: 110px; }
.xaxis { position: relative; height: 14px; }
.xaxis span { position: absolute; transform: translateX(-50%); font: 500 9.5px/1 var(--mono); color: var(--muted-fg); top: 3px; }
.lanes { position: absolute; inset: 0 0 0 auto; width: 34px; pointer-events: none; border-left: 1px solid var(--border-c); background: color-mix(in srgb, var(--card-bg) 80%, transparent); }
.lanes span { position: absolute; left: 0; right: 0; transform: translateY(-50%); text-align: center; font: 500 10px/1 var(--mono); color: var(--muted-fg); }
.lanes span { color: var(--c); opacity: 0.55; }
.lanes span.on { opacity: 1; font-weight: 700; }
.lanes i { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border-c); }
.scope-hint { position: absolute; inset: 0 34px 0 38px; display: grid; place-items: center; color: var(--muted-fg); font-size: 0.875rem; pointer-events: none; }
.readout { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border-c); font-size: 0.8125rem; }
.readout b { color: var(--foreground); font-weight: 600; }

/* ---------- send ---------- */
textarea.input.msg { min-height: 0; resize: vertical; font-family: var(--display); font-size: 0.95rem; }
.file-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-pick .small { overflow-wrap: anywhere; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.opt-label { font-size: 0.8125rem; font-weight: 500; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.875rem; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--foreground); flex: none; }
.vol { gap: 10px; color: var(--muted-fg); }
.vol input { flex: 1; accent-color: var(--foreground); }
.estimate { border: 1px solid var(--border-c); border-radius: 10px; padding: 10px 12px; font-size: 0.8125rem; display: flex; flex-direction: column; gap: 4px; }
.estimate .pipeline { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; color: var(--muted-fg); font-family: var(--mono); font-size: 0.75rem; }
.estimate .pipeline b { color: var(--foreground); font-weight: 500; }
.estimate .total { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.estimate .total span:last-child { font-family: var(--mono); font-weight: 500; }
.estimate .warn { color: var(--danger); }

.group { display: flex; flex-direction: column; gap: 14px; }

/* ---------- receive ---------- */
.rx-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cam { display: flex; flex-direction: column; gap: 8px; }
.cam-view { position: relative; border-radius: 10px; overflow: hidden; background: #000; }
.cam-view video { display: block; width: 100%; height: auto; }
.cam-guide {
  position: absolute; top: 50%; left: 50%; height: 70%; aspect-ratio: 1; transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 6px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
}
.cam-grid {
  --n: 3; position: absolute; inset: 0;
  background-image: linear-gradient(to right, rgba(255, 255, 255, 0.35) 1px, transparent 1px), linear-gradient(to bottom, rgba(255, 255, 255, 0.35) 1px, transparent 1px);
  background-size: calc(100% / var(--n)) calc(100% / var(--n));
}
.cam-view.portrait .cam-guide { height: auto; width: 70%; }
#cam-strip { width: 100%; height: 90px; border-radius: 8px; background: #000; display: block; }

/* ---------- flasher (sending by light) ---------- */
.flasher { position: fixed; inset: 0; z-index: 100; background: #000; display: grid; place-items: center; cursor: pointer; }
.fl-grid { display: grid; width: min(92vw, 92vh); aspect-ratio: 1; }
.fl-grid i { display: block; background: #000; }
.fl-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #111; }
.fl-bar span { display: block; height: 100%; width: 0; background: #444; }

.rx-result { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border-c); }
.rx-body { font-size: 1.15rem; font-weight: 500; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.rx-body img { display: block; max-width: 100%; max-height: 240px; border-radius: 8px; border: 1px solid var(--border-c); margin-bottom: 8px; }
.rx-body .file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.9rem; }
.rx-body .cipher { font: 400 0.75rem/1.5 var(--mono); color: var(--muted-fg); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 6px; font-size: 0.75rem; font-weight: 500; border: 1px solid var(--border-c); }
.badge .i { width: 13px; height: 13px; }
.badge.good { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border-c)); }
.badge.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border-c)); }
.badge.fix { color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 40%, var(--border-c)); }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.history li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--border-c); font-size: 0.875rem; }
.history li .i { width: 13px; height: 13px; align-self: center; }
.history li.good .i { color: var(--success); }
.history li.bad .i { color: var(--danger); }
.history li span { flex: 1; overflow-wrap: anywhere; }
.history li time { color: var(--muted-fg); font-size: 0.75rem; font-family: var(--mono); }

/* ---------- byte stream ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 0.72rem; color: var(--muted-fg); }
.lg::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.lg.hdr::before { background: var(--hdr); }
.lg.data::before { background: var(--foreground); }
.lg.par::before { background: var(--par); }
.lg.fix::before { background: var(--yellow); }
.lg.bad::before { background: var(--danger); }
.lg.pend::before { background: var(--muted-bg); border: 1px solid var(--border-c); }
.bytes { --hdr: var(--blue); --par: #a78bfa; display: flex; flex-wrap: wrap; gap: 2px 0; max-height: 300px; overflow-y: auto; font: 500 0.75rem/1.55 var(--mono); }
.bytes b { font-weight: 500; width: 2.6ch; text-align: center; border-radius: 3px; }
.bytes b.hdr { color: var(--hdr); }
.bytes b.data { color: var(--foreground); }
.bytes b.par { color: var(--par); }
.bytes b.pend { color: color-mix(in srgb, var(--muted-fg) 35%, transparent); }
.bytes b.now { background: var(--primary-bg); color: var(--primary-fg); }
.bytes b.fix { background: color-mix(in srgb, var(--yellow) 25%, transparent); color: var(--yellow); }
.bytes b.bad { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.bytes .gap { width: 100%; height: 6px; }

/* ---------- log ---------- */
.log { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; font: 400 0.78rem/1.5 var(--mono); display: flex; flex-direction: column; gap: 3px; }
.log:empty::before { content: 'Nothing yet.'; color: var(--muted-fg); font-family: var(--display); font-size: 0.8125rem; }
.log li { display: flex; gap: 10px; }
.log time { color: var(--muted-fg); flex: none; }
.log .dir { width: 1.2em; flex: none; text-align: center; }
.log .out .dir { color: var(--blue); }
.log .in .dir { color: var(--success); }
.log .err { color: var(--danger); }
.log .key { color: var(--yellow); }
.log span:last-child { overflow-wrap: anywhere; min-width: 0; }

/* ---------- how it works ---------- */
.sec { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; color: var(--subtle-fg); max-width: 720px; }
.steps b { color: var(--foreground); font-weight: 600; }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 24px 16px 64px; }
  .top { padding: 0 16px; }
  .scope-view { height: 220px; }
  .status { top: 60px; }
}
