/* ============================================================
   webssh — design system
   ============================================================ */

/* ---------- fonts ---------- */
@font-face {
  font-family: 'InterVar';
  src: url('/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrainsVar';
  src: url('/fonts/jbmono-var.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --bg:            #080b12;
  --bg-deep:       #05070c;
  --surface:       rgba(20, 25, 37, .72);
  --surface-solid: #141925;
  --surface-2:     rgba(255,255,255,.035);
  --surface-3:     rgba(255,255,255,.07);
  --border:        rgba(255,255,255,.075);
  --border-strong: rgba(255,255,255,.14);
  --fg:            #e6edf3;
  --fg-dim:        #8b98ab;
  --fg-faint:      #5c6779;

  --accent:        #a78bfa;
  --accent-2:      #7c5cf6;
  --accent-soft:   rgba(167,139,250,.14);
  --accent-glow:   rgba(167,139,250,.42);

  --ok:    #4ade80;
  --warn:  #fbbf24;
  --err:   #fb7185;

  --r-sm: 7px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --fast: .14s var(--ease);
  --med: .26s var(--ease);

  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.65);
  --shadow-lg: 0 30px 70px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(255,255,255,.04);

  --topbar-h: 52px;
  --tabbar-h: 40px;
  --status-h: 26px;

  --font: 'InterVar', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrainsVar', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* accent variants */
[data-accent="cyan"]    { --accent:#67e8f9; --accent-2:#22d3ee; --accent-soft:rgba(103,232,249,.14); --accent-glow:rgba(103,232,249,.42); }
[data-accent="emerald"] { --accent:#6ee7b7; --accent-2:#10b981; --accent-soft:rgba(110,231,183,.14); --accent-glow:rgba(110,231,183,.42); }
[data-accent="amber"]   { --accent:#fcd34d; --accent-2:#f59e0b; --accent-soft:rgba(252,211,77,.14); --accent-glow:rgba(252,211,77,.42); }
[data-accent="rose"]    { --accent:#fda4af; --accent-2:#f43f5e; --accent-soft:rgba(253,164,175,.14); --accent-glow:rgba(253,164,175,.42); }
[data-accent="blue"]    { --accent:#93c5fd; --accent-2:#3b82f6; --accent-soft:rgba(147,197,253,.14); --accent-glow:rgba(147,197,253,.42); }
[data-accent="pink"]    { --accent:#f9a8d4; --accent-2:#ec4899; --accent-soft:rgba(249,168,212,.14); --accent-glow:rgba(249,168,212,.42); }
[data-accent="orange"]  { --accent:#fdba74; --accent-2:#f97316; --accent-soft:rgba(253,186,116,.14); --accent-glow:rgba(253,186,116,.42); }

/* ---------- reset ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  text-rendering: optimizeLegibility;
}
/* subtle film grain for depth */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  opacity: .022;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
.hidden { display: none !important; }
::selection { background: var(--accent-soft); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.18); background-clip: padding-box; }

/* ---------- icons ---------- */
.ic { width: 18px; height: 18px; display: block; flex: 0 0 auto; }
.ic-xs { width: 15px; height: 15px; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }
.ic-xl { width: 46px; height: 46px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 11px;
  border-radius: var(--r-sm);
  color: var(--fg-dim);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast), transform var(--fast), box-shadow var(--fast);
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); color: var(--fg); }
.btn:active { transform: translateY(1px); }
.btn.icon-only { width: 32px; padding: 0; justify-content: center; }
.btn-xs { height: 26px; padding: 0 7px; }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-ghost { border-color: var(--border); background: var(--surface-2); }
.btn-primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: #0b0d14; font-weight: 650;
  box-shadow: 0 6px 18px -8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.28);
}
.btn-primary:hover { filter: brightness(1.07); color: #0b0d14; box-shadow: 0 10px 26px -8px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.3); }
.btn-block { width: 100%; justify-content: center; height: 40px; font-size: 14px; }
.btn.is-active { background: var(--accent-soft); color: var(--accent); border-color: rgba(167,139,250,.28); }

kbd {
  font-family: var(--font);
  font-size: 10.5px; font-weight: 600;
  padding: 2px 5px; border-radius: 5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  color: var(--fg-faint);
  line-height: 1.2;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: radial-gradient(1200px 700px at 50% -15%, #16203a 0%, var(--bg) 60%), var(--bg-deep);
  z-index: 60;
}
.aurora { position: absolute; inset: -25%; filter: blur(90px); opacity: .5; pointer-events: none; }
.aurora span {
  position: absolute; display: block; border-radius: 50%;
  animation: drift 18s var(--ease-out) infinite alternate;
}
.aurora span:nth-child(1) { width: 46vw; height: 46vw; left: 8%;  top: 6%;  background: radial-gradient(circle, var(--accent-2), transparent 66%); }
.aurora span:nth-child(2) { width: 38vw; height: 38vw; right: 6%; top: 22%; background: radial-gradient(circle, #22d3ee, transparent 66%); animation-delay: -6s; }
.aurora span:nth-child(3) { width: 34vw; height: 34vw; left: 32%; bottom: 2%; background: radial-gradient(circle, #ec4899, transparent 66%); animation-delay: -12s; }
@keyframes drift {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(6%, -7%, 0) scale(1.18); }
}

.login-box {
  position: relative;
  width: min(380px, 92vw);
  padding: 38px 34px 26px;
  border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(23,29,44,.86), rgba(14,18,28,.92));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  animation: rise .5s var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.login-glow {
  position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(140deg, var(--accent-glow), transparent 42%, transparent 62%, rgba(34,211,238,.22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  padding: 1px; opacity: .65;
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 16px;
  display: grid; place-items: center; border-radius: 16px;
  color: #fff;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 30px -10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.35);
}
.login-box h1 { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.login-sub { text-align: center; color: var(--fg-faint); font-size: 13px; margin-bottom: 24px; }
.field { position: relative; margin-bottom: 12px; }
.field input {
  width: 100%; height: 42px; padding: 0 14px 0 40px;
  border-radius: var(--r-md);
  background: rgba(0,0,0,.34);
  border: 1px solid var(--border);
  outline: none; font-size: 14px;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.field input:focus {
  border-color: var(--accent);
  background: rgba(0,0,0,.5);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-ic { position: absolute; left: 13px; top: 12px; color: var(--fg-faint); pointer-events: none; }
.login-error { min-height: 20px; margin-top: 10px; text-align: center; color: var(--err); font-size: 12.5px; }
.login-error.shake { animation: shake .35s; }
@keyframes shake { 10%,90% { transform: translateX(-2px); } 30%,70% { transform: translateX(4px); } 50% { transform: translateX(-4px); } }
.login-foot { margin-top: 14px; text-align: center; color: var(--fg-faint); font-size: 11.5px; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: flex; flex-direction: column; height: 100%; }

.topbar {
  height: var(--topbar-h); flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(17,22,33,.92), rgba(13,17,26,.82));
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 20;
  position: relative;
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-glow) 22%, var(--accent-glow) 78%, transparent);
  opacity: .5; pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 27px; height: 27px; display: grid; place-items: center; border-radius: 8px;
  color: #fff; background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 14px -5px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.3);
}
.brand-text { font-weight: 650; letter-spacing: -.2px; font-size: 14.5px; }
.brand-badge {
  font-family: var(--mono); font-size: 10.5px; color: var(--fg-faint);
  padding: 2px 7px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.sysinfo { display: flex; gap: 6px; flex: 1; min-width: 0; overflow: hidden; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--fg-dim); font-size: 11px; font-family: var(--mono);
  white-space: nowrap;
}
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.spark i { width: 2.5px; background: var(--accent); border-radius: 1px; opacity: .85; transition: height var(--med); }
.topbar-actions { display: flex; align-items: center; gap: 5px; margin-left: auto; }

.body { display: flex; flex: 1; min-height: 0; }

/* ---------- file manager ---------- */
.filepanel {
  width: 0; overflow: hidden; flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(16,21,31,.72), rgba(11,15,23,.78));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width .28s var(--ease-out);
  backdrop-filter: blur(12px);
}
.filepanel.open { width: 330px; }
.fp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 9px; border-bottom: 1px solid var(--border);
  min-height: 42px;
}
.fp-crumbs {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 1px;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap;
}
.fp-crumbs::-webkit-scrollbar { display: none; }
.crumb {
  padding: 3px 7px; border-radius: 6px; cursor: pointer;
  color: var(--fg-faint); font-size: 11.5px; font-family: var(--mono);
  transition: background var(--fast), color var(--fast);
}
.crumb:hover { background: var(--surface-3); color: var(--fg); }
.crumb.last { color: var(--accent); font-weight: 600; }
.crumb-sep { color: var(--fg-faint); opacity: .5; font-size: 10px; }
.fp-actions { display: flex; gap: 2px; }
.fp-cols {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 12px 5px; border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.14);
}
.fp-col {
  font-size: 10px; font-weight: 650; letter-spacing: .7px; text-transform: uppercase;
  color: var(--fg-faint); transition: color var(--fast);
}
.fp-col:hover { color: var(--accent); }
.fp-col.sorted { color: var(--accent); }
.fp-col.sorted::after { content: ' ↓'; }
.fp-col.sorted.asc::after { content: ' ↑'; }

.fp-list { flex: 1; overflow-y: auto; padding: 6px 6px 10px; }
.fp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; color: var(--fg-dim);
  border: 1px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
  animation: rowin .2s var(--ease-out) both;
}
@keyframes rowin { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.fp-row:hover { background: var(--surface-3); color: var(--fg); border-color: var(--border); }
.fp-row.sel { background: var(--accent-soft); border-color: rgba(167,139,250,.3); color: var(--fg); }
.fp-ic { width: 17px; height: 17px; flex: 0 0 auto; color: var(--fg-faint); }
.fp-row.dir .fp-ic { color: var(--accent); }
.fp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-meta { color: var(--fg-faint); font-size: 10.5px; font-family: var(--mono); }
.fp-ops { display: flex; gap: 2px; opacity: 0; transition: opacity var(--fast); }
.fp-row:hover .fp-ops { opacity: 1; }
.fp-ops button {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 6px; color: var(--fg-faint);
  transition: background var(--fast), color var(--fast);
}
.fp-ops button:hover { background: var(--surface-3); color: var(--fg); }
.fp-ops button.danger:hover { background: rgba(251,113,133,.15); color: var(--err); }
.fp-foot {
  border-top: 1px solid var(--border); padding: 6px 10px;
  color: var(--fg-faint); font-size: 10.5px; font-family: var(--mono);
  display: flex; justify-content: space-between; gap: 8px;
}
.fp-empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 34px 18px; color: var(--fg-faint); font-size: 12.5px; text-align: center;
}
.fp-empty .ic { opacity: .35; }

/* ---------- tabs ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.tabbar {
  display: flex; align-items: stretch; gap: 3px;
  height: var(--tabbar-h); flex: 0 0 auto;
  padding: 5px 8px 0;
  background: linear-gradient(180deg, rgba(9,12,19,.96), rgba(10,13,21,.6));
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 11px; cursor: pointer;
  border-radius: 9px 9px 0 0;
  color: var(--fg-faint); font-size: 12.5px; font-family: var(--mono);
  border: 1px solid transparent; border-bottom: none;
  position: relative; top: 1px;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
  animation: tabin .22s var(--ease-out) both;
}
@keyframes tabin { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.tab:hover { background: var(--surface-2); color: var(--fg-dim); }
.tab.active {
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border-color: var(--border);
  color: var(--fg);
}
.tab.active::after {
  content: ''; position: absolute; left: 12px; right: 12px; top: 0; height: 2px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px var(--accent-glow);
}
.tab .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: 0 0 auto;
  background: var(--ok); box-shadow: 0 0 7px rgba(74,222,128,.55);
  transition: background var(--fast), box-shadow var(--fast);
}
.tab .dot.off { background: var(--err); box-shadow: 0 0 7px rgba(251,113,133,.5); }
.tab .dot.busy { background: var(--warn); box-shadow: 0 0 7px rgba(251,191,36,.5); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.tab .tab-name { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .tab-x {
  width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px;
  opacity: 0; color: var(--fg-faint); font-size: 15px; line-height: 1;
  transition: opacity var(--fast), background var(--fast), color var(--fast);
}
.tab:hover .tab-x, .tab.active .tab-x { opacity: .75; }
.tab .tab-x:hover { background: rgba(251,113,133,.16); color: var(--err); opacity: 1; }
.tab-add {
  width: 30px; border-radius: 9px 9px 0 0; color: var(--fg-faint);
  display: grid; place-items: center;
  border: 1px dashed transparent;
  transition: color var(--fast), background var(--fast), border-color var(--fast);
}
.tab-add:hover { color: var(--accent); background: var(--accent-soft); border-color: rgba(167,139,250,.25); }

/* ---------- terminal ---------- */
.term-host { flex: 1; min-height: 0; position: relative; padding: 8px; }
.term-wrap {
  position: absolute; inset: 8px;
  display: none; overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: 0 18px 40px -26px rgba(0,0,0,.9);
  transition: border-color var(--med), box-shadow var(--med);
}
.term-wrap.active { display: block; animation: termfade .22s var(--ease-out); }
@keyframes termfade { from { opacity: .35; transform: scale(.995); } to { opacity: 1; transform: none; } }
.term-wrap::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  opacity: .55; pointer-events: none;
}
.term-wrap .xterm { height: 100%; padding: 10px 6px 6px 16px; }
.term-wrap .xterm-viewport { background: transparent !important; }
.term-wrap .xterm-viewport::-webkit-scrollbar { width: 9px; }
.term-wrap .xterm-viewport::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }
.term-wrap .xterm-screen { z-index: 1; }
.term-wrap .xterm-cursor-layer { z-index: 3; }
.term-disconnect {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  background: rgba(6,9,14,.78); backdrop-filter: blur(6px);
  color: var(--fg-dim); z-index: 6;
}
.term-disconnect.show { display: flex; }
.term-disconnect .disc-title { font-size: 15px; color: var(--err); display: flex; align-items: center; gap: 8px; }

/* ---------- floating terminal actions ---------- */
.float-actions {
  position: absolute; top: 10px; right: 18px; z-index: 8;
  display: flex; gap: 6px;
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--med), transform var(--med);
}
.float-actions.show { opacity: 1; transform: none; pointer-events: auto; }
.fab {
  width: 30px; height: 30px; display: grid; place-items: center;
  border-radius: 9px; color: var(--fg-dim);
  background: rgba(22,28,42,.92);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  transition: color var(--fast), background var(--fast), transform var(--fast);
}
.fab:hover { color: var(--fg); background: rgba(32,40,58,.95); transform: translateY(-1px); }
#fab-bottom .ic { transform: rotate(90deg); }

/* ---------- welcome ---------- */
.welcome {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center;
  background: radial-gradient(900px 520px at 50% 30%, rgba(30,38,58,.55), transparent 70%), var(--bg);
  animation: fade .35s var(--ease-out) both;
}
.welcome.hide { animation: fadeout .25s var(--ease) both; pointer-events: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; transform: scale(.99); } }
.welcome-inner { text-align: center; width: min(680px, 90%); }
.welcome-logo {
  width: 74px; height: 74px; margin: 0 auto 18px;
  display: grid; place-items: center; border-radius: 22px; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 22px 50px -16px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.35);
  animation: floaty 5s ease-in-out infinite;
}
@keyframes floaty { 50% { transform: translateY(-6px); } }
.welcome h2 {
  font-size: 26px; font-weight: 700; letter-spacing: -.5px;
  background: linear-gradient(120deg, var(--fg) 30%, var(--accent) 70%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.welcome-sub { color: var(--fg-faint); font-size: 13px; margin-top: 6px; font-family: var(--mono); }
.welcome-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 9px; margin: 26px 0 20px;
}
.wcard {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; text-align: left;
  transition: transform var(--fast), background var(--fast), border-color var(--fast), box-shadow var(--fast);
}
.wcard:hover {
  transform: translateY(-2px);
  background: var(--surface-3); border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.wcard .wc-ic {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); flex: 0 0 auto;
}
.wcard .wc-t { font-size: 13px; font-weight: 550; }
.wcard .wc-s { font-size: 11px; color: var(--fg-faint); font-family: var(--mono); }
.welcome-hint { color: var(--fg-faint); font-size: 11.5px; }
.welcome-hint kbd { margin: 0 1px; }

/* ---------- drop overlay ---------- */
.drop-overlay {
  position: absolute; inset: 12px; z-index: 30;
  display: none; align-items: center; justify-content: center;
  background: rgba(8,11,18,.82);
  border: 2px dashed var(--accent); border-radius: var(--r-lg);
  backdrop-filter: blur(8px);
  animation: fade .2s var(--ease-out) both;
}
.drop-overlay.show { display: flex; }
.drop-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--accent); font-size: 15px; font-weight: 600;
}

/* ---------- status bar ---------- */
.statusbar {
  height: var(--status-h); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(11,15,23,.9), rgba(8,11,17,.95));
  border-top: 1px solid var(--border);
  color: var(--fg-faint); font-size: 11px; font-family: var(--mono);
}
.st-left { display: inline-flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-faint); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(74,222,128,.6); }
.status-dot.err { background: var(--err); box-shadow: 0 0 8px rgba(251,113,133,.6); }

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.palette-wrap {
  position: fixed; inset: 0; z-index: 70;
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12vh;
  background: rgba(4,6,11,.6);
  backdrop-filter: blur(8px);
  animation: fade .18s var(--ease-out) both;
}
.palette {
  width: min(620px, 92vw); max-height: 62vh;
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(24,30,45,.97), rgba(15,19,29,.98));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: palin .22s var(--ease-out) both;
}
@keyframes palin { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.palette-search {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
  color: var(--fg-faint);
}
.palette-search input {
  flex: 1; background: none; border: 0; outline: none;
  font-size: 15px; color: var(--fg);
}
.palette-search input::placeholder { color: var(--fg-faint); }
.palette-list { overflow-y: auto; padding: 6px; }
.pitem {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  color: var(--fg-dim); font-size: 13.5px;
  border: 1px solid transparent;
}
.pitem .p-ic {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--fg-dim); flex: 0 0 auto;
}
.pitem .p-t { flex: 1; }
.pitem .p-k { font-family: var(--mono); font-size: 11px; color: var(--fg-faint); }
.pitem.sel { background: var(--accent-soft); border-color: rgba(167,139,250,.28); color: var(--fg); }
.pitem.sel .p-ic { background: var(--accent); color: #0b0d14; }
.palette-empty { padding: 26px; text-align: center; color: var(--fg-faint); font-size: 13px; }
.palette-foot {
  padding: 7px 14px; border-top: 1px solid var(--border);
  color: var(--fg-faint); font-size: 11px; display: flex; gap: 6px; align-items: center;
}

/* ============================================================
   POPOVER / THEMES
   ============================================================ */
.popover {
  position: fixed; z-index: 65; top: 58px; right: 12px;
  width: 248px; padding: 12px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(24,30,45,.97), rgba(15,19,29,.98));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: palin .2s var(--ease-out) both;
}
.popover-title {
  font-size: 10.5px; font-weight: 650; letter-spacing: .8px; text-transform: uppercase;
  color: var(--fg-faint); margin: 2px 0 8px;
}
.popover-title + .swatches { margin-bottom: 14px; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch {
  width: 24px; height: 24px; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; position: relative;
  transition: transform var(--fast), box-shadow var(--fast);
}
.swatch:hover { transform: scale(1.12); }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.12); }
.theme-list { display: flex; flex-direction: column; gap: 2px; max-height: 210px; overflow-y: auto; }
.thitem {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px;
  border-radius: 7px; cursor: pointer; font-size: 12.5px; color: var(--fg-dim);
  transition: background var(--fast), color var(--fast);
}
.thitem:hover { background: var(--surface-3); color: var(--fg); }
.thitem.sel { background: var(--accent-soft); color: var(--fg); }
.thitem .th-dots { display: flex; gap: 2px; }
.thitem .th-dots i { width: 9px; height: 9px; border-radius: 3px; }

/* ============================================================
   MODAL (editor)
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(4,6,11,.66); backdrop-filter: blur(8px);
  animation: fade .18s var(--ease-out) both;
}
.modal-box {
  width: min(960px, 100%); height: min(82vh, 720px);
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: palin .22s var(--ease-out) both;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.modal-path { font-family: var(--mono); font-size: 12.5px; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 6px; flex: 0 0 auto; }
#ed-content {
  flex: 1; width: 100%; border: 0; outline: none; resize: none; padding: 14px 16px;
  background: var(--bg-deep); color: var(--fg);
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  tab-size: 2;
}
.modal-foot { padding: 6px 13px; border-top: 1px solid var(--border); color: var(--fg-faint); font-size: 11px; font-family: var(--mono); }

/* ============================================================
   TOASTS
   ============================================================ */
.toasts {
  position: fixed; right: 16px; bottom: 38px; z-index: 80;
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 230px; max-width: 380px;
  padding: 10px 13px; border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(26,32,47,.97), rgba(17,21,32,.97));
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 13px; color: var(--fg);
  animation: toastin .28s var(--ease-out) both;
  pointer-events: auto;
}
.toast.out { animation: toastout .22s var(--ease) both; }
.toast .t-ic { width: 18px; height: 18px; flex: 0 0 auto; color: var(--accent); }
.toast.ok .t-ic { color: var(--ok); }
.toast.err .t-ic { color: var(--err); }
@keyframes toastin { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateX(18px) scale(.97); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .hide-sm { display: none !important; }
  .sysinfo { display: none; }
}
@media (max-width: 640px) {
  .filepanel.open { width: 100%; position: absolute; z-index: 30; inset: 0; border-right: 0; }
  .brand-text { display: none; }
  .brand-badge { display: none; }
  .welcome-grid { grid-template-columns: 1fr 1fr; }
  .tab .tab-name { max-width: 110px; }
  .welcome h2 { font-size: 23px; }
  .statusbar { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
