/*
 * sarka: the web client's look (2026-11-16) - Smudder's three themes
 * (slate, black, white), each with its own 16 ANSI colours tuned to read
 * on its background, and a monospace screen that fills the window.
 */
:root {
  color-scheme: dark;
  --bg: #161b22;
  --bar: #1d242d;
  --panel: #202833;
  --line: #2c3642;
  --fg: #d5dde6;
  --dim: #8796a8;
  --accent: #e0a85a;
  --accent-ink: #1a1307;
  --echo: #7fb2d9;
  --client: #b9a4e0;
  --ok: #6fcf8e;
  --bad: #ef6f6c;
  --c0: #3b4452; --c1: #e06c69; --c2: #79c27c; --c3: #d9b45f;
  --c4: #6ea2e6; --c5: #c788d6; --c6: #5fc0c4; --c7: #c9d1da;
  --c8: #6b7686; --c9: #ff8c88; --c10: #9fe39f; --c11: #ffd97a;
  --c12: #98c2ff; --c13: #eaa6f5; --c14: #8ae6e8; --c15: #ffffff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --size: 14px;
}
body[data-theme="black"] {
  --bg: #000; --bar: #0d0d0d; --panel: #141414; --line: #262626;
  --fg: #d6d6d6; --dim: #8a8a8a; --echo: #79b0ff; --client: #c1a3ff;
  --c0: #4a4a4a; --c1: #ff5f56; --c2: #5fd75f; --c3: #e8c547;
  --c4: #5f9cff; --c5: #d17cff; --c6: #3fd0d4; --c7: #d0d0d0;
  --c8: #767676; --c9: #ff8a80; --c10: #90ee90; --c11: #ffe270;
  --c12: #8fbaff; --c13: #e6a2ff; --c14: #7ff0f2; --c15: #ffffff;
}
body[data-theme="white"] {
  color-scheme: light;
  --bg: #fbfbf8; --bar: #efeee8; --panel: #ffffff; --line: #d9d7cf;
  --fg: #1f2328; --dim: #6a6f77; --accent: #a8641c; --accent-ink: #fff;
  --echo: #1d5fa8; --client: #6b4bb0; --ok: #1f8a46; --bad: #c43b37;
  --c0: #3d3d3d; --c1: #b3261e; --c2: #2b7a2f; --c3: #8a6200;
  --c4: #1f5fbf; --c5: #8e3aa3; --c6: #0f7c80; --c7: #555b63;
  --c8: #6d6d6d; --c9: #d6382f; --c10: #36913b; --c11: #a87700;
  --c12: #2f78e0; --c13: #a94cc0; --c14: #12959a; --c15: #111111;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 var(--sans);
  overflow: hidden;
}
[hidden] { display: none !important; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ---- the bar */
#bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: 0.02em; }
.brand .mark {
  width: 14px; height: 14px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #8a5a22);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.status { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.status[data-state="open"] .dot { background: var(--ok); }
.status[data-state="closed"] .dot { background: var(--bad); }
.status[data-state="connecting"] .dot { background: var(--accent); }
.tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
button {
  font: 13px var(--sans);
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}
button:hover { border-color: var(--dim); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, #out:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button[aria-pressed="true"] { background: var(--panel); border-color: var(--accent); }
#btn-connect { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

/* ---- the screen */
#screen { position: relative; flex: 1; min-height: 0; }
#out {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px 6px;
  font: var(--size)/1.35 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-variant-ligatures: none;
  tab-size: 8;
}
#out .ln { min-height: 1.35em; }
#out .echo { color: var(--echo); }
#out .client { color: var(--client); font-style: italic; }
#out .list { color: var(--client); }
#out .err { color: var(--bad); }
#newer {
  position: absolute; right: 18px; bottom: 10px;
  background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

/* the ANSI palette - text and backgrounds */
.f0 { color: var(--c0); } .f1 { color: var(--c1); } .f2 { color: var(--c2); } .f3 { color: var(--c3); }
.f4 { color: var(--c4); } .f5 { color: var(--c5); } .f6 { color: var(--c6); } .f7 { color: var(--c7); }
.f8 { color: var(--c8); } .f9 { color: var(--c9); } .f10 { color: var(--c10); } .f11 { color: var(--c11); }
.f12 { color: var(--c12); } .f13 { color: var(--c13); } .f14 { color: var(--c14); } .f15 { color: var(--c15); }
.b0 { background: var(--c0); } .b1 { background: var(--c1); } .b2 { background: var(--c2); } .b3 { background: var(--c3); }
.b4 { background: var(--c4); } .b5 { background: var(--c5); } .b6 { background: var(--c6); } .b7 { background: var(--c7); }
.b8 { background: var(--c8); } .b9 { background: var(--c9); } .b10 { background: var(--c10); } .b11 { background: var(--c11); }
.b12 { background: var(--c12); } .b13 { background: var(--c13); } .b14 { background: var(--c14); } .b15 { background: var(--c15); }
.fbg { color: var(--bg); } .bfg { background: var(--fg); }
.bold { font-weight: 650; }
.dim { opacity: 0.7; }
.ital { font-style: italic; }
.ul { text-decoration: underline; }
.blink { animation: blink 1.2s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .blink { animation: none; text-decoration: underline dotted; } }

/* ---- the direction pad */
#pad { background: var(--bar); border-top: 1px solid var(--line); padding: 8px 16px; }
.pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 76px));
  gap: 6px;
  justify-content: center;
}
.pad-grid button { padding: 10px 0; font-family: var(--mono); }

/* ---- the input */
#inputbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bar);
  border-top: 1px solid var(--line);
}
#prompt-sign { color: var(--accent); font: 600 16px var(--mono); }
#input {
  flex: 1;
  min-width: 0;
  font: var(--size) var(--mono);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}
#input.secret { border-color: var(--accent); }
#btn-send { padding: 8px 14px; }

/* ---- dialogs */
dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
#settings { width: min(520px, calc(100vw - 32px)); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 16px; text-wrap: balance; }
.close { border: 0; font-size: 16px; padding: 4px 8px; }
.tabs { display: flex; gap: 4px; padding: 8px 16px 0; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 10px; color: var(--dim); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab-body { padding: 12px 16px 16px; overflow-y: auto; max-height: calc(100dvh - 170px); }
.tab-body p.hint { margin: 0 0 10px; color: var(--dim); font-size: 13px; max-width: 70ch; }
.tab-body code { font-family: var(--mono); font-size: 12.5px; color: var(--fg); }
.defs { display: flex; flex-direction: column; gap: 6px; }
.def { display: flex; align-items: center; gap: 6px; }
.def input[type="text"], .add input, textarea, select, .settings-body input[type="range"] {
  font: 13px var(--mono);
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.def input[type="text"] { flex: 1; min-width: 0; }
.def.off input[type="text"] { opacity: 0.55; }
.def .del { color: var(--bad); }
.def input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.add { display: flex; gap: 6px; margin-top: 10px; }
.add input { flex: 1; min-width: 0; }
.count { color: var(--dim); font-size: 12px; margin: 8px 0 0; }
textarea { width: 100%; min-height: 260px; resize: vertical; }
.filebtns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.report { white-space: pre-wrap; font: 12.5px var(--mono); color: var(--dim); }
.settings-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.settings-body .row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.settings-body .row.check { justify-content: flex-start; }
.settings-body select { min-width: 140px; }
.note { margin: 0; color: var(--dim); font-size: 13px; }
.switches { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0;
  display: flex; flex-wrap: wrap; gap: 8px 18px; }
.switches legend { color: var(--dim); font-size: 12px; padding: 0 4px; }
.switches label { display: flex; align-items: center; gap: 6px; }
.switches input, .kind-switch input { accent-color: var(--accent); width: 16px; height: 16px; }
.kind-switch { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 13px; }
.defs.all-off { opacity: 0.5; }

@media (max-width: 560px) {
  #bar { gap: 8px; }
  .tools { margin-left: 0; width: 100%; }
  .tools button { flex: 1; padding: 6px 4px; }
  #btn-send { display: none; }
}
