:root {
  --accent: #0d99ff;
  --accent-hover: #007be5;
  --accent-soft: #e5f4ff;
  --text: #1e1e1e;
  --muted: #757575;
  --border: #e6e6e6;
  --bg: #ffffff;
  --bg-2: #f5f5f5;
  --bg-hover: #f0f0f0;
  --danger: #f24822;
  --dark: #2c2c2c;
  --radius: 6px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); font-size: 13px; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }

.btn { border: 1px solid transparent; border-radius: var(--radius); padding: 7px 14px; background: var(--bg-2); font-weight: 500; line-height: 16px; white-space: nowrap; }
.btn:hover { background: #e9e9e9; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; border-radius: 4px; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; color: inherit; padding: 0; }
.icon-btn:hover { background: var(--bg-hover); }
.input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; outline: none; background: #fff; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }

/* ---------- login ---------- */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #f5f5f5, #e8f4ff); }
.auth-card { width: 380px; background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 10px 40px rgba(0,0,0,.08); }
.auth-card h1 { font-size: 22px; margin: 16px 0 6px; }
.auth-card .btn { width: 100%; padding: 10px; margin-top: 6px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--muted); }
.auth-error { color: var(--danger); min-height: 18px; margin-bottom: 8px; font-size: 12px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: 240px 1fr; height: 100%; }
.dash-side { border-right: 1px solid var(--border); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.dash-user { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--radius); cursor: pointer; margin-bottom: 8px; }
.dash-user:hover { background: var(--bg-hover); }
.avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius); cursor: pointer; color: var(--text); }
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav-item .count { margin-left: auto; color: var(--muted); font-size: 11px; }
.nav-title { font-size: 11px; color: var(--muted); padding: 16px 10px 6px; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.dash-main { overflow-y: auto; display: flex; flex-direction: column; }
.dash-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); gap: 12px; position: sticky; top: 0; background: #fff; z-index: 2; }
.dash-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.dash-actions { display: flex; gap: 8px; align-items: center; }
.search { width: 260px; }
.new-cards { display: flex; flex-wrap: wrap; gap: 14px; padding: 20px 28px 0; }
.new-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; cursor: pointer; min-width: 220px; background: #fff; }
.new-card:hover { border-color: var(--accent); }
.new-card .ic { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; }
.new-card b { display: block; }
.new-card small { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; padding: 20px 28px 40px; }
.file-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fff; transition: box-shadow .15s; }
.file-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.file-card.selected { outline: 2px solid var(--accent); }
.file-thumb { aspect-ratio: 16/10; background: var(--bg-2); display: flex; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--border); }
.file-thumb img { width: 100%; height: 100%; object-fit: contain; }
.file-thumb .ph { font-size: 36px; color: #cfcfcf; }
.file-info { padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.file-info .meta { min-width: 0; flex: 1; }
.file-info .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { color: var(--muted); font-size: 11px; }
.empty { padding: 80px 28px; text-align: center; color: var(--muted); }

/* ---------- modal, menus, toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal { background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.ctx-menu { position: fixed; z-index: 2000; background: #1e1e1e; color: #fff; border-radius: 8px; padding: 6px 0; min-width: 220px; box-shadow: 0 8px 30px rgba(0,0,0,.3); font-size: 12px; }
.ctx-item { display: flex; justify-content: space-between; padding: 6px 16px; cursor: default; gap: 24px; }
.ctx-item:hover { background: var(--accent); }
.ctx-item.disabled { opacity: .4; }
.ctx-item.disabled:hover { background: transparent; }
.ctx-item.danger:hover { background: var(--danger); }
.ctx-sc { color: rgba(255,255,255,.55); }
.ctx-sep { height: 1px; background: rgba(255,255,255,.12); margin: 5px 0; }
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 3000; align-items: center; }
.toast { background: #1e1e1e; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.2); transition: opacity .3s; max-width: min(720px, calc(100vw - 32px)); white-space: pre-wrap; word-break: break-word; }
.toast.error { background: var(--danger); user-select: text; -webkit-user-select: text; cursor: text; }
.toast.hide { opacity: 0; pointer-events: none; }

.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.member-row .who { flex: 1; min-width: 0; }
.member-row .who small { display: block; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.select { border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 8px; background: #fff; }
.list-item { padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.list-item .grow { flex: 1; min-width: 0; }
.kbd-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 24px; font-size: 12px; }
.kbd-grid kbd { background: var(--bg-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-family: inherit; font-size: 11px; }
.kbd-grid h4 { grid-column: 1 / -1; margin: 12px 0 4px; }
