:root {
  --bg: #0d0d12;
  --panel: #16161e;
  --border: #2a2a3a;
  --text: #e0e0e4;
  --muted: #6b6b78;
  --accent: #4a9eff;
  --ok: #34d399;
  --err: #f87171;
  --nav-h: 76px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

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

body {
  padding-bottom: var(--nav-h);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ====== 底部菜单栏 (3项, 宽间距) ====== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 80;
  padding: 4px 16px;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0));
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color .15s;
  min-width: 64px;
  position: relative;
}
.nav-item svg { width: 26px; height: 26px; }
.nav-item.active { color: var(--accent); }
.nav-item.primary-btn {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 52px; height: 52px;
  padding: 0;
  margin-top: -28px;
  box-shadow: 0 4px 16px rgba(74,158,255,.4);
  min-width: 52px;
}
.nav-item.primary-btn svg { width: 26px; height: 26px; }

/* ====== 页面 ====== */
.page { padding: 0; }
.page.hidden { display: none !important; }
.page-body { padding: 8px 4px; }

/* ====== 贴纸墙 ====== */
.board { position: relative; width: 100vw; }
.tile {
  position: absolute;
  cursor: pointer;
  transition: transform .15s ease;
}
.tile:active { transform: scale(1.08); }
@media (hover: hover) {
  .tile:hover { transform: scale(1.1); z-index: 2; }
}
.tile img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)) drop-shadow(0 4px 10px rgba(0,0,0,.2));
}
.empty-state { padding: 120px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ====== hover 卡片 ====== */
.hover-card {
  position: fixed; z-index: 200;
  background: rgba(24,24,30,.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px; padding: 10px 14px;
  max-width: 240px; pointer-events: none;
  font-size: 12px; color: #e0e0e4;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .15s;
}
.hover-card.show { opacity: 1; }
.hover-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.hover-desc { color: #aaa; line-height: 1.4; }

/* ====== Lightbox ====== */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
}
.lightbox.hidden { display: none !important; }
.lb-swipe {
  overflow: hidden; touch-action: pan-y;
  display: flex; align-items: center; justify-content: center;
  max-width: 96vw; max-height: 72vh;
}
.lb-img {
  max-width: 92vw; max-height: 72vh;
  border-radius: 6px; cursor: default;
  transition: opacity .2s, transform .25s ease;
  pointer-events: none;
}
.lb-swipe.dragging .lb-img { transition: none; }
.lb-loading {
  position: absolute; top: 40%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3; pointer-events: none;
}
.lb-loading.hidden { display: none; }
.lb-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: lb-spin .6s linear infinite;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }
.lb-footer {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; max-width: 92vw;
  margin-top: 12px; cursor: default;
}
.lb-info {
  text-align: center;
  padding: 4px 10px; max-width: 300px;
}
.lb-name { font-size: 12px; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-desc { font-size: 11px; color: #999; line-height: 1.4; max-height: 40px; overflow-y: auto; }
.lb-actions-row {
  display: flex; gap: 10px; justify-content: center;
}
.lb-action {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  color: #fff; font-size: 14px; cursor: pointer; z-index: 2;
  padding: 8px 24px; border-radius: 20px;
  transition: opacity .15s, background .15s;
  flex-shrink: 0;
}
.lb-action:disabled { opacity: .5; cursor: default; }
.lb-action:active { background: rgba(255,255,255,.2); }
.lb-info {
  text-align: center;
  padding: 4px 10px;
  border-radius: 8px;
  min-width: 0; flex: 1; max-width: 240px;
}
.lb-name { font-size: 12px; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-desc { font-size: 11px; color: #999; line-height: 1.4; max-height: 40px; overflow-y: auto; }
.lb-close { position: absolute; top: 16px; right: 16px; color: #fff; font-size: 28px; cursor: pointer; z-index: 2; background: none; border: none; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.06); border: none;
  color: #fff; font-size: 40px; cursor: pointer; z-index: 2;
  width: 40px; height: 64px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.lb-prev { left: 4px; } .lb-next { right: 4px; }

/* ====== 底部抽屉 ====== */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150; display: none;
}
.drawer-overlay.show { display: block; }
.drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  z-index: 151; padding: 16px;
  padding-bottom: calc(var(--nav-h) + 20px);
  transform: translateY(100%);
  transition: transform .25s ease;
  max-height: 60vh; overflow-y: auto;
}
.drawer.show { transform: translateY(0); }
.drawer-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; text-align: center; }
.drawer-field { margin-bottom: 10px; }
.drawer-field label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.drawer-field textarea {
  width: 100%; resize: vertical; min-height: 60px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 8px; font-size: 13px;
}
.drawer-actions { display: flex; gap: 8px; margin-top: 12px; }
.drawer-actions .btn { flex: 1; text-align: center; }

/* ====== 队列页 ====== */
.queue-page { padding: 0 4px; }
.queue-card {
  background: var(--panel); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 6px;
}
.queue-card-row {
  display: flex; align-items: center; gap: 10px;
}
.queue-card.waiting { border-left: 3px solid var(--muted); }
.queue-card.uploading,
.queue-card.cutting,
.queue-card.saving { border-left: 3px solid var(--accent); }
.queue-card.done { border-left: 3px solid var(--ok); }
.queue-card.error { border-left: 3px solid var(--err); }
.queue-card.clickable { cursor: pointer; }
.queue-card.clickable:active { opacity: .85; }
.queue-card-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-card-status { font-size: 12px; flex-shrink: 0; }
.queue-card.waiting .queue-card-status { color: var(--muted); }
.queue-card.done .queue-card-status { color: var(--ok); }
.queue-card.error .queue-card-status { color: var(--err); }
.queue-card-dismiss { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 4px; line-height: 1; }

.queue-card-steps { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
.step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.12); transition: background .2s;
}
.step-dot.done { background: var(--ok); }
.step-dot.active { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.step-dot.failed { background: var(--err); }
.step-line { width: 10px; height: 2px; background: rgba(255,255,255,.1); }

.queue-card-expand {
  display: none; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.queue-card-expand.show { display: flex; }
.queue-detail-thumb {
  width: 48px; height: 48px; border-radius: 6px; overflow: hidden; flex-shrink: 0;
  background: var(--bg);
}
.queue-detail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue-detail-info { flex: 1; min-width: 0; }
.queue-detail-step { font-size: 11px; color: var(--err); margin-bottom: 4px; }
.queue-detail-error { font-size: 12px; color: var(--muted); word-break: break-all; line-height: 1.4; }
.queue-badge {
  position: absolute; top: -4px; right: 0;
  color: #fff;
  font-size: 10px; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.queue-badge.badge-blue { background: var(--accent); }
.queue-badge.badge-red { background: var(--err); }

/* ====== 通用按钮 ====== */
.btn {
  background: var(--panel); border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 6px;
  font-size: 13px; cursor: pointer; transition: background .15s;
}
.btn:hover { background: #1e1e2c; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin .5s linear infinite;
  top: 50%; left: 50%; margin: -8px 0 0 -8px;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3d8ce6; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger:hover { background: #e05858; }

input, textarea {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 6px 10px;
  font-size: 13px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ====== Toast (灵动岛) ====== */
.toast-container {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1c1c1e; border: none;
  border-radius: 28px; padding: 10px 22px; font-size: 13px;
  color: #fff; white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  animation: di-in .35s cubic-bezier(.4,0,.2,1);
  pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
}
.toast.err { color: var(--err); }
.toast.ok { color: var(--ok); }
@keyframes di-in {
  0% { opacity: 0; transform: scaleX(.6) scaleY(.4); border-radius: 28px; }
  50% { transform: scaleX(1.08) scaleY(1.04); }
  100% { opacity: 1; transform: scaleX(1) scaleY(1); }
}

/* ====== 登录模态框 ====== */
#loginModal input { padding: 10px 14px; font-size: 14px; }
#loginModal .btn { padding: 10px; font-size: 14px; }

/* ====== 移动端 ====== */
@media (max-width: 640px) {
  .hover-card { display: none !important; }
  .lb-img { max-width: 96vw; max-height: 64vh; }
  .lb-swipe { max-height: 64vh; }
  .lb-nav { display: none; }
  .lb-close { top: 10px; right: 10px; font-size: 22px; }
  .lb-action { font-size: 13px; padding: 7px 18px; }
}

/* ====== 桌面端 ====== */
@media (min-width: 641px) {
  .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-radius: 14px 14px 0 0; }
}
