/* ============ Shelf — styles ============ */
:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --side: 252px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --c-image: #df8e5e; --c-video: #9a86ee; --c-audio: #4fb8a6; --c-document: #6fa8e6; --c-text: #b2aa92; --c-archive: #d0aa50; --c-other: #9a948a;
}
[data-theme="dark"] {
  --bg: #121110; --bg-2: #171614; --surface: #1c1a18; --surface-2: #24221f; --surface-3: #2d2a26;
  --line: #2c2925; --line-2: #3a3631; --text: #f2ede5; --muted: #a59d90; --faint: #6f685e;
  --accent: #e8a33d; --accent-2: #f2bb63; --accent-ink: #1d1406; --accent-soft: rgba(232, 163, 61, .13);
  --danger: #ec6a58; --danger-soft: rgba(236, 106, 88, .12); --ok: #67bb84; --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --overlay: rgba(8, 7, 6, .72); color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f3ee; --bg-2: #efebe4; --surface: #ffffff; --surface-2: #f4f0ea; --surface-3: #ebe6de;
  --line: #e6e0d6; --line-2: #d8d0c4; --text: #1f1b16; --muted: #6f675c; --faint: #a49b8e;
  --accent: #c47e14; --accent-2: #a96a0c; --accent-ink: #ffffff; --accent-soft: rgba(196, 126, 20, .11);
  --danger: #c9412f; --danger-soft: rgba(201, 65, 47, .09); --ok: #2f8a50; --shadow: 0 18px 50px rgba(60, 45, 20, .16);
  --overlay: rgba(30, 24, 16, .45); color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
::selection { background: var(--accent); color: var(--accent-ink); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: .92em; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.boot { height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; transform: scale(.94); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 550; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, color .15s;
}
.btn:hover { background: var(--surface-3); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: 8px; }
.btn.icon { width: 38px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-2); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--faint); font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s var(--ease), background .2s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); background: var(--accent-ink); }
.seg { display: inline-flex; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { border: 0; background: none; height: 30px; padding: 0 10px; border-radius: 7px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(900px 500px at 20% 0%, rgba(232, 163, 61, .22), transparent 60%), radial-gradient(700px 500px at 100% 100%, rgba(154, 134, 238, .16), transparent 60%), var(--bg-2);
  border-right: 1px solid var(--line);
}
.auth-art h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(34px, 4vw, 54px); line-height: 1.08; letter-spacing: -.01em; margin: 0 0 14px; max-width: 12ch; }
.auth-art p { color: var(--muted); max-width: 40ch; font-size: 16px; }
.auth-shelf { display: flex; align-items: flex-end; gap: 10px; height: 180px; margin: 30px 0; }
.auth-shelf span { width: 34px; border-radius: 5px 5px 2px 2px; animation: rise .8s var(--ease) both; box-shadow: inset -6px 0 0 rgba(0, 0, 0, .12); }
.auth-shelf::after { content: ""; }
.auth-base { height: 8px; border-radius: 4px; background: var(--line-2); margin-top: -2px; }
.auth-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 520px; }
.auth-feats div { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); font-size: 13.5px; }
.auth-feats svg { color: var(--accent); margin-top: 1px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; animation: rise .5s var(--ease); }
.auth-card h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); margin: 0 0 26px; }
.auth-card .btn.primary { width: 100%; height: 44px; margin-top: 6px; }
.auth-switch { margin-top: 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.auth-switch a { color: var(--accent); font-weight: 600; cursor: pointer; }
.form-err { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); padding: 9px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .01em; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; border-right: 1px solid var(--line); background: var(--bg-2); overflow-y: auto;
}
.side .brand { padding: 4px 8px 14px; }
.new-btn { width: 100%; height: 44px; justify-content: flex-start; padding: 0 16px; margin-bottom: 10px; border-radius: 12px; box-shadow: 0 6px 20px rgba(232, 163, 61, .18); }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 12px; border-radius: 10px; color: var(--muted); font-weight: 520;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--text); }
.nav a.on svg { color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav a.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.storage { margin-top: auto; padding: 14px 12px 6px; }
.storage .bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 8px 0 6px; display: flex; }
.storage .bar i { display: block; height: 100%; }
.storage .txt { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 26px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.search { position: relative; flex: 1; max-width: 560px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 38px; height: 40px; background: var(--surface); border-color: var(--line); border-radius: 12px; }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
kbd { font: 11.5px var(--mono); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--line-2); color: var(--faint); background: var(--bg-2); }
.top .spacer { flex: 1; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--accent), #c9603e); color: #1d1406; border: 0; flex: none;
}
.menu-btn { display: none; }
.content { padding: 22px 26px 80px; flex: 1; position: relative; }

/* ---------- Page head ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head h1 { font-family: var(--serif); font-weight: 500; font-size: 30px; margin: 0; letter-spacing: -.005em; line-height: 1.15; }
.head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { padding: 2px 6px; border-radius: 6px; }
.crumbs a:hover { background: var(--surface-2); color: var(--text); }
.crumbs a.drop-target { outline: 2px dashed var(--accent); }
.crumbs svg { width: 14px; height: 14px; color: var(--faint); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Selection bar ---------- */
.selbar {
  position: sticky; top: 65px; z-index: 15; display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 16px; margin: -6px 0 16px;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .2s var(--ease);
}
.selbar b { margin-right: auto; font-weight: 600; }

/* ---------- Grid ---------- */
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 6px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; margin-bottom: 26px; }
.grid.folders { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card {
  position: relative; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); overflow: hidden; cursor: pointer;
  transition: border-color .15s, transform .15s var(--ease), box-shadow .15s; user-select: none; animation: fade .3s both;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .18); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card.drop-target { border-color: var(--accent); background: var(--accent-soft); }
.card.dragging { opacity: .45; }
.thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease), opacity .3s; }
.card:hover .thumb img { transform: scale(1.03); }
.thumb .kind-ic { width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--k) 16%, transparent); color: var(--k); }
.thumb .kind-ic svg { width: 28px; height: 28px; }
.thumb .ext { position: absolute; bottom: 8px; left: 8px; font: 700 10.5px var(--mono); letter-spacing: .04em; padding: 2px 6px; border-radius: 5px; background: rgba(0, 0, 0, .55); color: #fff; text-transform: uppercase; }
.thumb .dur { position: absolute; bottom: 8px; right: 8px; font: 600 11.5px var(--font); padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: #fff; }
.thumb .play { position: absolute; width: 44px; height: 44px; border-radius: 50%; background: rgba(0, 0, 0, .55); display: grid; place-items: center; backdrop-filter: blur(4px); }
.thumb .play::after { content: ""; border-left: 14px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent; margin-left: 4px; }
.meta { padding: 10px 12px 11px; }
.meta .name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.meta .sub { color: var(--faint); font-size: 12.5px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.check {
  position: absolute; top: 9px; left: 9px; width: 24px; height: 24px; border-radius: 7px; border: 2px solid rgba(255, 255, 255, .85);
  background: rgba(0, 0, 0, .3); display: grid; place-items: center; opacity: 0; transition: opacity .15s; z-index: 2;
}
.check svg { width: 14px; height: 14px; stroke: var(--accent-ink); stroke-width: 3; opacity: 0; }
.card:hover .check, .selecting .check { opacity: 1; }
.card.sel .check { background: var(--accent); border-color: var(--accent); opacity: 1; }
.card.sel .check svg { opacity: 1; }
.card-acts { position: absolute; top: 7px; right: 7px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; z-index: 2; }
.card:hover .card-acts { opacity: 1; }
.card-acts button { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); }
.card-acts button:hover { background: rgba(0, 0, 0, .8); }
.card-acts svg { width: 16px; height: 16px; }
.star-pin { position: absolute; top: 9px; right: 9px; color: var(--accent); z-index: 1; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5)); }
.star-pin svg { fill: var(--accent); width: 18px; height: 18px; }
.card:hover .star-pin { opacity: 0; }

.fcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.fcard .fic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--fc, var(--accent)) 15%, transparent); color: var(--fc, var(--accent)); flex: none; }
.fcard .fic svg { width: 22px; height: 22px; }
.fcard .meta { padding: 0; flex: 1; min-width: 0; }
.fcard .check { top: 50%; transform: translateY(-50%); left: auto; right: 44px; border-color: var(--line-2); background: var(--surface); }
.fcard .card-acts { top: 50%; transform: translateY(-50%); }
.fcard .card-acts button { background: transparent; color: var(--muted); }
.fcard .card-acts button:hover { background: var(--surface-3); color: var(--text); }
.fcard:hover { transform: none; }

/* Photos (gallery) */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-bottom: 28px; }
.gallery .card { border-radius: 10px; border: 0; }
.gallery .thumb { aspect-ratio: 1; }
.gallery .meta { display: none; }
.gallery .card:hover { transform: none; }
.month { font-family: var(--serif); font-size: 20px; margin: 4px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.month small { font-family: var(--font); font-size: 13px; color: var(--faint); }

/* List */
.list { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); margin-bottom: 26px; }
.lrow { display: grid; grid-template-columns: 34px 44px minmax(0, 1fr) 110px 150px 84px; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--surface-2); }
.lrow.sel { background: var(--accent-soft); }
.lrow.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.lrow.headrow { cursor: default; background: var(--bg-2); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); padding-top: 9px; padding-bottom: 9px; }
.lrow.headrow:hover { background: var(--bg-2); }
.lrow .lthumb { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: color-mix(in srgb, var(--k, var(--accent)) 14%, var(--surface-2)); color: var(--k, var(--accent)); }
.lrow .lthumb img { width: 100%; height: 100%; object-fit: cover; }
.lrow .lname { font-weight: 540; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.lrow .lname svg.star { fill: var(--accent); stroke: var(--accent); width: 15px; height: 15px; }
.lrow .c { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .lacts { display: flex; justify-content: flex-end; opacity: .0; }
.lrow:hover .lacts { opacity: 1; }
.lbox { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-2); display: grid; place-items: center; }
.lrow.sel .lbox { background: var(--accent); border-color: var(--accent); }
.lbox svg { width: 12px; height: 12px; stroke: var(--accent-ink); stroke-width: 3; opacity: 0; }
.lrow.sel .lbox svg { opacity: 1; }

/* Empty */
.empty { text-align: center; padding: 70px 20px; border: 2px dashed var(--line-2); border-radius: var(--r-lg); animation: fade .4s; }
.empty .ill { width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .ill svg { width: 36px; height: 36px; }
.empty h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0 auto 18px; max-width: 42ch; }

.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Drop overlay ---------- */
.dropzone { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: var(--overlay); backdrop-filter: blur(4px); }
.dropzone.on { display: grid; animation: fade .15s; }
.dropzone div { padding: 50px 70px; border-radius: 24px; border: 2px dashed var(--accent); background: var(--surface); text-align: center; box-shadow: var(--shadow); }
.dropzone svg { width: 46px; height: 46px; color: var(--accent); margin-bottom: 10px; }
.dropzone h3 { font-family: var(--serif); font-weight: 500; font-size: 24px; margin: 0 0 4px; }

/* ---------- Uploads panel ---------- */
.uploads { position: fixed; right: 20px; bottom: 20px; z-index: 80; width: 360px; max-width: calc(100vw - 40px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: rise .25s var(--ease); }
.uploads header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.uploads header b { flex: 1; font-weight: 600; }
.uploads .ulist { max-height: 280px; overflow-y: auto; }
.uploads.min .ulist { display: none; }
.uitem { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.uitem:last-child { border-bottom: 0; }
.uitem .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uitem .s { color: var(--faint); font-size: 12px; }
.uitem .pb { grid-column: 1 / -1; height: 4px; border-radius: 9px; background: var(--surface-3); overflow: hidden; }
.uitem .pb i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uitem.done .pb i { background: var(--ok); }
.uitem.err .pb i { background: var(--danger); width: 100% !important; }
.uitem.err .s { color: var(--danger); }
.utotal { height: 3px; background: var(--surface-3); }
.utotal i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ---------- Menus ---------- */
.menu {
  position: fixed; z-index: 120; min-width: 210px; padding: 6px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line-2); box-shadow: var(--shadow); animation: rise .14s var(--ease);
}
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 14px; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.menu button kbd { margin-left: auto; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .mlabel { padding: 8px 10px 4px; font-size: 12px; color: var(--faint); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: var(--overlay); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: 100%; max-width: 460px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); animation: rise .2s var(--ease); }
.modal.wide { max-width: 620px; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 18px 20px 4px; }
.modal header h3 { flex: 1; margin: 0; font-family: var(--serif); font-weight: 500; font-size: 21px; }
.modal .body { padding: 12px 20px 6px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal p { margin: 0 0 12px; color: var(--muted); }

.tree { border: 1px solid var(--line); border-radius: 12px; max-height: 320px; overflow: auto; padding: 6px; background: var(--bg-2); }
.tree button { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; border: 0; background: none; border-radius: 8px; padding: 0 8px; text-align: left; }
.tree button:hover { background: var(--surface-2); }
.tree button.on { background: var(--accent-soft); color: var(--text); }
.tree button.on svg { color: var(--accent); }
.tree button[disabled] { opacity: .35; }

.linkbox { display: flex; gap: 6px; align-items: center; padding: 6px 6px 6px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg-2); margin-bottom: 8px; }
.linkbox input { flex: 1; border: 0; background: none; outline: none; font: 13px var(--mono); min-width: 0; color: var(--text); }
.share-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.share-row:last-child { border-bottom: 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip svg { width: 12px; height: 12px; }

/* ---------- Viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(8, 7, 6, .96); display: grid; grid-template-rows: auto 1fr; animation: fade .18s; color: #f2ede5; }
.viewer header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.viewer header .vname { flex: 1; min-width: 0; }
.viewer header .vname b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer header .vname span { font-size: 12.5px; color: #a59d90; }
.viewer .vbtn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: #e9e3da; display: grid; place-items: center; }
.viewer .vbtn:hover { background: rgba(255, 255, 255, .1); }
.viewer .vbtn.on { background: rgba(232, 163, 61, .16); color: #e8a33d; }
.viewer .vbtn.starred svg { fill: #e8a33d; stroke: #e8a33d; }
.viewer .vbody { position: relative; display: grid; grid-template-columns: 1fr auto; min-height: 0; }
.viewer .stage { position: relative; display: grid; place-items: center; min-height: 0; min-width: 0; padding: 0 70px 24px; overflow: hidden; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: calc(100vh - 100px); border-radius: 6px; object-fit: contain; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); animation: fade .25s; }
.viewer .stage img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
.viewer .stage img { cursor: zoom-in; }
.viewer .stage iframe { width: min(1000px, 100%); height: calc(100vh - 100px); border: 0; border-radius: 8px; background: #fff; }
.viewer .stage pre, .viewer .stage textarea.code { width: min(1000px, 100%); height: calc(100vh - 110px); overflow: auto; margin: 0; padding: 18px 20px; border-radius: 10px; background: #1a1816; border: 1px solid #2c2925; font: 13px/1.6 var(--mono); color: #e9e3da; white-space: pre-wrap; word-break: break-word; }
.viewer .stage textarea.code { resize: none; outline: none; }
.viewer .audio-card { width: min(460px, 100%); padding: 36px; border-radius: 22px; background: #1c1a18; border: 1px solid #2c2925; text-align: center; }
.viewer .audio-card .disc { width: 140px; height: 140px; margin: 0 auto 22px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, #2b2824 22%, #4fb8a6 23%, #2f6d63 60%, #1d3f3a 100%); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); }
.viewer .audio-card .disc.playing { animation: spin 6s linear infinite; }
.viewer .audio-card .disc::after { content: ""; width: 16px; height: 16px; border-radius: 50%; background: #121110; }
.viewer .audio-card b { display: block; margin-bottom: 18px; font-size: 16px; word-break: break-word; }
.viewer .audio-card audio { width: 100%; }
.viewer .generic { text-align: center; color: #a59d90; }
.viewer .generic .kind-ic { width: 96px; height: 96px; border-radius: 24px; margin: 0 auto 16px; display: grid; place-items: center; background: color-mix(in srgb, var(--k) 18%, transparent); color: var(--k); }
.viewer .generic .kind-ic svg { width: 46px; height: 46px; }
.viewer .nav-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08); color: #fff; display: grid; place-items: center; z-index: 2; }
.viewer .nav-arrow:hover { background: rgba(255, 255, 255, .18); }
.viewer .nav-arrow.prev { left: 14px; }
.viewer .nav-arrow.next { right: 14px; }
.viewer .info { width: 320px; border-left: 1px solid #2c2925; padding: 18px 20px; overflow-y: auto; background: #151412; }
.viewer .info h4 { margin: 0 0 14px; font-family: var(--serif); font-weight: 500; font-size: 18px; }
.viewer .info dl { display: grid; grid-template-columns: 96px 1fr; gap: 9px 10px; margin: 0 0 18px; font-size: 13px; }
.viewer .info dt { color: #8a8276; }
.viewer .info dd { margin: 0; word-break: break-all; }
.viewer .info textarea { width: 100%; min-height: 90px; background: #1c1a18; border: 1px solid #3a3631; color: #f2ede5; border-radius: 10px; padding: 10px; resize: vertical; outline: none; }
.viewer .info textarea:focus { border-color: #e8a33d; }

/* ---------- Pages (settings/admin/shared) ---------- */
.cards { display: grid; gap: 16px; max-width: 920px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; animation: rise .3s var(--ease) both; }
.panel h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 20px; }
.panel > p.lead { margin: 0 0 16px; color: var(--muted); font-size: 13.5px; }
.panel .row + .row { margin-top: 10px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; max-width: 920px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 26px; font-family: var(--serif); font-weight: 500; margin-top: 4px; font-variant-numeric: tabular-nums; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.ubar { width: 120px; height: 5px; border-radius: 9px; background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.ubar i { display: block; height: 100%; background: var(--accent); }
.typebar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); margin: 12px 0 14px; }
.typebar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.keybox { padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--accent); font: 13px var(--mono); word-break: break-all; margin: 10px 0; }
pre.code { margin: 8px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font: 12.5px/1.6 var(--mono); overflow-x: auto; white-space: pre; }
.act-row { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.act-row:last-child { border-bottom: 0; }
.act-row time { color: var(--faint); font-size: 12.5px; min-width: 120px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 550; box-shadow: var(--shadow); animation: rise .25s var(--ease); max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .viewer .info { position: absolute; right: 0; top: 0; bottom: 0; z-index: 3; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 55; background: var(--overlay); animation: fade .2s; }
  .menu-btn { display: inline-flex; }
  .top { padding: 10px 14px; gap: 8px; }
  .search kbd, .hide-sm, .top .spacer { display: none !important; }
  .content { padding: 16px 14px 90px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 3px; }
  .lrow { grid-template-columns: 30px 40px minmax(0, 1fr) 70px; }
  .lrow .c.date, .lrow .lacts { display: none; }
  .check, .card-acts { opacity: 1; }
  .card-acts button.hide-touch { display: none; }
  .viewer .stage { padding: 0 8px 16px; }
  .viewer .nav-arrow { width: 40px; height: 40px; background: rgba(0, 0, 0, .4); }
  .viewer .info { width: 100%; }
  .head h1 { font-size: 25px; }
  .selbar { top: 61px; flex-wrap: wrap; }
  .selbar .lbl { display: none; }
}

/* ---------- Avatars ---------- */
.avatar { overflow: hidden; padding: 0; position: relative; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.big { width: 64px; height: 64px; font-size: 24px; cursor: pointer; }
.avatar.big .cam { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; opacity: 0; transition: opacity .15s; }
.avatar.big:hover .cam { opacity: 1; }
.crop { position: relative; width: 280px; height: 280px; margin: 4px auto 14px; overflow: hidden; border-radius: 16px; background: #000; touch-action: none; cursor: grab; }
.crop.grabbing { cursor: grabbing; }
.crop img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; pointer-events: none; }
.crop::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 400px rgba(0, 0, 0, .55); border: 2px solid rgba(255, 255, 255, .85); pointer-events: none; }
.crop-zoom { display: flex; align-items: center; gap: 10px; padding: 0 6px 6px; color: var(--muted); }
.crop-zoom input { flex: 1; accent-color: var(--accent); }
.crop-zoom svg:first-child { width: 14px; height: 14px; }

/* ---------- Moderation ---------- */
.mod-notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; margin: -4px 0 16px; border-radius: 12px; font-size: 13.5px; color: var(--muted);
  background: color-mix(in srgb, var(--accent) 9%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.mod-notice svg { color: var(--accent); margin-top: 1px; }
.mod-notice b { color: var(--text); font-weight: 600; }
.mod-choice { display: grid; gap: 8px; margin-bottom: 14px; }
.mod-opt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line-2); cursor: pointer; }
.mod-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mod-opt input { margin-top: 3px; accent-color: var(--accent); }
.mod-opt b { display: block; font-weight: 600; }
.mod-opt small { color: var(--muted); }
