@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/vendor/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/vendor/fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/vendor/fonts/jetbrains-mono-latin-400-italic.woff2') format('woff2');
}

:root {
  --bg-0: #0a0a0c;
  --bg-1: #111114;
  --bg-2: #17171c;
  --bg-3: #1d1d23;
  --border: #26262d;
  --border-soft: #1a1a1f;
  --text: #ededf0;
  --text-dim: #9a9aa3;
  --text-faint: #5e5e68;
  --accent: #7cc4ff;
  --accent-2: #b794f4;
  --accent-soft: rgba(124, 196, 255, 0.10);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.10);
  --ok: #6ee7a0;
  --warn: #f0c674;
  --mono: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --radius-sm: 5px;
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--text); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #2e2e36; background-clip: content-box; border: 2px solid transparent; }

/* Buttons */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  letter-spacing: -0.005em;
}
button:hover { background: var(--bg-3); border-color: #2e2e36; }
button:active { transform: translateY(0.5px); }
button.primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg-0);
  font-weight: 600;
}
button.primary:hover { background: #ffffff; border-color: #ffffff; }
button.danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  padding: 6px 8px;
}
button.danger:hover { background: var(--danger-soft); }
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
button.ghost:hover { background: var(--bg-2); color: var(--text); }
button.icon {
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Inputs */
input[type="text"], input[type="password"], input[type="search"] {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s ease, background 0.12s ease;
}
input:focus { border-color: var(--accent); background: var(--bg-1); }
input::placeholder { color: var(--text-faint); }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% -10%, rgba(124, 196, 255, 0.04), transparent 60%),
    radial-gradient(600px 400px at 80% 110%, rgba(183, 148, 244, 0.04), transparent 60%),
    var(--bg-0);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 24px 60px rgba(0,0,0,0.4);
}
.login-card h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--mono);
}
.login-card h1 .dot { color: var(--accent); font-weight: 400; }
.login-card .sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 4px 0 24px;
}
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card .err {
  color: var(--danger);
  font-size: 12px;
  min-height: 16px;
}

/* App shell */
.shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 28px 80px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}
.topbar h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-family: var(--mono);
  color: var(--text);
}
.topbar h1 .dot { color: var(--accent); font-weight: 400; }
.topbar .actions { display: flex; gap: 6px; align-items: center; }

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 16px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-1);
}
.empty .title { color: var(--text); font-size: 14px; margin: 0 0 6px; font-weight: 500; }
.empty p { margin: 0; font-size: 13px; color: var(--text-faint); }

/* Session rows */
.sessions { display: flex; flex-direction: column; gap: 6px; }
.session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  transition: border-color 0.12s ease, background 0.12s ease;
  cursor: pointer;
}
.session:hover {
  border-color: var(--border);
  background: var(--bg-2);
}
.session .name {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.session .meta {
  color: var(--text-faint);
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.session .meta .sep { color: #3a3a42; }
.session .meta .path {
  font-family: var(--mono);
  color: var(--text-dim);
}
.session .right { display: flex; align-items: center; gap: 4px; }
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
}
.dot.live {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(110, 231, 160, 0.12);
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay[hidden] { display: none !important; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fadein 0.16s ease;
  padding: 28px;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideup { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal {
  width: min(820px, 100%);
  height: min(78vh, 720px);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.03) inset;
  animation: slideup 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.modal-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-head h2 .lead {
  color: var(--accent);
  font-weight: 400;
}
.modal-head .head-meta {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  display: flex;
  gap: 12px;
  align-items: center;
}
.modal-head .head-meta .grp { display: flex; gap: 4px; align-items: center; }
.modal-head .close { padding: 4px 10px; font-size: 18px; line-height: 1; color: var(--text-dim); }

.modal-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  flex: 1;
  min-height: 0;
}

/* ─── Sidebar with quick + recent ─── */
.qsidebar {
  border-right: 1px solid var(--border-soft);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-0);
  overflow-y: auto;
}
.qsidebar .qhead {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: 10px 12px 6px;
}
.qsidebar .qhead:first-child { padding-top: 4px; }
.qitem {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  position: relative;
}
.qitem:hover { background: var(--bg-2); color: var(--text); }
.qitem.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.qitem.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.qitem .qicon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qitem.active .qicon { opacity: 1; }
.qitem .qlabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.qitem .qsub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  margin-left: auto;
  flex-shrink: 0;
}

/* ─── Main pane ─── */
.qmain {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-1);
}

/* Top: location bar */
.qlocation {
  padding: 16px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.qlocation .label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.qpath-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  transition: border-color 0.12s ease;
}
.qpath-wrap:focus-within { border-color: var(--accent); }
.qpath-wrap .qpicon { color: var(--text-faint); flex-shrink: 0; display: flex; }
.qpath {
  flex: 1;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  outline: none;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.qpath:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
}
.qpath .crumb {
  cursor: pointer;
  color: var(--text);
  transition: color 0.08s;
}
.qpath .crumb:hover { color: var(--accent); }
.qpath .crumb.terminal { color: var(--accent); }
.qpath .sep { color: var(--text-faint); margin: 0 6px; user-select: none; }

/* Filter */
.qfilter {
  padding: 0 22px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.qfilter .qfwrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.qfilter .qfwrap .qficon {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  display: flex;
  pointer-events: none;
}
.qfilter input[type="search"] {
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 12px 8px 36px;
  border-radius: 7px;
  background: var(--bg-0);
}
.qfilter input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--text-faint);
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M4 4l8 8M12 4l-8 8" stroke="black" stroke-width="2" fill="none"/></svg>') center / contain no-repeat;
  cursor: pointer;
}
.qfilter .opt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.qfilter .opt input { width: auto; }

/* Folder list */
.qlist {
  overflow-y: auto;
  flex: 1;
  padding: 0 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.qsection {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  padding: 12px 12px 6px;
}
.qrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
  user-select: none;
  transition: background 0.08s ease;
}
.qrow:hover { background: var(--bg-2); }
.qrow.focused {
  background: var(--accent-soft);
  color: var(--accent);
}
.qrow.focused .ricon { color: var(--accent); }
.qrow.up { color: var(--text-faint); }
.qrow.up:hover { color: var(--text-dim); }
.qrow .ricon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: #f0c674;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qrow .rname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
}
.qrow .rmeta {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  margin-left: auto;
}
.qrow .renter {
  font-size: 10px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.1s ease;
  font-family: var(--mono);
}
.qrow:hover .renter, .qrow.focused .renter { opacity: 1; }
.qrow.up .ricon { color: var(--text-faint); }
.qrow.recent .ricon { color: var(--text-dim); }

.qlist-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  font-family: var(--mono);
}

/* ─── Footer ─── */
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-0);
  flex-shrink: 0;
}
.modal-foot .target {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-foot .target .ricon { color: #f0c674; display: flex; }
.modal-foot .target .lbl {
  color: var(--text-faint);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--sans);
}
.modal-foot .target .path {
  color: var(--text);
}
.modal-foot .name-in {
  width: 200px;
  font-size: 12.5px;
  padding: 8px 12px;
  font-family: var(--mono);
}

/* Keyboard hint chips */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: 4px;
  line-height: 1;
}

/* ─── Terminal page ───────────────────────────────────────── */
body.term-page { background: #0a0a0c; overflow: hidden; }
.term-top {
  height: 38px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
  user-select: none;
}
.term-top .back { color: var(--text-dim); padding: 4px 8px; font-size: 14px; }
.term-top .back:hover { color: var(--text); }
.term-top .name {
  font-family: var(--mono);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
}
.term-top .name .prefix { color: var(--text-faint); }
.term-top .path { font-family: var(--mono); color: var(--text-faint); font-size: 11.5px; }
.term-top .spacer { flex: 1; }
.term-top .status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-dim);
}
#terminal {
  position: absolute;
  top: 38px;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 14px 8px;
  background: #0a0a0c;
}
.xterm { font-feature-settings: "calt" 1, "liga" 0; }
.xterm .xterm-viewport { background: transparent !important; }
.xterm .xterm-screen { background: #0a0a0c; }

/* WebGL canvas crisp */
.xterm canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

@media (max-width: 640px) {
  .modal-body { grid-template-columns: 1fr; }
  .qsidebar { display: none; }
  .shell { padding: 24px 16px 60px; }
}
