/* Dashboard shell (icon rail, section sidebar, top bar) and the section pages. */
.dash {
  display: grid; min-height: 100vh;
  grid-template-columns: var(--dash-rail-w) var(--dash-side-w) minmax(0, 1fr);
  grid-template-rows: var(--dash-topbar-h) 1fr;
  grid-template-areas: "rail side top" "rail side main";
}
.dash[data-side="off"] { grid-template-columns: var(--dash-rail-w) 0 minmax(0, 1fr); }

/* icon rail */
.rail { grid-area: rail; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); padding: 0 0 var(--sp-3); border-right: 1px solid var(--sb-border); background: var(--sb-bg); z-index: 20; }
.rail-logo { display: grid; place-items: center; width: 100%; height: var(--dash-topbar-h); border-bottom: 1px solid var(--sb-border); margin-bottom: var(--sp-2); flex: none; }
.rail-logo img { width: 22px; height: 22px; border-radius: 5px; }
.rail-item { position: relative; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); color: var(--sb-text-muted); text-decoration: none; }
.rail-item:hover { background: var(--sb-surface-2); color: var(--sb-text); text-decoration: none; }
.rail-item[aria-current="true"] { background: var(--sb-surface-3); color: var(--sb-text); }
.rail-item .tip { position: absolute; left: 40px; top: 50%; translate: 0 -50%; padding: 4px 8px; border-radius: var(--r-sm); background: var(--sb-surface-3); border: 1px solid var(--sb-border-strong); color: var(--sb-text); font-size: var(--fs-xs); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 30; }
.rail-item:hover .tip, .rail-item:focus-visible .tip { opacity: 1; }
.rail-end { margin-top: auto; display: grid; gap: var(--sp-1); }

/* section sidebar */
.side { grid-area: side; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--sb-border); background: var(--sb-bg); }
.dash[data-side="off"] .side { display: none; }
.side-title { display: flex; align-items: center; height: var(--dash-topbar-h); padding: 0 var(--sp-4); border-bottom: 1px solid var(--sb-border); font-family: var(--font-display); font-weight: var(--fw-semibold); }
.side-nav { display: grid; gap: 2px; padding: var(--sp-3) var(--sp-2); }
.side-label { padding: var(--sp-3) var(--sp-3) var(--sp-1); color: var(--sb-text-faint); font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.nav-item { display: flex; align-items: center; gap: var(--sp-3); height: 30px; padding: 0 var(--sp-3); border-radius: var(--r-md); color: var(--sb-text-muted); font-size: var(--fs-sm); text-decoration: none; }
.nav-item:hover { background: var(--sb-surface-2); color: var(--sb-text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--sb-surface-3); color: var(--sb-text); }

/* top bar */
.topbar { grid-area: top; position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: var(--sp-3); height: var(--dash-topbar-h); padding: 0 var(--sp-5); border-bottom: 1px solid var(--sb-border); background: var(--sb-bg); }
.crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-sm); color: var(--sb-text-muted); }
.crumbs a { color: var(--sb-text-muted); }
.crumbs a:hover { color: var(--sb-text); text-decoration: none; }
.crumbs .sep { color: var(--sb-text-faint); }
.crumbs [aria-current="page"] { color: var(--sb-text); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .menu-btn, .topbar .brand { display: none; }
.user-btn { display: inline-flex; align-items: center; gap: var(--sp-2); height: 32px; padding: 0 var(--sp-2) 0 var(--sp-1); border: 1px solid transparent; border-radius: var(--r-md); background: none; color: var(--sb-text); font-size: var(--fs-sm); }
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--sb-surface-2); }
.user-btn .name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-wrap { position: relative; }
.user-wrap .menu { right: 0; top: 38px; }

/* main */
.main { grid-area: main; min-width: 0; }
.page { width: 100%; padding: var(--sp-6) var(--sp-6) var(--sp-8); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); align-content: start; } /* minmax(0, ...) and min-width: 0 let code blocks scroll inside the page instead of widening it */
.page > * { min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-head h1 { font-size: 24px; line-height: 1.25; font-weight: var(--fw-semibold); }
.page-head p { margin: 4px 0 0; color: var(--sb-text-muted); max-width: 64ch; }
.section-title { display: flex; align-items: center; gap: var(--sp-3); margin: 0 0 var(--sp-3); font-size: var(--fs-md); }
.section-title .badge { margin-left: 0; }

/* slide-over menu on small screens */
.drawer { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 86vw); display: flex; flex-direction: column; background: var(--sb-bg); border-right: 1px solid var(--sb-border-strong); transform: translateX(-100%); transition: transform .2s var(--ease); visibility: hidden; }
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; height: var(--dash-topbar-h); padding: 0 var(--sp-3) 0 var(--sp-4); border-bottom: 1px solid var(--sb-border); flex: none; }
.drawer .side-nav { overflow-y: auto; }
.scrim { position: fixed; inset: 0; z-index: 55; background: var(--sb-overlay); }
.brand { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--sb-text); font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-md); text-decoration: none; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 22px; height: 22px; border-radius: 5px; }

@media (max-width: 768px) {
  .dash, .dash[data-side="off"] { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .rail, .side { display: none; }
  .topbar { padding: 0 var(--sp-3); }
  .topbar .menu-btn, .topbar .brand { display: inline-flex; }
  .crumbs { display: none; }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
  .user-btn .name { display: none; }
}
@media (min-width: 769px) { .drawer, .scrim { display: none; } }

/* ---------- overview ---------- */
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.quick-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-4); border: 1px solid var(--sb-border); border-radius: var(--r-lg); background: var(--sb-surface-1); color: var(--sb-text); text-align: left; width: 100%; text-decoration: none; }
.quick-item:hover { background: var(--sb-surface-2); border-color: var(--sb-border-strong); text-decoration: none; }
.quick-item .tile { background: var(--sb-brand-soft); color: var(--sb-ok); }
.quick-item strong { display: block; font-weight: var(--fw-semibold); }
.quick-item span { color: var(--sb-text-muted); font-size: var(--fs-xs); }
@media (max-width: 720px) { .quick { grid-template-columns: minmax(0, 1fr); } }
.rowlist { list-style: none; margin: 0; padding: 0; }
.rowlist li { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--sb-border); }
.rowlist li:last-child { border-bottom: 0; }
.rowlist .cell-name { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.rowlist .cell-title { font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowlist .cell-sub { color: var(--sb-text-muted); font-size: var(--fs-xs); }
.rowlist .cell-text { display: grid; min-width: 0; }
.cli-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--sp-5); align-items: center; }
.cli-card h3 { font-size: var(--fs-md); margin-bottom: var(--sp-1); }
.cli-card p { color: var(--sb-text-muted); margin: 0 0 var(--sp-3); }
@media (max-width: 800px) { .cli-card { grid-template-columns: minmax(0, 1fr); } }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-5); counter-reset: step; }
.steps > li { min-width: 0; position: relative; padding-left: 40px; counter-increment: step; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--sb-border-strong); background: var(--sb-surface-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--sb-text-muted); }
.steps h3 { font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.steps p { color: var(--sb-text-muted); margin: 0 0 var(--sp-2); }

/* ---------- files ---------- */
.drop { display: grid; gap: var(--sp-4); padding: var(--sp-5); border: 1px dashed var(--sb-border-strong); border-radius: var(--r-lg); background: var(--sb-surface-1); }
.drop-main { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.drop-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-md); background: var(--sb-surface-3); color: var(--sb-text-muted); flex: none; }
.drop-text { flex: 1; min-width: 200px; display: grid; }
.drop-text span { color: var(--sb-text-muted); font-size: var(--fs-xs); }
.drop-opts { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.progress { display: block; height: 3px; border-radius: var(--r-pill); background: var(--sb-surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--sb-brand); transition: width .1s linear; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
#overlay { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: var(--sb-overlay); color: var(--sb-text); font-family: var(--font-display); font-size: var(--fs-h3); font-weight: var(--fw-semibold); border: 2px dashed var(--sb-brand); pointer-events: none; }
.paste { border: 1px solid var(--sb-border); border-radius: var(--r-lg); background: var(--sb-surface-1); }
.paste > summary { padding: var(--sp-3) var(--sp-4); cursor: pointer; font-weight: var(--fw-medium); list-style: none; display: flex; align-items: center; gap: var(--sp-2); }
.paste > summary::-webkit-details-marker { display: none; }
.paste > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 1.5px solid var(--sb-text-muted); border-bottom: 1.5px solid var(--sb-text-muted); rotate: 45deg; translate: 0 -2px; }
.paste[open] > summary::after { rotate: 225deg; translate: 0 2px; }
.paste-form { display: grid; gap: var(--sp-3); padding: 0 var(--sp-4) var(--sp-4); }
.paste-row, .form-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; }
.paste-row > .field, .form-row > .field, .paste-row > .check, .form-row > .check { margin-bottom: 0; }
.paste-row > .check, .form-row > .check { min-height: 32px; } /* same height as the controls beside it, so its label centres on theirs */ /* the row's gap spaces it; a bottom margin would lift the button above the input */
.paste-row .input { width: auto; flex: 1; min-width: 160px; }

/* ---------- keys, users, account ---------- */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-3) var(--sp-6); margin: 0; }
.facts dt { color: var(--sb-text-muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }

/* ---------- link activity dialog (links.js) ---------- */
.act-dlg { width: min(720px, calc(100vw - 24px)); }
.abody { flex: 1; min-height: 0; overflow: auto; padding: var(--sp-5); }
.astats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.astat { display: grid; gap: 2px; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--sb-border); border-radius: var(--r-lg); background: var(--sb-surface-2); min-width: 0; }
.astat-label { color: var(--sb-text-muted); font-size: var(--fs-xs); }
.astat-val { font-family: var(--font-display); font-size: var(--fs-h3); line-height: 28px; font-weight: var(--fw-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.astat:last-child .astat-val { font-size: var(--fs-sm); }
.afacts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: var(--sp-4) 0 0; }
.afacts dt { color: var(--sb-text-muted); }
.afacts dd { margin: 0; overflow-wrap: anywhere; }
.ahint { margin: var(--sp-3) 0 0; color: var(--sb-text-muted); font-size: var(--fs-xs); }
.asect { display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-5) 0 var(--sp-2); }
.asessions { list-style: none; margin: 0; padding: 0; border: 1px solid var(--sb-border); border-radius: var(--r-lg); overflow: hidden; }
.asess + .asess { border-top: 1px solid var(--sb-border); }
.asess-head { display: flex; align-items: flex-start; gap: var(--sp-3); width: 100%; padding: var(--sp-3) var(--sp-4); border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.asess-head:hover { background: var(--sb-surface-2); }
.asess-head[aria-expanded=true] .chev { transform: rotate(180deg); }
.avatar.isbot { background: var(--sb-warn-soft); color: var(--sb-warn); }
.acol { display: grid; flex: 1; gap: 2px; min-width: 0; }
.aline1 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.awhen { margin-left: auto; color: var(--sb-text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.aline { color: var(--sb-text-muted); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.aline code { color: var(--sb-text); white-space: nowrap; }
.aacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chev { flex: none; margin-top: 7px; color: var(--sb-text-faint); transition: transform .15s; }
.asess.isbot .acol > :not(.aline1) { opacity: .8; }
.adetail { padding: 0 var(--sp-4) var(--sp-4) 56px; }
.adetail .aline { margin: 0 0 var(--sp-2); }
.tl { list-style: none; margin: 0; padding: 0 0 0 var(--sp-3); display: grid; gap: 4px; border-left: 1px solid var(--sb-border); }
.tl li { display: flex; gap: var(--sp-3); font-size: var(--fs-xs); }
.tl-when { flex: none; min-width: 150px; color: var(--sb-text-muted); }
@media (max-width: 640px) {
  .astats { grid-template-columns: 1fr 1fr; }
  .abody { padding: var(--sp-4); }
  .awhen { flex-basis: 100%; margin-left: 0; order: 3; }
  .adetail { padding-left: var(--sp-4); }
  .tl li { flex-direction: column; gap: 0; } .tl-when { min-width: 0; }
  .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; } .facts dd { margin-bottom: var(--sp-3); }
}
label.btn:has(.file-input:focus-visible) { outline: 2px solid var(--sb-brand); outline-offset: 2px; }

/* recent uploads: a pill at the bottom-left that opens a short list of the newest files */
.recent { position: fixed; z-index: 40; right: var(--sp-4); bottom: var(--sp-4); display: grid; gap: var(--sp-3); justify-items: end; } /* bottom-right: the rail and sidebar own the left edge */
.recent-pill { display: inline-flex; align-items: center; gap: var(--sp-3); height: 44px; padding: 0 var(--sp-4); border: 1px solid var(--sb-border-strong); border-radius: var(--r-pill); background: var(--sb-surface-2); color: var(--sb-text); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; box-shadow: 0 8px 24px rgb(0 0 0 / .3); }
.recent-pill:hover { background: var(--sb-surface-3); }
.recent-pill .ic, .recent-pill svg { color: var(--sb-brand); }
.recent-count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill); background: var(--sb-brand-fill); color: var(--sb-on-brand); font-size: var(--fs-xs); font-weight: var(--fw-semibold); }
.recent-panel { width: min(380px, calc(100vw - 2 * var(--sp-4))); border: 1px solid var(--sb-border-strong); border-radius: var(--r-xl); background: var(--sb-surface-1); box-shadow: 0 24px 60px rgb(0 0 0 / .45); overflow: hidden; }
.recent-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--sb-border); }
.recent-head h2 { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.recent-list { max-height: min(46vh, 340px); overflow-y: auto; }
.recent-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--sb-border); }
.recent-row:last-child { border-bottom: 0; }
.recent-text { display: grid; flex: 1; min-width: 0; }
.recent-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-medium); }
.recent-sub { color: var(--sb-text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.recent-foot { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--sb-border); background: var(--sb-surface-2); }
.recent-foot p { margin: 0; color: var(--sb-text-muted); font-size: var(--fs-sm); }
.recent-foot-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--sb-brand-soft); color: var(--sb-brand); flex: none; }
@media (max-width: 768px) { .recent { right: var(--sp-3); bottom: var(--sp-3); } }

/* settings */
.theme-opts { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-3) 0; }
.theme-opt { display: inline-flex; align-items: center; gap: var(--sp-3); height: 44px; padding: 0 var(--sp-4) 0 var(--sp-3); border: 1px solid var(--sb-border-strong); border-radius: var(--r-md); background: var(--sb-surface-2); color: var(--sb-text); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer; }
.theme-opt:hover { border-color: var(--sb-text-faint); }
.theme-opt[aria-pressed="true"] { border-color: var(--sb-brand); background: var(--sb-brand-soft); color: var(--sb-brand); }
.theme-swatch { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--sb-border-strong); flex: none; }
.theme-swatch[data-swatch="dark"] { background: #131413; }
.theme-swatch[data-swatch="light"] { background: #fcfcfc; }
.theme-swatch[data-swatch="system"] { background: linear-gradient(90deg, #131413 50%, #fcfcfc 50%); }
.plain-list { list-style: disc; margin: var(--sp-3) 0 var(--sp-4); padding-left: var(--sp-5); color: var(--sb-text-muted); display: grid; gap: var(--sp-1); }
.card-danger { border-color: color-mix(in srgb, var(--sb-bad) 45%, transparent); }
.card-danger .section-title { color: var(--sb-bad); }
.form-row .field { min-width: min(100%, 220px); }
.card-danger .form-row .field { flex: 1; max-width: 420px; }

/* account */
.profile-hero { display: flex; align-items: center; gap: var(--sp-5); flex-wrap: wrap; }
.profile-hero h2 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: var(--fw-semibold); }
.profile-hero p { margin: 2px 0 0; }
.profile-hero .chips { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.avatar-lg { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--sb-brand-soft); border: 1px solid var(--sb-brand-ring); color: var(--sb-brand); font-size: 22px; font-weight: var(--fw-semibold); letter-spacing: .02em; flex: none; }
.chip-soft { display: inline-flex; align-items: center; height: 26px; padding: 0 var(--sp-3); border-radius: var(--r-pill); background: var(--sb-surface-2); border: 1px solid var(--sb-border); color: var(--sb-text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.account-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--sp-5); align-items: start; }
@media (max-width: 960px) { .account-grid { grid-template-columns: minmax(0, 1fr); } .profile-hero .chips { margin-left: 0; } }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.sec-head .section-title { margin: 0; }
.profile-form { display: grid; gap: 0; max-width: 520px; }
.fp-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.fp { display: block; font: 12.5px var(--font-mono); color: var(--sb-text-muted); background: none; border: 0; padding: 0; overflow-wrap: anywhere; }
.soft { border: 0; border-top: 1px solid var(--sb-border); margin: var(--sp-4) 0; }
