/* ==========================================================================
   xctl — X account control.  Operator-only ops tool.
   Signature: each account is a living X identity. The roster is a grid of
   compact cards (hue accent strip + small avatar + @handle); opening one slides
   in a detail drawer whose tabs hold Profile, Keys, History and Messages.
   Monochrome cool-graphite ink true to the X rebrand; white pill primaries like
   X's own buttons; colour only ever signals state.
   ========================================================================== */

@font-face {
  font-family: "Plex Sans";
  src: url("./fonts/plex-sans.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("./fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Plex Mono";
  src: url("./fonts/plex-mono-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  --ink-900: #0a0c11;
  --ink-850: #0e121a;
  --ink-800: #141922;
  --ink-780: #171d27;
  --ink-750: #1b212c;
  --ink-700: #232a36;
  --line:        rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);

  --paper:       #eef1f6;
  --paper-dim:   #99a2b2;
  --paper-faint: #646e80;

  --pill:      #f3f5f9;
  --pill-ink:  #0a0c11;

  --live: #5b9dff;
  --ok:   #3ecf8e;
  --bad:  #ff6b5e;
  --warn: #f2b14c;

  --focus: #8fb8ff;

  --r-card: 14px;
  --r-ctl: 9px;
  --r-pill: 999px;

  --shell: 1180px;
  --gutter: 26px;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 80% -10%, rgba(91, 157, 255, .06), transparent 60%),
    radial-gradient(900px 540px at 4% 2%, rgba(62, 207, 142, .03), transparent 55%),
    var(--ink-900);
  background-attachment: fixed;
  color: var(--paper);
  font-family: "Plex Sans", system-ui, sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.mono { font-family: "Plex Mono", ui-monospace, monospace; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
img { display: block; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---- toasts -------------------------------------------------------------- */
.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 120; pointer-events: none; width: min(92vw, 460px);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; width: 100%;
  background: #0d1119; border: 1px solid var(--line-strong);
  border-left: 3px solid var(--paper-faint); border-radius: 12px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .8);
  font-size: 14px; animation: toast-in .28s var(--ease);
}
.toast.is-ok  { border-left-color: var(--ok); }
.toast.is-bad { border-left-color: var(--bad); }
.toast .ico { flex: none; width: 17px; height: 17px; }
.toast.is-ok .ico  { color: var(--ok); }
.toast.is-bad .ico { color: var(--bad); }
.toast.is-leaving { animation: toast-out .22s var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px); } }

/* ==========================================================================
   SIGN-IN
   ========================================================================== */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 40px var(--gutter); }
.gate-card { width: min(420px, 100%); text-align: left; }
.brandmark {
  display: inline-grid; place-items: center; width: 60px; height: 60px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: linear-gradient(160deg, var(--ink-780), var(--ink-850));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}
.brandmark svg { width: 28px; height: 28px; }
.gate h1 { margin: 26px 0 6px; font-size: 30px; font-weight: 400; letter-spacing: -.015em; line-height: 1.12; }
.gate .sub { margin: 0 0 30px; max-width: 42ch; color: var(--paper-dim); font-size: 15px; }
.wallets { display: grid; gap: 11px; }
.gate .err { margin-top: 18px; min-height: 1.2em; }
.gate .foot { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--paper-faint); font-size: 12.5px; }

/* ==========================================================================
   APP SHELL
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--ink-900) 82%, transparent);
  backdrop-filter: blur(14px) saturate(130%);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: var(--shell); margin: 0 auto; padding: 13px var(--gutter); display: flex; align-items: center; gap: 16px; }
.wordmark { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wordmark .glyph {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: linear-gradient(160deg, var(--ink-780), var(--ink-850));
}
.wordmark .glyph svg { width: 17px; height: 17px; }
.wordmark .name { font-size: 17px; letter-spacing: .02em; }
.wordmark .desc { color: var(--paper-faint); font-size: 12px; border-left: 1px solid var(--line); padding-left: 11px; margin-left: 2px; }
.topbar .spacer { flex: 1; }

.queue {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--paper-dim);
  padding: 6px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--ink-800);
  opacity: 0; transform: translateY(-2px); transition: opacity .25s, transform .25s;
}
.queue.on { opacity: 1; transform: none; }
.queue .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pip 1.5s var(--ease) infinite; }
@keyframes pip {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 60%, transparent); }
  70%  { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.usage {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--paper-dim);
  padding: 6px 11px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--ink-800); white-space: nowrap;
}
.usage[hidden] { display: none; }
.usage svg { width: 13px; height: 13px; color: var(--paper-faint); }

.wallet-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--ink-800); font-size: 13px;
}
.wallet-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.wallet-chip .addr { color: var(--paper-dim); }

/* ---- buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong);
  background: var(--ink-750); color: var(--paper); font-size: 13px; line-height: 1;
  transition: background .16s, border-color .16s, transform .06s, opacity .16s; white-space: nowrap; user-select: none;
}
.btn:hover:not(:disabled) { background: var(--ink-700); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--paper-dim); }
.btn.ghost:hover:not(:disabled) { color: var(--paper); background: var(--ink-800); }
.btn.pill { background: var(--pill); color: var(--pill-ink); border-color: transparent; border-radius: var(--r-pill); padding: 9px 16px; }
.btn.pill:hover:not(:disabled) { background: #fff; }
.btn.pill svg { opacity: .85; }
.btn.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); color: var(--bad); background: transparent; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.btn.danger.solid { background: color-mix(in srgb, var(--bad) 88%, #000); color: #fff; border-color: transparent; }
.btn.danger.solid:hover:not(:disabled) { background: var(--bad); }
.btn.sm { padding: 7px 11px; font-size: 12.5px; }
.btn.big { padding: 13px 18px; font-size: 15px; }
.btn.block { width: 100%; }
.spin { display: inline-block; }
.spin circle { opacity: .25; }
.spin path { opacity: .9; transform-origin: center; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--paper-dim);
  transition: background .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--ink-750); color: var(--paper); }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* ---- main content -------------------------------------------------------- */
.main { max-width: var(--shell); margin: 0 auto; padding: 26px var(--gutter) 90px; }
.section-head { display: flex; align-items: flex-end; gap: 14px; margin: 4px 0 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 26px; font-weight: 400; letter-spacing: -.012em; }
.section-head .count { color: var(--paper-faint); font-size: 13px; padding-bottom: 5px; }
.section-head .spacer { flex: 1; }

/* generic inline error slot */
.err { color: var(--bad); font-size: 13px; line-height: 1.45; display: flex; gap: 7px; align-items: flex-start; }
.err:empty { display: none; }
.err svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }

/* ==========================================================================
   ACCOUNT GRID — compact cards
   ========================================================================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }

.card {
  --hue: 220;
  position: relative; display: flex; flex-direction: column;
  background: var(--ink-800); border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: hidden; cursor: pointer; transition: border-color .18s, background .18s, transform .08s;
}
.card:hover { border-color: var(--line-strong); background: var(--ink-780); }
.card:active { transform: translateY(1px); }
.card.is-open { border-color: color-mix(in srgb, var(--live) 40%, var(--line-strong)); }

/* slim living-profile signature: a hue accent strip, not a banner */
.card .accent { height: 3px; position: relative; overflow: hidden;
  background: linear-gradient(90deg, hsl(var(--hue) 46% 34%), hsl(calc(var(--hue) + 28) 40% 22%)); }
.card.is-working .accent::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, #fff, transparent); opacity: .7; animation: slide 1.15s var(--ease) infinite;
}
@keyframes slide { 0% { left: -42%; } 100% { left: 100%; } }

.card-main { display: flex; align-items: center; gap: 12px; padding: 13px 14px 10px; }
.card-avatar {
  position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: hsl(var(--hue) 30% 20%); overflow: hidden; display: grid; place-items: center;
  box-shadow: 0 0 0 1px var(--line-strong), 0 0 0 3px hsl(var(--hue) 42% 26% / .35);
}
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-avatar .mg { font-family: "Plex Mono", monospace; font-weight: 500; font-size: 16px; color: hsl(var(--hue) 50% 74%); text-transform: uppercase; }
.card.is-working .card-avatar { box-shadow: 0 0 0 2px var(--live), 0 0 14px -3px color-mix(in srgb, var(--live) 70%, transparent); }

.card-id { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.card-name { font-size: 14.5px; letter-spacing: -.005em; color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-handle { font-family: "Plex Mono", monospace; font-size: 12.5px; color: var(--paper-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-handle.none { color: var(--paper-faint); }

.card-meta { display: flex; align-items: center; gap: 8px; padding: 0 14px 12px; }
.card-meta .spacer { flex: 1; }

.card-actions { margin-top: auto; display: flex; align-items: center; gap: 2px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--ink-850); }
.card-actions .spacer { flex: 1; }
.card-actions .sep { width: 1px; height: 18px; background: var(--line); margin: 0 5px; flex: none; }
.card-open { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--paper-faint); }
.card-open svg { width: 16px; height: 16px; transform: rotate(-90deg); }

/* bulk-selection affordance */
.card.selected { border-color: color-mix(in srgb, var(--live) 55%, var(--line-strong)); background: color-mix(in srgb, var(--live) 6%, var(--ink-800)); }
.card.selected.is-open { background: color-mix(in srgb, var(--live) 8%, var(--ink-780)); }
.card-check { display: inline-grid; place-items: center; width: 30px; height: 30px; cursor: pointer; }
.card-chk { width: 16px; height: 16px; accent-color: var(--live); cursor: pointer; }

/* bulk toolbar above the grid */
.bulkbar {
  position: sticky; top: 63px; z-index: 30; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 10px 14px; border-radius: var(--r-ctl);
  border: 1px solid color-mix(in srgb, var(--live) 40%, var(--line-strong)); background: color-mix(in srgb, var(--live) 9%, var(--ink-800));
  backdrop-filter: blur(8px);
}
.bulkbar[hidden] { display: none; }
.bulk-count { font-size: 13px; color: var(--paper); }
.bulkbar .spacer { flex: 1; }

.geo {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: var(--r-pill);
  background: var(--ink-850); border: 1px solid var(--line);
  font-family: "Plex Mono", monospace; font-size: 10.5px; letter-spacing: .04em; color: var(--paper-dim); text-transform: uppercase;
}
.card-actions .geo { background: var(--ink-800); }
.geo svg { width: 12px; height: 12px; }

.lamp { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--paper-faint); }
.lamp .d { width: 7px; height: 7px; border-radius: 50%; background: var(--paper-faint); flex: none; }
.lamp .t { display: none; }
.lamp[data-state="working"] { color: var(--live); }
.lamp[data-state="working"] .d { background: var(--live); animation: blink 1s steps(2, start) infinite; }
.lamp[data-state="ok"] { color: var(--ok); } .lamp[data-state="ok"] .d { background: var(--ok); }
.lamp[data-state="warn"] { color: var(--warn); } .lamp[data-state="warn"] .d { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.lamp[data-state="error"] { color: var(--bad); } .lamp[data-state="error"] .d { background: var(--bad); }
@keyframes blink { 50% { opacity: .35; } }

/* ==========================================================================
   DETAIL DRAWER  (holds the four-tab panel for one account)
   ========================================================================== */
dialog.drawer {
  position: fixed; top: 0; right: 0; margin: 0; padding: 0; border: 0;
  height: 100dvh; max-height: 100dvh; width: min(560px, 100vw);
  border-left: 1px solid var(--line-strong); background: var(--ink-800); color: var(--paper);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: -30px 0 80px -30px rgba(0, 0, 0, .8);
}
dialog.drawer::backdrop { background: rgba(5, 6, 10, .6); backdrop-filter: blur(3px); }
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] { animation: drawer-in .28s var(--ease); }
  dialog.drawer::backdrop { animation: fade-in .25s; }
}
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes fade-in { from { opacity: 0; } }

.drawer-top { display: flex; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-top .label { font-size: 12.5px; color: var(--paper-faint); }
.drawer-top .spacer { flex: 1; }
.drawer-confirm:empty { display: none; }
.drawer-confirm > .confirm { margin: 12px 16px 0; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.detail { display: block; }

.dhead { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px; }
.dhead .accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; overflow: hidden;
  background: linear-gradient(90deg, hsl(var(--hue) 45% 30%), hsl(calc(var(--hue) + 30) 40% 22%)); }
.detail.is-working .dhead .accent::after {
  content: ""; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, #fff, transparent); opacity: .7; animation: slide 1.15s var(--ease) infinite;
}
.avatar {
  position: relative; flex: none; width: 56px; height: 56px; border-radius: 50%;
  background: hsl(var(--hue) 30% 20%); box-shadow: 0 0 0 1px var(--line-strong);
  display: grid; place-items: center; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .monogram { font-family: "Plex Mono", monospace; font-weight: 500; font-size: 22px; color: hsl(var(--hue) 48% 72%); text-transform: uppercase; }
.detail.is-working .avatar { box-shadow: 0 0 0 2px var(--live), 0 0 16px -2px color-mix(in srgb, var(--live) 70%, transparent); }
.dhead .who { min-width: 0; }
.dhead .who .name { font-size: 18px; letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
.dhead .who .name .unset { color: var(--paper-faint); }
.dhead .who .handle { font-family: "Plex Mono", monospace; font-size: 13px; color: var(--paper-dim); margin-top: 2px; }
.dhead .who .handle.none { color: var(--paper-faint); }
.hcontrols { display: flex; flex-wrap: wrap; gap: 7px; margin-left: auto; }

.ipline {
  display: none; align-items: center; gap: 9px; flex-wrap: wrap; margin: 0 16px 14px; padding: 10px 12px;
  background: var(--ink-850); border: 1px solid var(--line); border-radius: var(--r-ctl); font-size: 12.5px; color: var(--paper-dim);
}
.ipline.show { display: flex; }
.ipline .ip { font-family: "Plex Mono", monospace; color: var(--paper); font-size: 13px; }
.ipline .k { color: var(--paper-faint); }
.ipline svg { width: 14px; height: 14px; color: var(--ok); flex: none; }

/* ---- tabs ---------------------------------------------------------------- */
.tabs {
  display: flex; gap: 2px; padding: 0 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; position: sticky; top: 0; background: var(--ink-800); z-index: 2;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 12px; background: transparent; border: 0;
  border-bottom: 2px solid transparent; color: var(--paper-faint); font-size: 13px; white-space: nowrap; transition: color .15s;
}
.tab svg { width: 15px; height: 15px; }
.tab:hover { color: var(--paper-dim); }
.tab[aria-selected="true"] { color: var(--paper); border-bottom-color: var(--paper); }
.tabpanel { padding: 16px; }
.tabpanel[hidden] { display: none; }

/* ---- Profile editor ------------------------------------------------------ */
.editor { display: grid; gap: 15px; }
.field { display: grid; gap: 7px; }
.field > .lab { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; color: var(--paper-dim); }
.field .lab .spacer { flex: 1; }
.counter { font-family: "Plex Mono", monospace; font-size: 11.5px; color: var(--paper-faint); }
.counter.warn { color: var(--warn); } .counter.over { color: var(--bad); }
.inp, .ta {
  width: 100%; padding: 10px 12px; background: var(--ink-850); color: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-ctl); font: inherit; font-size: 14px; transition: border-color .15s;
}
.inp::placeholder, .ta::placeholder { color: var(--paper-faint); }
.inp:focus, .ta:focus { outline: none; border-color: color-mix(in srgb, var(--focus) 60%, var(--line)); }
.ta { resize: vertical; min-height: 72px; line-height: 1.5; }
.inp.mono { font-family: "Plex Mono", monospace; font-size: 13px; }
.images { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.images .hint { color: var(--paper-faint); font-size: 12px; flex: 1; min-width: 140px; }
.editor-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-foot .saved { color: var(--ok); font-size: 13px; display: none; align-items: center; gap: 6px; }
.editor-foot .saved svg { width: 15px; height: 15px; }
.editor-foot .saved.show { display: inline-flex; }
.editor-foot .spacer { flex: 1; }

.sub { border-top: 1px solid var(--line); padding-top: 15px; display: grid; gap: 10px; }
.sub-title { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--paper); }
.sub-title svg { width: 15px; height: 15px; color: var(--paper-dim); }
.sub-title .tag { font-size: 11px; color: var(--paper-faint); }
.handle-edit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.handle-edit .at { font-family: "Plex Mono", monospace; color: var(--paper-faint); }
.handle-edit .inp { flex: 1; min-width: 150px; }

.confirm {
  display: grid; gap: 10px; padding: 13px; border-radius: var(--r-ctl);
  background: color-mix(in srgb, var(--bad) 8%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line));
  font-size: 13px; color: var(--paper-dim);
}
.confirm .q { line-height: 1.5; }
.confirm .q b { color: var(--paper); font-weight: 400; }
.confirm .row2 { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.confirm .row2 .spacer { flex: 1; }
.confirm .typed { flex: 1; min-width: 140px; }

/* ==========================================================================
   KEYS
   ========================================================================== */
.sensitive {
  display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-ctl);
  background: color-mix(in srgb, var(--warn) 9%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 32%, var(--line));
  color: var(--paper-dim); font-size: 12.5px; line-height: 1.5;
}
.sensitive svg { width: 15px; height: 15px; color: var(--warn); flex: none; margin-top: 1px; }
.keys { display: grid; gap: 14px; }
.keys-masked { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-ctl); background: var(--ink-850); }
.keys-masked .dots { font-family: "Plex Mono", monospace; letter-spacing: .25em; color: var(--paper-faint); font-size: 18px; flex: 1; min-width: 120px; }
.cred { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--ink-850); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.cred .lab { font-size: 11px; color: var(--paper-faint); width: 70px; flex: none; }
.cred .val { font-family: "Plex Mono", monospace; font-size: 13.5px; color: var(--paper); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.otp { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--ink-850); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.otp-ring { position: relative; width: 54px; height: 54px; flex: none; }
.otp-ring svg { width: 54px; height: 54px; transform: rotate(-90deg); }
.otp-ring .track { stroke: var(--line-strong); }
.otp-ring .arc { stroke: var(--live); transition: stroke .3s; }
.otp-ring .secs { position: absolute; inset: 0; display: grid; place-items: center; font-family: "Plex Mono", monospace; font-size: 13px; color: var(--paper-dim); }
.otp-main { min-width: 0; }
.otp-code { font-family: "Plex Mono", monospace; font-weight: 500; font-size: 30px; letter-spacing: .14em; color: var(--paper); }
.otp-sub { font-size: 12px; color: var(--paper-faint); margin-top: 2px; }
.otp.expiring .arc { stroke: var(--warn); }
.otp > .icon-btn { margin-left: auto; }

/* ==========================================================================
   HISTORY
   ========================================================================== */
.timeline { display: grid; gap: 0; }
.event { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding: 10px 0; }
.event:not(:last-child) { border-bottom: 1px solid var(--line); }
.event .node { position: relative; display: flex; justify-content: center; padding-top: 4px; }
.event .node .d { width: 9px; height: 9px; border-radius: 50%; background: hsl(var(--hue) 45% 55%); box-shadow: 0 0 0 3px color-mix(in srgb, hsl(var(--hue) 45% 55%) 20%, transparent); }
.event .body { min-width: 0; }
.ev-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ev-field { font-family: "Plex Mono", monospace; font-size: 11px; text-transform: lowercase; color: var(--paper-dim); padding: 2px 7px; border: 1px solid var(--line); border-radius: var(--r-pill); }
.ev-time { font-size: 12px; color: var(--paper-faint); margin-left: auto; }
.ev-change { margin-top: 5px; font-size: 13.5px; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.ev-change .from { color: var(--paper-faint); text-decoration: line-through; overflow-wrap: anywhere; }
.ev-change .arrow { color: var(--paper-faint); display: inline-flex; }
.ev-change .arrow svg { width: 14px; height: 14px; }
.ev-change .to { color: var(--paper); overflow-wrap: anywhere; }
.ev-change .mono { font-family: "Plex Mono", monospace; font-size: 13px; }

/* ==========================================================================
   MESSAGES
   ========================================================================== */
.compose { display: grid; gap: 9px; }
.compose-lab { display: flex; gap: 8px; font-size: 12.5px; color: var(--paper-dim); }
.compose-lab .spacer { flex: 1; }
.compose-foot { display: flex; align-items: center; gap: 12px; }
.compose-foot .spacer { flex: 1; }
.media-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 170px; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--paper-dim); background: var(--card); }
.media-chip > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-chip .chip-x { flex: none; width: 18px; height: 18px; line-height: 16px; text-align: center; border: none; border-radius: 50%; cursor: pointer; color: var(--paper-faint); background: transparent; font-size: 15px; }
.media-chip .chip-x:hover { color: var(--bad); background: var(--line); }
.tweet-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.tweet-tools .spacer { flex: 1; }
.tweet-list { display: grid; gap: 8px; margin-top: 12px; }
.tweet { display: flex; gap: 11px; padding: 11px 12px; background: var(--ink-850); border: 1px solid var(--line); border-radius: var(--r-ctl); transition: border-color .15s, background .15s; }
.tweet.sel { border-color: color-mix(in srgb, var(--live) 45%, var(--line)); background: color-mix(in srgb, var(--live) 7%, var(--ink-850)); }
.tweet .chk { margin-top: 3px; flex: none; width: 16px; height: 16px; accent-color: var(--live); }
.tweet .body { flex: 1; min-width: 0; }
.tweet .text { font-size: 13.5px; line-height: 1.5; color: var(--paper); overflow-wrap: anywhere; white-space: pre-wrap; }
.tweet .meta { margin-top: 6px; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--paper-faint); }
.tweet .meta a { color: var(--live); text-decoration: none; }
.tweet .meta a:hover { text-decoration: underline; }
.tweet .del { flex: none; }
.muted { color: var(--paper-faint); font-size: 13px; text-align: center; padding: 22px 10px; }

/* ---- empty state --------------------------------------------------------- */
.empty {
  grid-column: 1 / -1;
  border: 1px dashed var(--line-strong); border-radius: var(--r-card); padding: 48px 28px; text-align: center;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .012) 0 2px, transparent 2px 8px), var(--ink-850);
}
.empty .ghost { width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 18px; border: 2px dashed var(--line-strong); display: grid; place-items: center; color: var(--paper-faint); }
.empty .ghost svg { width: 24px; height: 24px; }
.empty h3 { margin: 0 0 7px; font-size: 20px; font-weight: 400; }
.empty p { margin: 0 auto 22px; color: var(--paper-dim); max-width: 42ch; font-size: 14.5px; }

/* ---- add-account dialog -------------------------------------------------- */
dialog.modal { width: min(520px, 94vw); padding: 0; border: 0; background: transparent; color: var(--paper); max-height: 90vh; }
dialog.modal::backdrop { background: rgba(5, 6, 10, .64); backdrop-filter: blur(4px); }
.modal-in { background: var(--ink-800); border: 1px solid var(--line-strong); border-radius: 18px; overflow: hidden; box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .85); display: flex; flex-direction: column; max-height: 90vh; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 400; }
.modal-head .spacer { flex: 1; }
.modal-head svg { width: 18px; height: 18px; color: var(--paper-dim); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 15px; }
.modal-body .note { display: flex; gap: 9px; align-items: flex-start; padding: 11px 13px; border-radius: 10px; background: var(--ink-850); border: 1px solid var(--line); color: var(--paper-dim); font-size: 12.5px; line-height: 1.5; }
.modal-body .note svg { width: 15px; height: 15px; color: var(--paper-faint); flex: none; margin-top: 1px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.modal-foot { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--line); }
.modal-foot .err { flex: 1; }

/* bulk run list */
.bulk-list { display: grid; gap: 6px; }
.bulk-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--ink-850); border: 1px solid var(--line); border-radius: var(--r-ctl); }
.bulk-row .br-id { font-size: 13px; color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bulk-row .spacer { flex: 1; }
.bchip { font-size: 11.5px; padding: 3px 9px; border-radius: var(--r-pill); border: 1px solid var(--line); color: var(--paper-faint); white-space: nowrap; }
.bchip[data-state="queued"] { color: var(--paper-dim); }
.bchip[data-state="running"] { color: var(--live); border-color: color-mix(in srgb, var(--live) 45%, var(--line)); }
.bchip[data-state="done"] { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.bchip[data-state="failed"] { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.bulk-summary:empty { display: none; }
.bulk-summary { font-size: 13px; color: var(--paper-dim); padding-top: 4px; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 720px) {
  :root { --gutter: 15px; }
  .wordmark .desc { display: none; }
  .section-head h2 { font-size: 22px; }
  .row2 { grid-template-columns: 1fr; }
  .topbar-in { gap: 10px; }
  .wallet-chip .addr { display: none; }
  .gate h1 { font-size: 26px; }
  .hcontrols { width: 100%; margin-left: 0; }
  .dhead { gap: 12px; }
}
@media (max-width: 420px) {
  .otp-code { font-size: 25px; }
}

/* ==========================================================================
   MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .card.is-working .accent::after, .detail.is-working .dhead .accent::after { animation: none; left: 0; width: 100%; }
  .card.is-working .card-avatar, .detail.is-working .avatar { animation: none; }
  .lamp[data-state="working"] .d, .queue .pip { animation: none; }
  .spin path { animation: spin 1.2s linear infinite; }
  dialog.drawer[open], dialog.drawer::backdrop { animation: none; }
}
