:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #1c1b19;
  --muted: #6b6860;
  --line: #dedbd3;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --good-bg: #dff3e0; --good-ink: #19692a;
  --warn-bg: #fdf0d2; --warn-ink: #7a5300;
  --bad-bg: #fbe1df;  --bad-ink: #9b1c14;
  --off-bg: #ecebe6;  --off-ink: #55524b;
  --code: #f1efe9;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; line-height: 1.45; }
header { padding: 18px 24px 6px; }
h1 { margin: 0; font-size: 1.5rem; }
h2 { margin: 0 0 6px; font-size: 1.05rem; }
.sub { margin: 4px 0 0; color: var(--muted); }
main { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 16px; padding: 12px 24px 8px; align-items: start; }
.left { display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.right { min-height: 480px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: 0.9rem; }
.hint.inline { margin: 0; }
code { background: var(--code); padding: 1px 4px; border-radius: 3px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92em; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px; font: inherit; font-weight: 400; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 5px;
}
textarea { resize: vertical; font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92rem; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: grid; gap: 12px; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.sub { grid-template-columns: 1fr auto; align-items: end; }
.row.sub button { margin-bottom: 10px; }
.row.send { grid-template-columns: 150px 1fr; align-items: start; }
.grow { min-width: 0; }
.pw { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.check { font-weight: 400; padding-top: 22px; }
.check input { margin-right: 6px; }
.check.keep { padding-top: 0; margin-bottom: 12px; }
.quick { border: 1px dashed var(--line); border-radius: 6px; padding: 10px 12px 2px; margin-bottom: 12px; background: #fbfaf8; }

button { font: inherit; padding: 7px 14px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); cursor: pointer; }
button:hover:not(:disabled) { border-color: #b9b5aa; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary.stop { background: #b3261e; border-color: #b3261e; }
button.ghost { margin-top: 4px; padding: 7px 10px; font-size: 0.85rem; }
.note { margin-left: 10px; font-size: 0.9rem; color: var(--muted); }
.note.bad { color: var(--bad-ink); }

.status { margin: -16px -16px 14px; padding: 9px 16px; border-radius: 8px 8px 0 0; font-weight: 600; font-size: 0.92rem; }
.status.off { background: var(--off-bg); color: var(--off-ink); }
.status.wait { background: var(--warn-bg); color: var(--warn-ink); }
.status.on { background: var(--good-bg); color: var(--good-ink); }
.status.bad { background: var(--bad-bg); color: var(--bad-ink); }

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips li { display: inline-flex; align-items: center; gap: 6px; background: var(--code); border-radius: 14px; padding: 3px 4px 3px 10px; font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.88rem; }
.chips li.refused { background: var(--bad-bg); color: var(--bad-ink); }
.chips button { border: none; background: transparent; padding: 0 6px; font-size: 1rem; line-height: 1; }

.msgbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.msgbar h2 { margin: 0; }
.tools { display: flex; gap: 8px; align-items: center; }
.tools input { margin: 0; width: 230px; }
.badge { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 10px; background: var(--code); font-size: 0.8rem; text-align: center; font-weight: 600; }
.empty { display: grid; gap: 4px; justify-items: center; text-align: center; color: var(--muted); padding: 70px 20px; }
.empty strong { color: var(--ink); font-size: 1.05rem; }
.list { display: grid; gap: 8px; max-height: calc(100vh - 210px); overflow: auto; }
.msg { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.msg.sent { border-left: 4px solid var(--accent); }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 0.82rem; color: var(--muted); }
.meta .topic { color: var(--ink); font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.9rem; font-weight: 600; background: none; border: none; padding: 0; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.meta .topic:hover { text-decoration: underline; }
.tag { border-radius: 3px; padding: 0 5px; font-size: 0.75rem; font-weight: 600; }
.tag.retained { background: var(--warn-bg); color: var(--warn-ink); }
.tag.out { background: #dfe9fa; color: #1a4a99; }
pre.payload { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.88rem; }
pre.payload.none { color: var(--muted); font-style: italic; }

footer { padding: 4px 24px 22px; color: var(--muted); font-size: 0.88rem; }
footer p { margin: 0; max-width: 90ch; }

/* Tabs: one panel is shown at a time. */
[hidden] { display: none !important; }
.tabbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tabs button { margin-bottom: -1px; padding: 8px 18px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); font-weight: 600; }
.tabs button:hover:not([aria-selected="true"]) { color: var(--ink); border-color: transparent; }
.tabs button[aria-selected="true"] { background: var(--card); border-color: var(--line); color: var(--ink); }
.pill { margin-bottom: 7px; padding: 2px 10px; border-radius: 12px; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.pill.off { background: var(--off-bg); color: var(--off-ink); }
.pill.wait { background: var(--warn-bg); color: var(--warn-ink); }
.pill.on { background: var(--good-bg); color: var(--good-ink); }

/* The Devices tab. */
.wide { margin: 12px 24px 8px; }
.empty button { margin-top: 10px; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
td .strong { font-weight: 600; }
td .mono { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.86rem; overflow-wrap: anywhere; }
td .small { font-size: 0.82rem; color: var(--muted); }
td .version { font-size: 1.05rem; font-weight: 600; white-space: nowrap; }
td .note { font-style: italic; }
td > div + div { margin-top: 2px; }
.stamp { margin: 10px 0 0; }
.stamp.bad { color: var(--bad-ink); font-weight: 600; }
footer code { white-space: nowrap; }

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 12px; }
  header, footer { padding-left: 12px; padding-right: 12px; }
  .list { max-height: none; }
  .tools input { width: 150px; }
  .wide { margin: 12px; }
}
