/* everything — shell + shared components. Apps add their own CSS. */
:root {
  --bg: #f6f7f9; --surface: #fff; --surface-2: #f1f3f6; --hover: #eef0f4; --border: #e3e6eb;
  --text: #1c2026; --muted: #6b7380; --accent: #4f5bd5; --accent-2: #3f4bc4; --accent-soft: #e9ebfb;
  --danger: #d33a3a; --danger-soft: #fdecec; --ok: #23915a;
  --radius: 10px; --radius-s: 7px;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --shadow-l: 0 12px 32px rgb(16 24 40 / .16), 0 2px 6px rgb(16 24 40 / .08);
  --sidebar: 220px;
  --ico-folder: #5b8def; --ico-image: #d9822b; --ico-video: #c2416b; --ico-audio: #8b5cf6;
  --ico-archive: #8a6d3b; --ico-pdf: #d33a3a; --ico-text: #6b7380; --ico-code: #23915a;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317; --surface: #181b20; --surface-2: #1f2329; --hover: #252a31; --border: #2c3139;
    --text: #e6e8eb; --muted: #949ba6; --accent: #7c86f0; --accent-2: #949cf4; --accent-soft: #262a4a;
    --danger: #f06060; --danger-soft: #3a1f22;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-l: 0 12px 32px rgb(0 0 0 / .5);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; }
#root { height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.center { display: grid; place-items: center; height: 100%; padding: 2rem; text-align: center; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- shell ---- */
.shell { display: flex; height: 100%; }
.sidebar { width: var(--sidebar); flex: none; display: flex; flex-direction: column; gap: 2px; padding: 14px 10px;
  background: var(--surface); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; padding: 4px 8px 16px; }
.brand.big { font-size: 22px; justify-content: center; padding-bottom: 8px; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px; border: 2.5px solid #fff; border-radius: 50%; }
.brand.big .logo { width: 32px; height: 32px; border-radius: 9px; }
.brand.big .logo::after { inset: 8px; border-width: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s); color: var(--text);
  border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

@media (max-width: 720px) {
  .shell { flex-direction: column-reverse; }
  .sidebar { width: auto; flex-direction: row; padding: 6px; border-right: 0; border-top: 1px solid var(--border); }
  .sidebar .brand, .sidebar .grow { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px; align-items: center; }
  .user-btn { width: auto; }
  .user-btn span:not(.avatar) { display: none; }
}

/* ---- auth ---- */
.auth { display: grid; place-items: center; height: 100%; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.auth-card .btn { margin-top: 16px; }
.error { color: var(--danger); min-height: 1em; margin: 8px 0 0; font-size: 13px; }

/* ---- form controls ---- */
.label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
.input { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius-s);
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.btn.block { width: 100%; padding: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-s); border: 0; background: none; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.check { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgb(10 12 16 / .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-l); width: 100%; max-width: 420px; max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; animation: pop .14s; }
.modal.wide { max-width: 640px; }
.modal header { display: flex; align-items: center; gap: 8px; padding: 14px 14px 4px 20px; }
.modal header h2 { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 8px 20px 16px; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(4px); } }

/* ---- menu ---- */
.menu { position: fixed; z-index: 60; min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-l); padding: 5px; animation: fade .08s; }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-align: left; }
.menu-item:hover, .menu-item:focus { background: var(--hover); outline: none; }
.menu-item .icon { color: var(--muted); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item:disabled { opacity: .4; cursor: default; }

/* ---- toasts ---- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 70; align-items: center; pointer-events: none; }
.toast { background: #23272f; color: #fff; padding: 10px 16px; border-radius: var(--radius); box-shadow: var(--shadow-l); max-width: 90vw; animation: pop .15s; transition: opacity .3s; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }
.toast.out { opacity: 0; }

/* ---- generic page layout for simple apps ---- */
.page { overflow: auto; height: 100%; }
.page-inner { max-width: 860px; margin: 0 auto; padding: 28px 24px 60px; }
.page h1 { font-size: 22px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 8px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.danger-text, .danger-text .icon { color: var(--danger); }
.schema { background: var(--surface-2); border-radius: var(--radius-s); padding: 12px; overflow: auto; max-height: 280px; margin: 0; }
.page-inner.narrow { max-width: 480px; padding-top: 8vh; }
.link-card .error { margin-bottom: 8px; }

/* picker list (shared) */
.picker-list { border: 1px solid var(--border); border-radius: var(--radius); margin: 10px 0; max-height: 300px; overflow: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; text-align: left; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--hover); }
.picker-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-empty { padding: 20px; text-align: center; margin: 0; }
.btn.small { padding: 5px 9px; font-size: 13px; }

