/* 1:1 复刻 Lsky Pro（兰空图床）视觉规范：Tailwind gray 色阶 + shadow-custom + Nunito */
:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --slate-50: #f8fafc;
  --slate-600: #475569;
  --stone-300: #d6d3d1;
  --blue-500: #3b82f6;
  --blue-300: #93c5fd;
  --indigo-500: #6366f1;
  --indigo-400: #818cf8;
  --red-500: #ef4444;
  --green-600: #16a34a;
  --shadow-custom: 0px 4px 6px -1px rgba(0, 0, 0, 0.04);
  --header-h: 56px;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: Nunito, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
a { text-decoration: none; color: inherit; }
button { font: inherit; color: inherit; }
i.fas, i.far { font-style: normal; }

::-webkit-scrollbar { width: 8px; height: 100%; min-height: 8px; }
::-webkit-scrollbar-thumb { background: #cad3e2; border-radius: 6px; }
::-webkit-scrollbar-track { background: #fff; border-radius: 6px; }
.scrollbar-none { scrollbar-width: none; -ms-overflow-style: none; }
.scrollbar-none::-webkit-scrollbar { display: none; }

/* ============ 顶栏 ============ */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9;
  height: var(--header-h);
  background: var(--gray-700);
  color: #fff;
  display: flex; justify-content: center;
  box-shadow: 0 15px 10px -15px rgba(0, 0, 0, 0.3);
  transition: all 0.3s;
}
.header-inner {
  width: 100%; padding: 0 24px;
  display: flex; justify-content: space-between; align-items: center;
}
.header-left { display: flex; align-items: center; max-width: 70%; }
.header-title { font-size: 20px; line-height: 28px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  display: none; width: 24px; height: 24px; padding: 16px;
  margin: 0 16px 0 -4px; border: none; background: none; color: #fff;
  align-items: center; justify-content: center; border-radius: 9999px; cursor: pointer;
  font-size: 20px;
}
.header-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px; border: none;
  background: rgba(255, 255, 255, 0.1); color: #fff;
  font-size: 14px; cursor: pointer;
}
.header-btn:hover { background: rgba(255, 255, 255, 0.2); }
.avatar {
  width: 32px; height: 32px; border-radius: 9999px;
  background: var(--gray-800); color: #fff;
  display: grid; place-items: center; font-size: 14px;
}

/* ============ 侧栏 ============ */
.sidebar {
  position: fixed; top: 0; left: 0; z-index: 10;
  width: var(--sidebar-w); height: 100vh;
  background: #fff;
  box-shadow: var(--shadow-custom);
  transition: all 0.3s;
  display: flex; flex-direction: column;
}
.sidebar-brand {
  height: var(--header-h); padding: 0 24px; flex: none;
  background: var(--gray-600); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-brand a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { display: none; }
.sidebar-body {
  flex: 1; padding: 16px 16px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow-y: auto; overscroll-behavior: contain;
}
.nav-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.nav-group-title { color: var(--gray-400); font-size: 14px; margin: 0 16px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 16px; width: 100%;
  border: none; background: none; cursor: pointer;
  color: var(--slate-600); font-size: 14px; border-radius: 6px;
  text-align: left;
}
.nav-link:hover { background: var(--gray-100); }
.nav-link.active { background: var(--gray-100); }
.nav-link i { color: var(--blue-500); width: 18px; text-align: center; }
.nav-link span { letter-spacing: 0.1em; }
.nav-link .nav-count { margin-left: auto; letter-spacing: 0; color: var(--gray-400); font-size: 12px; }

.capacity { display: flex; flex-direction: column; gap: 8px; margin: 40px 0 20px; padding: 0 20px; width: 100%; }
.capacity p { color: var(--gray-700); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.capacity .capacity-value { color: var(--gray-800); font-size: 14px; }
.capacity .capacity-hint { color: var(--gray-400); font-size: 12px; }

.sidebar-overlay {
  position: fixed; inset: 0; z-index: 9;
  background: rgba(0, 0, 0, 0.75);
}

/* ============ 内容容器 ============ */
.content {
  position: absolute; top: var(--header-h); left: var(--sidebar-w); right: 0; bottom: 0;
  padding: 16px 24px 56px;
  overflow-y: auto;
  transition: all 0.3s;
}

/* ============ 卡片 / 通用 ============ */
.card {
  padding: 16px;
  background: #fff;
  border-radius: 6px;
  box-shadow: var(--shadow-custom);
  margin-bottom: 16px;
}
.card-title {
  font-size: 24px; line-height: 32px;
  letter-spacing: 0.05em; color: var(--gray-700); margin-bottom: 8px;
  text-shadow: -4px 4px 0 rgb(0 0 0 / 10%);
}
.card-desc { color: var(--gray-500); font-size: 14px; }

.box { border-radius: 6px; width: 100%; overflow: hidden; box-shadow: var(--shadow-custom); margin-bottom: 16px; }
.box-title { padding: 12px 16px; background: var(--slate-50); color: var(--gray-800); font-size: 16px; }
.box-content { background: #fff; width: 100%; padding: 16px; }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  border-radius: 6px; border: none; cursor: pointer;
  color: var(--gray-600); background: rgba(0, 0, 0, 0.1);
}
.btn:hover { background: rgba(0, 0, 0, 0.2); color: var(--gray-700); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--indigo-500); color: #fff; }
.btn-primary:hover { background: #4f46e5; color: #fff; }
.btn-block { width: 100%; }

.toolbar-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; padding: 8px 12px; border-radius: 4px;
  color: var(--gray-800); background: none; border: none; cursor: pointer;
}
.toolbar-link:hover { background: var(--gray-100); }
.toolbar-link i { color: var(--blue-500); }
.toolbar-link.danger i { color: var(--red-500); }

.no-data {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  padding: 40px 0; gap: 8px; color: var(--gray-300);
}
.no-data i { font-size: 48px; }
.no-data p { font-size: 16px; }

/* ============ 登录 ============ */
.guest {
  min-height: 100vh; padding: 24px 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--gray-100);
}
.guest-logo { color: var(--gray-500); font-size: 56px; margin-bottom: 24px; }
.guest-card {
  width: 100%; max-width: 448px;
  padding: 16px 24px 24px;
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-custom);
}
.guest-card h2 { font-size: 18px; color: var(--gray-700); margin-bottom: 4px; }
.guest-card .sub { font-size: 13px; color: var(--gray-400); margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; color: var(--gray-700); margin-bottom: 4px; }
.form-input {
  display: block; width: 100%;
  padding: 9px 12px; font-size: 14px;
  border: 1px solid transparent; border-radius: 6px;
  background: var(--gray-100); color: var(--gray-800);
  outline: none;
}
.form-input:focus { border-color: var(--gray-500); background: #fff; }
.form-row { margin-bottom: 16px; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.form-hint { font-size: 13px; color: var(--gray-500); }
.alert {
  padding: 10px 12px; border-radius: 6px; font-size: 13px;
  background: #fef2f2; color: #b91c1c; margin-bottom: 16px;
}

/* ============ 上传 ============ */
.dropzone {
  margin-top: 12px;
  border: 2px dotted var(--stone-300); border-radius: 6px;
  width: 100%;
}
.dropzone.is-drag { border-color: var(--indigo-400); background: #eef2ff; }
.upload-container {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 16px; padding: 8px; width: 100%; min-height: 340px;
  color: var(--gray-500); cursor: pointer; text-align: center;
}
.upload-container .clear {
  position: absolute; top: 4px; right: 4px;
  width: 32px; height: 32px; display: none;
  align-items: center; justify-content: center;
  font-size: 20px; color: var(--gray-400); cursor: pointer;
  background: none; border: none;
}
.dropzone:hover .upload-container .clear.visible { display: flex; }
.upload-container .clear:hover { color: var(--gray-500); }
.upload-all { background: none; border: none; cursor: pointer; color: inherit; }
.upload-all i { font-size: 60px; }
.upload-all:hover i { color: var(--indigo-400); }
.upload-tip { font-size: 16px; line-height: 1.6; }
.upload-preview { display: none; flex-direction: column; margin: 8px; }
.upload-preview.visible { display: flex; }

.preview-item {
  position: relative; overflow: hidden;
  width: 100%; display: flex; align-items: center;
  padding: 8px; margin-bottom: 8px;
  border-radius: 6px; background: var(--gray-50);
}
.preview-progress-wrap { position: absolute; inset: 0; }
.preview-progress { width: 0; height: 100%; background: var(--gray-200); opacity: 0.7; transition: width 0.25s ease; }
.preview-main { position: relative; display: flex; width: 100%; min-width: 0; }
.preview-thumb {
  width: 40px; height: 40px; flex: none;
  background: var(--gray-200); border-radius: 8px; overflow: hidden; cursor: pointer;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.preview-info { display: flex; flex-direction: column; justify-content: flex-end; margin-left: 8px; width: 80%; opacity: 0.7; min-width: 0; }
.preview-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-actions { position: absolute; right: 8px; display: flex; gap: 8px; }
.preview-actions button {
  display: flex; justify-content: center; align-items: center;
  width: 40px; height: 40px; border-radius: 9999px; border: none;
  color: var(--gray-600); background: var(--gray-100); cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.preview-actions button:hover { background: var(--gray-200); }
.preview-item.is-done .preview-info { opacity: 1; }
.preview-item.is-error .preview-meta { color: var(--red-500); }

/* 链接区 */
.links-card { position: relative; }
.links-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.links-tools button {
  padding: 4px 8px; border-radius: 6px; border: none;
  font-size: 12px; color: var(--gray-800); background: var(--gray-100); cursor: pointer;
}
.links-tools button:hover { background: var(--gray-200); }
.link-tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; font-size: 14px; }
.link-tabs button {
  display: flex; justify-content: center; align-items: center;
  padding: 8px 32px; white-space: nowrap;
  border: none; border-bottom: 2px solid transparent;
  background: none; cursor: pointer; color: var(--gray-700);
}
.link-tabs button:hover { background: var(--gray-100); }
.link-tabs button.active { border-bottom-color: var(--indigo-500); }
.link-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.link-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px; background: var(--gray-100);
}
.link-row input {
  flex: 1; min-width: 0; border: none; background: none; outline: none;
  font-size: 13px; color: var(--gray-700);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.link-row button {
  flex: none; padding: 4px 10px; border-radius: 4px; border: none;
  font-size: 12px; color: var(--gray-600); background: #fff; cursor: pointer;
}
.link-row button:hover { color: var(--indigo-500); }

/* ============ 图片管理 ============ */
.images-toolbar {
  position: relative; z-index: 3;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px; margin: -16px -24px 16px;
  background: #fff; border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
.images-toolbar-left, .images-toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-input {
  padding: 6px 10px; border: none; outline: none; border-radius: 4px;
  background: var(--gray-100); font-size: 14px; width: 144px;
  transition: width 0.3s;
}
.search-input:hover, .search-input:focus { width: 208px; }

.images-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.images-item {
  position: relative; display: block; cursor: default;
  border-radius: 4px; overflow: hidden;
  outline: 2px solid transparent; outline-offset: 2px;
  transition: outline-color 0.15s;
  background: var(--gray-200);
  aspect-ratio: 4 / 3;
}
.images-item:hover, .images-item.selected { outline-color: var(--blue-500); }
.images-item img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: pointer; }
.image-selector { position: absolute; top: 0; right: 0; z-index: 2; display: none; overflow: hidden; cursor: pointer; }
.images-item:hover .image-selector, .images-item.selected .image-selector { display: block; }
.image-selector div { padding: 4px; font-size: 24px; }
.image-selector i {
  display: block; border-radius: 9999px;
  color: #fff; border: 1px solid var(--gray-500); background: #fff;
}
.images-item.selected .image-selector i { color: #0061ff; border-color: #fff; background: #fff; }
.image-mask {
  position: absolute; left: 0; right: 0; bottom: 0; height: 80px; z-index: 1;
  background-image: linear-gradient(to top, #000, transparent);
  pointer-events: none;
}
.image-mask-text { position: absolute; left: 8px; bottom: 8px; color: #fff; z-index: 2; width: 90%; }
.image-mask-text .filename { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-mask-text .date { font-size: 12px; opacity: 0.9; }
.image-actions { position: absolute; top: 4px; left: 4px; z-index: 3; display: none; gap: 4px; }
.images-item:hover .image-actions { display: flex; }
.image-actions button {
  padding: 2px 8px; border-radius: 4px; border: none; cursor: pointer;
  font-size: 12px; color: var(--gray-700); background: rgba(255, 255, 255, 0.9);
}
.image-actions button:hover { background: #fff; color: var(--indigo-500); }
.image-actions button.danger:hover { color: var(--red-500); }

/* ============ API 文档 ============ */
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc-table th, .doc-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--gray-200); color: var(--gray-700);
  vertical-align: top;
}
.doc-table th { color: var(--gray-500); font-weight: 600; width: 160px; }
.doc-table tr:last-child th, .doc-table tr:last-child td { border-bottom: none; }
code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.box-content code {
  padding: 2px 6px; border-radius: 4px;
  background: var(--gray-100); color: var(--gray-700); font-size: 13px;
}
.box-content pre {
  margin: 0; padding: 16px; overflow-x: auto;
  background: var(--gray-800); border-radius: 6px;
}
.box-content pre code {
  padding: 0; background: none; color: #e5e7eb; font-size: 13px; line-height: 1.7;
}

/* ============ 弹窗 / 预览 ============ */
.modal { position: fixed; inset: 0; z-index: 20; overflow-y: auto; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(107, 114, 128, 0.75); }
.modal-dialog {
  position: relative; margin: 48px auto; max-width: 896px; width: calc(100% - 32px);
}
.modal-panel {
  position: relative; background: #fff; padding: 32px 24px;
  border-radius: 2px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 24px; height: 24px; border: none; background: none;
  color: var(--gray-400); cursor: pointer; font-size: 18px;
}
.modal-close:hover { color: var(--gray-500); }
.modal-panel img { width: 100%; height: auto; border-radius: 8px; display: block; }
.modal-caption { margin-top: 12px; font-size: 13px; color: var(--gray-500); text-align: center; word-break: break-all; }

.viewer-backdrop { background-color: rgba(0, 0, 0, 0.75); }

/* ============ toast（沿用 toastr 视觉） ============ */
#toast-container {
  position: fixed; top: 12px; right: 12px; z-index: 999999;
  display: flex; flex-direction: column; pointer-events: none;
}
#toast-container > div {
  position: relative; width: 300px; margin: 0 0 6px;
  padding: 10px 12px 10px 44px;
  border-radius: 3px; color: #fff; font-size: 13px;
  box-shadow: 0 0 12px hsla(0, 0%, 72%, 0.47);
  opacity: 0.9; pointer-events: auto;
  animation: toast-in 0.25s ease;
}
#toast-container > div:hover { opacity: 1; }
#toast-container > div::before {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 18px;
}
.toast-success { background-color: #51a351; }
.toast-success::before { content: '\f058'; }
.toast-error { background-color: #bd362f; }
.toast-error::before { content: '\f057'; }
.toast-info { background-color: #2f96b4; }
.toast-info::before { content: '\f05a'; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } }

/* ============ 响应式（复刻 sm 断点行为） ============ */
@media (max-width: 640px) {
  .menu-toggle { display: inline-flex; }
  .sidebar { width: 75%; left: -600px; }
  .sidebar.open { left: 0; }
  .sidebar-brand { justify-content: space-between; }
  .sidebar-close { display: block; background: none; border: none; color: #fff; cursor: pointer; }
  .content { left: 0; padding: 16px; }
  .images-toolbar { margin: -16px -16px 16px; }
  .search-input { display: none; }
  .card-title { font-size: 20px; }
  .upload-container { min-height: 150px; }
}
