/* Stellar Forge Studio — core design system
   Tokens, layout shell, components. View-specific styles live in views-*.css. */
:root{
  --bg:#07080d; --bg-2:#0a0b12; --surface:#0f111a; --surface-2:#151826; --surface-3:#1c2032; --surface-4:#242940;
  --hover:rgba(255,255,255,.045); --active:rgba(255,255,255,.07);
  --border:rgba(255,255,255,.07); --border-strong:rgba(255,255,255,.14);
  --text:#eef0f6; --text-2:#a7abbc; --muted:#6f7389;
  --accent:#5b7cfa; --accent-2:#8f6bff; --accent-soft:rgba(91,124,250,.14); --accent-text:#9fb2ff;
  --good:#3ccf6a; --good-soft:rgba(60,207,106,.13); --warn:#f5b83d; --warn-soft:rgba(245,184,61,.13);
  --bad:#ef6b6b; --bad-soft:rgba(239,107,107,.13); --info:#5fb3f9;
  --p-urgent:#ef4444; --p-high:#f97316; --p-medium:#eab308; --p-low:#3b9cf5; --p-none:#6f7389;
  --radius-xl:20px; --radius-lg:14px; --radius-md:11px; --radius-sm:8px;
  --shadow-sm:0 1px 2px rgba(0,0,0,.3);
  --shadow:0 1px 0 rgba(255,255,255,.035) inset, 0 18px 40px -24px rgba(0,0,0,.7);
  --shadow-lg:0 24px 64px -16px rgba(0,0,0,.65), 0 0 0 1px var(--border);
  --font-display:'Space Grotesk','Inter',system-ui,sans-serif;
  --font-body:'Inter',system-ui,-apple-system,'Segoe UI',sans-serif;
  --font-mono:'JetBrains Mono',ui-monospace,Consolas,monospace;
  --sidebar-w:252px; --topbar-h:60px; --bottomnav-h:64px;
  --ease:cubic-bezier(.2,.8,.2,1); --ease-spring:cubic-bezier(.34,1.56,.64,1);
  color-scheme:dark;
}
:root[data-theme="light"]{
  --bg:#f3f4f8; --bg-2:#fbfbfd; --surface:#ffffff; --surface-2:#f6f7fb; --surface-3:#eceef5; --surface-4:#e2e5ef;
  --hover:rgba(15,18,40,.045); --active:rgba(15,18,40,.07);
  --border:rgba(15,18,40,.09); --border-strong:rgba(15,18,40,.17);
  --text:#12131c; --text-2:#4b4f66; --muted:#7e8299;
  --accent:#3f5fe0; --accent-2:#7451f0; --accent-soft:rgba(63,95,224,.1); --accent-text:#3150c9;
  --good:#12a150; --good-soft:rgba(18,161,80,.1); --warn:#c98500; --warn-soft:rgba(201,133,0,.1);
  --bad:#d93b3b; --bad-soft:rgba(217,59,59,.09); --info:#2a78d6;
  --shadow-sm:0 1px 2px rgba(15,18,40,.06);
  --shadow:0 1px 2px rgba(15,18,40,.04), 0 12px 32px -20px rgba(15,18,40,.22);
  --shadow-lg:0 24px 60px -18px rgba(15,18,40,.28), 0 0 0 1px var(--border);
  color-scheme:light;
}

*{box-sizing:border-box; margin:0; padding:0;}
html,body{height:100%;}
body{
  background:var(--bg); color:var(--text); font-family:var(--font-body); font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased; -webkit-tap-highlight-color:transparent; overflow:hidden;
}
a{color:inherit; text-decoration:none;}
button,input,select,textarea{font:inherit; color:inherit;}
button{cursor:pointer; background:none; border:0;}
img,svg,video,canvas{display:block; max-width:100%;}
h1,h2,h3,h4{font-family:var(--font-display); letter-spacing:-.02em; line-height:1.2;}
::selection{background:color-mix(in srgb, var(--accent) 35%, transparent);}
*{scrollbar-width:thin; scrollbar-color:var(--surface-4) transparent;}
::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-thumb{background:var(--surface-4); border-radius:10px; border:3px solid transparent; background-clip:padding-box;}
::-webkit-scrollbar-track{background:transparent;}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:6px;}
.ic{width:16px; height:16px; flex-shrink:0; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}

/* ---------- utilities ---------- */
.row{display:flex; align-items:center; gap:10px;} .row.wrap{flex-wrap:wrap;} .row.top{align-items:flex-start;}
.col{display:flex; flex-direction:column; gap:10px;}
.grow{flex:1; min-width:0;} .shrink-0{flex-shrink:0;}
.between{justify-content:space-between;} .end{justify-content:flex-end;} .center{justify-content:center; text-align:center;}
.gap-4{gap:4px;} .gap-6{gap:6px;} .gap-8{gap:8px;} .gap-16{gap:16px;} .gap-20{gap:20px;}
.mt-4{margin-top:4px;} .mt-8{margin-top:8px;} .mt-12{margin-top:12px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;}
.muted{color:var(--muted);} .text-2{color:var(--text-2);} .small{font-size:12.5px;} .tiny{font-size:11.5px;}
.mono{font-family:var(--font-mono);} .num{font-variant-numeric:tabular-nums;} .bold{font-weight:600;}
.good{color:var(--good);} .bad{color:var(--bad);} .warn{color:var(--warn);} .accent{color:var(--accent-text);}
.truncate{overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0;}
.sr-only{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap;}
.hidden{display:none !important;}
.eyebrow{font-family:var(--font-mono); font-size:10.5px; letter-spacing:1.4px; text-transform:uppercase; color:var(--muted);}
.divider{height:1px; background:var(--border); margin:14px 0;}
@media (max-width:899px){ .hide-mobile{display:none !important;} }
@media (min-width:900px){ .show-mobile{display:none !important;} }

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px; height:36px; padding:0 14px;
  border-radius:10px; font-weight:600; font-size:13.5px; white-space:nowrap; border:1px solid transparent;
  transition:transform .15s var(--ease), background .2s, border-color .2s, color .2s, filter .2s, box-shadow .2s;
  user-select:none; position:relative;
}
.btn:active:not(:disabled){transform:scale(.97);}
.btn:disabled{opacity:.5; cursor:not-allowed;}
.btn .ic{width:15px; height:15px;}
.btn-primary{background:linear-gradient(135deg,var(--accent),var(--accent-2)); color:#fff; box-shadow:0 8px 22px -12px rgba(91,124,250,.9);}
.btn-primary:hover:not(:disabled){filter:brightness(1.1); box-shadow:0 10px 26px -10px rgba(91,124,250,.9);}
.btn-ghost{background:var(--surface-2); border-color:var(--border); color:var(--text);}
.btn-ghost:hover:not(:disabled){background:var(--surface-3); border-color:var(--border-strong);}
.btn-subtle{color:var(--text-2);} .btn-subtle:hover:not(:disabled){background:var(--hover); color:var(--text);}
.btn-danger{background:var(--bad-soft); color:var(--bad); border-color:color-mix(in srgb,var(--bad) 30%,transparent);}
.btn-danger:hover:not(:disabled){background:var(--bad); color:#fff;}
.btn-sm{height:30px; padding:0 10px; font-size:12.5px; border-radius:8px;}
.btn-lg{height:44px; padding:0 20px; font-size:14.5px; border-radius:12px;}
.btn-block{width:100%;}
.btn-icon{width:36px; padding:0;} .btn-icon.btn-sm{width:30px;}
.icon-btn{
  width:36px; height:36px; border-radius:10px; display:inline-flex; align-items:center; justify-content:center;
  color:var(--text-2); position:relative; transition:background .2s, color .2s, transform .15s;
}
.icon-btn:hover{background:var(--hover); color:var(--text);} .icon-btn:active{transform:scale(.92);}
.icon-btn .ic{width:18px; height:18px;}
.icon-btn.sm{width:28px; height:28px; border-radius:7px;} .icon-btn.sm .ic{width:15px; height:15px;}
.btn.is-loading{color:transparent !important; pointer-events:none;}
.btn.is-loading::after{content:""; position:absolute; width:16px; height:16px; border-radius:50%; border:2px solid rgba(255,255,255,.35); border-top-color:#fff; animation:spin .7s linear infinite;}
.btn-ghost.is-loading::after,.btn-subtle.is-loading::after{border-color:var(--border-strong); border-top-color:var(--text);}
.spinner{width:18px; height:18px; border-radius:50%; border:2px solid var(--border-strong); border-top-color:var(--accent); animation:spin .7s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}

/* ---------- forms ---------- */
.input,.select,.textarea{
  width:100%; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; color:var(--text);
  padding:0 12px; height:38px; font-size:14px; transition:border-color .2s, box-shadow .2s, background .2s; outline:none;
}
.textarea{padding:10px 12px; height:auto; min-height:90px; resize:vertical; line-height:1.55;}
.input::placeholder,.textarea::placeholder{color:var(--muted);}
.input:hover,.select:hover,.textarea:hover{border-color:var(--border-strong);}
.input:focus,.select:focus,.textarea:focus{border-color:color-mix(in srgb,var(--accent) 70%,transparent); box-shadow:0 0 0 3px var(--accent-soft); background:var(--surface);}
.select{appearance:none; padding-right:32px; cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8ea3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 11px center;}
.input-sm{height:32px; font-size:13px; border-radius:8px;}
.field{display:flex; flex-direction:column; gap:6px;}
.field > label,.label{font-size:12.5px; font-weight:600; color:var(--text-2);}
.field .hint{font-size:12px; color:var(--muted);}
.field .err{font-size:12.5px; color:var(--bad);}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
@media (max-width:640px){ .form-grid{grid-template-columns:1fr;} }
.input-icon{position:relative;} .input-icon .ic{position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none;}
.input-icon .input{padding-left:34px;}
.check{display:inline-flex; align-items:center; gap:9px; cursor:pointer; user-select:none; font-size:13.5px;}
.check input{appearance:none; width:18px; height:18px; border-radius:6px; border:1.5px solid var(--border-strong); background:var(--surface-2); display:grid; place-items:center; transition:all .18s var(--ease); flex-shrink:0; cursor:pointer;}
.check input::after{content:""; width:9px; height:5px; border:2px solid #fff; border-top:0; border-right:0; transform:rotate(-45deg) scale(0); margin-top:-2px; transition:transform .2s var(--ease-spring);}
.check input:checked{background:var(--accent); border-color:var(--accent);}
.check input:checked::after{transform:rotate(-45deg) scale(1);}
.switch{position:relative; display:inline-flex; width:38px; height:22px; flex-shrink:0;}
.switch input{appearance:none; width:100%; height:100%; border-radius:999px; background:var(--surface-4); cursor:pointer; transition:background .2s;}
.switch input::after{content:""; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; transition:transform .25s var(--ease-spring); box-shadow:0 1px 3px rgba(0,0,0,.3);}
.switch input:checked{background:var(--accent);} .switch input:checked::after{transform:translateX(16px);}

/* ---------- cards, chips, badges ---------- */
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow);}
.card-pad{padding:18px 20px;}
.card-head{display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 20px 0;}
.card-title{font-family:var(--font-display); font-weight:600; font-size:15.5px; display:flex; align-items:center; gap:8px;}
.card-title .ic{color:var(--muted);}
.card-body{padding:14px 20px 18px;}
.card.hoverable{transition:transform .25s var(--ease), border-color .25s, box-shadow .25s;}
.card.hoverable:hover{transform:translateY(-2px); border-color:var(--border-strong);}
.chip{display:inline-flex; align-items:center; gap:6px; height:26px; padding:0 10px; border-radius:999px; font-size:12px; font-weight:600;
  background:var(--surface-2); border:1px solid var(--border); color:var(--text-2); white-space:nowrap; transition:all .18s;}
button.chip:hover{border-color:var(--border-strong); color:var(--text);}
.chip.on{background:var(--accent-soft); color:var(--text); border-color:color-mix(in srgb,var(--accent) 45%,transparent);}
.chip .ic{width:13px; height:13px;}
.tag{display:inline-flex; align-items:center; gap:5px; height:21px; padding:0 8px; border-radius:6px; font-size:11.5px; font-weight:600;
  --c:#5b7cfa; color:color-mix(in srgb,var(--c) 75%,var(--text)); background:color-mix(in srgb,var(--c) 16%,transparent); white-space:nowrap;}
.tag-dot{width:8px; height:8px; border-radius:50%; background:var(--c,#5b7cfa); flex-shrink:0;}
.badge{display:inline-flex; align-items:center; justify-content:center; min-width:18px; height:18px; padding:0 5px; border-radius:999px;
  font-size:10.5px; font-weight:700; background:var(--accent); color:#fff;}
.badge.soft{background:var(--accent-soft); color:var(--accent-text);}
.badge.bad{background:var(--bad);} .badge.good{background:var(--good-soft); color:var(--good);} .badge.warn{background:var(--warn-soft); color:var(--warn);}
.kbd{font-family:var(--font-mono); font-size:10.5px; padding:2px 6px; border-radius:5px; border:1px solid var(--border-strong); color:var(--muted); background:var(--surface-2);}
.role-badge{font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.6px; padding:2px 7px; border-radius:6px; background:var(--surface-3); color:var(--text-2);}
.role-badge.admin{background:color-mix(in srgb,var(--accent-2) 18%,transparent); color:color-mix(in srgb,var(--accent-2) 70%,var(--text));}
.role-badge.viewer{background:var(--warn-soft); color:var(--warn);}

/* priority */
.prio{display:inline-flex; align-items:center; gap:5px; font-size:12px; font-weight:600; color:var(--pc);}
.prio .ic{width:13px; height:13px;}
.prio-0{--pc:var(--p-none);} .prio-1{--pc:var(--p-low);} .prio-2{--pc:var(--p-medium);} .prio-3{--pc:var(--p-high);} .prio-4{--pc:var(--p-urgent);}

/* avatar */
.avatar{--av:#5b7cfa; position:relative; display:inline-flex; align-items:center; justify-content:center; border-radius:50%; flex-shrink:0;
  background:linear-gradient(135deg, var(--av), color-mix(in srgb,var(--av) 55%,#000)); color:#fff; font-weight:700; letter-spacing:.02em;
  box-shadow:0 0 0 2px var(--surface); user-select:none;}
.avatar .presence{position:absolute; right:-1px; bottom:-1px; width:31%; height:31%; min-width:8px; min-height:8px; border-radius:50%;
  background:var(--good); box-shadow:0 0 0 2px var(--surface);}
.avatar-stack{display:inline-flex; align-items:center;} .avatar-stack .avatar{margin-left:-7px;} .avatar-stack .avatar:first-child{margin-left:0;}
.avatar-more{display:inline-flex; align-items:center; justify-content:center; border-radius:50%; background:var(--surface-3); color:var(--text-2); font-size:10.5px; font-weight:700; margin-left:-7px; box-shadow:0 0 0 2px var(--surface);}

/* progress */
.progress{height:6px; border-radius:999px; background:var(--surface-3); overflow:hidden;}
.progress > i{display:block; height:100%; width:0; border-radius:inherit; background:linear-gradient(90deg,var(--accent),var(--accent-2)); transition:width .8s var(--ease);}
.progress.warn > i{background:var(--warn);} .progress.bad > i{background:var(--bad);} .progress.good > i{background:var(--good);}
.progress.lg{height:9px;}

/* tabs / segmented */
.tabs{display:flex; gap:2px; border-bottom:1px solid var(--border); overflow-x:auto; scrollbar-width:none;}
.tabs::-webkit-scrollbar{display:none;}
.tab{position:relative; padding:10px 14px; font-weight:600; font-size:13.5px; color:var(--text-2); white-space:nowrap; transition:color .2s; display:inline-flex; align-items:center; gap:7px;}
.tab:hover{color:var(--text);}
.tab.on{color:var(--text);}
.tab::after{content:""; position:absolute; left:10px; right:10px; bottom:-1px; height:2px; border-radius:2px; background:var(--accent); transform:scaleX(0); transition:transform .3s var(--ease);}
.tab.on::after{transform:scaleX(1);}
.seg{display:inline-flex; background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:3px; gap:2px;}
.seg button{height:28px; padding:0 11px; border-radius:7px; font-size:12.5px; font-weight:600; color:var(--text-2); display:inline-flex; align-items:center; gap:6px; transition:all .2s;}
.seg button:hover{color:var(--text);}
.seg button.on{background:var(--surface-4); color:var(--text); box-shadow:var(--shadow-sm);}

/* table */
.table-wrap{overflow-x:auto;}
.table{width:100%; border-collapse:collapse; font-size:13.5px;}
.table th{font-size:11px; font-weight:600; letter-spacing:.6px; text-transform:uppercase; color:var(--muted); text-align:left; padding:10px 12px; border-bottom:1px solid var(--border); white-space:nowrap;}
.table td{padding:11px 12px; border-bottom:1px solid var(--border); vertical-align:middle;}
.table tr:last-child td{border-bottom:0;}
.table tbody tr{transition:background .15s;} .table tbody tr:hover{background:var(--hover);}

/* empty & skeleton */
.empty-state{display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:48px 20px; gap:10px; color:var(--text-2);}
.empty-state .es-icon{width:56px; height:56px; border-radius:16px; display:grid; place-items:center; background:var(--accent-soft); color:var(--accent-text); margin-bottom:4px; animation:float 4s ease-in-out infinite;}
.empty-state .es-icon .ic{width:26px; height:26px;}
.empty-state h3{font-size:17px; color:var(--text);}
.empty-state p{max-width:380px; font-size:13.5px;}
@keyframes float{0%,100%{transform:translateY(0);}50%{transform:translateY(-5px);}}
.skeleton{background:linear-gradient(90deg,var(--surface-2) 25%,var(--surface-3) 37%,var(--surface-2) 63%); background-size:400% 100%; animation:shimmer 1.4s ease infinite; border-radius:8px;}
.sk-line{height:12px; margin:10px 0;} .sk-block{height:80px;}
@keyframes shimmer{0%{background-position:100% 50%;}100%{background-position:0 50%;}}

/* ---------- app shell ---------- */
.app{display:grid; grid-template-columns:var(--sidebar-w) 1fr; height:100vh; height:100dvh;}
.sidebar{background:var(--bg-2); border-right:1px solid var(--border); display:flex; flex-direction:column; min-height:0; z-index:40;}
.sb-brand{display:flex; align-items:center; gap:11px; padding:16px 18px 14px; font-family:var(--font-display); font-weight:700; font-size:15.5px;}
.sb-brand img{width:32px; height:32px; border-radius:50%; box-shadow:0 4px 16px -4px rgba(91,124,250,.7);}
.sb-brand small{display:block; font-family:var(--font-body); font-weight:500; font-size:11.5px; color:var(--muted); letter-spacing:0;}
.sb-search{margin:4px 12px 10px; height:36px; display:flex; align-items:center; gap:8px; padding:0 10px; border-radius:10px; background:var(--surface-2); border:1px solid var(--border); color:var(--muted); font-size:13px; transition:border-color .2s, color .2s;}
.sb-search:hover{border-color:var(--border-strong); color:var(--text-2);}
.sb-search .kbd{margin-left:auto;}
.sb-scroll{flex:1; overflow-y:auto; padding:2px 10px 12px; min-height:0;}
.sb-label{font-size:10.5px; font-weight:700; letter-spacing:1px; text-transform:uppercase; color:var(--muted); padding:14px 10px 6px; display:flex; align-items:center; justify-content:space-between;}
.sb-label button{color:var(--muted); border-radius:6px; padding:2px;} .sb-label button:hover{color:var(--text); background:var(--hover);}
.nav-item{position:relative; display:flex; align-items:center; gap:11px; height:38px; padding:0 10px; border-radius:9px; color:var(--text-2); font-weight:500; font-size:13.5px; transition:background .18s, color .18s;}
.nav-item .ic{width:18px; height:18px;}
.nav-item:hover{background:var(--hover); color:var(--text);}
.nav-item.on{background:var(--active); color:var(--text);}
.nav-item.on::before{content:""; position:absolute; left:-10px; top:9px; bottom:9px; width:3px; border-radius:0 3px 3px 0; background:linear-gradient(var(--accent),var(--accent-2)); animation:barIn .3s var(--ease);}
.nav-item.on .ic{color:var(--accent-text);}
.nav-item .badge{margin-left:auto;}
@keyframes barIn{from{transform:scaleY(0);}to{transform:scaleY(1);}}
.sb-board{display:flex; align-items:center; gap:9px; height:32px; padding:0 10px 0 14px; border-radius:8px; color:var(--text-2); font-size:13px; transition:background .18s,color .18s;}
.sb-board:hover{background:var(--hover); color:var(--text);} .sb-board.on{color:var(--text); background:var(--hover);}
.sb-board .bi{width:20px; text-align:center; font-size:13px;}
.sb-foot{border-top:1px solid var(--border); padding:12px;}
.storage-mini{padding:10px 10px 12px; border-radius:10px; transition:background .2s; display:block;}
.storage-mini:hover{background:var(--hover);}
.storage-mini .row{font-size:12px; color:var(--text-2); margin-bottom:7px; justify-content:space-between;}
.user-card{display:flex; align-items:center; gap:10px; padding:8px; border-radius:11px; width:100%; text-align:left; transition:background .2s;}
.user-card:hover{background:var(--hover);}
.user-card .uc-name{font-weight:600; font-size:13.5px;} .user-card .uc-sub{font-size:11.5px; color:var(--muted);}

.main{display:flex; flex-direction:column; min-width:0; min-height:0; position:relative;}
.topbar{height:var(--topbar-h); display:flex; align-items:center; gap:8px; padding:0 18px 0 22px; border-bottom:1px solid var(--border);
  background:color-mix(in srgb,var(--bg) 80%,transparent); backdrop-filter:blur(14px) saturate(1.3); position:relative; z-index:30; flex-shrink:0;}
.topbar .crumbs{display:flex; align-items:center; gap:8px; font-weight:600; font-size:14px; min-width:0;}
.topbar .crumbs .muted{font-weight:500;}
.topbar .tb-actions{margin-left:auto; display:flex; align-items:center; gap:4px;}
.notif-dot{position:absolute; top:6px; right:6px; min-width:16px; height:16px; padding:0 4px; border-radius:999px; background:var(--bad); color:#fff; font-size:10px; font-weight:700; display:flex; align-items:center; justify-content:center; box-shadow:0 0 0 2px var(--bg); animation:pop .4s var(--ease-spring);}
@keyframes pop{0%{transform:scale(0);}100%{transform:scale(1);}}
.content{flex:1; overflow-y:auto; overflow-x:hidden; min-height:0; scroll-behavior:smooth;}
.page{max-width:1320px; margin:0 auto; padding:26px 28px 48px;}
.page.wide{max-width:none;}
.page.flush{padding:0; max-width:none; height:100%;}
.page-head{display:flex; align-items:flex-end; justify-content:space-between; gap:16px; flex-wrap:wrap; margin-bottom:22px;}
/* title block claims a real width so the actions wrap below it on phones */
.page-head > .grow{flex:1 1 260px;}
.page-title{font-size:26px; font-weight:700; letter-spacing:-.03em;}
.page-sub{color:var(--text-2); margin-top:4px; font-size:14px;}
.page-actions{display:flex; gap:8px; flex-wrap:wrap; align-items:center;}
/* "backwards" (not "both"): a transform kept after the animation would trap position:fixed children */
.page-enter{animation:pageIn .42s var(--ease) backwards;}
@keyframes pageIn{from{opacity:0; transform:translateY(10px);}to{opacity:1; transform:none;}}
.stagger > *{animation:fadeUp .5s var(--ease) backwards; animation-delay:calc(var(--i,0) * 45ms);}
@keyframes fadeUp{from{opacity:0; transform:translateY(12px);}to{opacity:1; transform:none;}}
.fade-in{animation:fadeIn .3s ease both;}
@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}

.bottom-nav{display:none;}
.drawer-backdrop{display:none;}

@media (max-width:899px){
  .app{grid-template-columns:1fr;}
  .sidebar{position:fixed; inset:0 auto 0 0; width:min(84vw,300px); transform:translateX(-102%); transition:transform .35s var(--ease); box-shadow:var(--shadow-lg); padding-top:env(safe-area-inset-top);}
  .app.drawer-open .sidebar{transform:none;}
  .drawer-backdrop{display:block; position:fixed; inset:0; z-index:39; background:rgba(0,0,0,.5); backdrop-filter:blur(2px); opacity:0; pointer-events:none; transition:opacity .3s;}
  .app.drawer-open .drawer-backdrop{opacity:1; pointer-events:auto;}
  .topbar{padding:0 8px 0 12px; padding-top:env(safe-area-inset-top); height:calc(var(--topbar-h) + env(safe-area-inset-top));}
  .content{padding-bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom));}
  .page{padding:18px 16px 32px;}
  .page-title{font-size:22px;}
  .page-head{margin-bottom:16px; align-items:flex-start;}
  .bottom-nav{display:grid; grid-template-columns:repeat(5,1fr); position:fixed; left:0; right:0; bottom:0; z-index:35;
    height:calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom:env(safe-area-inset-bottom);
    background:color-mix(in srgb,var(--bg-2) 88%,transparent); backdrop-filter:blur(16px) saturate(1.4); border-top:1px solid var(--border);}
  .bn-item{display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; font-size:10.5px; font-weight:600; color:var(--muted); position:relative; transition:color .2s;}
  .bn-item .ic{width:21px; height:21px; transition:transform .3s var(--ease-spring);}
  .bn-item.on{color:var(--accent-text);} .bn-item.on .ic{transform:translateY(-2px) scale(1.08);}
  .bn-item.on::before{content:""; position:absolute; top:6px; width:40px; height:30px; border-radius:10px; background:var(--accent-soft); z-index:-1; animation:pop .35s var(--ease-spring);}
  .bn-item .notif-dot{top:6px; right:calc(50% - 20px);}
  .btn,.input,.select{min-height:40px;} .btn-sm{min-height:34px;}
  .input,.select,.textarea{font-size:16px;} /* stops iOS zoom on focus */
}

/* ---------- modal / sheet ---------- */
.modal-backdrop{position:fixed; inset:0; z-index:100; background:rgba(4,5,10,.6); backdrop-filter:blur(4px); display:flex; align-items:center; justify-content:center; padding:24px; animation:fadeIn .2s ease both;}
.modal{background:var(--surface); border:1px solid var(--border-strong); border-radius:var(--radius-xl); box-shadow:var(--shadow-lg); width:100%; max-height:calc(100dvh - 48px); display:flex; flex-direction:column; animation:modalIn .32s var(--ease-spring) both; min-height:0;}
.modal-sm{max-width:420px;} .modal-md{max-width:560px;} .modal-lg{max-width:860px;} .modal-xl{max-width:1100px;}
.modal-head{display:flex; align-items:center; gap:12px; padding:18px 20px 14px; border-bottom:1px solid var(--border);}
.modal-head h3{font-size:17px; flex:1; min-width:0;}
.modal-body{padding:18px 20px; overflow-y:auto; min-height:0; flex:1;}
.modal-foot{display:flex; justify-content:flex-end; gap:8px; padding:14px 20px; border-top:1px solid var(--border); flex-wrap:wrap;}
.modal-backdrop.closing{animation:fadeOut .2s ease both;} .modal-backdrop.closing .modal{animation:modalOut .2s ease both;}
@keyframes modalIn{from{opacity:0; transform:translateY(14px) scale(.97);}to{opacity:1; transform:none;}}
@keyframes modalOut{to{opacity:0; transform:translateY(10px) scale(.98);}}
@keyframes fadeOut{to{opacity:0;}}
@media (max-width:640px){
  .modal-backdrop{align-items:flex-end; padding:0;}
  .modal{max-width:none !important; border-radius:20px 20px 0 0; max-height:92dvh; animation:sheetIn .38s var(--ease) both; padding-bottom:env(safe-area-inset-bottom);}
  .modal.modal-full-mobile{max-height:100dvh; height:100dvh; border-radius:0;}
  .modal-head::before{content:""; position:absolute; left:50%; top:7px; width:38px; height:4px; border-radius:4px; background:var(--border-strong); transform:translateX(-50%);}
  .modal-head{position:relative; padding-top:22px;}
  .modal-backdrop.closing .modal{animation:sheetOut .22s ease both;}
  @keyframes sheetIn{from{transform:translateY(100%);}to{transform:none;}}
  @keyframes sheetOut{to{transform:translateY(100%);}}
}

/* ---------- popover menu ---------- */
.menu{position:fixed; z-index:120; min-width:200px; max-width:300px; max-height:calc(100dvh - 16px); overflow-y:auto; background:var(--surface-2); border:1px solid var(--border-strong); border-radius:12px; box-shadow:var(--shadow-lg); padding:5px; animation:menuIn .18s var(--ease) both; transform-origin:top right;}
.menu-item{display:flex; align-items:center; gap:10px; width:100%; height:34px; padding:0 10px; border-radius:8px; font-size:13.5px; color:var(--text); text-align:left;}
.menu-item:hover,.menu-item:focus-visible{background:var(--hover); outline:none;}
.menu-item .ic{color:var(--text-2); width:15px; height:15px;}
.menu-item.danger{color:var(--bad);} .menu-item.danger .ic{color:var(--bad);}
.menu-item:disabled{opacity:.45; cursor:not-allowed;}
.menu-item .hint{margin-left:auto; font-size:11.5px; color:var(--muted);}
.menu-sep{height:1px; background:var(--border); margin:5px 4px;}
.menu-label{font-size:11px; font-weight:600; color:var(--muted); padding:6px 10px 4px; text-transform:uppercase; letter-spacing:.6px;}
@keyframes menuIn{from{opacity:0; transform:scale(.96) translateY(-4px);}to{opacity:1; transform:none;}}
@media (max-width:640px){
  .menu.as-sheet{left:8px !important; right:8px !important; top:auto !important; bottom:calc(8px + env(safe-area-inset-bottom)) !important; max-width:none; border-radius:16px; padding:8px; animation:sheetIn .3s var(--ease) both;}
  .menu.as-sheet .menu-item{height:46px; font-size:15px;}
  .menu-scrim{position:fixed; inset:0; z-index:119; background:rgba(0,0,0,.45); animation:fadeIn .2s both;}
}

/* ---------- toasts ---------- */
.toasts{position:fixed; z-index:200; right:20px; bottom:20px; display:flex; flex-direction:column; gap:8px; align-items:flex-end; pointer-events:none;}
.toast{pointer-events:auto; display:flex; align-items:center; gap:10px; min-width:240px; max-width:380px; padding:11px 12px 11px 14px; border-radius:12px; background:var(--surface-3); border:1px solid var(--border-strong); box-shadow:var(--shadow-lg); font-size:13.5px; animation:toastIn .38s var(--ease-spring) both;}
.toast .ic{width:17px; height:17px;} .toast.success .ic{color:var(--good);} .toast.error .ic{color:var(--bad);} .toast.info .ic{color:var(--accent-text);} .toast.warn .ic{color:var(--warn);}
.toast .t-msg{flex:1;} .toast button{font-weight:700; color:var(--accent-text); font-size:13px; padding:4px 6px; border-radius:6px;}
.toast button:hover{background:var(--hover);}
.toast.out{animation:toastOut .25s ease both;}
@keyframes toastIn{from{opacity:0; transform:translateY(16px) scale(.95);}to{opacity:1; transform:none;}}
@keyframes toastOut{to{opacity:0; transform:translateX(30px);}}
@media (max-width:899px){ .toasts{left:12px; right:12px; bottom:calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + 10px); align-items:stretch;} .toast{max-width:none;} }

/* ---------- command palette ---------- */
.palette-backdrop{position:fixed; inset:0; z-index:150; background:rgba(4,5,10,.55); backdrop-filter:blur(3px); display:flex; justify-content:center; padding:12vh 16px 16px; animation:fadeIn .15s both;}
.palette{width:100%; max-width:620px; background:var(--surface); border:1px solid var(--border-strong); border-radius:16px; box-shadow:var(--shadow-lg); overflow:hidden; display:flex; flex-direction:column; max-height:70vh; animation:modalIn .25s var(--ease) both; align-self:flex-start;}
.palette-input{display:flex; align-items:center; gap:10px; padding:0 16px; border-bottom:1px solid var(--border);}
.palette-input input{flex:1; height:54px; background:none; border:0; outline:none; font-size:16px;}
.palette-input .ic{color:var(--muted); width:18px; height:18px;}
.palette-list{overflow-y:auto; padding:6px;}
.palette-group{font-size:11px; font-weight:600; letter-spacing:.6px; text-transform:uppercase; color:var(--muted); padding:10px 10px 4px;}
.palette-item{display:flex; align-items:center; gap:11px; padding:9px 10px; border-radius:9px; cursor:pointer; font-size:14px;}
.palette-item .ic{color:var(--text-2);} .palette-item .pi-sub{margin-left:auto; font-size:12px; color:var(--muted);}
.palette-item.sel{background:var(--accent-soft);} .palette-item.sel .ic{color:var(--accent-text);}
.palette-foot{display:flex; gap:14px; padding:9px 14px; border-top:1px solid var(--border); font-size:11.5px; color:var(--muted);}
@media (max-width:640px){ .palette-backdrop{padding:10px;} .palette{max-height:80vh;} .palette-foot{display:none;} }

/* ---------- notifications panel ---------- */
.notif-panel{position:fixed; z-index:110; top:calc(var(--topbar-h) - 4px); right:14px; width:380px; max-height:min(560px,75vh); display:flex; flex-direction:column;
  background:var(--surface); border:1px solid var(--border-strong); border-radius:16px; box-shadow:var(--shadow-lg); animation:menuIn .2s var(--ease) both; overflow:hidden;}
.notif-head{display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border);}
.notif-list{overflow-y:auto;}
.notif-item{display:flex; gap:11px; padding:12px 16px; border-bottom:1px solid var(--border); cursor:pointer; transition:background .15s; position:relative;}
.notif-item:hover{background:var(--hover);}
.notif-item.unread::after{content:""; position:absolute; right:14px; top:18px; width:8px; height:8px; border-radius:50%; background:var(--accent);}
.notif-item .nt{font-size:13.5px; padding-right:14px;} .notif-item .nm{font-size:11.5px; color:var(--muted); margin-top:2px;}
@media (max-width:640px){ .notif-panel{left:8px; right:8px; width:auto; top:calc(var(--topbar-h) + env(safe-area-inset-top));} }

/* ---------- auth screens ---------- */
.auth{min-height:100vh; min-height:100dvh; display:flex; align-items:center; justify-content:center; padding:24px 16px; position:relative; overflow:hidden; overflow-y:auto; height:100%;}
.auth-bg{position:fixed; inset:0; z-index:0; pointer-events:none; overflow:hidden;}
.auth-bg i{position:absolute; border-radius:50%; filter:blur(80px); opacity:.5;}
.auth-bg i:nth-child(1){width:520px; height:520px; left:-120px; top:-140px; background:#3f5fe0; animation:drift1 18s ease-in-out infinite;}
.auth-bg i:nth-child(2){width:440px; height:440px; right:-120px; bottom:-120px; background:#7451f0; animation:drift2 22s ease-in-out infinite;}
.auth-bg i:nth-child(3){width:300px; height:300px; left:55%; top:20%; background:#d07bff; opacity:.18; animation:drift1 26s ease-in-out infinite reverse;}
:root[data-theme="light"] .auth-bg i{opacity:.22;}
@keyframes drift1{0%,100%{transform:translate(0,0);}50%{transform:translate(80px,60px);}}
@keyframes drift2{0%,100%{transform:translate(0,0);}50%{transform:translate(-70px,-50px);}}
.auth-grid{position:absolute; inset:0; background-image:linear-gradient(var(--border) 1px,transparent 1px),linear-gradient(90deg,var(--border) 1px,transparent 1px); background-size:44px 44px; mask-image:radial-gradient(circle at 50% 40%,#000,transparent 70%); opacity:.6;}
.auth-card{position:relative; z-index:1; width:100%; max-width:410px; background:color-mix(in srgb,var(--surface) 88%,transparent); backdrop-filter:blur(20px); border:1px solid var(--border-strong); border-radius:24px; padding:34px 30px 28px; box-shadow:var(--shadow-lg); animation:modalIn .55s var(--ease) both;}
.auth-card.wide{max-width:480px;}
.auth-brand{display:flex; flex-direction:column; align-items:center; gap:12px; text-align:center; margin-bottom:26px;}
.auth-brand img{width:58px; height:58px; border-radius:50%; box-shadow:0 10px 30px -8px rgba(91,124,250,.8); animation:float 5s ease-in-out infinite;}
.auth-brand h1{font-size:22px;} .auth-brand p{color:var(--text-2); font-size:13.5px;}
.auth-form{display:flex; flex-direction:column; gap:14px;}
.auth-error{padding:10px 12px; border-radius:10px; background:var(--bad-soft); color:var(--bad); font-size:13px; border:1px solid color-mix(in srgb,var(--bad) 25%,transparent); animation:shake .4s ease;}
.auth-warn{padding:10px 12px; border-radius:10px; background:var(--warn-soft); color:var(--warn); font-size:12.5px; line-height:1.45; border:1px solid color-mix(in srgb,var(--warn) 25%,transparent);}
.auth-foot{text-align:center; margin-top:18px; font-size:12px; color:var(--muted);}
.auth-foot a{color:var(--text-2);} .auth-foot a:hover{color:var(--text);}
@keyframes shake{10%,90%{transform:translateX(-1px);}20%,80%{transform:translateX(2px);}30%,50%,70%{transform:translateX(-4px);}40%,60%{transform:translateX(4px);}}
.pw-wrap{position:relative;} .pw-wrap .input{padding-right:42px;}
.pw-wrap .icon-btn{position:absolute; right:3px; top:50%; transform:translateY(-50%); width:32px; height:32px;}
.otp-input{text-align:center; font-family:var(--font-mono); font-size:22px !important; letter-spacing:.4em; height:52px;}
.strength{display:flex; gap:4px; margin-top:2px;} .strength i{flex:1; height:4px; border-radius:4px; background:var(--surface-3); transition:background .3s;}
.strength.s1 i:nth-child(-n+1){background:var(--bad);} .strength.s2 i:nth-child(-n+2){background:var(--warn);}
.strength.s3 i:nth-child(-n+3){background:#9ccf3c;} .strength.s4 i{background:var(--good);}
.qr-box{background:#fff; border-radius:14px; padding:12px; width:fit-content; margin:0 auto; box-shadow:var(--shadow);}
.qr-box svg,.qr-box img{width:180px; height:180px;}
.secret-box{font-family:var(--font-mono); font-size:13.5px; letter-spacing:.08em; padding:10px 12px; border-radius:10px; background:var(--surface-2); border:1px dashed var(--border-strong); text-align:center; word-break:break-all; user-select:all;}
.codes-grid{display:grid; grid-template-columns:1fr 1fr; gap:6px; font-family:var(--font-mono); font-size:13.5px;}
.codes-grid span{padding:7px 10px; border-radius:8px; background:var(--surface-2); text-align:center;}
.steps{display:flex; gap:6px; justify-content:center; margin-bottom:18px;} .steps i{width:22px; height:4px; border-radius:4px; background:var(--surface-3); transition:all .3s;} .steps i.on{background:var(--accent); width:34px;}

/* ---------- boot loader ---------- */
.boot{position:fixed; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; background:var(--bg); z-index:300; transition:opacity .35s;}
.boot img{width:54px; height:54px; border-radius:50%; animation:bootPulse 1.4s ease-in-out infinite;}
.boot.done{opacity:0; pointer-events:none;}
@keyframes bootPulse{0%,100%{transform:scale(1); box-shadow:0 0 0 0 rgba(91,124,250,.5);}50%{transform:scale(1.06); box-shadow:0 0 0 14px rgba(91,124,250,0);}}

/* ---------- markdown ---------- */
.md{font-size:14.5px; line-height:1.7; color:var(--text); word-wrap:break-word;}
.md > *:first-child{margin-top:0;} .md > *:last-child{margin-bottom:0;}
.md h1,.md h2,.md h3,.md h4{margin:1.4em 0 .5em;} .md h1{font-size:1.75em;} .md h2{font-size:1.38em; padding-bottom:.3em; border-bottom:1px solid var(--border);} .md h3{font-size:1.15em;} .md h4{font-size:1em;}
.md p,.md ul,.md ol,.md blockquote,.md pre,.md table{margin:0 0 .9em;}
.md ul,.md ol{padding-left:1.5em;} .md li{margin:.2em 0;} .md li > ul,.md li > ol{margin:.2em 0;}
.md li.task{list-style:none; margin-left:-1.4em; display:flex; gap:8px; align-items:flex-start;}
.md li.task input{margin-top:.38em; accent-color:var(--accent); pointer-events:none;}
.md li.task.done > span{color:var(--muted); text-decoration:line-through;}
.md a{color:var(--accent-text); text-decoration:underline; text-underline-offset:3px; text-decoration-color:color-mix(in srgb,var(--accent) 45%,transparent);}
.md a:hover{text-decoration-color:currentColor;}
.md code{font-family:var(--font-mono); font-size:.86em; padding:.15em .4em; border-radius:6px; background:var(--surface-3); border:1px solid var(--border);}
.md pre{background:var(--surface-2); border:1px solid var(--border); border-radius:12px; padding:14px 16px; overflow-x:auto; font-size:13px; line-height:1.6;}
.md pre code{background:none; border:0; padding:0; font-size:inherit;}
.md blockquote{border-left:3px solid var(--accent); padding:.2em 0 .2em 1em; color:var(--text-2); background:var(--accent-soft); border-radius:0 10px 10px 0;}
.md hr{border:0; height:1px; background:var(--border); margin:1.6em 0;}
.md table{border-collapse:collapse; width:100%; display:block; overflow-x:auto;}
.md th,.md td{border:1px solid var(--border); padding:7px 11px; text-align:left;} .md th{background:var(--surface-2); font-weight:600;}
.md img{max-width:100%; border-radius:10px; margin:.4em 0;}
.md .mention{color:var(--accent-text); font-weight:600; background:var(--accent-soft); padding:0 4px; border-radius:5px; text-decoration:none;}
.md mark{background:color-mix(in srgb,var(--warn) 30%,transparent); color:inherit; padding:0 2px; border-radius:3px;}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; scroll-behavior:auto !important;}
}
:root[data-motion="reduce"] *,:root[data-motion="reduce"] *::before,:root[data-motion="reduce"] *::after{animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important;}
