:root {
  --bg: #14161a; --panel: #1d2026; --line: #2c3038; --text: #e8e6e3; --muted: #9aa0a8;
  --accent: #d97757; --ok: #5fb37a; --warn: #e2b04a; --bad: #e06c6c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
.view { min-height: 100dvh; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.center input, .center button { width: min(340px, 100%); }
h1 { margin: 0; font-size: 34px; } h2 { margin: 0; font-size: 20px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.msg { min-height: 1.4em; color: var(--warn); }
button, select, input, textarea { font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
button { cursor: pointer; } button:active { transform: scale(.97); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.big { padding: 14px 18px; font-size: 17px; }
.ghost { background: transparent; border-color: transparent; color: var(--muted); text-decoration: none; padding: 8px; }
details { width: min(340px, 100%); } details[open] { display: flex; flex-direction: column; gap: 10px; }
summary { color: var(--muted); cursor: pointer; }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.spacer { flex: 1; }
.new { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 14px; }
@media (min-width: 700px) { .new { grid-template-columns: 2fr 2fr auto; } }
#chats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; cursor: pointer; }
.chat .t { font-weight: 600; } .chat .d { color: var(--muted); font-size: 13px; grid-column: 1; }
.chat .acts { grid-row: 1 / span 2; grid-column: 2; display: flex; gap: 6px; align-items: center; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.pill.working { background: #24364a; color: #8cc4ff; }
.pill.blocked { background: #4a3a1a; color: var(--warn); }
.pill.stopped, .pill.failed { background: #4a2222; color: var(--bad); }
.term { display: flex; flex-direction: column; height: 100dvh; padding-left: 0; padding-right: 0; }
.term .bar { padding: 6px 8px; }
.term .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#term { flex: 1; min-height: 0; padding: 0 4px; }
.keys { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; border-top: 1px solid var(--line); }
.keys button { flex: 0 0 auto; padding: 8px 12px; font-size: 14px; }
.input { display: flex; gap: 6px; padding: 6px 8px 8px; }
.input textarea { flex: 1; resize: none; max-height: 30vh; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
td pre { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--muted); }
.tabs { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.tabs button.on { border-color: var(--accent); color: var(--accent); }
.lvl-error { color: var(--bad); } .lvl-warn { color: var(--warn); }
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 14px; }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; padding: 4px 4px 8px; outline: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 14px; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.chip svg, #pk-list svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.chip.static { color: var(--muted); }
.chip.icon { padding: 6px 8px; }
.chip .x { border: 0; background: none; padding: 0 0 0 2px; color: var(--muted); font-size: 16px; line-height: 1; }
#chip-extra { display: contents; }
.send { border-radius: 10px; padding: 6px 14px; font-size: 18px; }
dialog#picker { width: min(520px, calc(100vw - 24px)); max-height: 80dvh; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); color: var(--text); padding: 10px; display: none; flex-direction: column; gap: 8px; }
dialog#picker[open] { display: flex; }
dialog::backdrop { background: rgba(0,0,0,.55); }
.pk-head { display: flex; align-items: center; gap: 6px; }
.pk-head .title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
#pk-recent { display: flex; flex-wrap: wrap; gap: 6px; }
#pk-recent .muted { width: 100%; }
#pk-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 120px; }
#pk-list li { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
#pk-list li span { flex: 1; } #pk-list li b { color: var(--muted); font-weight: 400; }
