/* ===========================================================
   XYZ Panel – design system
   Dark, quiet, monochrome. Colour only where it carries meaning
   (online/offline, diff, update available).
   =========================================================== */

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #141414;
  --bg-inset: #111111;
  --surface: #1c1c1c;
  --surface-sunken: #181818;
  --surface-hover: #242424;
  --border: #2c2c2c;
  --border-strong: #3d3d3d;
  --text: #f5f5f5;
  --text-muted: #9a9a9a;
  --text-faint: #6b6b6b;
  --ok: #46a758;
  --warn: #e3b341;
  --danger: #f47067;
  --danger-bg: #3a1d1d;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius: 12px;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.45);
  --ring: 0 0 0 3px rgba(255, 255, 255, 0.08);
  --header-h: 56px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-faint); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; letter-spacing: -0.02em; } h2 { font-size: 20px; } h3 { font-size: 15px; }
p { margin: 0; }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
:focus-visible { outline: 2px solid var(--text-faint); outline-offset: 2px; }
svg.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: text-bottom; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.text-success { color: var(--ok); } .text-danger { color: var(--danger); } .text-done { color: var(--text-muted); } .text-attention { color: var(--warn); }

/* ---------- brand ---------- */
.brand-mark { width: 32px; height: 32px; border-radius: var(--radius-md); display: grid; place-items: center; font-weight: 600; font-size: 12px; letter-spacing: 0.04em; color: var(--text); background: linear-gradient(180deg, #2a2a2a, #1f1f1f); border: 1px solid var(--border-strong); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 17px; }

/* ---------- header: brand · icon nav (centre) · actions ---------- */
.site-header { position: sticky; top: 0; z-index: 40; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; height: var(--header-h); padding: 0 20px; background: rgba(20, 20, 20, 0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.site-brand { justify-self: start; display: inline-flex; text-decoration: none !important; }
.site-brand:hover .brand-mark { border-color: var(--text-faint); }
.site-nav { display: flex; align-items: center; gap: 4px; }
.site-actions { justify-self: end; display: flex; align-items: center; gap: 2px; }
.site-icon { position: relative; display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: var(--radius-md); background: none; color: var(--text-faint); cursor: pointer; text-decoration: none !important; transition: color .15s, background .15s; }
.site-icon svg.icon { width: 18px; height: 18px; }
.site-icon:hover, .site-icon:focus-visible { color: var(--text); background: var(--surface-hover); outline: none; }
.site-icon[aria-current="page"] { color: var(--text); }
.site-icon[aria-current="page"]::before { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--text); }
.site-icon::after { content: attr(data-label); position: absolute; top: calc(100% + 8px); left: 50%; transform: translate(-50%, -4px); padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-hover); color: var(--text); font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .15s, transform .15s; }
.site-icon:hover::after, .site-icon:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .25s; }
.site-actions .site-icon:last-child::after { left: auto; right: 0; transform: translateY(-4px); }
.site-actions .site-icon:last-child:hover::after { transform: none; }

/* ---------- layout ---------- */
main { max-width: 1012px; margin: 0 auto; padding: 32px 24px 72px; }
main.wide { max-width: 1280px; }
.page-head { display: flex; align-items: center; gap: 8px 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1, .page-head h2 { flex: 1; min-width: 0; font-size: 24px; letter-spacing: -0.02em; line-height: 1.25; }
.page-title { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; padding-bottom: 16px; margin-bottom: 24px; border-bottom: 1px solid var(--border); animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.page-title h1, .page-title h2 { flex: 1; min-width: 0; font-size: 24px; letter-spacing: -0.02em; line-height: 1.25; }
.page-title .sub { display: block; margin-top: 2px; font-size: 14px; font-weight: 400; color: var(--text-muted); letter-spacing: 0; }
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.section-title { margin: 0 0 10px; font-size: 14px; font-weight: 600; }

/* underline tabs (repo, pull request) */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; padding: 10px 12px 12px; color: var(--text-muted); white-space: nowrap; text-decoration: none !important; }
.tab .tab-inner { display: inline-flex; align-items: center; gap: 8px; }
.tab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: 0; height: 2px; border-radius: 2px; background: transparent; }
.tab:hover { color: var(--text); }
.tab:hover::after { background: var(--border-strong); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { background: var(--text); }
.tab .icon { color: inherit; }

.avatar { width: 32px; height: 32px; flex: none; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-hover); border: 1px solid var(--border-strong); color: var(--text); font-size: 12px; font-weight: 600; letter-spacing: .02em; user-select: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; color: var(--text); background: var(--surface); cursor: pointer; text-decoration: none !important; transition: background .15s, border-color .15s, color .15s, opacity .15s; }
.btn:hover { background: var(--surface-hover); border-color: #4a4a4a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { color: var(--text-muted); }
.btn-primary { color: var(--bg); background: var(--text); border-color: transparent; }
.btn-primary:hover { background: #dedede; border-color: transparent; }
.btn-primary .icon { color: inherit; }
.btn-danger:hover { color: var(--danger); border-color: #5a2a2a; background: var(--surface); }
.btn-danger:hover .icon { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-icon { width: 34px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn-invisible { background: none; border-color: transparent; color: var(--text-muted); }
.btn-invisible:hover { color: var(--text); background: var(--surface-hover); border-color: var(--border); }
.btn-group { display: inline-flex; padding: 3px; gap: 3px; border-radius: var(--radius-md); background: var(--bg-inset); border: 1px solid var(--border-strong); }
.btn-group .btn { height: 28px; border: 0; background: none; color: var(--text-muted); font-size: 13px; padding: 0 10px; }
.btn-group .btn:hover { color: var(--text); }
.btn-group .btn.selected { background: var(--surface-hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ---------- inputs ---------- */
.input, select.input, textarea.input { width: 100%; min-height: 36px; padding: 7px 12px; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--bg-inset); color: var(--text); outline: none; font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: var(--text-faint); box-shadow: var(--ring); }
.input:disabled { opacity: .6; }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
select.input { appearance: none; cursor: pointer; padding-right: 32px; 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='%239a9a9a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
select.input option { background: var(--surface); }
.input-sm { min-height: 30px; height: 30px; font-size: 12px; padding: 3px 10px; }
.input-icon { position: relative; flex: 1; min-width: 180px; }
.input-icon .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.input-icon .input { padding-left: 34px; height: 34px; min-height: 34px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
label.field > span.hint { font-weight: 400; color: var(--text-faint); font-size: 12px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.checkbox input { accent-color: #e5e5e5; }

/* ---------- boxes ---------- */
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.box-header { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 16px; background: var(--surface-sunken); border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-muted); min-width: 0; }
.box-header:last-child { border-bottom: 0; }
.box-header h3, .box-header strong { font-size: 14px; color: var(--text); }
.box-body { padding: 16px; }
.box-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); min-height: 44px; min-width: 0; }
.box-header + .box-row, .box > .box-row:first-child { border-top: 0; }
.box-row.hover:hover { background: var(--surface-hover); }
.box-row.lg { padding: 12px 16px; }
.box-footer { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-sunken); }

.stat { animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.stat .stat-label { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.stat .stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: var(--surface-hover); border-radius: 999px; overflow: hidden; margin-top: 14px; }
.meter > i { display: block; height: 100%; background: var(--text-muted); border-radius: 999px; transition: width .4s; }
.meter > i.warn { background: var(--warn); } .meter > i.crit { background: var(--danger); }
.spark { width: 100%; height: 36px; margin-top: 10px; display: block; }

.label { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; font-size: 11px; font-weight: 500; line-height: 18px; border: 1px solid var(--border-strong); border-radius: 999px; white-space: nowrap; color: var(--text-muted); }
.label .icon { width: 12px; height: 12px; }
.label-accent { background: #3a3a3a; border-color: #3a3a3a; color: var(--text); }
.label-success { color: var(--ok); border-color: #2b4a31; }
.label-done { color: var(--text); }
.label-danger { color: var(--danger); border-color: #5a2a2a; }
.label-attention { color: var(--warn); border-color: #5a4a1d; }
.counter { display: inline-block; min-width: 20px; padding: 0 7px; border-radius: 999px; background: var(--surface-hover); color: var(--text); font-size: 12px; font-weight: 500; line-height: 20px; text-align: center; }
.state { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; border: 1px solid var(--border-strong); }
.state-open { color: var(--bg); background: var(--text); border-color: transparent; }
.state-closed { color: var(--text-muted); }
.state-merged { color: var(--text); background: #3a3a3a; border-color: #3a3a3a; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--text-faint); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(70, 167, 88, .15); }
.dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(244, 112, 103, .15); }

.blankslate { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.blankslate .icon { width: 22px; height: 22px; color: var(--text-faint); margin-bottom: 10px; }
.blankslate h3 { margin-bottom: 2px; font-size: 14px; color: var(--text); }
.blankslate p { color: var(--text-muted); margin: 0 0 14px; font-size: 13px; }

.flash { padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); display: flex; gap: 8px; align-items: center; font-size: 13px; background: var(--surface); }
.flash-danger { border-color: #5a2a2a; background: var(--danger-bg); }
.flash-warn { border-color: #5a4a1d; }
.flash-warn .icon { color: var(--warn); }
.flash-info { color: var(--text-muted); }

.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 16px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb strong, .breadcrumb a:last-child { color: var(--text); font-weight: 600; }
.breadcrumb .sep { color: var(--text-faint); }

/* ---------- login ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(900px 420px at 50% -120px, rgba(255, 255, 255, .05), transparent 70%); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; max-width: none; }
.login-card { width: 100%; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 32px; animation: rise .7s cubic-bezier(.2, .8, .2, 1) both; }
.login-card form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pw-row { width: 100%; display: flex; gap: 6px; padding: 5px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); transition: border-color .2s, box-shadow .2s; }
.pw-row:focus-within { border-color: var(--border-strong); box-shadow: 0 0 0 4px rgba(255, 255, 255, .06); }
.pw-row input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 12px; font-size: 15px; height: 38px; }
.pw-row input::placeholder { color: var(--text-faint); }
.pw-row input.otp { letter-spacing: .3em; font-variant-numeric: tabular-nums; }
.pw-row input.otp::placeholder { letter-spacing: normal; }
.pw-go { width: 38px; height: 38px; flex: none; border: 0; border-radius: 10px; color: var(--bg); background: var(--text); cursor: pointer; display: grid; place-items: center; transition: transform .15s, opacity .2s; }
.pw-go svg.icon { width: 18px; height: 18px; stroke-width: 2.2; }
.pw-go:hover { transform: translateX(2px); }
.pw-go:disabled { opacity: .5; cursor: wait; }
.msg { min-height: 18px; margin-top: 4px; font-size: 13px; color: var(--text-muted); text-align: center; }
.msg.error { color: var(--danger); }
.msg a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-faint); }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.qr { display: block; border-radius: var(--radius); background: #fff; padding: 6px; width: 176px; height: 176px; }
.secret { font: 12px var(--mono); color: var(--text-faint); text-align: center; word-break: break-all; user-select: all; }
.shake { animation: shake .4s; }

/* ---------- menus, dialogs, toasts ---------- */
.menu { position: absolute; z-index: 50; min-width: 200px; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: 13px; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-hover); text-decoration: none; }
.menu-item .icon { color: var(--text-muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px -6px; }
.menu-head { padding: 6px 10px 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }

dialog { margin: auto; padding: 20px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .55); width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
dialog[open] { animation: pop-in .16s ease-out; }
dialog.wide { width: min(680px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dialog-head h3 { flex: 1; font-size: 16px; }
.dialog-body { overflow: auto; max-height: calc(100dvh - 220px); padding: 2px; margin: -2px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 32px); }
.toast { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: var(--radius-md); background: var(--surface-hover); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop); font-size: 13px; animation: toast-in .2s ease-out; }
.toast .icon { color: var(--text-muted); } .toast.error .icon { color: var(--danger); }

.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--text-muted); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.loading { display: flex; justify-content: center; padding: 48px; }

/* ---------- files / code ---------- */
.file-row .icon { color: var(--text-faint); }
.file-row .icon.dir { color: var(--text-muted); fill: rgba(255, 255, 255, .06); }
.file-row a { color: var(--text); }
.file-row input[type=checkbox], .box-header input[type=checkbox] { accent-color: #e5e5e5; margin: 0; flex: none; }
.row-check-space { width: 13px; flex: none; }
.icon-space { width: 16px; flex: none; }
.col-by { width: 90px; text-align: right; }
.col-size { width: 80px; text-align: right; }
.col-time { width: 110px; text-align: right; }
.sort-row { min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
.sort-btn { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 0; border: 0; background: none; color: var(--text-muted); font-size: 12px; cursor: pointer; }
.sort-btn.grow { justify-content: flex-start; }
.sort-btn:hover, .sort-btn.on { color: var(--text); }
.sort-btn .icon { width: 12px; height: 12px; }
.file-row .lock { display: inline-flex; vertical-align: -2px; margin-left: 6px; }
.file-row .lock .icon { width: 13px; height: 13px; color: var(--text-faint); }
.access-rows { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); }
.access-level { width: 130px; flex: none; }
.access-choice { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.access-choice input { margin-top: 3px; accent-color: #e5e5e5; }
.drop-target { outline: 2px dashed var(--border-strong); outline-offset: 2px; }
.picker-list { max-height: 50vh; overflow: auto; }
.picker-row { width: 100%; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.picker-row:first-child { border-top: 0; }
.picker-row:disabled { opacity: .4; cursor: not-allowed; }
.preview { display: flex; justify-content: center; padding: 16px; background: var(--surface-sunken); }
.preview img { max-width: 100%; max-height: 75vh; object-fit: contain; }
.preview video { max-width: 100%; max-height: 75vh; }
.preview audio { width: min(560px, 100%); }
.preview-frame { width: 100%; height: 80vh; border: 0; background: #fff; }
.upload-panel { position: fixed; z-index: 60; right: 16px; bottom: 16px; width: min(380px, calc(100vw - 32px)); padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-hover); box-shadow: var(--shadow-pop); }
.upload-panel .meter { margin-top: 10px; }
.upload-panel .meter > i { width: 0; }
.code { overflow: auto; font: 12px/20px var(--mono); background: var(--surface); }
.code table { border-collapse: collapse; width: 100%; }
.code td { padding: 0 12px; white-space: pre; vertical-align: top; }
.code td.ln { width: 1%; min-width: 50px; text-align: right; color: var(--text-faint); user-select: none; }
.code tr:hover td { background: rgba(255, 255, 255, .03); }
.code-edit { font: 12px/20px var(--mono); border: 0 !important; border-radius: 0; box-shadow: none !important; min-height: 60vh; padding: 12px 16px; }
.markdown { padding: 24px 32px; line-height: 1.65; overflow-wrap: break-word; }
.markdown > :first-child { margin-top: 0; } .markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2 { padding-bottom: .3em; border-bottom: 1px solid var(--border); margin: 24px 0 16px; }
.markdown h1 { font-size: 1.8em; } .markdown h2 { font-size: 1.4em; } .markdown h3 { font-size: 1.15em; margin: 24px 0 12px; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown blockquote { margin: 0 0 16px; }
.markdown a { text-decoration: underline; text-decoration-color: var(--text-faint); text-underline-offset: 3px; }
.markdown code { background: var(--surface-hover); padding: .2em .4em; border-radius: var(--radius-sm); font-size: 85%; }
.markdown pre { background: var(--bg-inset); border: 1px solid var(--border); padding: 16px; border-radius: var(--radius-md); overflow: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown blockquote { padding: 0 1em; color: var(--text-muted); border-left: 3px solid var(--border-strong); }
.markdown hr { border: 0; border-top: 1px solid var(--border); }
.comment-body.markdown { padding: 16px; }

/* ---------- diffs (monochrome like the reference) ---------- */
.diff-file { margin-bottom: 12px; overflow: visible; }
.diff-file .box-header { border-radius: var(--radius) var(--radius) 0 0; }
.diff-file .diff { border-radius: 0 0 var(--radius) var(--radius); }
.diff-file .box-header { position: sticky; top: var(--header-h); z-index: 2; font-family: var(--mono); font-size: 12px; cursor: pointer; color: var(--text); }
.diff { font: 12px/20px var(--mono); overflow-x: auto; }
.diff table { border-collapse: collapse; width: 100%; }
.diff td { padding: 0 8px; white-space: pre; }
.diff td.n { width: 1%; min-width: 44px; text-align: right; color: var(--text-faint); user-select: none; }
.diff tr.add td { background: rgba(255, 255, 255, .075); color: #fafafa; }
.diff tr.del td { background: rgba(0, 0, 0, .35); color: var(--text-faint); }
.diff tr.del td:last-child { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .18); }
.diff tr.hunk td { background: #1f1f1f; color: var(--text-faint); }
.diffstat { display: inline-flex; gap: 1px; } .diffstat i { width: 8px; height: 8px; border-radius: 2px; background: var(--surface-hover); }
.diffstat i.a { background: var(--text); } .diffstat i.d { background: var(--text-faint); }

/* ---------- timeline ---------- */
.timeline-item { display: flex; gap: 14px; margin-bottom: 16px; }
.timeline-item .box { flex: 1; min-width: 0; }
.timeline-item .box-header { min-height: 38px; padding: 6px 16px; }
.timeline-event { display: flex; align-items: center; gap: 8px; margin: 0 0 16px 46px; color: var(--text-muted); font-size: 13px; }
.timeline-event .badge { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); }
.timeline-event .badge.merged { background: var(--text); color: var(--bg); border-color: transparent; }
.side-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; }
.sidebar-section { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.sidebar-section h4 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--text-faint); }
.merge-box { display: flex; gap: 14px; align-items: flex-start; }
.merge-box .badge { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 1px solid var(--border-strong); }
.issue-title { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.issue-title h1 { font-size: 26px; font-weight: 500; letter-spacing: -0.02em; }

/* ---------- kanban ---------- */
.board { display: flex; gap: 20px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; min-height: calc(100vh - 260px); }
.column { flex: 0 0 290px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.column-head { display: flex; align-items: center; gap: 9px; padding: 0 2px 10px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.column-head .counter { color: var(--text-muted); font-size: 11px; line-height: 19px; }
.kdot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--text-muted); }
.kdot-doing { background: linear-gradient(90deg, var(--text-muted) 50%, transparent 50%); }
.kdot-done { background: var(--text-muted); }
.column-cards { display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.board.is-dragging .column-cards { min-height: 72px; border-radius: var(--radius); outline: 1px dashed var(--border); outline-offset: 2px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: grab; user-select: none; transition: border-color .15s, background .15s; }
.card:hover { border-color: var(--border-strong); }
.card.dragging { opacity: .5; }
.card.is-done { background: none; }
.card.is-done .card-title { color: var(--text-faint); }
.card-title { font-size: 14px; font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-faint); }
.drop-marker { height: 2px; background: var(--text); border-radius: 2px; margin: -5px 0; }
.column-add { justify-content: flex-start; color: var(--text-faint); height: 36px; border-radius: 10px; }
.column-add:hover { color: var(--text-muted); background: var(--surface); border-color: transparent; }
.column.new { flex-basis: 220px; }
.column.new .column-add { border: 1px dashed var(--border-strong); justify-content: center; }

/* ---------- mind map ---------- */
.mindmap-wrap { position: relative; height: max(440px, calc(100vh - 230px)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background-color: #161616; background-image: radial-gradient(circle, #262626 1px, transparent 1.2px); background-size: 22px 22px; cursor: grab; outline: none; user-select: none; }
.mindmap-wrap:focus-visible { border-color: var(--border-strong); }
.mindmap-wrap.panning { cursor: grabbing; }
.mindmap-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.mindmap-layer svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.mm-node { position: absolute; height: 34px; padding: 0 14px; display: flex; align-items: center; justify-content: center; white-space: nowrap; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text); cursor: pointer; font-size: 13px; transition: box-shadow .12s, border-color .12s; }
.mm-node:hover { border-color: var(--text-faint); }
.mm-node.d0 { border-radius: 999px; border-color: var(--text); background: var(--text); color: var(--bg); font-size: 15px; font-weight: 600; }
.mm-node.d1 { font-weight: 600; font-size: 14px; }
.mm-node.d2 { background: #1a1a1a; }
.mm-node.d3 { border-color: var(--border); background: #181818; color: var(--text-muted); }
.mm-node.selected { box-shadow: 0 0 0 2px #161616, 0 0 0 4px var(--text); }
.mm-node.d0.selected { box-shadow: 0 0 0 3px #161616, 0 0 0 5px var(--text-muted); }
.mm-node input { font: inherit; color: inherit; background: none; border: 0; outline: none; padding: 0; width: 100%; text-align: center; }
.mm-node .fold { position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); font-size: 10px; line-height: 14px; text-align: center; color: var(--text-muted); font-weight: 500; }
.mm-toolbar { position: absolute; top: 12px; left: 12px; z-index: 5; display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.mm-help { position: absolute; bottom: 12px; left: 12px; z-index: 5; font-size: 12px; color: var(--text-faint); }
.kbd { display: inline-block; padding: 0 5px; font: 11px/16px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); color: var(--text-muted); }

/* ---------- projects ---------- */
.project-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; min-height: 132px; color: var(--text); text-decoration: none !important; transition: border-color .15s, background .15s; animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.project-card:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.project-card h3 { flex: 1; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptype { width: 30px; height: 30px; flex: none; border-radius: var(--radius-md); display: grid; place-items: center; color: var(--text-muted); background: var(--surface-hover); border: 1px solid var(--border); font-size: 11px; font-weight: 600; }
.project-card .bar { height: 4px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; margin-top: auto; }
.project-card .bar i { display: block; height: 100%; background: var(--text-muted); border-radius: 999px; }

/* ---------- modpack ---------- */
.mod-icon { width: 40px; height: 40px; border-radius: var(--radius-md); background: var(--surface-hover); border: 1px solid var(--border); flex: none; object-fit: cover; display: grid; place-items: center; color: var(--text-faint); }
.mod-row.has-update { background: rgba(255, 255, 255, .02); }
.mod-row.disabled .mod-icon, .mod-row.disabled .mod-title { opacity: .45; }
.switch { position: relative; flex: none; width: 36px; height: 20px; padding: 0; border: 0; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-muted); transition: transform .2s, background .2s; }
.switch.on { background: var(--text); }
.switch.on::after { transform: translateX(16px); background: var(--bg); }

/* ---------- documents (Docs-style editor) ---------- */
.file-row .icon.docfile { color: var(--text); }
.doc-shell { margin: -32px -24px 0; }
.doc-head { display: flex; align-items: center; gap: 10px; padding: 14px 24px 10px; }
.doc-icon { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: var(--radius-md); background: var(--surface-hover); border: 1px solid var(--border); color: var(--text); }
.doc-title { width: 100%; max-width: 520px; padding: 2px 6px; margin-left: -6px; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; outline: none; }
.doc-title:hover:not([readonly]) { border-color: var(--border-strong); }
.doc-title:focus { border-color: var(--text-faint); box-shadow: var(--ring); }
.doc-meta { display: flex; gap: 6px; font-size: 12px; color: var(--text-faint); padding-left: 1px; }
.doc-toolbar { position: sticky; top: var(--header-h); z-index: 10; display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin: 0 24px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(28, 28, 28, .92); backdrop-filter: blur(10px); }
.doc-tool { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-muted); cursor: pointer; }
.doc-tool:hover { background: var(--surface-hover); color: var(--text); }
.doc-tool.on { background: #3a3a3a; color: var(--text); }
.doc-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--border-strong); }
.doc-style { height: 32px; padding: 0 28px 0 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font-size: 13px; cursor: pointer; appearance: none; outline: none; 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='%239a9a9a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
.doc-style:hover { background-color: var(--surface-hover); }
.doc-style option { background: var(--surface); }
.doc-canvas { display: flex; align-items: flex-start; gap: 20px; padding: 24px 16px 96px; }
.doc-main { flex: 1; min-width: 0; }
/* document tabs */
.doc-tabs { position: sticky; top: calc(var(--header-h) + 64px); width: 220px; flex: none; padding: 4px; }
.doc-tabs-head { display: flex; align-items: center; gap: 2px; padding: 0 2px 6px 8px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.doc-tool.sm { width: 26px; height: 26px; }
.doc-tool.sm .icon { width: 14px; height: 14px; }
.doc-tabs-list { display: flex; flex-direction: column; gap: 2px; }
.doc-tab { position: relative; display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 4px 0 10px; border-radius: var(--radius-sm); color: var(--text-muted); font-size: 13px; cursor: pointer; user-select: none; }
.doc-tab .icon { width: 15px; height: 15px; flex: none; }
.doc-tab:hover { background: var(--surface-hover); color: var(--text); }
.doc-tab.on { background: #2c2c2c; color: var(--text); font-weight: 500; }
.doc-tab.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--text); }
.doc-tab-people { display: flex; gap: 2px; }
.doc-tab-people i { width: 7px; height: 7px; border-radius: 50%; }
.doc-tab-more { width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-faint); cursor: pointer; opacity: 0; }
.doc-tab:hover .doc-tab-more, .doc-tab.on .doc-tab-more { opacity: 1; }
.doc-tab-more:hover { background: var(--border); color: var(--text); }
.doc-tab-more .icon { width: 14px; height: 14px; }
.doc-tasks:empty { display: none; }
/* toolbar: fonts, sizes, colours */
.doc-font { width: 132px; }
.doc-size { width: 64px; padding-right: 22px; }
.doc-tool { position: relative; }
.doc-tool .color-bar { position: absolute; left: 8px; right: 8px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--text-muted); }
.color-pop { min-width: 0; width: 214px; }
.color-pop .swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding: 8px 6px; }
.color-pop .swatch { width: 26px; height: 26px; border: 1px solid rgba(255, 255, 255, .15); border-radius: 50%; cursor: pointer; padding: 0; }
.color-pop .swatch:hover, .color-pop .swatch.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text-muted); }
.color-pop .custom-color { cursor: pointer; }
.color-pop .custom-color input { width: 18px; height: 18px; padding: 0; border: 0; background: none; cursor: pointer; }
/* checklists */
.doc-page ul[data-type="taskList"] { list-style: none; padding-left: 2px; }
.doc-page li[data-type="taskItem"] { display: flex; align-items: flex-start; gap: 8px; }
.doc-page li[data-type="taskItem"] > label { flex: none; margin-top: 3px; user-select: none; }
.doc-page li[data-type="taskItem"] > label input { width: 15px; height: 15px; margin: 0; accent-color: #46a758; cursor: pointer; }
.doc-page li[data-type="taskItem"] > div { flex: 1; min-width: 0; }
.doc-page li[data-type="taskItem"] > div > p { margin: 0; }
.doc-page li[data-type="taskItem"][data-checked="true"] > div { color: var(--text-faint); text-decoration: line-through; text-decoration-color: var(--text-faint); }
.doc-page li[data-type="taskItem"] ul[data-type="taskList"] { margin: 2px 0 0; }
/* saved-file view (no checkbox inputs there) */
.doc-page li[data-type="taskItem"] > span:empty::before { content: "☐"; color: var(--text-muted); }
.doc-page li[data-type="taskItem"][data-checked="true"] > span:empty::before { content: "☑"; color: var(--ok); }
.doc-page sup, .doc-page sub { font-size: .75em; }
.doc-print { display: none; }
.doc-page { width: 100%; max-width: 816px; min-height: 1056px; margin: 0 auto; padding: 72px 88px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); outline: none; font-size: 15px; line-height: 1.7; color: var(--text); overflow-wrap: break-word; cursor: text; }
.doc-page:focus-visible { outline: none; }
.doc-page > :first-child { margin-top: 0; }
.doc-page p { margin: 0 0 10px; }
.doc-page h1 { font-size: 28px; margin: 28px 0 12px; letter-spacing: -0.02em; line-height: 1.25; }
.doc-page h2 { font-size: 21px; margin: 24px 0 10px; }
.doc-page h3 { font-size: 17px; margin: 20px 0 8px; }
.doc-page ul, .doc-page ol { margin: 0 0 10px; padding-left: 26px; }
.doc-page li { margin: 2px 0; }
.doc-page blockquote { margin: 0 0 10px; padding: 2px 16px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.doc-page pre { margin: 0 0 10px; padding: 12px 16px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-md); font: 13px/1.6 var(--mono); white-space: pre-wrap; }
.doc-page code { font: 13px var(--mono); background: var(--surface-hover); padding: .1em .35em; border-radius: 4px; }
.doc-page hr { border: 0; border-top: 1px solid var(--border-strong); margin: 20px 0; }
.doc-page a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--text-faint); }
.doc-page [style*="background-color"] { color: #141414; border-radius: 2px; }
.doc-page[contenteditable="false"] { cursor: default; }

.doc-status.warn { color: var(--warn); }
.doc-people { display: flex; align-items: center; }
.doc-person { width: 30px; height: 30px; margin-left: -6px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-hover); border: 2px solid; box-shadow: 0 0 0 2px var(--bg); font-size: 10px; font-weight: 600; color: var(--text); cursor: default; }
.doc-canvas .ProseMirror { outline: none; white-space: pre-wrap; }
.doc-page mark { background: #fff3a3; color: #141414; border-radius: 2px; padding: 0 1px; }
.doc-page p.is-editor-empty:first-child::before { content: attr(data-placeholder); color: var(--text-faint); float: left; height: 0; pointer-events: none; }
.collaboration-carets__caret { position: relative; margin: 0 -1px; border-left: 1px solid; border-right: 1px solid; word-break: normal; pointer-events: none; }
.collaboration-carets__label { position: absolute; top: -1.45em; left: -1px; padding: 1px 6px; border-radius: 4px 4px 4px 0; color: #141414; font: 600 11px/1.4 var(--font); white-space: nowrap; user-select: none; pointer-events: none; }

@media (max-width: 768px) {
  .doc-shell { margin: -20px -16px 0; }
  .doc-head { padding: 12px 16px 8px; }
  .doc-toolbar { margin: 0 8px; }
  .doc-canvas { flex-direction: column; gap: 8px; padding: 12px 0 64px; }
  .doc-tabs { position: static; width: 100%; padding: 0 8px; }
  .doc-tabs-list { flex-direction: row; overflow-x: auto; scrollbar-width: none; }
  .doc-tab { flex: none; max-width: 200px; }
  .doc-main { width: 100%; }
  .doc-page { padding: 32px 22px; min-height: 70vh; border-radius: 0; border-left: 0; border-right: 0; }
}

@media print {
  .site-header, .doc-head, .doc-toolbar, #toasts, .print-hide, .upload-panel { display: none !important; }
  /* Printing / PDF is for owners and admins only */
  body.no-print > * { display: none !important; }
  body.no-print::after { content: "Printing is only available to owners and admins."; display: block; padding: 24px; color: #000; }
  .box { border: 0 !important; background: #fff !important; }
  .code, .code td, .markdown { background: #fff !important; color: #000 !important; }
  body, main, .doc-shell, .doc-canvas { background: #fff !important; margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .doc-page { max-width: none; min-height: 0; padding: 0; border: 0; box-shadow: none; color: #000; background: #fff; }
  .doc-page blockquote, .doc-page a { color: #333; }
  .doc-tabs, .doc-show-tabs { display: none !important; }
  .doc-page li[data-type="taskItem"][data-checked="true"] > div { color: #777; }
  body.print-all .doc-canvas { display: none !important; }
  body.print-all .doc-print { display: block !important; }
  .doc-print-tab + .doc-print-tab { break-before: page; }
  .doc-print-title { font-size: 12px !important; font-weight: 600; color: #777; text-transform: uppercase; letter-spacing: .06em; margin: 0 0 16px !important; }
}

/* ---------- animations & mobile ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 768px) {
  .side-layout { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .markdown { padding: 16px; }
  .diff-file .box-header { position: static; }
}
@media (max-width: 560px) {
  .site-header { padding: 0 10px; gap: 4px; }
  .site-nav { gap: 0; }
  .site-icon { width: 34px; }
  .site-icon::after { display: none; }
  main { padding: 20px 16px 56px; }
  .input, .pw-row input { font-size: 16px; }
}
