:root {
  --bg: #f4f5f2; --card: #ffffff; --ink: #1d2320; --muted: #66706a; --line: #dfe3de;
  --accent: #2f6f4e; --accent-ink: #ffffff; --ok: #2f8f4e; --bad: #c24a3a; --warn: #c7871c;
  --event: #2f6f4e; --off: #556070;
  --radius: 14px; --gap: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15191a; --card: #1f2527; --ink: #ecefe9; --muted: #9aa49e; --line: #2d3537; --accent: #5fb588; --accent-ink: #0d1510; --event: #3f9c6a; --off: #6b7786; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.4rem; margin: 0 0 .75rem; }
h2 { font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 .5rem; font-weight: 600; }
.page { max-width: 760px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 420px; padding-top: 10vh; }
.center { text-align: center; }
.top { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto; padding: 14px 16px 0; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.brand.big { font-size: 1.6rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { margin-left: auto; }
.inline { display: inline; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: var(--gap); }
.card.err { border-color: var(--bad); }
.stack > * + * { margin-top: 12px; }
.grid2 { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.plain li:first-child { border-top: 0; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.status.ok .dot { background: var(--ok); }
.status.bad .dot { background: var(--bad); }
p.status { display: flex; align-items: center; gap: 10px; margin: 0; }
.badge { min-width: 28px; text-align: center; padding: 2px 8px; border-radius: 999px; background: var(--line); font-weight: 600; font-size: .85rem; }
.badge.hot { background: var(--accent); color: var(--accent-ink); }
label { display: block; font-size: .9rem; color: var(--muted); }
input[type=password], input[type=text], input[type=tel], input[type=date], input[type=time], select {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; font-size: 1.05rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
input.code { font-size: 1.6rem; letter-spacing: .3em; text-align: center; }
button, .button { display: inline-block; font: inherit; padding: 12px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); width: 100%; font-weight: 600; }
button.link { background: none; border: 0; color: var(--accent); padding: 4px; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
.row.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.pill { border-radius: 999px; padding: 10px 16px; }
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); opacity: 1; }
.notice { padding: 10px 14px; border-radius: 10px; background: var(--line); }
.notice.ok { background: color-mix(in srgb, var(--ok) 15%, var(--card)); }
.notice.err { background: color-mix(in srgb, var(--bad) 15%, var(--card)); }
.mode { border-width: 2px; }
.mode.event { border-color: var(--event); }
.mode.off { border-color: var(--off); }
.mode-head { display: flex; align-items: baseline; gap: 12px; }
.mode-head .label { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: .85rem; letter-spacing: .04em; }
.mode-head .value { font-size: 2.2rem; font-weight: 800; }
.mode.event .value { color: var(--event); }
.mode.off .value { color: var(--off); }
.steps li + li { margin-top: 10px; }
.qr { margin: 10px 0; background: #fff; padding: 8px; border-radius: 10px; display: inline-block; }
.qr svg { width: 200px; height: 200px; display: block; }
code.secret { display: block; word-break: break-all; margin-top: 6px; font-size: .95rem; }
.tabs { position: sticky; top: 0; z-index: 5; display: flex; justify-content: center; gap: 4px; background: var(--card); border-bottom: 1px solid var(--line); padding: 6px 8px; max-width: 760px; margin: 10px auto 0; }
.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: .8rem; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 4px; border-radius: 8px; }
.tabs a .ico { font-size: 1rem; }
.tabs a.active { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.tabs a.disabled { opacity: .4; pointer-events: none; }
@media (min-width: 900px) {
  .tabs { border: 1px solid var(--line); border-radius: var(--radius); }
  .tabs a { flex: none; font-size: .9rem; padding: 8px 14px; }
}
.big-number { font-size: 1.6rem; font-weight: 700; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { margin-top: 0; flex: 1; }
.row button.primary { width: auto; }
.row.buttons form.htmx-request button { opacity: .6; }
form.inline { display: inline; }
details.event { border-top: 1px solid var(--line); padding: 8px 0; }
details.event:first-of-type { border-top: 0; }
details.event summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; padding: 6px 0; }
details.event summary::-webkit-details-marker { display: none; }
details.event[data-past] summary { opacity: .55; }
details.event form { padding: 8px 0 4px; }
.row label { flex: 1; }
.row.window { padding: 8px 0; border-top: 1px solid var(--line); }
.row.window:first-of-type { border-top: 0; }
.row.window .wlabel { flex: 0 0 5.5em; font-weight: 600; }
.row.window input { flex: 1; min-width: 0; }
.notice.applying { background: color-mix(in srgb, var(--warn) 18%, var(--card)); }
a.rowlink { text-decoration: none; color: inherit; display: flex; flex-direction: column; flex: 1; }
.hidden { display: none !important; }
.tabsel { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tabsel .tab { border: 0; background: none; padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tabsel .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
textarea { width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
audio { width: 100%; }
#wave { width: 100%; display: block; border-radius: 10px; background: var(--bg); touch-action: none; }
input[type=file] { display: block; width: 100%; }
#rec-start.recording { background: var(--bad); border-color: var(--bad); }
blockquote.ref { margin: 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 10px 10px 0; white-space: pre-wrap; }
a.pill { text-decoration: none; color: var(--ink); }
.calls .dir { width: 24px; text-align: center; font-weight: 700; color: var(--muted); flex: none; }
.calls .dir.in { color: var(--ok); } .calls .dir.out { color: var(--accent); }
.calls .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.codes { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.codes th, table.codes td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
table.codes th { border-top: 0; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.codes td:first-child { white-space: nowrap; font-weight: 600; }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
