:root,
[data-theme="dark"] {
  --bg: #111115;
  --surface: #17171d;
  --hover: #1e1e26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ededeb;
  --text-2: #9b9aa3;
  --text-3: #66656f;
  --accent: #d4b46a;
  --accent-bg: rgba(212, 180, 106, 0.10);
  --danger: #e06c75;
  --danger-bg: rgba(224, 108, 117, 0.12);
  --btn-text: #111115;
  --backdrop: rgba(0, 0, 0, 0.56);
  --header-bg: rgba(17, 17, 21, 0.88);
}

[data-theme="light"] {
  --bg: #faf9f6;
  --surface: #ffffff;
  --hover: #f3f1ec;
  --border: rgba(24, 24, 27, 0.09);
  --border-strong: rgba(24, 24, 27, 0.18);
  --text: #18181b;
  --text-2: #63636b;
  --text-3: #96969f;
  --accent: #9a762b;
  --accent-bg: rgba(154, 118, 43, 0.09);
  --danger: #c43b47;
  --danger-bg: rgba(196, 59, 71, 0.10);
  --btn-text: #ffffff;
  --backdrop: rgba(24, 24, 27, 0.34);
  --header-bg: rgba(250, 249, 246, 0.88);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans SC", "Source Han Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, "SFMono-Regular", monospace;
  font-variant-numeric: tabular-nums;
}

.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Theme-aware logos */
[data-theme="dark"] .studio-logo { filter: invert(1) brightness(1.06); opacity: 0.84; }
[data-theme="light"] .studio-logo { filter: none; opacity: 0.86; }
[data-theme="dark"] .proj-logo-dark { display: block; }
[data-theme="dark"] .proj-logo-light { display: none; }
[data-theme="light"] .proj-logo-dark { display: none; }
[data-theme="light"] .proj-logo-light { display: block; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  user-select: none;
}
.brand-lockup .studio-logo { height: 22px; width: auto; object-fit: contain; transition: opacity 0.15s; }
.brand-lockup .studio-logo:hover { opacity: 1; }
.brand-slash { color: var(--text-3); font-weight: 300; font-size: 14px; }
.brand-lockup .proj-logo-dark { height: 30px; width: auto; object-fit: contain; }
.brand-lockup .proj-logo-light { height: 26px; width: auto; object-fit: contain; }

.nav { display: flex; align-items: center; gap: 22px; }
.nav-link {
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 500; }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  height: 1.5px;
  background: var(--accent);
}

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.search-wrap { position: relative; }
.search-input {
  width: 210px;
  padding: 6px 26px 6px 11px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease;
}
.search-input:focus { border-color: var(--border-strong); }
.search-kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-3);
  pointer-events: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--hover);
}
.btn-icon { width: 32px; height: 32px; padding: 0; }
.btn-accent {
  background: var(--accent);
  color: var(--btn-text);
  font-weight: 500;
}
.btn-accent:hover { opacity: 0.9; }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { border-color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.auth-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}
.auth-dot.on { background: var(--accent); }

/* Main Container */
.container {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 30px 20px 24px;
}

/* Vault 2-zone layout */
.vault-grid {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.sidebar-label {
  padding: 0 10px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-3);
}
.dir-list { display: flex; flex-direction: column; gap: 2px; }
.dir-item {
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s, color 0.12s;
}
.dir-item:hover { background: var(--hover); color: var(--text); }
.dir-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }
.dir-count { color: var(--text-3); font-size: 11px; }

.main-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.context-title { display: flex; align-items: baseline; gap: 8px; }
.context-title h1 { margin: 0; font-size: 15px; font-weight: 500; }
.context-count { font-size: 12px; color: var(--text-3); }

.mode-switch { display: flex; align-items: center; gap: 4px; }
.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
}
.mode-btn.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

.head-bar {
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.head-bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.head-hash { color: var(--accent); flex-shrink: 0; }
.head-msg { color: var(--text-2); }
.head-time { color: var(--text-3); flex-shrink: 0; }

/* Table */
.panel {
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.table-head {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) 1.35fr 84px 86px;
  gap: 14px;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
.file-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.25fr) 1.35fr 84px 86px;
  gap: 14px;
  padding: 12px 16px;
  align-items: center;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.12s;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--hover); }
.file-name-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.file-name { font-weight: 500; color: var(--text); }
.file-pair-hint { color: var(--accent); font-size: 11px; flex-shrink: 0; }
.file-ver-hint { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.file-msg { color: var(--text-2); }
.col-right { text-align: right; color: var(--text-2); }
.col-time { text-align: right; color: var(--text-3); }

/* Gallery */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.gallery-tile {
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.gallery-tile:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.gallery-thumb {
  height: 136px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-bottom: 1px solid var(--border);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-ext {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.gallery-meta { padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; }
.gallery-sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); }

/* Empty state */
.empty-box {
  padding: 52px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Commits & Releases */
.narrow-section { max-width: 780px; display: flex; flex-direction: column; gap: 18px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h1 { margin: 0; font-size: 16px; font-weight: 500; }
.section-head p { margin: 4px 0 0; font-size: 12px; color: var(--text-3); }

.commit-row {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}
.commit-row:last-child { border-bottom: none; }
.commit-sub { margin-top: 3px; font-size: 11px; color: var(--text-3); }

.release-list { display: flex; flex-direction: column; gap: 12px; }
.release-card {
  padding: 18px 20px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.release-tag { color: var(--accent); font-size: 12px; margin-right: 8px; }
.release-title { font-size: 14px; font-weight: 500; }
.release-desc { margin: 6px 0 0; font-size: 12px; color: var(--text-2); }
.release-meta { margin-top: 6px; font-size: 11px; color: var(--text-3); }
.release-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Slide-over Drawer */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--backdrop);
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: 100%;
  max-width: 470px;
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
  border-left: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: slideLeft 0.16s ease-out both;
}
@keyframes slideLeft {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.drawer-head h3 { margin: 0; font-size: 14px; font-weight: 500; word-break: break-all; }
.drawer-head p { margin: 4px 0 0; font-size: 12px; color: var(--text-2); }
.drawer-preview-img {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: block;
  cursor: zoom-in;
}
.drawer-preview-text {
  margin: 0;
  padding: 14px;
  max-height: 260px;
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.drawer-actions { display: flex; gap: 8px; }
.drawer-actions .btn-accent { flex: 1; padding: 8px 12px; }
.kv-list {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}
.kv-row { display: flex; justify-content: space-between; gap: 12px; }
.kv-k { color: var(--text-3); flex-shrink: 0; }
.kv-v { color: var(--text); text-align: right; word-break: break-all; }

.paired-box {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.ver-section {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ver-card {
  padding: 11px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 460px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 14px; font-weight: 500; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.field span { color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  outline: none;
  font-size: 12px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--border-strong); }

.dropzone {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 24px 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-bg); color: var(--text); }
.upload-queue { display: flex; flex-direction: column; gap: 6px; max-height: 140px; overflow-y: auto; }
.queue-item {
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.progress-track {
  height: 4px;
  border-radius: 99px;
  background: var(--bg);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.12s linear;
}
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 4px; }

/* Footer */
.footer {
  width: 100%;
  max-width: 1140px;
  margin: 18px auto 0;
  padding: 22px 20px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-3);
}
.footer-left { display: flex; align-items: center; gap: 12px; }
.footer-left .studio-logo { height: 18px; width: auto; opacity: 0.58; }

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

@media (max-width: 820px) {
  .vault-grid { grid-template-columns: 1fr; gap: 18px; }
  .dir-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .dir-item { width: auto; padding: 5px 10px; }
  .search-wrap { display: none; }
  .brand-lockup .studio-logo, .brand-slash { display: none; }
  .table-head, .file-row { grid-template-columns: 1fr 78px 76px; }
  .col-msg { display: none; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .release-card { flex-direction: column; align-items: flex-start; }
}
