/* ==========================================================================
   蓝鸢尾笺の图床 · 全站样式
   设计倾向：低饱和、细边框、大量留白，避免花哨渐变与过度圆角。
   ========================================================================== */

:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --surface-3: #f1efea;
  --border: #e5e2db;
  --border-strong: #d3cfc6;
  --text: #23211e;
  --text-soft: #6c665d;
  --text-mute: #9b958a;
  --accent: #2f6b57;
  --accent-hover: #275a49;
  --accent-soft: #e9f1ed;
  --danger: #ab3f2e;
  --danger-soft: #fbeceb;
  --warn: #8c6516;
  --warn-soft: #fbf2df;
  --ok: #2f6b57;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(35, 33, 30, 0.05);
  --shadow: 0 6px 24px -12px rgba(35, 33, 30, 0.22);
  --shadow-lg: 0 24px 60px -24px rgba(35, 33, 30, 0.35);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --topbar-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191817;
    --surface: #222120;
    --surface-2: #262524;
    --surface-3: #2d2c2a;
    --border: #35332f;
    --border-strong: #474440;
    --text: #eae7e1;
    --text-soft: #a8a29a;
    --text-mute: #7d776e;
    --accent: #6fb897;
    --accent-hover: #85c7a8;
    --accent-soft: #23302b;
    --danger: #e08375;
    --danger-soft: #382422;
    --warn: #d8ad63;
    --warn-soft: #332a1b;
    --ok: #6fb897;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 6px 24px -12px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* 关键：给滚动条预留空间，页面切换时内容不会左右抖动 */
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* 细滚动条：不抢占视觉，也不会突然消失造成跳动 */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 10px;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-mute);
  border: 3px solid transparent;
  background-clip: padding-box;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

code,
pre,
.mono {
  font-family: var(--mono);
  font-size: 0.86em;
}

code {
  background: var(--surface-3);
  border-radius: 5px;
  padding: 0.12em 0.4em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ------------------------------------------------------------------ 布局 */

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 22px 64px;
}

.container-narrow {
  max-width: 720px;
}

.container-mid {
  max-width: 940px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 15.5px;
  color: var(--text);
  letter-spacing: -0.015em;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.82;
}

.brand-mark {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: block;
}

.nav {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
}

.nav a {
  color: var(--text-soft);
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.nav a.active {
  color: var(--text);
  background: var(--surface-3);
  font-weight: 550;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text-soft);
  max-width: 220px;
}

.user-chip:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head .sub {
  color: var(--text-soft);
  font-size: 13.5px;
  margin-top: 4px;
}

.page-head-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------- 批量选择栏 */

.selection-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

#selection-count {
  font-weight: 600;
  color: var(--text);
}

#selection-bar {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}

/* 移动图片时的文件夹选择列表：比下拉框好找，且能显示每个文件夹的图片数 */
.pick-list {
  max-height: 264px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 5px;
  display: grid;
  gap: 3px;
}

.pick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.pick-item:hover {
  background: var(--surface-3);
}

.pick-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pick-item.active .pick-hint {
  color: rgba(255, 255, 255, 0.82);
}

.pick-item .pick-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.pick-item .pick-hint {
  font-size: 11.5px;
  color: var(--text-mute);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ 卡片 */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 18px;
}

.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.card-head h2,
.card-head h3 {
  font-size: 15px;
}

.card-head .desc {
  color: var(--text-mute);
  font-size: 12.5px;
  margin-top: 3px;
  font-weight: 400;
}

.card-body {
  padding: 18px;
}

.card-body.tight {
  padding: 0;
}

.card-body + .card-body {
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
  margin-bottom: 10px;
}

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, color 0.15s;
  user-select: none;
}

.btn:hover {
  background: var(--surface-3);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn[aria-busy='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #14201b;
  }
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-soft);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: transparent;
}

.btn-danger:hover {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 6px;
  width: 30px;
  height: 30px;
}

.btn-group {
  display: inline-flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------------ 表单 */

.field {
  margin-bottom: 15px;
}

.field:last-child {
  margin-bottom: 0;
}

.field > label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 6px;
  color: var(--text);
}

.field .hint {
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 5px;
  line-height: 1.5;
}

input[type='text'],
input[type='password'],
input[type='email'],
input[type='number'],
input[type='search'],
input[type='url'],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  max-width: 100%;
}

textarea {
  resize: vertical;
  min-height: 78px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-mute);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-3);
  color: var(--text-mute);
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239b958a' stroke-width='1.5' stroke-linecap='round' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.field-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field-row > .field {
  flex: 1 1 180px;
  margin-bottom: 0;
}

.field-row > .field-auto {
  flex: 0 0 auto;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-group > input {
  flex: 1;
}

.input-inline {
  display: flex;
  align-items: center;
  gap: 9px;
}

.radio-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.radio-card {
  flex: 1 1 140px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.radio-card:hover {
  border-color: var(--text-mute);
}

.radio-card input {
  margin-right: 7px;
  accent-color: var(--accent);
}

.radio-card.checked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.radio-card .sub {
  display: block;
  font-size: 12px;
  color: var(--text-mute);
  margin-left: 22px;
  line-height: 1.45;
}

.switch-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.switch-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.switch-row:first-child {
  padding-top: 0;
}

.switch-row .label {
  font-size: 14px;
  font-weight: 550;
}

.switch-row .hint {
  font-size: 12.5px;
  color: var(--text-mute);
  margin-top: 3px;
  max-width: 52ch;
  line-height: 1.55;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

/*
 * 带文字的开关：外壳要能容纳整段说明文字。
 * 只用 .switch 时宽度被锁死在 42px（轨道本身），文字会被压成一列单字，
 * 所以这里让外壳变成「轨道 + 文字」的弹性行，宽度交给内容决定。
 */
.switch:has(.switch-label) {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: auto;
  max-width: 100%;
  height: auto;
  min-height: 24px;
}

/* 和左侧标签并排时不需要额外下移 */
.switch-row > .switch:not(:has(.switch-label)) {
  margin-top: 0;
}

.switch:has(.switch-label) .track {
  /* 轨道自己做定位上下文，勾选框就覆盖在轨道上，文字区域不受影响 */
  position: relative;
  inset: auto;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
}

.switch:has(.switch-label) input {
  position: absolute;
  inset: 0;
  width: 42px;
  height: 24px;
  z-index: 2;
}

.switch:has(.switch-label) .switch-label {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 0;
  line-height: 1.5;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.switch .track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 100px;
  transition: background 0.2s;
}

.switch .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .track {
  background: var(--accent);
}

.switch input:checked + .track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ------------------------------------------------------------------ 提示 */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 15px;
}

.alert-info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent);
  color: color-mix(in srgb, var(--accent) 88%, var(--text));
}

.alert-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 28%, transparent);
  color: color-mix(in srgb, var(--warn) 90%, var(--text));
}

.alert-danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  color: color-mix(in srgb, var(--danger) 90%, var(--text));
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  min-height: 0;
}

.error-text:empty {
  display: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 8px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.01em;
  background: var(--surface-3);
  color: var(--text-soft);
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-outline {
  background: transparent;
  border-color: var(--border-strong);
}

/* ------------------------------------------------------------------ 表格 */

.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}

table.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.table tbody tr:last-child td {
  border-bottom: 0;
}

table.table tbody tr:hover {
  background: var(--surface-2);
}

table.table td.nowrap,
table.table th.nowrap {
  white-space: nowrap;
}

table.table td.right,
table.table th.right {
  text-align: right;
}

.cell-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
}

.cell-user .meta {
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.35;
}

.cell-user .name {
  font-weight: 550;
}

/* ------------------------------------------------------------------ 图片 */

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}

.image-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.image-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.image-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}

.image-thumb {
  display: block;
  aspect-ratio: 4 / 3;
  width: 100%;
  background: var(--surface-3);
  overflow: hidden;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.image-card:hover .image-thumb img {
  transform: scale(1.03);
}

.image-meta {
  padding: 9px 11px;
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

.image-meta .name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}

.image-meta .sub {
  color: var(--text-mute);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
}

.image-actions {
  padding: 0 11px 11px;
  display: flex;
  gap: 6px;
}

.image-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.image-card:hover .image-check,
.image-card.selected .image-check {
  opacity: 1;
}

.image-card.selected .image-check {
  background: var(--accent);
  border-color: var(--accent);
}

.image-check svg {
  width: 13px;
  height: 13px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  opacity: 0;
}

.image-card.selected .image-check svg {
  opacity: 1;
}

/* -------------------------------------------------------------- 空状态 */

.empty {
  text-align: center;
  padding: 54px 20px;
  color: var(--text-mute);
  font-size: 14px;
}

.empty svg {
  width: 42px;
  height: 42px;
  stroke: var(--border-strong);
  fill: none;
  stroke-width: 1.4;
  margin-bottom: 12px;
}

.empty .title {
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 550;
  margin-bottom: 5px;
}

/* ------------------------------------------------------------ 上传区域 */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--text-mute);
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone .title {
  font-weight: 550;
  color: var(--text);
  margin-bottom: 4px;
}

.dropzone .hint {
  font-size: 12.5px;
  color: var(--text-mute);
}

.upload-list {
  margin-top: 14px;
  display: grid;
  gap: 7px;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.upload-item .fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  height: 3px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 12px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width 0.2s;
}

/* ---------------------------------------------------------- 文件夹树 */

.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-soft);
  transition: background 0.12s, color 0.12s;
  border: 1px solid transparent;
}

.folder-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.folder-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
  border-color: color-mix(in srgb, var(--accent) 20%, transparent);
}

.folder-item .fname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item .count {
  font-size: 11.5px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}

.folder-item .row-actions {
  display: none;
  gap: 2px;
}

.folder-item:hover .row-actions {
  display: flex;
}

.folder-children {
  margin-left: 14px;
  border-left: 1px solid var(--border);
  padding-left: 5px;
}

/* -------------------------------------------------------------- 标签页 */

.tabs {
  display: flex;
  gap: 3px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs button {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--text-soft);
  padding: 9px 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 550;
}

/* ---------------------------------------------------------------- 分页 */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 0 4px;
  font-size: 13px;
  color: var(--text-soft);
}

.pager .pages {
  display: flex;
  gap: 3px;
}

.pager button {
  min-width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0 8px;
}

.pager button:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
}

.pager button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .pager button.active {
    color: #14201b;
  }
}

.pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* -------------------------------------------------------------- 弹窗 */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.42);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.15s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: pop 0.18s ease;
}

.modal-wide {
  max-width: 640px;
}

.modal-head {
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head h3 {
  font-size: 15.5px;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ Toast */

.toast-host {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 40px);
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 100px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
  max-width: 100%;
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.success {
  background: var(--ok);
  color: #fff;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ 公告 */

.notice {
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 12px;
}

.notice.important {
  border-left-color: var(--warn);
  background: var(--warn-soft);
}

.notice h3 {
  font-size: 14.5px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.notice .time {
  font-size: 12px;
  color: var(--text-mute);
  font-weight: 400;
}

.notice .content {
  font-size: 13.5px;
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.notice .content.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------ 统计 */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat {
  background: var(--surface);
  padding: 16px 18px;
}

.stat .label {
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: 0.03em;
  margin-bottom: 5px;
}

.stat .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat .value small {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-mute);
  margin-left: 3px;
}

/* ------------------------------------------------------- 公开图库 */

.gallery-head {
  padding: 34px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 26px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.gallery-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.gallery-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.gallery-card .thumb {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}

.gallery-card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-card .bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
  border-top: 1px solid var(--border);
}

.gallery-card .bar .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-soft);
}

.api-box {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.api-box code {
  /* 接口地址很长：自己撑满一行并允许横向滚动，不要撑破卡片，也不要被裁掉 */
  flex: 1 1 100%;
  min-width: 0;
  padding: 8px 11px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--text-soft);
}

/*
 * 「调用方式」表格：单元格里的代码片段常常比列还宽。
 * 用自动表格布局让说明列按内容自适应（放得下「随机图库页面」这类标签），
 * 代码列则在自己的滚动容器里横向滚动，表格不会撑破卡片。
 */
.api-table td:first-child {
  width: 1px; /* 配合 auto 布局 = 「尽量窄，但放得下内容」 */
  white-space: nowrap;
}

.api-table td:last-child {
  width: auto;
  overflow: hidden;
}

.api-table code {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  white-space: pre;
  background: transparent;
  padding: 0;
  font-size: 12px;
  line-height: 1.7;
}

/* 正文里的行内代码允许在任意位置断行，避免长 URL 顶破布局 */
.alert code,
.hint code,
.field code {
  word-break: break-all;
}

/* ------------------------------------------------------------ 灯箱 */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 19, 17, 0.94);
  z-index: 300;
  display: flex;
  flex-direction: column;
  animation: fade 0.18s ease;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  color: #e8e5df;
  font-size: 13.5px;
  flex-shrink: 0;
}

.lightbox-bar .info {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #b8b3aa;
}

.lightbox-bar .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.lightbox-bar .btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #f0ede7;
}

.lightbox-bar .btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lightbox-stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0 18px 18px;
  min-height: 0;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }

/* ------------------------------------------------------------ 杂项 */

.muted { color: var(--text-mute); }
.soft { color: var(--text-soft); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack { display: grid; gap: 14px; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }

.two-col {
  display: grid;
  grid-template-columns: 232px 1fr;
  gap: 20px;
  align-items: start;
}

/* 只有一侧有内容时（例如随机图 API 选了「全部图片」）收成单列，不留空白 */
.two-col.single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 720px;
}

.dash-layout {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.side-sticky {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
}

@media (max-width: 900px) {
  .two-col,
  .dash-layout {
    grid-template-columns: 1fr;
  }

  .side-sticky {
    position: static;
  }

  .container {
    padding: 20px 16px 56px;
  }

  .topbar-inner {
    padding: 0 16px;
    gap: 12px;
  }

  .nav a {
    padding: 6px 8px;
    font-size: 13.5px;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 11px;
  }
}

@media (max-width: 560px) {
  .brand span {
    display: none;
  }

  .user-chip span {
    display: none;
  }

  .user-chip {
    padding: 4px;
    border-color: transparent;
  }
}

/* ------------------------------------------------------- 错误页 */

body.page-error {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.error-card {
  text-align: center;
  padding: 40px;
}

.error-code {
  font-size: 56px;
  font-weight: 650;
  letter-spacing: -0.04em;
  color: var(--border-strong);
  line-height: 1;
  margin-bottom: 14px;
}

.error-card p {
  color: var(--text-soft);
  margin-bottom: 20px;
}

/* --------------------------------------------------------- 首页 */

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 34px;
  align-items: center;
  padding: 36px 0 30px;
}

.home-hero h1 {
  font-size: 33px;
  font-weight: 640;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}

.home-hero .lead {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--text-soft);
  max-width: 50ch;
}

.home-hero-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 18px;
}

.stat-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.stat-line:last-child {
  border-bottom: 0;
}

.stat-line .k {
  font-size: 13.5px;
  color: var(--text-soft);
}

.stat-line .v {
  font-size: 18.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.section-heading {
  font-size: 17px;
  font-weight: 620;
  letter-spacing: -0.012em;
  margin-bottom: 14px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(228px, 1fr));
  gap: 14px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
}

.feature h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature p {
  font-size: 13.5px;
  line-height: 1.72;
  color: var(--text-soft);
}

/* -------------------------------------------------------- 登录页 */

.auth-card {
  max-width: 424px;
  margin: 44px auto 0;
  overflow: hidden;
}

.auth-card .tabs {
  border-bottom: 1px solid var(--border);
}

.auth-card .card-body {
  padding: 24px 24px 26px;
}

/* ---------------------------------------------------------- 页脚 */

.site-footer {
  max-width: 1080px;
  margin: 60px auto 0;
  padding: 22px 24px 36px;
  border-top: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 12.5px;
  line-height: 1.85;
  text-align: center;
  /* 页脚内容由后台自定义，保留换行但不解析 HTML */
  white-space: pre-line;
  word-break: break-word;
}

/* -------------------------------------------------- 后台页脚编辑器 */

/* 预览区刻意做成和前台页脚一样的观感，所见即所得 */
.footer-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 16px 18px;
  color: var(--text-mute);
  font-size: 12.5px;
  line-height: 1.85;
  text-align: center;
  white-space: pre-line;
  word-break: break-word;
  min-height: 52px;
}

#footer-vars .btn {
  font-family: var(--mono);
  font-size: 12px;
}

.site-footer a {
  color: var(--text-soft);
}

.right {
  text-align: right;
}

@media (max-width: 900px) {
  .home-hero {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 20px 0;
  }

  .home-hero h1 {
    font-size: 26px;
  }

  .site-footer {
    margin-top: 40px;
    padding: 20px 18px 30px;
  }
}
