:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #5d6b80;
  --line: #e3e8ef;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e8f1ff;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --ok: #067647;
  --folder: #e7a008;
  --shadow: 0 10px 30px rgba(23, 32, 51, 0.08);
  --radius: 14px;
  --top: 60px;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at top left, #dce9ff, transparent 42%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 28px 22px 24px;
}
.brand-mark, .brand::before {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent) url("/static/favicon.svg") center / 26px no-repeat;
  display: inline-block;
}
.login-card h1 { margin: 14px 0 8px; font-size: 32px; }
.lede { margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px 12px;
  font-size: 16px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.btn, .icon-btn, .sidenav button, .more, .crumb button, .menu button, .tile {
  border: 0;
  background: transparent;
}
.btn {
  border-radius: 999px;
  padding: 10px 14px;
  min-height: 44px;
  background: #fff;
  border: 1px solid var(--line);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.quiet { background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--top);
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; }
.brand::before { content: ""; width: 28px; height: 28px; }
.search { flex: 1; }
.search input { background: var(--bg); border-radius: 999px; }
.who { display: flex; align-items: center; gap: 8px; }
.who-name { display: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.icon-btn { width: 44px; height: 44px; border-radius: 12px; }
.burger, .burger::before, .burger::after {
  display: block; width: 16px; height: 2px; background: var(--ink); position: relative;
}
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -5px; }
.burger::after { top: 5px; }

.shell { min-height: calc(100vh - var(--top)); }
.scrim { position: fixed; inset: var(--top) 0 0; background: rgba(17, 24, 39, 0.35); z-index: 25; }
aside {
  position: fixed;
  z-index: 30;
  top: var(--top);
  bottom: 0;
  left: 0;
  width: min(84vw, 300px);
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  transform: translateX(-105%);
  transition: transform 0.18s ease;
}
aside.open { transform: none; }
.sidenav { display: grid; gap: 4px; }
.sidenav button, .tree-node {
  width: 100%;
  text-align: left;
  border-radius: 10px;
  padding: 12px;
  min-height: 44px;
}
.sidenav button.active, .tree-node.active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.tree-label { margin: 16px 8px 6px; color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
.tree-node { display: block; color: var(--ink); }

main { padding: 12px 12px 88px; }
.main-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.crumb { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 44px; }
.crumb button { color: var(--accent); padding: 6px; border-radius: 8px; }
.crumb .sep { color: var(--muted); }
.main-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 8px 0; padding: 8px; border-radius: 12px; background: var(--accent-soft);
}

.list { display: grid; gap: 8px; }
.row, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px; }
.row.selected, .card.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.file-btn { display: flex; gap: 10px; align-items: center; text-align: left; background: transparent; border: 0; min-height: 48px; width: 100%; }
.meta { color: var(--muted); font-size: 12px; }
.name { font-weight: 650; word-break: break-all; }
.glyph {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: #eef2f6; overflow: hidden; font-size: 12px; color: var(--muted);
}
.glyph.folder { background: #fff6dd; color: #8a5a00; }
.glyph img { width: 100%; height: 100%; object-fit: cover; }
.more { width: 44px; height: 44px; border-radius: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
.card { padding: 8px; display: grid; gap: 8px; }
.card .thumb {
  aspect-ratio: 4 / 3; border-radius: 10px; background: #eef2f6; display: grid; place-items: center; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.check { width: 20px; height: 20px; }

.empty, .loading, .error-box { padding: 28px 8px; color: var(--muted); text-align: center; }
.error-box { color: var(--danger); }
.alert { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; }

.menu {
  position: fixed; z-index: 40; min-width: 180px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.menu button { display: block; width: 100%; text-align: left; padding: 12px; border-radius: 8px; background: transparent; border: 0; }
.menu button:hover, .menu button:focus { background: var(--bg); }
.menu .danger { color: var(--danger); }

.modal { position: fixed; inset: 0; z-index: 50; background: rgba(17, 24, 39, 0.45); display: grid; align-items: end; }
.modal[hidden], .lightbox[hidden], .scrim[hidden], .dock[hidden], .bulk[hidden] { display: none; }
.sheet {
  background: #fff; border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: min(86vh, 720px); overflow: auto;
}
.sheet h2 { margin: 0 0 12px; font-size: 20px; }
.sheet .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.picker-list { display: grid; gap: 6px; margin-top: 10px; }
.picker-list button { text-align: left; background: var(--bg); border: 0; border-radius: 10px; padding: 12px; min-height: 44px; }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(8, 12, 20, 0.92); display: grid; place-items: center; padding: 16px; }
.lightbox img, .lightbox video { max-width: min(1100px, 100%); max-height: calc(100vh - 80px); }
.lightbox .close {
  position: absolute; top: 12px; right: 12px; color: #fff; background: transparent; border: 0; min-height: 44px; font-size: 16px;
}

.dock {
  position: fixed; right: 12px; bottom: 12px; z-index: 35; width: min(360px, calc(100vw - 24px));
  background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px;
}
.dock h3 { margin: 0 0 8px; font-size: 14px; }
.up-item { display: grid; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); }

.toasts { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 70; display: grid; gap: 8px; }
.toast { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.toast.ok { background: var(--ok); }

.panel { display: grid; gap: 10px; }
.ticket, .token {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: grid; gap: 8px;
}
.ticket h3, .token h3 { margin: 0; font-size: 16px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions input, .row-actions select { width: auto; flex: 1 1 9rem; min-width: 8rem; }

main.drop { outline: 2px dashed var(--accent); outline-offset: -8px; background: #f7fbff; }

@media (min-width: 900px) {
  .icon-btn { display: none; }
  .who-name { display: inline; }
  aside { transform: none; width: 248px; top: var(--top); }
  main { margin-left: 248px; padding: 20px 24px 40px; }
  .modal { align-items: center; }
  .sheet { width: min(520px, calc(100% - 32px)); border-radius: 18px; margin: 0 auto; }
  .toasts { left: auto; width: 320px; }
}
