:root {
  color-scheme: dark;
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  --bg: #1a1a1a;
  --bar: #141414;
  --sidebar: #1c1c1c;
  --surface: #242424;
  --surface-2: #2b2b2b;
  --surface-3: #333333;
  --text: #ededed;
  --muted: #a0a0a0;
  --line: #383838;
  --line-strong: #4a4a4a;
  --yellow: #ffd100;
  --yellow-ink: #141414;
  --accent-soft: #3a3210;
  --accent-text: #ffd100;
  --danger: #ff7b7b;
  --danger-soft: #3a1c1c;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f4;
  --bar: #ffffff;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --surface-3: #efefef;
  --text: #202020;
  --muted: #666666;
  --line: #e0e0e0;
  --line-strong: #cccccc;
  --yellow: #e6b800;
  --yellow-ink: #1a1a1a;
  --accent-soft: #fff6d6;
  --accent-text: #8a6a00;
  --danger: #c62828;
  --danger-soft: #fdecec;
  --shadow: 0 2px 12px rgba(0, 0, 0, .1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-logo, .logo-img { display: block; object-fit: contain; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 4px;
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
button:hover, .button:hover { background: var(--surface-2); border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); font-weight: 700; }
button.primary:hover, .button.primary:hover { background: #ffdc3d; border-color: #ffdc3d; }
button.secondary, .button.secondary { background: var(--surface); color: var(--text); }
button.danger { color: var(--danger); border-color: var(--line-strong); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.compact, .compact { min-height: 28px; padding: 0 9px; font-size: 11.5px; }
button.icon-only { min-height: 30px; width: 30px; padding: 0; }
input {
  min-width: 0; min-height: 32px; padding: 5px 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 4px; font-size: 12px;
}
input:focus { border-color: var(--yellow); outline: none; }
input::placeholder { color: #808080; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: 46px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--bar); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 22px; height: 22px; }
.brand-product { font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.session { display: flex; align-items: center; gap: 5px; }
.top-action { min-height: 28px; padding: 0 9px; font-size: 11.5px; }
.top-icon { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; width: 28px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--muted); text-decoration: none; }
.top-icon:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.avatar { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; background: var(--yellow); color: var(--yellow-ink); font-size: 10px; font-weight: 800; text-transform: uppercase; }

.login { min-height: calc(100vh - 46px); padding: 36px 18px; display: grid; place-items: center; }
.login-shell { width: min(100%, 880px); display: grid; grid-template-columns: 1fr 380px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); }
.login-brand { position: relative; overflow: hidden; padding: 40px 38px; background: radial-gradient(circle at 18% 15%, #303020, var(--bar) 62%); color: var(--text); display: flex; flex-direction: column; }
.login-brand::before { content: ""; position: absolute; right: -160px; bottom: -180px; width: 380px; height: 380px; border: 1px solid #ffffff12; border-radius: 50%; }
.login-brand::after { content: ""; position: absolute; right: -60px; top: -90px; width: 250px; height: 250px; border-radius: 50%; background: #ffd10010; }
.login-brand-inner { position: relative; z-index: 1; }
.login-logo { display: flex; align-items: center; gap: 9px; margin-bottom: 58px; font-size: 13px; font-weight: 800; letter-spacing: .1em; }
.login-logo .logo-img { width: 25px; height: 25px; }
.login-brand h2 { margin: 0 0 12px; font-size: 28px; line-height: 1.35; color: var(--text); }
.login-brand p { margin: 0; color: var(--muted); font-size: 13px; }
.login-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; }
.login-points li { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--muted); }
.login-points .icon { color: var(--yellow); }
.signin { background: var(--surface); border-left: 1px solid var(--line); }
.signin-header { padding: 32px 30px 18px; border-bottom: 1px solid var(--line); }
.signin-header h1 { margin: 0; font-size: 20px; }
.signin-header p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.signin-form, .user-form { display: grid; gap: 14px; padding: 24px 30px 30px; }
form label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; }
.input-wrap { position: relative; display: block; }
.input-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-wrap input { width: 100%; min-height: 36px; padding-left: 36px; }
.signin-form .primary { min-height: 36px; margin-top: 2px; }
.error { color: var(--danger); margin: 0; font-size: 12px; }

.workspace { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: calc(100vh - 46px); }
.sidebar { position: sticky; top: 46px; align-self: start; height: calc(100vh - 46px); overflow-y: auto; display: flex; flex-direction: column; padding: 8px; background: var(--sidebar); border-right: 1px solid var(--line); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 8px 8px 10px; }
.sidebar-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-toggle { min-height: 24px; width: 24px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.sidebar-toggle:hover { background: var(--surface-2); }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav button, .sidebar-link {
  display: flex; align-items: center; gap: 10px; min-height: 31px; padding: 0 9px;
  border: 0; border-radius: 3px; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 500; text-align: left; text-decoration: none;
}
.sidebar nav button:hover, .sidebar-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav button[aria-current] { background: var(--yellow); color: var(--yellow-ink); font-weight: 700; }
.sidebar nav button[aria-current]:hover { background: var(--yellow); color: var(--yellow-ink); }
.sidebar nav button .icon { width: 15px; height: 15px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 2px; }
.sidebar-foot { margin-top: 8px; padding: 8px 9px 2px; border-top: 1px solid var(--line); color: #777; font-size: 10px; }
:root[data-sidebar="collapsed"] .workspace { grid-template-columns: 52px minmax(0, 1fr); }
:root[data-sidebar="collapsed"] .sidebar { padding-inline: 6px; }
:root[data-sidebar="collapsed"] .sidebar-label,
:root[data-sidebar="collapsed"] .nav-text,
:root[data-sidebar="collapsed"] .sidebar-foot { display: none; }
:root[data-sidebar="collapsed"] .sidebar-head { justify-content: center; padding-inline: 0; }
:root[data-sidebar="collapsed"] .sidebar nav button,
:root[data-sidebar="collapsed"] .sidebar-link { justify-content: center; padding: 0; }
:root[data-sidebar="collapsed"] .sidebar-toggle .icon { transform: scaleX(-1); }

.content { width: min(100%, 1500px); margin-inline: auto; padding: 12px 16px 32px; }
.notice { margin: 0 0 10px; padding: 8px 12px; background: var(--accent-soft); border: 1px solid var(--line); border-left: 3px solid var(--yellow); border-radius: 3px; color: var(--accent-text); font-size: 12px; }
.search-row { display: flex; gap: 7px; margin-bottom: 8px; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field input { width: 100%; min-height: 34px; padding-right: 34px; font-size: 12px; }
.search-field .icon { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-toggle { min-height: 30px; font-size: 11.5px; }
.switch { width: 22px; height: 12px; border-radius: 999px; background: var(--line-strong); position: relative; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--text); transition: transform .15s; }
.filter-toggle[aria-expanded="true"] .switch, .filter-toggle[aria-pressed="true"] .switch { background: var(--yellow); }
.filter-toggle[aria-expanded="true"] .switch::after, .filter-toggle[aria-pressed="true"] .switch::after { background: var(--yellow-ink); transform: translateX(10px); }
.filter-fields { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.filter-field { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.filter-field input { min-height: 30px; padding: 3px 8px; font-size: 11.5px; }
#filter-serial { width: 140px; }
.view-switch { display: flex; gap: 2px; margin-left: auto; }
.view-switch button { min-height: 30px; width: 30px; padding: 0; background: transparent; border-color: transparent; color: var(--muted); }
.view-switch button[aria-pressed="true"] { background: var(--surface-2); border-color: var(--line-strong); color: var(--yellow); }
.quick-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.quick-tab { min-height: 27px; padding: 0 10px; font-size: 11px; color: var(--muted); background: transparent; border-color: var(--line); }
.quick-tab:hover { color: var(--text); }
.quick-tab.is-active { background: var(--yellow); border-color: var(--yellow); color: var(--yellow-ink); font-weight: 700; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.result-actions { display: flex; align-items: center; gap: 8px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }
.bulk-bar .muted { margin-right: auto; }
.select-col { width: 34px; padding-right: 0; }
td.select-cell { width: 34px; padding-right: 0; }
input[type="checkbox"] { width: 14px; height: 14px; min-height: 0; padding: 0; margin: 0; accent-color: var(--yellow); cursor: pointer; vertical-align: middle; }
.card-check { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.card-check input { cursor: pointer; }
.day-group > td { padding: 0 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.day-group.day-alt > td { background: var(--surface-3); }
.day-group-inner, .day-group-card { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; }
.day-group-card { grid-column: 1 / -1; padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); }
.day-group-card.day-alt { background: var(--surface-3); }
.day-label { color: var(--accent-text); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.day-select { min-height: 22px; padding: 0 8px; font-size: 10.5px; color: var(--accent-text); }
.muted { color: var(--muted); font-size: 11.5px; }
.surface { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
th { padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.file-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-icon { width: 27px; height: 27px; flex: none; display: grid; place-items: center; border-radius: 3px; background: var(--surface-3); color: var(--yellow); }
.cover { display: block; flex: none; border-radius: 3px; background: var(--surface-3); object-fit: cover; opacity: 0; transition: opacity .18s ease; }
.cover.is-loaded { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .cover { transition: none; } }
.row-cover { width: 44px; height: 30px; }
.card-cover { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 3px 3px 0 0; }
.card-cover-fallback { width: 100%; height: 130px; border-radius: 3px 3px 0 0; }
.file-title { font-weight: 600; overflow-wrap: anywhere; }
.serial { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: var(--muted); }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; white-space: nowrap; }
.icon-link { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 11.5px; font-weight: 500; }
.icon-link:hover { background: var(--surface-2); border-color: var(--yellow); color: var(--yellow); text-decoration: none; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 10.5px; font-weight: 600; }
.badge-admin { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.video-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 12px; }
.video-card { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); }
.video-card-top { display: flex; align-items: center; gap: 9px; }
.video-card-meta { color: var(--muted); font-size: 10.5px; line-height: 1.5; overflow-wrap: anywhere; }
.video-card .row-actions { justify-content: flex-start; }
.empty { padding: 42px 18px 48px; text-align: center; }
.empty-icon { width: 62px; height: 62px; margin: 0 auto 18px; color: var(--yellow); display: grid; place-items: center; }
.empty-icon .logo-img { width: 62px; height: 62px; }
.empty strong { display: block; font-size: 13px; font-weight: 600; }
.empty p { margin: 7px 0 0; color: var(--muted); font-size: 11.5px; }
.quick-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; max-width: 800px; margin: 30px auto 0; }
.quick-card { display: grid; gap: 5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); text-align: left; }
.quick-card.is-active { border-color: var(--yellow); }
.quick-open { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 26px; padding: 0; border: 0; background: transparent; font-size: 11.5px; font-weight: 600; }
.quick-open:hover { background: transparent; border-color: transparent; color: var(--yellow); }
.quick-open .icon { color: var(--muted); }
.quick-default { min-height: 18px; padding: 0; border: 0; background: transparent; color: var(--yellow); font-size: 10.5px; font-weight: 700; justify-self: start; }
.quick-default:hover { background: transparent; border-color: transparent; color: #ffdc3d; }
.pagination { padding: 9px 12px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; border-top: 1px solid var(--line); }
#page-number { color: var(--muted); font-size: 11.5px; min-width: 54px; text-align: center; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-heading h1 { margin: 0 0 5px; font-size: 19px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.form-card { max-width: 520px; }
.file-info { min-width: 0; }
.shared-badge { display: block; margin-top: 2px; color: var(--yellow); font-size: 10px; }

dialog { width: min(450px, 94vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
dialog::backdrop { background: rgba(0, 0, 0, .72); }
.dialog-header { padding: 11px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
h2 { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; }
#player { width: min(1000px, 94vw); }
#player video { display: block; width: 100%; max-height: 68vh; background: #000; }
#player .dialog-actions, #player .error { padding: 11px 14px; }
.share-body { padding: 16px; display: grid; gap: 12px; }
.share-body > p { margin: 0; }
.share-form { display: flex; gap: 7px; }
.share-form input { flex: 1; min-width: 0; }
.share-list-heading { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.share-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; max-height: 220px; overflow-y: auto; }
.share-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); font-size: 12px; }
.share-list .empty-share { justify-content: center; color: var(--muted); }

@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; max-width: 400px; }
  .login-brand { display: none; }
}
@media (max-width: 750px) {
  .topbar { padding-inline: 10px; }
  .workspace { display: block; }
  .sidebar { position: static; height: auto; overflow: visible; padding: 7px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-head { padding-bottom: 5px; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-bottom { margin-top: 7px; grid-auto-flow: column; justify-content: start; }
  .content { padding: 10px 10px 26px; }
  th, td { padding: 8px 9px; }
  .quick-cards { grid-template-columns: 1fr; }
  .view-switch { margin-left: 0; }
}
