:root {
  --bg: #0b0a09;
  --panel: #12110f;
  --ink: #f2ede5;
  --muted: #9a9286;
  --faint: #645d54;
  --line: rgba(255, 240, 220, 0.08);
  --line-strong: rgba(255, 240, 220, 0.16);
  --accent: #f0b660;
  --accent-soft: rgba(240, 182, 96, 0.12);
  --side-w: 272px;
  --side-rail: 72px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; background: var(--bg); color: var(--ink); font: 14px/1.4 var(--sans);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- sidebar ---------- */
.sidebar {
  flex: none; width: var(--side-w); height: 100%; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #14120f, #0e0d0b); border-right: 1px solid var(--line);
  transition: width .35s var(--ease); overflow: hidden; z-index: 2;
}
body.collapsed .sidebar { width: var(--side-rail); }

.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 18px; white-space: nowrap; }
.logo {
  flex: none; width: 36px; height: 36px; border-radius: 10px; position: relative; overflow: hidden;
  background: #1d1a16; box-shadow: inset 0 0 0 1px var(--line-strong);
}
.logo span { position: absolute; bottom: 7px; width: 6px; border-radius: 2px 2px 1px 1px; transform-origin: bottom center; }
.logo span:nth-child(1) { left: 9px; height: 15px; background: #d9674e; transform: rotate(-14deg); }
.logo span:nth-child(2) { left: 15px; height: 20px; background: var(--accent); box-shadow: 0 0 10px rgba(240,182,96,.6); }
.logo span:nth-child(3) { left: 21px; height: 15px; background: #3f8f8a; transform: rotate(14deg); }
.brand-name { font: 400 25px/1 var(--serif); letter-spacing: -.01em; }
.brand-name em { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--faint); letter-spacing: .12em; text-transform: uppercase; margin-top: 4px; }
.brand-text, .nav-text, .nav-key, .nav-label, .open-new span { transition: opacity .2s; }
body.collapsed .brand-text, body.collapsed .nav-text, body.collapsed .nav-key,
body.collapsed .nav-label, body.collapsed .open-new span { opacity: 0; pointer-events: none; }

.nav-label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 10px 22px 8px; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; overflow-y: auto; flex: 1; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px;
  color: var(--ink); text-decoration: none; white-space: nowrap; border: 1px solid transparent;
  transition: background .2s, border-color .2s;
}
.nav-item:hover { background: rgba(255, 255, 255, .04); }
.nav-item.active { background: var(--accent-soft); border-color: rgba(240, 182, 96, .25); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); box-shadow: 0 0 12px var(--accent);
}
.nav-icon {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted);
  transition: color .2s;
}
.nav-icon svg { width: 22px; height: 22px; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: var(--accent); }
.nav-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.nav-name { font-weight: 600; font-size: 13.5px; }
.nav-tag { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.nav-key {
  font-size: 10.5px; color: var(--faint); border: 1px solid var(--line-strong); border-radius: 5px;
  width: 18px; height: 18px; display: grid; place-items: center; flex: none;
}
.badge { font-style: normal; font-size: 10px; font-weight: 600; color: var(--accent); border: 1px solid rgba(240,182,96,.4); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

.side-foot { display: flex; align-items: center; gap: 8px; padding: 14px 12px 16px; border-top: 1px solid var(--line); }
.open-new {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; min-width: 0;
  color: var(--muted); text-decoration: none; font-size: 12.5px; white-space: nowrap; overflow: hidden;
}
.open-new svg, .collapse svg { width: 18px; height: 18px; flex: none; }
.open-new:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.collapse {
  flex: none; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: transparent;
  display: grid; place-items: center; color: var(--muted); transition: transform .35s var(--ease);
}
.collapse:hover { color: var(--ink); border-color: var(--line-strong); }
body.collapsed .collapse { transform: rotate(180deg); }
body.collapsed .side-foot { flex-direction: column-reverse; }
body.collapsed .open-new { flex: none; width: 36px; justify-content: center; padding: 9px; }

/* ---------- workspace ---------- */
.workspace { position: relative; flex: 1; min-width: 0; height: 100%; background: var(--bg); }
.workspace iframe {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block;
  opacity: 0; pointer-events: none; transition: opacity .35s ease;
}
.workspace iframe.active { opacity: 1; pointer-events: auto; }

.veil { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; background: var(--bg); animation: fadeIn .2s; }
.veil-card { text-align: center; }
.veil-icon { width: 46px; height: 46px; margin: 0 auto 14px; color: var(--accent); }
.veil-icon svg { width: 100%; height: 100%; }
.veil-name { font: 400 30px var(--serif); }
.veil-bar { width: 160px; height: 3px; margin: 16px auto 0; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.veil-bar i { display: block; width: 40%; height: 100%; background: var(--accent); border-radius: 3px; animation: slide 1.1s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- sign in / sign out ---------- */
.sign-out { flex: none; margin: 0; }
body.collapsed .sign-out .collapse { transform: none; }

.login-page { display: grid; place-items: center; overflow: auto; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; padding: 8px 24px 28px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
}
.login-card .brand { padding: 20px 0 6px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.login-field input {
  font: inherit; font-size: 14px; color: var(--ink); background: #1a1815; border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .2s;
}
.login-field input:focus { border-color: var(--accent); }
.login-submit {
  margin-top: 6px; padding: 11px; border: 0; border-radius: 10px; font-weight: 600;
  background: var(--accent); color: #1a1408;
}
.login-submit:hover { filter: brightness(1.08); }
.login-error {
  margin: 0; padding: 9px 12px; border-radius: 10px; font-size: 13px;
  color: #f3b3a5; background: rgba(217, 103, 78, .12); border: 1px solid rgba(217, 103, 78, .35);
}

/* ---------- small screens: sidebar becomes a top strip ---------- */
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { width: 100% !important; height: auto; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 10px 12px; }
  .brand-sub, .nav-label, .side-foot, .nav-tag, .nav-key { display: none; }
  .nav { flex-direction: row; padding: 6px; overflow-x: auto; }
  .nav-item { padding: 6px 10px; }
  .nav-item.active::before { display: none; }
  body.collapsed .brand-text, body.collapsed .nav-text { opacity: 1; }
}
