/* ============================================================
   图片分享系统 —— 设计系统（与 itools 统一的设计语言）
   ============================================================ */
:root {
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-elev: #eef0f6;
  --bg-input: #ffffff;
  --text: #1f2329;
  --text-2: #57606a;
  --text-3: #8b949e;
  --border: #e3e7ee;
  --primary: #4c6ef5;
  --primary-hover: #3b5bdb;
  --primary-weak: #edf1ff;
  --accent: #f47c66;
  --success: #2f9e44;
  --success-weak: #e6f4ea;
  --danger: #e5534b;
  --danger-weak: #fdebea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(23, 30, 50, .06), 0 1px 6px rgba(23, 30, 50, .05);
  --shadow-md: 0 4px 18px rgba(23, 30, 50, .09);
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
}
[data-theme="dark"] {
  --bg: #12141a;
  --bg-card: #1a1d26;
  --bg-elev: #22252f;
  --bg-input: #22252f;
  --text: #e6e8ee;
  --text-2: #a8b0bd;
  --text-3: #6f7887;
  --border: #2b2f3c;
  --primary: #6a8bff;
  --primary-hover: #8aa3ff;
  --primary-weak: #232c4a;
  --success-weak: #1d2f24;
  --danger-weak: #3a2225;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.65;
  color: var(--text); background: var(--bg); min-height: 100vh;
  display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
.mono { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-card) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { height: 60px; display: flex; align-items: center; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-logo { width: 26px; height: 26px; }
.topnav { margin-left: 10px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topnav-link { padding: 6px 14px; border-radius: 999px; color: var(--text-2); font-size: 14px; transition: all .18s; }
.topnav-link:hover { color: var(--primary); background: var(--primary-weak); }
.topnav-link.active { color: var(--primary); background: var(--primary-weak); font-weight: 600; }
.topnav:empty { display: none; }
.ext-mark { font-size: 11px; opacity: .6; margin-left: 2px; }
.site-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all .2s;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
.theme-toggle {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-2);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .2s;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle svg { width: 19px; height: 19px; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.container { width: min(1080px, 100% - 32px); margin-inline: auto; }
.main-content { flex: 1; padding: 24px 0 48px; }
.footer { border-top: 1px solid var(--border); padding: 22px 0; color: var(--text-3); font-size: 13px; text-align: center; }
.footer p { margin: 0; }

/* ---------- 首页瀑布流 ---------- */
.hero { text-align: center; padding: 22px 0 8px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; }
.hero p { margin: 0 0 22px; color: var(--text-2); }
.waterfall { columns: 4 240px; column-gap: 14px; }
.wf-card {
  break-inside: avoid; display: block; margin-bottom: 14px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.wf-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); color: var(--text); }
.wf-cover { position: relative; background: var(--bg-elev); }
.wf-cover img { display: block; width: 100%; height: auto; }
.wf-body { padding: 11px 14px 4px; }
.wf-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.wf-summary { margin: 0; color: var(--text-3); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wf-meta { display: flex; justify-content: space-between; padding: 8px 14px 12px; color: var(--text-3); font-size: 12px; }
.wf-card.no-image { padding: 16px; }
.wf-card.no-image .wf-body { padding: 0; }
.wf-card.no-image .wf-meta { padding: 8px 0 0; }
.waterfall-empty { text-align: center; color: var(--text-3); padding: 40px 0; }
.load-more-wrap { text-align: center; margin-top: 10px; }

/* ---------- 详情页 ---------- */
.detail { max-width: 860px; margin: 0 auto; }
.detail-header { text-align: center; margin-bottom: 26px; }
.detail-title { font-size: 26px; margin: 0 0 10px; }
.detail-meta { color: var(--text-3); font-size: 13.5px; display: flex; gap: 8px; justify-content: center; }
.detail-text { font-size: 15.5px; margin: 0 0 18px; }
.detail-figure { margin: 0 0 20px; }
.detail-figure img {
  width: 100%; border-radius: var(--radius); cursor: zoom-in; display: block;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.detail-figure figcaption { text-align: center; color: var(--text-3); font-size: 13px; margin-top: 8px; }
.detail-back { text-align: center; margin-top: 30px; }

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 12, 18, .92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 92vw; max-height: 88vh; object-fit: contain; cursor: zoom-in; transition: max-width .2s, max-height .2s; }
.lightbox img.zoomed { max-width: none; max-height: none; cursor: move; }
.lightbox-close, .lightbox-nav {
  position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-close { top: 18px; right: 22px; width: 44px; height: 44px; font-size: 24px; }
.lightbox-nav { top: 50%; translate: 0 -50%; width: 48px; height: 48px; font-size: 30px; }
.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }
.lightbox-caption { position: absolute; bottom: 18px; left: 50%; translate: -50% 0; color: rgba(255,255,255,.85); font-size: 13.5px; margin: 0; }

/* ---------- 后台 ---------- */
.admin-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.admin-head .tool-title { margin: 0; font-size: 22px; }
.tool-title { font-size: 24px; margin: 4px 0 20px; }
.auth-wrap { display: flex; justify-content: center; padding: 8vh 0; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.auth-card { width: min(380px, 92vw); padding: 30px 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-title { margin: 0 0 6px; font-size: 20px; text-align: center; }
.btn-block { width: 100%; }
.tool-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; }
.form-error { color: var(--danger); font-size: 13.5px; margin: 0; background: var(--danger-weak); border-radius: var(--radius-sm); padding: 9px 13px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 15px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.input {
  width: 100%; height: 40px; padding: 0 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-input); color: var(--text); font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.textarea { height: auto; padding: 11px 13px; resize: vertical; line-height: 1.6; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 20px;
  border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all .18s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--bg-card); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.btn-mini { height: 28px; padding: 0 12px; font-size: 12.5px; background: var(--bg-elev); color: var(--text-2); border: none; }
.btn-mini:hover { color: var(--primary); background: var(--primary-weak); }
.btn-danger { background: var(--danger-weak); color: var(--danger); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.hint { color: var(--text-3); font-size: 13px; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 26px 16px; text-align: center;
  transition: border-color .2s, background .2s; cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-weak); }
.dz-hint { margin: 0 0 6px; color: var(--text-2); }
.dz-sub { margin: 0; color: var(--text-3); font-size: 12.5px; }

.compose-grid { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.upload-list { display: flex; flex-direction: column; gap: 12px; }
.upload-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 9px;
}
.upload-item .ui-top { display: flex; gap: 10px; align-items: flex-start; }
.ui-thumb {
  flex: none; width: 72px; height: 72px; border-radius: var(--radius-sm); background: var(--bg-elev);
  object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--text-3); font-size: 11px;
}
.ui-info { flex: 1; min-width: 0; }
.ui-name { font-size: 13.5px; font-weight: 600; word-break: break-all; }
.ui-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.ui-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--bg-elev); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 3px; transition: width .2s; }
.progress-bar.done { background: var(--success); }
.progress-bar.error { background: var(--danger); }
.ui-input { height: 32px; font-size: 13px; }
.status-tag { font-size: 12px; border-radius: 999px; padding: 2px 10px; }
.status-tag.published { background: var(--success-weak); color: var(--success); }
.status-tag.draft { background: var(--bg-elev); color: var(--text-2); }
.status-tag.uploading { background: var(--primary-weak); color: var(--primary); }
.status-tag.error { background: var(--danger-weak); color: var(--danger); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { color: var(--text-3); font-weight: 600; font-size: 12.5px; }
.admin-table .ops { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table .t-clickable { cursor: pointer; }
.admin-table .t-clickable:hover .t-text { color: var(--primary); }
.admin-table .t-text { max-width: 360px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.pager-info { color: var(--text-3); font-size: 13.5px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; align-items: stretch; }
.settings-grid .tool-panel { margin-bottom: 0; }
/* 密码修改：竖排 + 充分间距 */
.pw-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.pw-form .btn { margin-top: 4px; }
.about-page { max-width: 820px; margin: 0 auto; }
.about-page .post-content { font-size: 15.5px; }
.about-page .post-content h2 { border-left: 4px solid var(--primary); padding-left: 12px; }
.icp { color: var(--text-3); }
@media (max-width: 720px) { .settings-grid { grid-template-columns: 1fr; } }
.admin-table .t-title { font-weight: 600; }
.admin-table .t-summary { color: var(--text-3); font-size: 12.5px; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.center-page { display: flex; align-items: center; justify-content: center; }
.notfound { text-align: center; padding: 80px 20px; }
.notfound h1 { font-size: 64px; margin: 0; color: var(--primary); }
.notfound p { color: var(--text-2); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; translate: -50% 20px; z-index: 99;
  background: var(--text); color: var(--bg-card); font-size: 13.5px;
  padding: 10px 20px; border-radius: 999px; box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity .25s, translate .25s;
}
.toast.show { opacity: 1; translate: -50% 0; }

@media (max-width: 900px) {
  .compose-grid { grid-template-columns: 1fr; }
}
