:root {
  --bg: #f4f1ea; --surface: #fcfbf7; --raised: #ffffff; --ink: #1d1b16; --muted: #6a6558; --line: #e1dbcd;
  --accent: #a55d00; --accent-ink: #fff; --accent-soft: #f6e7cc; --folder: #d18a1c; --danger: #b3261e; --shadow: 0 8px 30px rgba(40, 30, 10, .14);
  --radius: 12px; color-scheme: light dark;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16150f; --surface: #1e1c15; --raised: #27241b; --ink: #ece8dc; --muted: #a39d8c; --line: #37332a;
    --accent: #eaa53c; --accent-ink: #1d1500; --accent-soft: #3a2c10; --folder: #eaa53c; --danger: #ff8a80; --shadow: 0 8px 30px rgba(0, 0, 0, .5); }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; } h2 { font-size: 1.1rem; } h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { display: inline-flex; width: 20px; height: 20px; flex: none; } .ic svg { width: 100%; height: 100%; }
.ic.big { width: 44px; height: 44px; color: var(--muted); } .ic.big svg { stroke-width: 1.100; }
.ic.huge { width: 88px; height: 88px; opacity: .7; } .ic.huge svg { stroke-width: .8; }
.ic.k-folder { color: var(--folder); } .ic.k-folder svg { fill: color-mix(in srgb, var(--folder) 22%, transparent); }
.ic.tag { width: 14px; height: 14px; color: var(--accent); margin-left: 6px; vertical-align: -2px; }
.hint { color: var(--muted); font-size: .88rem; } .center { text-align: center; }
.stack { display: grid; gap: 12px; } .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--raised); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; } .btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); } .btn.block { width: 100%; min-height: 44px; } .btn:disabled { opacity: .55; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: none; border-radius: 9px; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
label { display: grid; gap: 5px; font-size: .86rem; font-weight: 550; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 1rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--raised); color: var(--ink); font-size: 16px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
form { display: grid; gap: 14px; } hr { border: 0; border-top: 1px solid var(--line); width: 100%; margin: 4px 0; }
.form-error { color: var(--danger); font-size: .9rem; min-height: 0; } .form-error:empty { display: none; }
.badge { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 8px; }
.badge.grey { background: var(--line); color: var(--muted); }

/* sign-in */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.brand .mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 18px; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.side .brand { padding: 0 8px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--muted); font-weight: 550; }
.side nav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.side nav a.on { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 10px 4px 0 8px; border-top: 1px solid var(--line); }
.who { min-width: 0; flex: 1; display: grid; } .who span { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 22px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.title { flex: 1; min-width: 140px; font-size: 1.15rem; font-weight: 700; }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.burger, .scrim { display: none; }
.content { padding: 20px 22px 110px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 1.05rem; }
.crumbs a { padding: 2px 6px; border-radius: 6px; color: var(--muted); } .crumbs a:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.crumbs > :last-child { color: var(--ink); } .sep { color: var(--line); }
.search { display: flex; align-items: center; gap: 6px; padding-left: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--raised); color: var(--muted); }
.search input { border: 0; background: none; width: 170px; min-height: 36px; padding: 0 8px 0 0; outline: none; }
.search:focus-within { border-color: var(--accent); }
select.sort { width: auto; min-height: 38px; font-size: .92rem; }

/* items */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.item { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; overflow: hidden; transition: border-color .12s, transform .12s; }
.item:hover { border-color: var(--muted); } .item.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.grid .thumb { aspect-ratio: 4 / 3; display: grid; place-items: center; background: color-mix(in srgb, var(--ink) 4%, transparent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .info { padding: 9px 40px 10px 11px; }
.name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.grid .name { display: block; }
.meta { color: var(--muted); font-size: .8rem; }
.grid .more { position: absolute; right: 2px; bottom: 6px; }
.pick { position: absolute; top: 8px; left: 8px; opacity: 0; } .item:hover .pick, .pick:checked, .pick:focus-visible { opacity: 1; }
@media (hover: none) { .pick { opacity: .85; } }
.rows { display: grid; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.rows .item { display: flex; align-items: center; gap: 12px; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); padding: 7px 8px 7px 40px; }
.rows .item:last-child { border-bottom: 0; } .rows .item.picked { box-shadow: none; background: var(--accent-soft); }
.rows .thumb { width: 40px; height: 40px; border-radius: 7px; overflow: hidden; display: grid; place-items: center; flex: none; }
.rows .thumb .ic.big { width: 28px; height: 28px; } .rows .info { flex: 1; min-width: 0; } .rows .pick { top: 50%; left: 12px; transform: translateY(-50%); opacity: .85; }
.bulk { position: sticky; top: 70px; z-index: 4; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--accent); }
.bulk b { margin-right: auto; }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .ic { width: 46px; height: 46px; opacity: .6; } .empty h3 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.dropping::after { content: "Drop files to upload here"; position: fixed; inset: 10px; z-index: 50; display: grid; place-items: center; font-size: 1.4rem; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--bg) 85%, transparent); border: 3px dashed var(--accent); border-radius: 18px; pointer-events: none; }

/* panels + rows */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; max-width: 900px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; max-width: 1000px; }
.panel > h3 { margin-bottom: 12px; }
.share-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--line); }
.share-row:last-child { border-bottom: 0; padding-bottom: 0; } .share-row:first-child { padding-top: 0; }
.share-row > div:first-child { flex: 1; min-width: 180px; } .share-row.off { opacity: .6; }
.tabs { display: inline-flex; padding: 3px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.tabs button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 550; color: var(--muted); }
.tabs button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* photos */
.month { margin-bottom: 26px; } .month h3 { margin-bottom: 10px; }
.mosaic { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 4px; }
.ph { aspect-ratio: 1; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; background: color-mix(in srgb, var(--ink) 6%, transparent); display: grid; place-items: center; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; } .ph:hover { filter: brightness(.9); }

/* dialogs, menus, toasts */
dialog.modal { width: min(480px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 15, 5, .45); }
.modal header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 10px 6px 20px; }
.modal h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 20px 20px; display: grid; gap: 14px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.linkbox { display: flex; gap: 8px; flex-wrap: wrap; } .linkbox input { flex: 1; min-width: 180px; font-size: .9rem; } .linkbox .hint { width: 100%; }
.fresh { display: grid; gap: 8px; padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.menu { position: absolute; z-index: 60; min-width: 190px; padding: 5px; background: var(--raised); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); display: grid; }
.menu button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; }
.menu button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); } .menu .danger { color: var(--danger); } .menu .ic { color: var(--muted); } .menu .danger .ic { color: inherit; }
.picker .where { display: flex; align-items: center; gap: 6px; min-height: 38px; }
.folders { display: grid; max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 4px; min-height: 80px; }
.folders button { display: flex; align-items: center; gap: 10px; padding: 9px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; }
.folders button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); } .folders .ic:first-child { color: var(--folder); } .folders .ic:last-child { margin-left: auto; color: var(--muted); }
.folders .hint { padding: 10px; }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; }
.toast { padding: 10px 16px; border-radius: 99px; background: var(--ink); color: var(--bg); font-weight: 550; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.bad { color: #2a0000; } }

/* uploads */
.uploads { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: min(340px, calc(100% - 32px)); background: var(--raised); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.uploads header { display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 6px 14px; min-height: 46px; border-bottom: 1px solid var(--line); }
.up-list { max-height: 220px; overflow: auto; padding: 4px 14px 10px; }
.up { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0; font-size: .86rem; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .up-state { color: var(--muted); } .up.err .up-state { color: var(--danger); grid-column: 1 / -1; }
.bar { grid-column: 1 / -1; height: 4px; border-radius: 9px; background: var(--line); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); transition: width .15s; }
.up.done .bar, .up.err .bar { display: none; }

/* preview */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(12, 11, 8, .96); color: #f1ede2; display: grid; grid-template: auto 1fr / auto 1fr auto; outline: none; }
.lightbox header { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; }
.lb-name { flex: 1; min-width: 0; display: grid; } .lb-name b, .lb-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .lb-name span { font-size: .8rem; opacity: .65; }
.lb-tools { display: flex; } .lightbox .icon-btn { color: #d8d3c6; } .lightbox .icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.stage { grid-column: 2; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 0 0 18px; }
.stage img, .stage video { max-width: 100%; max-height: calc(100dvh - 84px); object-fit: contain; border-radius: 4px; }
.stage iframe { width: min(1000px, 100%); height: calc(100dvh - 84px); border: 0; border-radius: 8px; background: #fff; }
.stage pre { width: min(900px, 100%); max-height: calc(100dvh - 84px); overflow: auto; margin: 0; padding: 18px; border-radius: 10px; background: #211f18; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; }
.nopreview { display: grid; justify-items: center; gap: 14px; text-align: center; }
.lightbox .nav { align-self: center; width: 48px; height: 72px; border: 0; background: none; color: #d8d3c6; cursor: pointer; display: grid; place-items: center; }
.lightbox .nav:hover { color: #fff; } .lightbox .nav .ic { width: 30px; height: 30px; } .lightbox .nav[hidden] { display: block !important; visibility: hidden; }
.lightbox .prev { grid-column: 1; } .lightbox .next { grid-column: 3; }

/* public page */
.public .content { max-width: 1200px; margin: 0 auto; } .public .crumbs { margin-bottom: 14px; }
.single { display: grid; place-items: center; min-height: 70dvh; }
.single-file { display: grid; justify-items: center; gap: 8px; padding: 26px; width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; cursor: pointer; }
.single-file .thumb { width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--ink) 4%, transparent); }
.single-file b { word-break: break-word; }

/* phones */
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 264px; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); }
  .nav-open .side { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgba(20, 15, 5, .45); }
  .burger { display: inline-grid; }
  .top { padding: 8px 12px; gap: 8px; } .content { padding: 14px 12px 120px; }
  .title { min-width: 0; flex-basis: calc(100% - 60px); } .tools { width: 100%; }
  .search { flex: 1; } .search input { width: 100%; min-width: 60px; }
  .tools .btn span:not(.ic) { display: none; } .public .tools .btn span:not(.ic) { display: inline; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .mosaic { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .lightbox .nav { width: 34px; } .two { grid-template-columns: 1fr; }
  .uploads { right: 8px; left: 8px; bottom: 8px; width: auto; }
  .bulk { top: 108px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 0s !important; } }
