/* Keep — minimal personal file locker. Dark default, light via [data-theme] */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #09090b;
  --surface: #101014;
  --card: #16161c;
  --card-hover: #1d1d25;
  --elevated: #22222b;
  --accent: #8b5cf6;
  --accent-strong: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --accent-glow: rgba(139, 92, 246, 0.35);
  --text: #ececf1;
  --text-dim: #a6a6b3;
  --text-muted: #5d5d6b;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --success: #34d399;
  --danger: #f87171;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f1eefb;
  --elevated: #ffffff;
  --accent: #7c3aed;
  --accent-strong: #6d28d9;
  --accent-soft: rgba(124, 58, 237, 0.09);
  --accent-glow: rgba(124, 58, 237, 0.22);
  --text: #17171c;
  --text-dim: #4b4b57;
  --text-muted: #9a9aa6;
  --border: rgba(20, 20, 40, 0.09);
  --border-strong: rgba(20, 20, 40, 0.16);
  --shadow: 0 12px 40px rgba(30, 20, 70, 0.14);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

html, body { height: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select { font: inherit; }
[hidden] { display: none !important; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); stroke-width: 2; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-dim);
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--text); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { width: 17px; height: 17px; }

.search {
  flex: 1;
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-muted);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 15px; height: 15px; }
.search input { flex: 1; background: none; border: none; outline: none; color: var(--text); min-width: 0; }
.search input::placeholder { color: var(--text-muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font: 600 10px/1 inherit; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-radius: 4px; padding: 3px 6px;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: 9px; font-weight: 600; font-size: 13px;
  transition: background 0.12s, transform 0.08s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent-strong); color: #fff; box-shadow: 0 2px 14px var(--accent-glow); }
.btn.primary:hover { background: var(--accent); }
.btn.ghost { background: var(--card); color: var(--text-dim); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn.wide { width: 100%; justify-content: center; }
.btn svg { width: 15px; height: 15px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 6px 0 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--card); font-size: 12px; color: var(--text-dim);
  max-width: 220px;
}
.user-chip b { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .icon-btn { width: 26px; height: 26px; }

/* --------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px 0;
}

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 6px 13px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  background: var(--card); border: 1px solid var(--border);
  white-space: nowrap;
  transition: all 0.12s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.toolbar-right { display: flex; align-items: center; gap: 8px; }
.count { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.select {
  height: 32px; padding: 0 8px;
  background: var(--card); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; outline: none; cursor: pointer;
}
.view-toggle { display: flex; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.view-toggle .icon-btn { width: 28px; height: 26px; border-radius: 6px; }

/* ------------------------------------------------------------------ body */
.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex; flex-direction: column;
  padding: 14px 10px 12px;
  gap: 4px;
  border-right: 1px solid var(--border);
  transition: margin-left 0.18s ease, opacity 0.18s;
}
.sidebar.hidden { margin-left: -220px; opacity: 0; pointer-events: none; }

.folders { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.folder-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-dim); font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px dashed transparent;
  transition: background 0.12s, color 0.12s;
}
.folder-item:hover { background: var(--card); color: var(--text); }
.folder-item.active { background: var(--accent-soft); color: var(--accent); }
.folder-item.drag-over { border-color: var(--accent); background: var(--accent-soft); }
.folder-item svg { width: 15px; height: 15px; }
.folder-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .fcount { font-size: 11px; color: var(--text-muted); }
.folder-item .fmenu { width: 22px; height: 22px; border-radius: 5px; display: none; place-items: center; color: var(--text-muted); }
.folder-item:hover .fmenu { display: grid; }
.folder-item .fmenu:hover { background: var(--elevated); color: var(--text); }
.folder-item .fname.editing { background: var(--bg); outline: 1px solid var(--accent); border-radius: 4px; padding: 1px 5px; }

.new-folder {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin-top: 2px;
  border-radius: 8px; border: 1px dashed var(--border-strong);
  color: var(--text-muted); font-size: 12.5px; font-weight: 500;
  transition: all 0.12s;
}
.new-folder:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.new-folder svg { width: 15px; height: 15px; }

.storage { margin-top: auto; padding: 10px 10px 2px; }
.storage-bar { height: 5px; background: var(--card); border-radius: 3px; overflow: hidden; }
.storage-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.storage-fill.warn { background: var(--danger); }
.storage-text { margin-top: 7px; font-size: 11px; color: var(--text-muted); }

/* ---------------------------------------------------------------- canvas */
.canvas { flex: 1; overflow-y: auto; padding: 16px; position: relative; }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; color: var(--text-muted); padding: 20px;
}
.empty svg { width: 42px; height: 42px; opacity: 0.4; margin-bottom: 8px; stroke-width: 1.4; }
.empty h2 { font-size: 17px; font-weight: 600; color: var(--text-dim); }
.empty p { font-size: 13px; max-width: 320px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.rows { display: flex; flex-direction: column; gap: 4px; }

/* file card (grid) */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.card.dragging { opacity: 0.4; }

.card-thumb {
  height: 96px;
  display: grid; place-items: center;
  background: var(--surface);
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-thumb svg { width: 26px; height: 26px; stroke-width: 1.5; opacity: 0.8; }

.card-info { padding: 9px 10px; }
.card-name { font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; }
.card-meta { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.card-name.editing, .row-name.editing { background: var(--bg); outline: 1px solid var(--accent); padding: 1px 5px; margin: -1px -5px; cursor: text; user-select: text; white-space: normal; word-break: break-all; }

.card-dots {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text-dim);
  opacity: 0; transition: opacity 0.12s;
}
.card:hover .card-dots, .row:hover .card-dots { opacity: 1; }
.card-dots:hover { color: var(--text); background: var(--elevated); }
.card-dots svg { width: 14px; height: 14px; }

/* file row (list) */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s;
}
.row:hover { border-color: var(--border-strong); }
.row.dragging { opacity: 0.4; }
.row-icon { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); overflow: hidden; flex-shrink: 0; }
.row-icon img { width: 100%; height: 100%; object-fit: cover; }
.row-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; }
.row-meta { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.row .card-dots { position: static; opacity: 0; }

/* file-kind colors */
.k-image { color: #f472b6; }
.k-media { color: #a78bfa; }
.k-doc { color: #60a5fa; }
.k-pdf { color: #f87171; }
.k-code { color: #34d399; }
.k-zip { color: #fbbf24; }
.k-other { color: var(--text-muted); }

/* ---------------------------------------------------------- drop overlay */
.drop-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(5px);
  display: grid; place-items: center;
  opacity: 0; visibility: hidden; transition: opacity 0.15s;
}
.drop-overlay.active { opacity: 1; visibility: visible; }
.drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 44px 60px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.drop-inner svg { width: 34px; height: 34px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ------------------------------------------------------------- ctx menu */
.ctx-menu {
  position: fixed; z-index: 200;
  min-width: 170px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: scale(0.96);
  transform-origin: top left;
  transition: all 0.09s;
}
.ctx-menu.open { opacity: 1; visibility: visible; transform: scale(1); }
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 12.5px; color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.ctx-item:hover { background: var(--accent-soft); color: var(--text); }
.ctx-item.danger:hover { background: rgba(248, 113, 113, 0.12); color: var(--danger); }
.ctx-item svg { width: 14px; height: 14px; opacity: 0.75; }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 6px; }
.ctx-label { padding: 7px 11px 3px; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }

/* ---------------------------------------------------------------- modals */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 18px;
}
.modal {
  position: relative;
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 26px;
  box-shadow: var(--shadow);
  animation: pop 0.16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-x { position: absolute; top: 12px; right: 12px; }

.auth-head { text-align: center; margin-bottom: 18px; }
.auth-logo { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.8; margin-bottom: 10px; }
.auth-head h2 { font-size: 18px; letter-spacing: -0.02em; }
.auth-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }

.auth-pending {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; padding: 9px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 9px;
  font-size: 12px; color: var(--accent);
}

.tabs { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; margin-bottom: 14px; }
.tab { flex: 1; padding: 7px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); transition: all 0.12s; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }

#authForm { display: flex; flex-direction: column; gap: 10px; }
#authForm input {
  height: 40px; padding: 0 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  outline: none; font-size: 13px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
#authForm input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-error { font-size: 12px; color: var(--danger); padding: 2px 2px 0; }

/* ---------------------------------------------------------------- viewer */
.viewer {
  position: fixed; inset: 0; z-index: 120;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: fade 0.14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.viewer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.viewer-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; gap: 6px; flex-shrink: 0; }
.viewer-actions .btn { height: 32px; padding: 0 11px; font-size: 12px; }
.viewer-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.viewer-center { flex: 1; display: grid; place-items: center; overflow: auto; padding: 20px; }
.viewer-center.dark { background: #000; }
.viewer-loading { display: grid; place-items: center; height: 100%; color: var(--text-muted); font-size: 13px; }

.spinner { width: 22px; height: 22px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* image viewer */
.iv-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; transition: transform 0.15s; }
.iv-bar {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 10px; background: var(--surface); border-top: 1px solid var(--border);
}
.iv-bar .icon-btn { background: var(--card); border: 1px solid var(--border); }
.iv-zoom { font-size: 11.5px; color: var(--text-muted); min-width: 44px; text-align: center; }

/* code editor */
.code-wrap { flex: 1; display: flex; overflow: hidden; }
.line-nums {
  padding: 14px 10px; min-width: 46px; text-align: right;
  background: var(--surface); color: var(--text-muted);
  font: 12px/1.65 "SF Mono", "Cascadia Code", Consolas, monospace;
  user-select: none; overflow: hidden; white-space: pre;
}
.code-area {
  flex: 1; padding: 14px; border: none; outline: none; resize: none;
  background: var(--bg); color: var(--text);
  font: 12px/1.65 "SF Mono", "Cascadia Code", Consolas, monospace;
  white-space: pre; overflow: auto; tab-size: 2;
}

/* markdown */
.md-wrap { flex: 1; display: flex; overflow: hidden; }
.md-half { flex: 1; display: flex; overflow: hidden; border-right: 1px solid var(--border); }
.md-preview { flex: 1; padding: 22px 26px; overflow-y: auto; background: var(--surface); line-height: 1.7; font-size: 13.5px; color: var(--text-dim); }
.md-preview h1, .md-preview h2, .md-preview h3 { color: var(--text); margin: 18px 0 8px; letter-spacing: -0.01em; }
.md-preview h1 { font-size: 22px; } .md-preview h2 { font-size: 17px; } .md-preview h3 { font-size: 14.5px; }
.md-preview p { margin: 8px 0; }
.md-preview code { background: var(--card); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: Consolas, monospace; }
.md-preview pre { background: var(--card); border: 1px solid var(--border); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.md-preview pre code { background: none; border: none; padding: 0; }
.md-preview ul, .md-preview ol { margin: 8px 0; padding-left: 22px; }
.md-preview blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 13px; color: var(--text-muted); margin: 10px 0; }
.md-preview a { color: var(--accent); }
.md-preview img { max-width: 100%; border-radius: 8px; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* json */
.json-tree { flex: 1; padding: 16px; overflow: auto; font: 12px/1.65 "SF Mono", Consolas, monospace; }
.j-key { color: #f472b6; } .j-str { color: #34d399; } .j-num { color: #60a5fa; }
.j-bool { color: #fbbf24; } .j-null { color: var(--text-muted); } .j-br { color: var(--text-dim); }
:root[data-theme="light"] .j-str { color: #059669; }
:root[data-theme="light"] .j-num { color: #2563eb; }
:root[data-theme="light"] .j-key { color: #db2777; }
:root[data-theme="light"] .j-bool { color: #b45309; }

/* csv */
.csv-wrap { flex: 1; overflow: auto; padding: 14px; }
.csv-table { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.csv-table th, .csv-table td { padding: 7px 12px; border: 1px solid var(--border); text-align: left; white-space: nowrap; }
.csv-table th { background: var(--surface); font-weight: 600; position: sticky; top: -14px; }
.csv-table td { color: var(--text-dim); }
.csv-table tr:hover td { background: var(--card); }

/* media */
.media-box { flex: 1; display: grid; place-items: center; padding: 20px; }
.media-box video { max-width: 100%; max-height: 100%; border-radius: 10px; background: #000; }
.audio-card { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(420px, 92%); }
.audio-art {
  width: 130px; height: 130px; border-radius: 20px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-strong), #ec4899);
  color: #fff; box-shadow: 0 10px 44px var(--accent-glow);
}
.audio-art svg { width: 44px; height: 44px; }
.audio-card audio { width: 100%; }
.audio-name { font-weight: 600; font-size: 14px; text-align: center; word-break: break-all; }

/* pdf + generic */
.pdf-frame { flex: 1; border: none; background: var(--surface); }
.generic {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--text-muted); text-align: center; padding: 20px;
}
.generic svg { width: 46px; height: 46px; stroke-width: 1.3; }
.generic .g-name { font-size: 14px; font-weight: 600; color: var(--text); word-break: break-all; max-width: 420px; }
.generic .g-meta { font-size: 12px; }

/* --------------------------------------------------------------- uploads */
.uploads {
  position: fixed; right: 16px; bottom: 16px; z-index: 140;
  width: 300px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.uploads-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 8px 9px 14px;
  font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.uploads-head .icon-btn { width: 26px; height: 26px; }
.uploads-list { max-height: 220px; overflow-y: auto; padding: 6px; }
.u-item { padding: 7px 8px; border-radius: 8px; }
.u-top { display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px; margin-bottom: 5px; }
.u-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.u-state { color: var(--text-muted); flex-shrink: 0; }
.u-state.ok { color: var(--success); } .u-state.err { color: var(--danger); }
.u-bar { height: 3px; background: var(--card); border-radius: 2px; overflow: hidden; }
.u-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.15s; }

/* ---------------------------------------------------------------- toasts */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px;
  background: var(--elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  animation: toast-in 0.16s ease;
  transition: opacity 0.2s;
}
.toast svg { width: 14px; height: 14px; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 720px) {
  .topbar { padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .search { order: 10; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .btn.primary span { display: none; }
  .btn.primary { width: 36px; padding: 0; justify-content: center; }
  .toolbar { padding: 8px 10px 0; flex-wrap: wrap; }
  .canvas { padding: 10px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .card-thumb { height: 76px; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 110;
    background: var(--surface); width: 240px;
    padding-top: 18px;
    box-shadow: var(--shadow);
  }
  .sidebar.hidden { margin-left: -260px; }
  .md-wrap { flex-direction: column; }
  .md-half { border-right: none; border-bottom: 1px solid var(--border); max-height: 45%; }
  .uploads { width: calc(100vw - 24px); right: 12px; }
  .user-chip { max-width: 130px; }
}
