/* SPDX-License-Identifier: GPL-3.0-or-later */
:root {
  --bg: #0b0e16;
  --panel: #131926;
  --line: #222b3b;
  --text: #d6deeb;
  --dim: #7b879c;
  --accent: #5aa0ff;
  --accent-bg: #1d3a66;
  --warn: #ffb347;
  --bad: #ff5a5a;
  --ok: #5ad17a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.3 system-ui, sans-serif; }
#app { display: flex; flex-direction: column; height: 100dvh; }
header, footer { background: var(--panel); border-color: var(--line); border-style: solid; border-width: 0; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 16px; border-bottom-width: 1px; }
footer { border-top-width: 1px; }
main { display: flex; flex: 1; min-height: 200px; }
main .view { position: relative; flex: 1; min-width: 0; }

.freq { font: 600 30px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.02em; cursor: text; user-select: none; min-width: 9ch; }
.freq .digit { padding: 0 0.02em; border-radius: 3px; }
.freq .digit:hover { background: var(--accent-bg); }
.freq .sep { color: var(--dim); }
.freq .unit { font-size: 13px; color: var(--dim); margin-left: 6px; font-weight: 400; }
.freq-input { background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 4px; padding: 2px 6px; width: 12ch; font-size: 24px; }

.group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
button { background: #1a2232; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; font: inherit; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button.on { background: var(--accent-bg); border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
label { display: flex; align-items: center; gap: 4px; color: var(--dim); }
input[type="range"] { width: 90px; accent-color: var(--accent); }
.num { font-variant-numeric: tabular-nums; color: var(--dim); min-width: 4ch; }

.group button.am { min-width: 5ch; }
.users-ctl { position: relative; }
.users-ctl input.name { width: 10ch; }
.users-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; max-height: 60vh; overflow: auto; padding: 6px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); font-size: 13px; }
.users-pop thead th { padding-top: 6px; }
.users-pop tr.pick { cursor: pointer; }
.users-pop tr.pick:hover td { background: var(--accent-bg); }
.users-pop tr.me td { color: #ff8a8a; }
.smeter { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.smeter .bar { position: relative; width: 140px; height: 10px; background: #0a0d14; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.smeter .sql { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--warn); }
.seg { display: inline-flex; }
.seg button { padding: 4px 7px; border-radius: 0; }
.seg button:first-child { border-radius: 4px 0 0 4px; }
.seg button:last-child { border-radius: 0 4px 4px 0; }
.smeter .fill { height: 100%; background: linear-gradient(90deg, #2a7a4a, var(--ok) 60%, var(--warn) 85%, var(--bad)); transition: width 60ms linear; }
.lamp { font-size: 11px; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); color: var(--dim); }
.lamp.lit { background: var(--bad); color: #fff; border-color: var(--bad); }

.pane { position: absolute; inset: 0; display: flex; flex-direction: column; }
.pane canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.pane .spectrum { flex: 0 0 30%; }
.pane .waterfall { flex: 1; min-height: 0; }
.pane .ghost { position: absolute; top: 0; bottom: 0; pointer-events: none; background: rgba(255, 255, 255, 0.07); border: 1px dashed rgba(255, 255, 255, 0.35); border-width: 0 1px; }
.pane .ghost span { position: absolute; top: 2px; left: 100%; margin-left: 4px; padding: 0 4px; border-radius: 3px; background: rgba(11, 14, 22, 0.8); color: var(--text); font: 12px ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; }
.pane .ghost span.left { left: auto; right: 100%; margin: 0 4px 0 0; }
.pane-error { position: absolute; top: 40%; width: 100%; text-align: center; color: var(--warn); pointer-events: none; }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(5, 8, 14, 0.75); }
.overlay.small { inset: auto 0 16px 0; background: none; pointer-events: none; }
.overlay.small > * { pointer-events: auto; }
.overlay .start { font-size: 18px; padding: 10px 22px; background: var(--accent-bg); border-color: var(--accent); }
.overlay.login input { width: min(260px, 80vw); font-size: 16px; padding: 6px 10px; }
.warn { color: var(--warn); }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 16px; background: var(--accent-bg); border-bottom: 1px solid var(--accent); font-size: 13px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px 24px; padding: 6px 16px; }
.status { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 4px 16px 6px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--line); }
.status .right { margin-left: auto; }
.conn.open { color: var(--ok); }
.conn.closed, .conn.busy, .conn.ended { color: var(--bad); }
.conn.connecting { color: var(--warn); }

.spots { display: flex; flex-direction: column; width: min(420px, 40vw); border-left: 1px solid var(--line); background: var(--panel); font-size: 12px; }
.spots-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.spots-bar input[type="text"] { flex: 1; min-width: 80px; }
.spots-bar .close { margin-left: auto; padding: 2px 8px; }
.spots-list { flex: 1; overflow: auto; padding: 0 8px 8px; }
.spots-list p { margin: 12px 0; }
.spots-list table { width: 100%; }
.spots-list thead th { position: sticky; top: 0; background: var(--panel); padding-top: 4px; }
.spots-list td.msg { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: normal; overflow-wrap: anywhere; }
.spots-list tbody tr { cursor: pointer; }
.spots-list tbody tr:hover td { background: var(--accent-bg); }
@media (max-width: 900px) {
  main { flex-direction: column; }
  .spots { width: auto; height: 40%; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 640px) {
  header { padding: 6px 16px; }
  .freq { font-size: 24px; }
  .smeter { margin-left: 0; }
  .smeter .bar { width: 100px; }
  .pane .spectrum { flex-basis: 25%; }
}

a { color: var(--accent); }
.dim { color: var(--dim); }
.ok { color: var(--ok); }

/* admin pages */
.admin { display: flex; flex-direction: column; height: 100dvh; }
.admin header .spacer { flex: 1; }
.admin .page { flex: 1; overflow: auto; padding: 12px 16px 32px; }
.admin-login { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 12vh auto; max-width: 420px; padding: 0 16px; text-align: center; }
.admin-login input { width: 100%; }
input[type="text"], input[type="password"], select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; font: inherit; }
input[type="text"]:focus, input[type="password"]:focus, select:focus { border-color: var(--accent); outline: none; }
input.bad { border-color: var(--bad); }
pre, code { font-family: ui-monospace, Menlo, Consolas, monospace; }
pre { background: var(--panel); padding: 6px 12px; border-radius: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; min-width: 0; overflow-x: auto; }
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card h4 { margin: 12px 0 4px; font-size: 13px; color: var(--dim); }
.card form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.card form p { flex-basis: 100%; margin: 0; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.card dt { color: var(--dim); }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; color: var(--dim); font-weight: 400; }
th, td { padding: 2px 10px 2px 0; white-space: nowrap; }
td.r, th.r { text-align: right; }
tr.dim td { color: var(--dim); }
table.wide { width: 100%; }
.page > div:has(> table.wide) { overflow-x: auto; }
.config { max-width: 900px; }
.config fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 6px 14px 10px; background: var(--panel); }
.config fieldset.sub { background: none; margin: 8px 0; }
.config legend { padding: 0 6px; font-weight: 600; }
.config .field { display: grid; grid-template-columns: 170px 1fr; gap: 4px 12px; padding: 5px 0; border-top: 1px solid var(--line); }
.config .field:first-of-type { border-top: 0; }
.config .name { color: var(--text); align-self: start; padding-top: 4px; }
.config .line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.config .line input[type="text"] { width: min(340px, 100%); }
.config .help { color: var(--dim); font-size: 12px; margin-top: 2px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 3px; border: 1px solid var(--warn); color: var(--warn); }
.tag.edit { border-color: var(--accent); color: var(--accent); }
.savebar { position: sticky; top: -12px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; margin-bottom: 8px; background: var(--bg); }
@media (max-width: 640px) {
  .config .field { grid-template-columns: 1fr; }
}

/* phone layout (ctl/mobile.tsx; doc/m7-mobile-ui.md) */
.m-app { display: flex; flex-direction: column; height: 100dvh; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.m-app button, .m-app select, .m-app input[type="range"] { touch-action: manipulation; }
.m-app button { min-height: 44px; font-size: 16px; border-radius: 8px; padding: 6px 12px; }
.m-app button:active { background: var(--accent-bg); }
/* a tap leaves :hover on in iOS: no hover styles here */
.m-app button:hover:not(:disabled) { border-color: var(--line); }
.m-app button.on:hover:not(:disabled), .m-app button.go:hover:not(:disabled), .m-cap:hover:not(:disabled) { border-color: var(--accent); }
.m-app input[type="text"] { font-size: 16px; min-height: 40px; }
.m-app select { font-size: 16px; min-height: 40px; }
.m-app input[type="range"] { width: 130px; height: 32px; }

.m-top { flex: none; padding: max(6px, env(safe-area-inset-top)) 14px 0; background: var(--panel); border-bottom: 1px solid var(--line); }
.m-top .m-freq { display: block; width: 100%; min-height: 0; padding: 0; border: 0; background: none; text-align: left; font: 600 40px/1.1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.02em; color: var(--text); }
.m-top .m-freq .unit { font-size: 16px; color: var(--dim); margin-left: 8px; font-weight: 400; }
.m-info { display: flex; gap: 14px; align-items: center; height: 22px; color: var(--dim); font-size: 14px; }
.m-info span:first-child { color: var(--accent); font-weight: 600; }
.m-info .lamp[hidden] { display: none; }
.m-meter { height: 4px; margin: 2px -14px 0; background: #0a0d14; }
.m-meter .fill { height: 100%; background: linear-gradient(90deg, #2a7a4a, var(--ok) 60%, var(--warn) 85%, var(--bad)); transition: width 60ms linear; }

.m-view { position: relative; flex: 1; min-height: 120px; }
.m-view .pane .spectrum { flex-basis: 22%; }
.m-app .banner { flex: none; padding: 6px 14px; }
.m-view .overlay.small { inset: auto 0 12px 0; }
.m-view .overlay .start { font-size: 20px; min-height: 52px; }

.m-dock { flex: none; display: flex; gap: 10px; align-items: center; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
.m-keys { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.m-row { display: flex; gap: 6px; flex-wrap: wrap; }
.m-keys .m-row { flex-wrap: nowrap; }
.m-row > * { flex: 1; min-width: 0; }
.m-row button { padding: 6px 2px; }
.m-app button.go { background: var(--accent-bg); border-color: var(--accent); }

.m-wheel { position: relative; flex: none; width: 150px; height: 150px; touch-action: none; cursor: grab; }
.m-wheel svg { width: 100%; height: 100%; display: block; }
.m-wheel .rim { fill: #0f1522; stroke: var(--line); stroke-width: 2; }
.m-wheel line { stroke: #3b4a66; stroke-width: 2; stroke-linecap: round; }
.m-wheel line.major { stroke: var(--accent); stroke-width: 3; }
.m-cap { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; margin: -35px 0 0 -35px; padding: 0 !important; border-radius: 50% !important; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; font-size: 14px !important; background: var(--accent-bg); border-color: var(--accent); }
.m-cap small { font-size: 10px; color: var(--dim); }

.m-sheet-back { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: rgba(5, 8, 14, 0.6); }
.m-sheet { width: 100%; max-height: 85dvh; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; padding-bottom: env(safe-area-inset-bottom); }
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px; font-size: 17px; }
.m-sheet-head button { min-width: 44px; }
.m-sheet-body { overflow: auto; padding: 0 14px 14px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.m-sheet-body h4 { margin: 8px 0 0; font-size: 13px; font-weight: 400; color: var(--dim); text-transform: uppercase; letter-spacing: 0.06em; }
.m-sheet .group { gap: 8px; }
.m-sheet input[type="range"] { flex: 1 1 140px; width: auto; min-width: 120px; }
.m-sheet label { flex: 1 1 220px; }
.m-sheet .users-pop { position: static; margin-top: 6px; max-height: 40vh; box-shadow: none; }
.m-sheet .spots { width: auto; height: 50vh; border: 0; }
.m-sheet .status { padding: 8px 0 0; }

.m-entry { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; min-height: 52px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; font: 600 36px/1.2 ui-monospace, "SF Mono", Menlo, monospace; }
.m-entry .unit { font-size: 14px; color: var(--dim); font-weight: 400; }
.m-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.m-pad .k { min-height: 58px; font-size: 26px; }
.m-bands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.m-bands button { min-height: 56px; font-size: 18px; }

@media (max-width: 380px) {
  .m-wheel { width: 128px; height: 128px; }
  .m-cap { width: 60px; height: 60px; margin: -30px 0 0 -30px; }
}

.ico { width: 22px; height: 22px; fill: currentColor; display: block; margin: 0 auto; }
.overlay .start { display: inline-flex; align-items: center; gap: 8px; }
.overlay .start .ico { margin: 0; }

/* ?debug=1 */
.pane .hud { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 4px 6px; z-index: 5; pointer-events: none; font: 10px/1.25 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: #9fe39f; background: rgba(0, 0, 0, 0.75); }
