:root {
  --bg: #fff;
  --bg2: #f5f5f7;
  --hover: #f0f0f2;
  --active: #e8e8ec;
  --line: #e6e6ea;
  --text: #1a1a1a;
  --muted: #7c7c84;
  --yellow: #ffdb4d;
  --yellow-h: #ffd21f;
  --sel: #fff4cc;
  --sel-line: #ffd84a;
  --blue: #3d7eff;
  --red: #f33;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0,0,0,.14), 0 1px 4px rgba(0,0,0,.08);
  --side: 248px;
  --top: 64px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 "YS Text", Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 18px; font-size: 13px; }

/* buttons */
.btn { border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer; background: var(--bg2); font-weight: 500; transition: background .15s, transform .05s; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { background: var(--active); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--yellow); }
.btn-primary:hover { background: var(--yellow-h); }
.btn-danger { background: #ffe5e5; color: #c00; }
.btn-danger:hover { background: #ffd6d6; }
.btn-wide { width: 100%; padding: 13px; font-size: 15px; }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; cursor: pointer; color: #555; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255,255,255,.15); color: #fff; }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; letter-spacing: -.2px; white-space: nowrap; }
.brand-logo { width: 32px; height: 32px; border-radius: 50%; background: #fc3f1d url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 21a4.5 4.5 0 0 1 .9-8.9 6 6 0 0 1 11.5 1.4A3.8 3.8 0 0 1 22 21z' fill='%23fff'/%3E%3C/svg%3E") center/100% no-repeat; flex: none; }
.brand.big { font-size: 28px; justify-content: center; }
.brand.big .brand-logo { width: 44px; height: 44px; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #fff8dc 0%, #f4f6fb 60%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 36px 28px 28px; box-shadow: var(--shadow); display: grid; gap: 12px; text-align: center; }
.login-card p { margin: 0 0 8px; }
input, textarea, select { font: inherit; color: inherit; }
.login-card input, .field { width: 100%; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--line); outline: none; background: #fff; transition: border-color .15s; }
.login-card input:focus, .field:focus { border-color: var(--yellow-h); }

/* layout */
.app { height: 100%; display: grid; grid-template-columns: var(--side) 1fr; grid-template-rows: var(--top) 1fr; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px; border-bottom: 1px solid transparent; }
.topbar .brand { width: calc(var(--side) - 36px); }
.burger { display: none; }
.search { flex: 1; max-width: 640px; display: flex; align-items: center; gap: 10px; background: var(--bg2); border-radius: 12px; padding: 0 14px; height: 44px; border: 1.5px solid transparent; transition: border-color .15s, background .15s; }
.search:focus-within { background: #fff; border-color: var(--yellow-h); }
.search svg { color: var(--muted); width: 20px; height: 20px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; min-width: 0; }
.user { margin-left: auto; position: relative; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; background: linear-gradient(135deg, #ffcf3f, #ff8a3d); color: #fff; font-weight: 700; font-size: 16px; }
.user-menu { right: 0; top: 48px; min-width: 220px; }
.menu-head { padding: 10px 14px 12px; display: grid; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head .muted { font-size: 12px; }

.sidebar { padding: 8px 12px 16px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; background: var(--bg); }
.create-wrap { position: relative; }
.btn-create { width: 100%; padding: 12px; font-size: 15px; border-radius: 12px; box-shadow: 0 2px 6px rgba(255,200,0,.35); }
.create-menu { top: 52px; left: 0; right: 0; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; font-size: 15px; color: #333; transition: background .12s; }
.nav a svg { color: #888; }
.nav a:hover { background: var(--hover); }
.nav a.active { background: var(--active); font-weight: 600; color: var(--text); }
.nav a.active svg { color: var(--text); }
.usage { margin-top: auto; padding: 14px; background: var(--bg2); border-radius: 12px; }
.usage-bar { height: 6px; background: #e1e1e6; border-radius: 3px; overflow: hidden; }
.usage-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffcf3f, #ff9e3d); border-radius: 3px; transition: width .4s; }
.usage-text { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 28px 6px; min-height: 60px; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 22px; font-weight: 600; min-width: 0; }
.crumbs a, .crumbs span.cur { padding: 2px 6px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { background: var(--hover); color: var(--text); }
.crumbs a.drop-over { background: var(--sel); color: var(--text); }
.crumbs .sep { color: #c4c4c8; font-weight: 400; }
.crumbs .sub { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.tools { display: flex; gap: 4px; flex: none; }
.sort-wrap { position: relative; }
.sort-menu { right: 0; top: 44px; min-width: 180px; }
.sort-menu button.on::after { content: "✓"; margin-left: auto; color: var(--muted); }

.selbar { position: absolute; top: 0; left: 0; right: 0; z-index: 5; height: 60px; display: flex; align-items: center; gap: 8px; padding: 0 20px; background: #fff; box-shadow: 0 1px 0 var(--line), 0 4px 12px rgba(0,0,0,.04); animation: slide .15s ease; }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }
#selCount { font-weight: 600; margin-right: 8px; white-space: nowrap; }
.sel-actions { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.sel-actions button { border: 0; background: transparent; padding: 8px 12px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sel-actions button:hover { background: var(--hover); }
.sel-actions button svg { width: 18px; height: 18px; }
.sel-actions button.danger { color: #d00; }

.content { flex: 1; overflow-y: auto; padding: 4px 20px 120px; outline: none; position: relative; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.6); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #eee; border-top-color: var(--yellow-h); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 80px 20px; display: grid; justify-items: center; gap: 10px; }
.empty .big-ico { width: 120px; height: 120px; opacity: .9; }
.empty b { color: var(--text); font-size: 18px; }

/* tiles */
.items.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.item { position: relative; border-radius: 12px; cursor: default; user-select: none; -webkit-user-select: none; border: 1.5px solid transparent; transition: background .1s; }
.tiles .item { padding: 12px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.item:hover { background: var(--hover); }
.item.selected { background: var(--sel); border-color: var(--sel-line); }
.item.drop-over { background: #e7efff; border-color: var(--blue); }
.item.cut { opacity: .45; }
.tiles .thumb { width: 100px; height: 88px; display: grid; place-items: center; }
.tiles .thumb img.pic { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.18); object-fit: cover; background: #f2f2f2; }
.tiles .thumb .ico { width: 80px; height: 80px; }
.tiles .name { font-size: 13px; line-height: 1.3; max-width: 100%; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tiles .meta { display: none; }
.check { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid #bbb; background: #fff; display: none; place-items: center; cursor: pointer; }
.check svg { width: 14px; height: 14px; stroke-width: 3; color: #000; opacity: 0; }
.item:hover .check, .has-sel .check { display: grid; }
.item.selected .check { background: var(--yellow); border-color: var(--yellow-h); }
.item.selected .check svg { opacity: 1; }
.badge-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.badge-play span { width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.55); display: grid; place-items: center; }
.badge-play svg { color: #fff; fill: #fff; width: 14px; height: 14px; }

/* list */
.items.list { display: flex; flex-direction: column; }
.list .list-head, .list .item { display: grid; grid-template-columns: 40px minmax(0,1fr) 160px 110px; align-items: center; gap: 12px; padding: 6px 12px 6px 44px; }
.list .list-head { color: var(--muted); font-size: 12.5px; padding-top: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.list .list-head span { cursor: pointer; }
.list .list-head span:hover { color: var(--text); }
.list .item { border-radius: 10px; min-height: 52px; }
.list .thumb { width: 40px; height: 40px; display: grid; place-items: center; }
.list .thumb img.pic { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.list .thumb .ico { width: 36px; height: 36px; }
.list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.list .name .loc { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.list .meta.size { text-align: right; }
.list .check { top: 50%; left: 12px; transform: translateY(-50%); }
.list .badge-play { display: none; }

/* photos */
.items.photos { display: block; }
.photo-group h3 { font-size: 16px; margin: 18px 4px 10px; font-weight: 600; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.photo-grid .item { padding: 0; border-radius: 6px; overflow: hidden; aspect-ratio: 1; border-width: 3px; }
.photo-grid .thumb { width: 100%; height: 100%; }
.photo-grid .thumb img.pic { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .thumb .ico { width: 64px; height: 64px; margin: auto; }
.photo-grid .thumb { display: grid; place-items: center; background: #f2f2f4; }
.photo-grid .name, .photo-grid .meta { display: none; }

/* menus */
.menu { position: absolute; z-index: 50; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; animation: pop .12s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.menu button { border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: #d00; }
.menu button svg { width: 18px; height: 18px; color: #666; }
.menu button.danger svg { color: #d00; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.menu .mi { width: 18px; text-align: center; color: #666; }
.ctx { position: fixed; min-width: 220px; }

/* drop */
.dropzone { position: fixed; inset: 0; z-index: 80; background: rgba(255, 219, 77, .16); border: 3px dashed var(--yellow-h); display: grid; place-items: center; pointer-events: none; }
.dz-inner { background: #fff; padding: 28px 40px; border-radius: 18px; box-shadow: var(--shadow); text-align: center; font-size: 17px; font-weight: 600; display: grid; justify-items: center; gap: 10px; }
.dz-inner svg { width: 40px; height: 40px; color: #e6b800; }
.dz-inner span { font-weight: 400; color: var(--muted); font-size: 14px; }

/* uploads */
.uploads { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 380px; max-width: calc(100vw - 32px); background: #fff; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.uploads-head { display: flex; align-items: center; gap: 2px; padding: 10px 8px 10px 18px; font-weight: 600; }
.uploads-head span { flex: 1; }
.uploads.min .uploads-list { display: none; }
.uploads.min #upToggle svg { transform: rotate(180deg); }
.uploads-total { height: 3px; background: #f0f0f0; }
.uploads-total span { display: block; height: 100%; width: 0; background: var(--yellow-h); transition: width .2s; }
.uploads-list { max-height: 300px; overflow-y: auto; padding: 4px 0; }
.up { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 7px 16px; }
.up .ico { width: 28px; height: 28px; }
.up .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.up .bar { height: 3px; background: #eee; border-radius: 2px; margin-top: 5px; overflow: hidden; }
.up .bar span { display: block; height: 100%; width: 0; background: var(--yellow-h); }
.up .st { font-size: 12px; color: var(--muted); white-space: nowrap; }
.up.done .st { color: #19a34a; }
.up.fail .st { color: var(--red); }
.up.done .bar, .up.fail .bar { display: none; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: #222; color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); animation: pop .15s ease; pointer-events: auto; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px); }
.toast.error { background: #c62828; }
.toast button { background: transparent; border: 0; color: var(--yellow); cursor: pointer; font-weight: 600; padding: 0; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.4); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 440px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); display: flex; flex-direction: column; gap: 14px; animation: pop .15s; }
.modal-card.wide { max-width: 760px; height: 80vh; }
.modal-card h2 { margin: 0; font-size: 20px; }
.modal-card .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal-card textarea.field { flex: 1; resize: none; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.picker { border: 1px solid var(--line); border-radius: 12px; overflow-y: auto; min-height: 240px; max-height: 50vh; padding: 6px; }
.picker .pk { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker .pk:hover { background: var(--hover); }
.picker .pk.on { background: var(--sel); }
.picker .pk .ico { width: 26px; height: 26px; }
.picker .pk .tw { width: 18px; color: #999; text-align: center; font-size: 11px; transition: transform .15s; }
.picker .pk .tw.open { transform: rotate(90deg); }
.picker .kids { margin-left: 20px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.seg button.on { border-color: var(--yellow-h); background: var(--sel); }
.props { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; }
.props span:nth-child(odd) { color: var(--muted); }
.props span:nth-child(even) { word-break: break-all; }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 95; background: rgba(12,12,14,.96); color: #fff; display: grid; grid-template-rows: auto 1fr; }
.viewer-top { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 20px; padding-top: max(10px, env(safe-area-inset-top)); }
.viewer-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.viewer-tools { display: flex; gap: 4px; }
.viewer-body { display: grid; place-items: center; overflow: hidden; padding: 0 72px 24px; min-height: 0; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100vh - 100px); border-radius: 4px; }
.viewer-body iframe { width: 100%; height: calc(100vh - 100px); border: 0; background: #fff; border-radius: 6px; }
.viewer-body pre { width: 100%; max-width: 1000px; height: calc(100vh - 100px); margin: 0; overflow: auto; background: #1d1d21; color: #e6e6e6; padding: 20px; border-radius: 10px; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.viewer-body .nopreview { text-align: center; display: grid; gap: 16px; justify-items: center; }
.viewer-body .nopreview .ico { width: 120px; height: 120px; }
.viewer-body audio { width: min(520px, 90vw); }
.viewer-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; display: grid; place-items: center; }
.viewer-nav:hover { background: rgba(255,255,255,.18); }
.viewer-nav.prev { left: 12px; }
.viewer-nav.next { right: 12px; }

.scrim { display: none; }

/* mobile */
@media (max-width: 860px) {
  :root { --top: 58px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .search { min-width: 0; }
  .user { flex: none; }
  .burger { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .brand { width: auto; }
  .topbar .brand span:last-child { display: none; }
  .sidebar { position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: 280px; padding-top: 20px; transform: translateX(-110%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(0,0,0,.3); }
  .toolbar { padding: 8px 16px 4px; }
  .crumbs { font-size: 18px; }
  .content { padding: 4px 10px 120px; }
  .items.tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .tiles .thumb { width: 80px; height: 72px; }
  .tiles .thumb .ico { width: 64px; height: 64px; }
  .list .list-head { display: none; }
  .list .item { grid-template-columns: 40px minmax(0,1fr) auto; padding-left: 12px; }
  .list .meta.date { display: none; }
  .list .check { display: none !important; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .viewer-body { padding: 0 8px 16px; }
  .viewer-nav { display: none; }
  .selbar { padding: 0 8px; }
  .sel-actions button span { display: none; }
  .uploads { right: 16px; bottom: 16px; }
}
