:root {
  color-scheme: dark;
  --bg: #0f1115; --fg: #e3e5e8; --mut: #8b919a; --line: #252932; --field: #171a21; --acc: #5aa2ff;
  --hit: 40px; /* touch target; the glyphs inside stay small */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.35 system-ui, sans-serif; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }

button { font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0 10px; min-width: var(--hit); min-height: var(--hit); cursor: pointer; -webkit-touch-callout: none; user-select: none; touch-action: manipulation; }
button:disabled { opacity: .4; }
button:focus-visible, textarea:focus-visible, #out:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--acc); outline-offset: -2px; }
.icon { padding: 0; font-size: 18px; line-height: 1; color: var(--mut); }

#bar { display: flex; align-items: center; border-bottom: 1px solid var(--line); flex: none; }
#chips { flex: 1; display: flex; overflow-x: auto; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 0 9px; font-size: 14px; color: var(--mut); white-space: nowrap; position: relative; }
.chip[aria-current="true"] { color: var(--fg); box-shadow: inset 0 -2px var(--acc); }
.chip .h { font-size: 10px; margin-right: 3px; opacity: .7; }
.chip.gone { text-decoration: line-through; opacity: .6; }
.chip[data-st]::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; vertical-align: 1px; }
.chip[data-st="attention"]::before { background: #d29922; }
.chip[data-st="working"]::before { background: var(--acc); }
.chip[data-st="ready"]::before { background: #3fb950; }
.chip.draft::after { content: ""; position: absolute; top: 8px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--acc); }

#state .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--mut); }
#state[data-s="ok"] .dot { background: #3fb950; }
#state[data-s="connecting"] .dot, #state[data-s="pending"] .dot { background: #d29922; }
#state[data-s="down"] .dot, #state[data-s="error"] .dot { background: #f85149; }

#notice { margin: 0; padding: 3px 10px; font-size: 12px; color: #d8b35d; border-bottom: 1px solid var(--line); flex: none; }
#storeErr { margin: 0; padding: 3px 10px; font-size: 12px; color: #f08a80; border-bottom: 1px solid var(--line); flex: none; }

#out { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 6px 8px; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.32 ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", monospace; overscroll-behavior: contain; }
#out:empty::before { content: attr(data-empty); color: var(--mut); font-family: system-ui, sans-serif; }

#pair { flex: 1; overflow-y: auto; padding: 16px; }
#pair h1 { font-size: 18px; margin: 0 0 12px; }
.fp { font-size: 30px; letter-spacing: 4px; line-height: 1.3; }
#menu .fp { font-size: 20px; letter-spacing: 2px; }
#pairState { color: var(--mut); font-size: 13px; }
.mut { color: var(--mut); font-size: 13px; }
code { font-size: 13px; user-select: all; overflow-wrap: anywhere; }
#sendBtn.wait { opacity: .45; }

#sendState { display: flex; align-items: center; gap: 4px; padding-left: 10px; font-size: 12px; color: var(--mut); border-top: 1px solid var(--line); flex: none; }
#sendState span { flex: 1; }
#sendState[data-s="unknown"], #sendState[data-s="failed"], #sendState[data-s="absent"] { color: #d8b35d; }
#restoreBtn { font-size: 12px; color: var(--acc); }

#keys { display: flex; overflow-x: auto; border-top: 1px solid var(--line); flex: none; scrollbar-width: none; }
#keys button { flex: none; font: 13px ui-monospace, monospace; color: var(--fg); }

#composer { display: flex; align-items: flex-end; border-top: 1px solid var(--line); flex: none; }
#draft { flex: 1; min-width: 0; resize: none; min-height: 34px; max-height: 30dvh; margin: 3px 0; padding: 7px 9px; border: 0; border-radius: 8px; background: var(--field); color: inherit; font: 16px/1.3 system-ui, sans-serif; }
#sendBtn { color: var(--acc); }

#hint { position: fixed; z-index: 10; max-width: min(320px, 90vw); padding: 6px 9px; border-radius: 6px; background: #2d333b; color: #fff; font-size: 13px; pointer-events: none; box-shadow: 0 2px 8px #0008; }

dialog { width: min(480px, 100vw); max-height: 90dvh; margin: auto auto 0; padding: 4px 12px 16px; border: 1px solid var(--line); border-radius: 12px 12px 0 0; background: #151820; color: var(--fg); }
dialog::backdrop { background: #0009; }
dialog .head { display: flex; justify-content: space-between; align-items: center; }
dialog h2 { font-size: 13px; font-weight: 600; color: var(--mut); margin: 14px 0 6px; }
dialog ul { margin: 0; padding-left: 18px; font-size: 14px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.row label { min-height: var(--hit); display: inline-flex; align-items: center; gap: 4px; padding-right: 8px; }
.row button { border: 1px solid var(--line); border-radius: 8px; }
input, select { min-height: var(--hit); padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); color: inherit; font: 16px system-ui, sans-serif; }
#startProject { flex: 1; min-width: 8em; }
#startResult { font-size: 13px; color: var(--mut); margin: 4px 0 0; min-height: 1em; }
