/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2430;
  --border: #2a3441;
  --border-soft: #232c38;
  --fg: #e6edf3;
  --fg-dim: #8b98a5;
  --fg-faint: #5c6773;
  --accent: #4f9cf9;
  --accent-soft: rgba(79, 156, 249, 0.16);
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --key-bg: #212a36;
  --key-bg-active: #2f3d4e;
  --key-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  --radius: 10px;
  --radius-sm: 7px;
  --pane-head: 24px;
  --topbar-h: 48px;
  --tabbar-h: 38px;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Symbols Nerd Font Mono sits AFTER the generic `monospace`: it has no Latin
     glyphs but a much wider advance, so letting it win the cascade would make
     xterm measure a bogus cell. Last position = powerline/devicon glyphs only. */
  --font-mono: "JetBrainsMono Nerd Font", "JetBrains Mono", ui-monospace, SFMono-Regular,
    "SF Mono", Menlo, Consolas, "Liberation Mono", monospace, "Symbols Nerd Font Mono";
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elev: #f6f8fa;
  --bg-elev-2: #eaeef2;
  --border: #d0d7de;
  --border-soft: #e4e8ec;
  --fg: #1f2328;
  --fg-dim: #59636e;
  --fg-faint: #848d97;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.12);
  --key-bg: #eef1f4;
  --key-bg-active: #dfe4ea;
  --key-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

/* ------------------------------------------------------------------ shell */
#app {
  position: fixed;
  inset: 0;
  /* Set from JS off visualViewport so the key bar rides above the soft keyboard. */
  height: var(--app-h, 100dvh);
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  /* The single implicit column must be pinned to the viewport width: left on
     `auto` it sizes to the key bar's max-content and drags the whole layout
     wider than the screen. */
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
}

#app > * { min-width: 0; }

/* ----------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: calc(var(--topbar-h) + var(--safe-t));
  padding: var(--safe-t) calc(8px + var(--safe-r)) 0 calc(8px + var(--safe-l));
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
}

.topbar__name {
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__meta {
  font-size: 11px;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.iconbtn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  font-size: 17px;
  transition: background 0.12s, color 0.12s;
}
.iconbtn:active { background: var(--bg-elev-2); }
.iconbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.iconbtn[hidden] { display: none; }

.status-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fg-faint);
  margin-inline: 4px 2px;
  transition: background 0.2s;
}
.status-dot[data-state="online"] { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-dot[data-state="connecting"] { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.status-dot[data-state="offline"] { background: var(--danger); }

@keyframes pulse { 50% { opacity: 0.3; } }

/* ------------------------------------------------------------------- tabs */
.tabbar {
  display: flex;
  align-items: stretch;
  height: var(--tabbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding-inline: var(--safe-l) var(--safe-r);
}

.tabbar__scroll {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar__scroll::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 46vw;
  padding: 0 8px 0 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--fg-dim);
  font-size: 12.5px;
  border: 1px solid transparent;
}
.tab[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: rgba(79, 156, 249, 0.35);
}
.tab__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab__close {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-size: 13px;
  color: var(--fg-faint);
}
.tab__close:active { background: var(--bg-elev); color: var(--danger); }
.tab__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.tab__dot[data-dead="true"] { background: var(--danger); }

.tabbar__add {
  flex: 0 0 auto;
  width: 38px;
  display: grid;
  place-items: center;
  color: var(--fg-dim);
  font-size: 20px;
  border-left: 1px solid var(--border-soft);
}
.tabbar__add:active { background: var(--bg-elev-2); }

/* --------------------------------------------------------------- terminal */
.term-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  overflow: hidden;
  padding-inline: var(--safe-l) var(--safe-r);
  /* Drag and long-press are handled in code. Leaving the browser its own
     panning, overscroll and long-press callout only fights those gestures. */
  touch-action: none;
  -webkit-touch-callout: none;
}

#terminal { width: 100%; height: 100%; }

/* Split panes. The separator is drawn inside the pane rather than as a gap, so
   the terminals keep every column the layout gives them. */
.pane--split { box-shadow: inset 0 0 0 1px var(--border); }
.pane--focused { box-shadow: inset 0 0 0 1px var(--accent); }

/* The control layer sits over the grid and is transparent to the pointer; only
   the controls themselves take clicks, so dragging and selecting still reach
   the terminal underneath. */
.pane-ctls { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.pane-ctls[hidden] { display: none; }

.pane-ctl { position: absolute; }

/* A header per pane: which shell this is, which shell to swap in, and a way to
   open another. The terminal below it is inset by the same height, so the strip
   never covers a line of output. */
.pane-head {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--pane-head);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 8px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--fg-dim);
  pointer-events: auto;
}
.pane-head--focused {
  background: var(--bg-elev-2);
  color: var(--fg);
  box-shadow: inset 2px 0 0 var(--accent);
}
.pane-head__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.pane-head__pick {
  flex: 0 0 auto;
  max-width: 116px;
  height: 18px;
  padding: 0 2px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--border);
}

.pane-head__add {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--border);
}
.pane-head__add:hover { color: var(--accent); border-color: var(--accent); }

.pane-head__close {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  font-size: 11px;
  line-height: 1;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg-dim);
  border: 1px solid var(--border);
}
.pane-head__close:hover { color: var(--danger); border-color: var(--danger); }

/* An empty pane is nothing but its own invitation to fill it. */
.pane-ctl__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--fg-faint);
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  pointer-events: auto;
}
.pane-ctl__empty:hover { color: var(--accent); }
#terminal .xterm { padding: 4px 6px; height: 100%; }
.xterm-viewport::-webkit-scrollbar { width: 6px; }
.xterm-viewport::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---------------------------------------------------------------- inputbar */
.inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

#imeInput {
  resize: none;
  outline: none;
  /* Below 16px iOS Safari zooms the whole page when the field takes focus. */
  font-size: 16px;
  font-family: var(--font-mono);
  line-height: 1.35;
}

/* Invisible mode: the field trails the terminal, taps fall through to xterm so
   selection keeps working, and focus is moved here in code. */
.inputbar[data-mode="overlay"] {
  position: relative;
  height: 0;
  padding: 0;
  overflow: visible;
}
.inputbar[data-mode="overlay"] #imeInput {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 20px;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}
.inputbar[data-mode="overlay"] .inputbar__send { display: none; }

/* Visible mode. */
.inputbar[data-mode="bar"] {
  padding: 7px 8px;
  padding-inline: calc(8px + var(--safe-l)) calc(8px + var(--safe-r));
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
}
.inputbar[data-mode="bar"] #imeInput {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 96px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--fg);
  caret-color: var(--accent);
}
.inputbar[data-mode="bar"] #imeInput:focus { border-color: var(--accent); }

.inputbar__send {
  flex: 0 0 auto;
  width: 42px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #04121f;
  font-size: 16px;
}
.inputbar__send:active { filter: brightness(0.9); }

.preedit {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92%, 420px);
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preedit[hidden] { display: none; }
.preedit__label {
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(2px);
  text-align: center;
  padding: 24px;
  z-index: 5;
}
.overlay[hidden] { display: none; }
.overlay__msg { font-size: 14px; color: var(--fg-dim); max-width: 30ch; line-height: 1.5; }
.overlay__title { font-size: 16px; font-weight: 600; }

.scroll-bottom {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
.scroll-bottom[hidden] { display: none; }

/* Opposite corner from the jump-to-bottom button so the two never overlap. */
.copy-sel {
  position: absolute;
  left: calc(12px + var(--safe-l));
  bottom: 12px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
.copy-sel:active { filter: brightness(0.9); }
.copy-sel[hidden] { display: none; }

/* -------------------------------------------------------------- key board */
.keybar {
  min-width: 0;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  user-select: none;
  -webkit-user-select: none;
}
.keybar[hidden] { display: none; }

.keybar__tabs {
  display: flex;
  gap: 2px;
  padding: 5px 6px 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-inline: calc(6px + var(--safe-l)) calc(6px + var(--safe-r));
}
.keybar__tabs::-webkit-scrollbar { display: none; }

.keybar__tab {
  flex: 0 0 auto;
  padding: 4px 10px;
  border-radius: 6px 6px 0 0;
  font-size: 11.5px;
  color: var(--fg-faint);
}
.keybar__tab[aria-selected="true"] { background: var(--bg-elev-2); color: var(--accent); }

.keybar__rows {
  display: flex;
  min-width: 0;
  gap: 5px;
  padding: 6px;
  padding-inline: calc(6px + var(--safe-l)) calc(6px + var(--safe-r));
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-elev-2);
}
.keybar__rows::-webkit-scrollbar { display: none; }
.keybar__rows[data-wrap="true"] { flex-wrap: wrap; overflow-x: hidden; }

.key {
  flex: 0 0 auto;
  min-width: 42px;
  height: 40px;
  padding: 0 9px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--key-bg);
  border: 1px solid var(--border-soft);
  box-shadow: var(--key-shadow);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background 0.08s, transform 0.08s;
}
.key:active, .key[data-pressed="true"] { background: var(--key-bg-active); transform: translateY(1px); }
.key[data-kind="mod"] { font-weight: 600; }
.key[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.key[data-locked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #04121f;
}
.key[data-kind="action"] { font-family: var(--font-ui); }

/* ------------------------------------------------------------- side panel */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 20;
}
.scrim[data-open="true"] { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(340px, 88vw);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 21;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
  padding-bottom: var(--safe-b);
}
.panel[data-open="true"] { transform: none; }

.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.panel__head h2 { margin: 0; font-size: 15px; flex: 1; }
.panel__body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; }

.section { margin-bottom: 22px; }
.section > h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-faint);
}

/* `display: flex` on a class outranks the UA stylesheet's [hidden], so a row
   hidden from script needs this to actually disappear. */
.row[hidden] { display: none; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.row:last-child { border-bottom: none; }
.row__label { flex: 1; min-width: 0; }
.row__hint { display: block; font-size: 11px; color: var(--fg-faint); margin-top: 2px; }
.row__value { color: var(--fg-dim); font-family: var(--font-mono); font-size: 12px; text-align: right; }

select, input[type="text"], input[type="password"], input[type="number"], textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 13px;
  outline: none;
  width: 100%;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: var(--font-mono); font-size: 12px; line-height: 1.5; resize: vertical; }

.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 1; }
.switch__track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  transition: background 0.16s, border-color 0.16s;
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fg-faint);
  transition: transform 0.16s, background 0.16s;
}
.switch input:checked + .switch__track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(18px); background: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
}
.btn:active { background: var(--border); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #04121f; }
.btn--danger { color: var(--danger); border-color: rgba(248, 81, 73, 0.4); }
.btn--block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.stepper { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.stepper button {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}
.stepper span { min-width: 34px; text-align: center; font-family: var(--font-mono); font-size: 12px; }

.meter { height: 5px; border-radius: 3px; background: var(--bg-elev-2); overflow: hidden; margin-top: 5px; }
.meter__fill { height: 100%; background: var(--accent); transition: width 0.4s; }
.meter__fill[data-level="warn"] { background: var(--warn); }
.meter__fill[data-level="crit"] { background: var(--danger); }

.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.session-item__meta { flex: 1; min-width: 0; }
.session-item .btn { padding: 7px 10px; }
.session-item__meta small { display: block; color: var(--fg-faint); font-size: 11px; font-family: var(--font-mono); }

/* ----------------------------------------------------------------- dialog */
dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--fg);
  padding: 0;
  width: min(520px, 92vw);
  max-height: 86dvh;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog__head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dialog__head h2 { margin: 0; font-size: 15px; flex: 1; }
.dialog__body { padding: 14px 16px; overflow-y: auto; max-height: 60dvh; }
.dialog__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }

.hint { font-size: 11.5px; color: var(--fg-faint); line-height: 1.6; margin: 6px 0 0; }
.hint code {
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0 4px;
}

/* ------------------------------------------------------------------ login */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
  z-index: 40;
  padding: 24px;
}
.login[hidden] { display: none; }
.login__card { width: min(360px, 100%); }
.login__logo { font-size: 34px; text-align: center; margin-bottom: 10px; }
.login__card h1 { margin: 0 0 4px; font-size: 19px; text-align: center; }
.login__card p { margin: 0 0 20px; font-size: 12.5px; color: var(--fg-dim); text-align: center; }
.login__field { margin-bottom: 12px; }
.login__field label { display: block; font-size: 12px; color: var(--fg-dim); margin-bottom: 5px; }
.login__error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 8px 0 0; text-align: center; }

/* ------------------------------------------------------------------ toast */
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}
.toast[data-kind="error"] { border-color: rgba(248, 81, 73, 0.5); color: var(--danger); }
.toast[data-kind="ok"] { border-color: rgba(63, 185, 80, 0.5); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------- key editor rows */
.keyedit { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.keyedit input { flex: 1 1 0; min-width: 0; }
.keyedit input.keyedit__label { flex: 0 0 74px; }
.keyedit button { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border); color: var(--fg-faint); }

/* ------------------------------------------------------------ wider views */
@media (min-width: 820px) {
  .key { min-width: 46px; height: 38px; font-size: 13.5px; }
  .keybar__rows { flex-wrap: wrap; overflow-x: visible; }
  .tab { max-width: 220px; }
}

@media (hover: hover) {
  .iconbtn:hover { background: var(--bg-elev-2); color: var(--fg); }
  .key:hover { background: var(--key-bg-active); }
  .btn:hover { border-color: var(--accent); }
}
