/* SPDX-License-Identifier: GPL-3.0-or-later */
:root {
  --bg: #f4f6f8; --card: #ffffff; --text: #16202a; --muted: #5b6875; --line: #d9dfe5;
  --accent: #0b7a75; --accent-2: #e6f4f3; --danger: #c62828; --warn: #8a5a00; --warn-bg: #fff4dc;
  --radius: 12px; --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1720; --card: #17212b; --text: #e8eef3; --muted: #9aa8b5; --line: #2a3744;
    --accent: #3cc7bf; --accent-2: #173a3a; --danger: #ef5350; --warn: #ffcc66; --warn-bg: #3a2e12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1720; --card: #17212b; --text: #e8eef3; --muted: #9aa8b5; --line: #2a3744;
  --accent: #3cc7bf; --accent-2: #173a3a; --danger: #ef5350; --warn: #ffcc66; --warn-bg: #3a2e12;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
a { color: var(--accent); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 1.1rem; margin-right: auto; }
.brand span { color: var(--accent); }
.pill { font-size: .8rem; padding: 3px 10px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--accent-2); color: var(--accent); }
.pill.busy { background: var(--warn-bg); color: var(--warn); }
.estop { background: var(--danger); color: #fff; border: 0; font-weight: 800; padding: 8px 14px; border-radius: 8px; letter-spacing: .04em; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.tab { display: none; }
.tab.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.accent { color: var(--accent); font-weight: 600; }
.warn { background: var(--warn-bg); color: var(--warn); padding: 8px 10px; border-radius: 8px; }
.result { font-weight: 600; min-height: 1.4em; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.wrap, .row.buttons { flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px 12px; align-items: end; }
.grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); }
label.grow { flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: .95rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%; }
input[type="checkbox"], input[type="radio"], input[type="range"] { width: auto; }
input.tiny { width: 4.5em; padding: 4px 6px; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
button, .file-btn { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; cursor: pointer; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.temps { display: flex; gap: 24px; font-size: 1.05rem; }
.log { max-height: 220px; overflow: auto; font-size: .78rem; background: var(--bg); padding: 8px; border-radius: 8px; white-space: pre-wrap; word-break: break-all; }
progress { width: 100%; height: 14px; accent-color: var(--accent); }
video.preview, .camera-box video { width: 100%; border-radius: 8px; background: #000; }
.camera-box { position: relative; }
.camera-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.chart { width: 100%; height: auto; background: var(--bg); border-radius: 8px; }
.cal-list { display: grid; gap: 10px; }
.cal-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.cal-item h3 { margin: 0 0 4px; }
.stars { display: grid; gap: 6px; }
.stars label { display: grid; grid-template-columns: 1fr auto 2em; align-items: center; color: var(--text); font-size: .95rem; }
.stars output { text-align: right; font-weight: 700; }
.rec-list { display: grid; gap: 6px; }
.rec { display: flex; flex-direction: row; color: var(--text); font-size: .95rem; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.rec input { margin-top: 4px; flex: none; }
.rec.chosen { border-color: var(--accent); background: var(--accent-2); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .85rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabs button { flex: 1; flex-direction: column; border: 0; border-radius: 0; background: none; font-size: .72rem; gap: 2px; min-height: var(--tabs-h); color: var(--muted); padding: 6px 2px; }
.tabs button .ico { font-size: 1.2rem; line-height: 1; }
.tabs button.active { color: var(--accent); font-weight: 700; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + 12px); background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; z-index: 10; max-width: 560px; margin: 0 auto; }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
