/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #1a2a1a;
  --ink2:       #3d5240;
  --ink3:       #6b7e6d;
  --ink4:       #9aaa9b;
  --paper:      #f5f0e8;
  --paper2:     #ede8dc;
  --paper3:     #e0dace;
  --paper4:     #d5cec1;
  --moss:       #2d5a27;
  --moss-dark:  #1e4019;
  --moss-light: #e8f0e7;
  --moss-mid:   #a8c4a5;
  --danger:     #b5392a;
  --accent:     #c17f3b;
  --card-bg:    #faf7f1;
  --card-shadow: 0 1px 4px rgba(26,42,26,0.07), 0 0 0 0.5px rgba(26,42,26,0.09);
  --nav-h:      56px;
}

html { font-size: 14px; scroll-behavior: smooth; }

body {
  background: var(--paper);
  font-family: 'Noto Sans SC', sans-serif;
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button { font-family: 'Noto Sans SC', sans-serif; cursor: pointer; border: none; background: none; }
input, textarea { font-family: 'Noto Sans SC', sans-serif; }
a { color: inherit; text-decoration: none; }

/* ─── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Page System ──────────────────────────────────────────────────────────── */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ─── Navigation ───────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--paper2);
  border-bottom: 1px solid var(--paper3);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav-left { display: flex; align-items: center; flex-shrink: 0; }

/* All pages get top padding to clear the fixed nav */
.page { padding-top: var(--nav-h); }
/* Login page has its own full-screen layout */
#page-login { padding-top: 0; }

.nav-logo {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 22px;
  color: var(--moss);
  letter-spacing: 2px;
  white-space: nowrap;
}

.nav-center-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  text-align: center;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink2);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-btn:hover { background: var(--paper3); }

.back-nav { color: var(--ink3); }
.back-nav:hover { color: var(--moss); }

.danger-btn { color: var(--danger) !important; }
.danger-btn:hover { background: #fdf0ee !important; }

.btn-primary {
  background: var(--moss) !important;
  color: #fff !important;
  font-weight: 500 !important;
}
.btn-primary:hover { background: var(--moss-dark) !important; }

/* ─── Login ────────────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* subtle dot pattern */
  background-image: radial-gradient(circle, var(--paper3) 1px, transparent 1px);
  background-size: 28px 28px;
}

.login-card {
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 20px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 32px rgba(26,42,26,0.10);
}

.login-logo {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 34px;
  color: var(--moss);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--ink3);
  margin-bottom: 30px;
  font-weight: 300;
}

.login-submit {
  width: 100%;
  background: var(--moss);
  color: #fff;
  border-radius: 12px;
  padding: 13px;
  font-size: 15px;
  font-weight: 500;
  margin-top: 6px;
  transition: background 0.15s, opacity 0.15s;
  letter-spacing: 0.5px;
}
.login-submit:hover { background: var(--moss-dark); }
.login-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.login-hint {
  font-size: 12px;
  color: var(--ink4);
  text-align: center;
  margin-top: 14px;
}

/* ─── Form Elements ────────────────────────────────────────────────────────── */
.form-field { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink3);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-input {
  width: 100%;
  border: 1px solid var(--paper3);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  border-color: var(--moss-mid);
  box-shadow: 0 0 0 3px rgba(45,90,39,0.08);
}
.form-input::placeholder { color: var(--ink4); }

.input-wrap { position: relative; }
.input-wrap .form-input { padding-right: 40px; }

.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink4);
  padding: 4px;
  border-radius: 4px;
}
.eye-btn svg { width: 16px; height: 16px; }
.eye-btn:hover { color: var(--ink3); }

.form-error {
  background: rgba(181,57,42,0.08);
  border: 1px solid rgba(181,57,42,0.2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ─── Search ───────────────────────────────────────────────────────────────── */
.search-wrap {
  padding: 16px 20px 10px;
  max-width: 760px;
  margin: 0 auto;
}

.search-box {
  background: var(--paper2);
  border: 1px solid var(--paper3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within {
  border-color: var(--moss-mid);
  box-shadow: 0 0 0 3px rgba(45,90,39,0.06);
}
.search-box > svg { width: 16px; height: 16px; color: var(--ink4); flex-shrink: 0; }

.search-box input {
  border: none;
  background: none;
  flex: 1;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}
.search-box input::placeholder { color: var(--ink4); }

.search-clear {
  color: var(--ink4);
  padding: 2px;
  border-radius: 50%;
}
.search-clear svg { width: 14px; height: 14px; }
.search-clear:hover { color: var(--ink3); }


/* ─── Notes Grid (Masonry via CSS columns) ─────────────────────────────────── */
.notes-grid {
  padding: 0 16px 100px;
  max-width: 960px;
  margin: 0 auto;
  columns: 2;
  column-gap: 12px;
}

@media (min-width: 600px) { .notes-grid { columns: 3; } }
@media (min-width: 900px) { .notes-grid { columns: 4; } }

/* ─── Note Card ────────────────────────────────────────────────────────────── */
.note-card {
  break-inside: avoid;
  margin-bottom: 12px;
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--card-shadow);
}
.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(26,42,26,0.11), 0 0 0 0.5px rgba(26,42,26,0.1);
}

.note-card-img {
  width: 100%;
  object-fit: cover;
  display: block;
  filter: sepia(6%) contrast(1.02);
}

.note-card-body { padding: 13px 14px; }

.note-card-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.55;
  margin-bottom: 6px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.note-card-text {
  font-size: 12.5px;
  color: var(--ink3);
  line-height: 1.75;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.note-card-footer {
  padding: 9px 14px 11px;
  border-top: 1px solid var(--paper3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.note-date { font-size: 11px; color: var(--ink4); flex-shrink: 0; }

.note-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.note-tag {
  background: var(--moss-light);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--moss);
}

/* ─── Loader / Empty ───────────────────────────────────────────────────────── */
.loader { display: flex; justify-content: center; padding: 24px; }

.page-loader {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 60px 0;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--paper3);
  border-top-color: var(--moss);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.list-end {
  text-align: center;
  font-size: 12px;
  color: var(--ink4);
  padding: 16px 0 80px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
}
.empty-state svg {
  width: 52px;
  height: 52px;
  color: var(--ink4);
  margin: 0 auto 14px;
}
.empty-state p {
  font-size: 14px;
  color: var(--ink3);
  line-height: 1.7;
}

.empty-small {
  font-size: 13px;
  color: var(--ink4);
  text-align: center;
  padding: 20px;
}

/* ─── Detail Page ──────────────────────────────────────────────────────────── */
.detail-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 28px 24px 100px;
}

.detail-cover {
  width: 100%;
  border-radius: 14px;
  margin-bottom: 22px;
  max-height: 320px;
  object-fit: cover;
  filter: sepia(5%) contrast(1.02);
}

.detail-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 10px;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink4);
  margin-bottom: 14px;
}
.detail-meta svg { width: 13px; height: 13px; }

.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.detail-tag {
  background: var(--moss-light);
  border: 1px solid var(--moss-mid);
  border-radius: 14px;
  padding: 3px 11px;
  font-size: 12.5px;
  color: var(--moss);
}

.detail-body {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  line-height: 1.95;
  color: var(--ink2);
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-divider {
  border: none;
  border-top: 1px dashed var(--paper3);
  margin: 24px 0;
}

.detail-img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.detail-img-thumb {
  border-radius: 8px;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  width: 100%;
  filter: sepia(5%);
  transition: opacity 0.15s, transform 0.15s;
}
.detail-img-thumb:hover { opacity: 0.88; transform: scale(1.02); }

/* ─── Edit Page ────────────────────────────────────────────────────────────── */
.edit-wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 22px 24px 100px;
}

.edit-title-input {
  border: none;
  background: none;
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  width: 100%;
  outline: none;
  line-height: 1.45;
  display: block;
}
.edit-title-input::placeholder { color: var(--ink4); }

.edit-divider {
  border: none;
  border-top: 1px solid var(--paper3);
  margin: 14px 0;
}

.edit-content-input {
  border: none;
  background: none;
  font-family: 'Noto Serif SC', serif;
  font-size: 15.5px;
  color: var(--ink2);
  width: 100%;
  outline: none;
  resize: none;
  line-height: 1.95;
  min-height: 220px;
  display: block;
}
.edit-content-input::placeholder { color: var(--ink4); }

.edit-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink4);
  margin: 22px 0 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.edit-tag-pick { display: flex; gap: 7px; flex-wrap: wrap; }

.edit-tag {
  background: var(--paper2);
  border: 1px solid var(--paper3);
  border-radius: 16px;
  padding: 5px 13px;
  font-size: 12.5px;
  color: var(--ink3);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.edit-tag:hover { border-color: var(--moss-mid); color: var(--moss); }
.edit-tag.selected {
  background: var(--moss);
  border-color: var(--moss);
  color: #fff;
}

.edit-img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-img-item {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.edit-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(5%);
}

.edit-img-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26,42,26,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.edit-img-overlay .spinner { border-color: rgba(255,255,255,0.4); border-top-color: #fff; }

.edit-img-error {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}
.edit-img-error svg { width: 18px; height: 18px; color: #fff; }
.edit-img-error span { font-size: 11px; color: #fff; }

.edit-img-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.edit-img-remove:hover { background: rgba(0,0,0,0.75); }
.edit-img-remove svg { width: 12px; height: 12px; color: #fff; }

.edit-add-img {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  border: 1.5px dashed var(--moss-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--moss-mid);
  transition: all 0.15s;
  flex-shrink: 0;
}
.edit-add-img svg { width: 26px; height: 26px; }
.edit-add-img:hover { border-color: var(--moss); color: var(--moss); background: var(--moss-light); }

.save-btn {
  background: var(--moss);
  color: #fff;
  border-radius: 10px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.save-btn:hover { background: var(--moss-dark); }
.save-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.save-tip {
  font-size: 13px;
  color: var(--moss);
  font-weight: 500;
}

/* ─── Sub pages (Tag / Account) ────────────────────────────────────────────── */
.sub-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 20px 80px;
}

.sub-card {
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
}

.sub-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink4);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

/* Tag page */
.tag-form-row { display: flex; gap: 8px; align-items: center; }
.tag-form-row .form-input { flex: 1; height: 40px; padding: 8px 12px; }

.tag-color-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.color-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2.5px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.color-dot:hover { transform: scale(1.12); }
.color-dot.active { border-color: var(--ink) !important; transform: scale(1.12); }

.tag-list-item {
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 11px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 7px;
  box-shadow: var(--card-shadow);
}
.tag-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tag-list-name { flex: 1; font-size: 14px; color: var(--ink); }
.tag-del-btn {
  color: var(--ink4);
  padding: 5px;
  border-radius: 6px;
  transition: all 0.15s;
}
.tag-del-btn svg { width: 15px; height: 15px; display: block; }
.tag-del-btn:hover { color: var(--danger); background: #fdf0ee; }

/* Account page */
.account-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}
.account-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--moss-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-avatar svg { width: 26px; height: 26px; color: var(--moss); }
.account-name { font-size: 16px; font-weight: 600; color: var(--ink); }
.account-sub { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.account-badge {
  margin-left: auto;
  border-radius: 12px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}
.account-badge.bound { background: #e8f5e8; color: #2d7d2d; }
.account-badge.unbound { background: #fff5e8; color: #c17f3b; }

.action-tile { display: flex; align-items: center; gap: 13px; cursor: pointer; }
.action-tile:hover { background: var(--paper2); }
.action-tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.action-tile-icon svg { width: 18px; height: 18px; }
.action-tile-text { flex: 1; }
.action-tile-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.action-tile-sub { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.action-chevron { width: 16px; height: 16px; color: var(--ink4); flex-shrink: 0; }

/* ─── Modals ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,42,26,0.32);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 26px 26px 22px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 48px rgba(26,42,26,0.16);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 14px;
}

.modal-body {
  font-size: 14px;
  color: var(--ink3);
  line-height: 1.7;
  margin-bottom: 4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn-cancel {
  background: var(--paper2);
  border: 1px solid var(--paper3);
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--ink2);
  transition: background 0.15s;
}
.btn-cancel:hover { background: var(--paper3); }

.btn-confirm {
  background: var(--moss);
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  color: #fff;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}
.btn-confirm:hover { background: var(--moss-dark); }
.btn-confirm.danger { background: var(--danger); }
.btn-confirm.danger:hover { background: #8c2b1f; }
.btn-confirm:disabled { opacity: 0.55; cursor: not-allowed; }

/* ─── Lightbox ─────────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,15,10,0.92);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.18s ease;
}

.lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  color: rgba(255,255,255,0.75);
  padding: 8px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.lightbox-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lightbox-close svg { width: 22px; height: 22px; }

.lightbox-prev, .lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.7);
  padding: 12px 8px;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-prev:hover, .lightbox-next:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lightbox-prev svg, .lightbox-next svg { width: 28px; height: 28px; }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,42,26,0.88);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 900;
  pointer-events: none;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
  white-space: nowrap;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .nav { padding: 0 12px; gap: 8px; }
  .nav-btn span, .nav-btn:not(.back-nav) { font-size: 12px; }
  .login-card { padding: 30px 22px 26px; }
  .detail-wrap, .edit-wrap { padding: 18px 16px 80px; }
  .detail-title { font-size: 20px; }
  .sub-wrap { padding: 16px 14px 80px; }
  .modal-box { padding: 22px 20px 18px; }
  .notes-grid { padding: 0 10px 80px; column-gap: 8px; }
}

/* ─── Detail Carousel ──────────────────────────────────────────────────────── */
.detail-carousel {
  margin-top: 24px;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  user-select: none;
}

.carousel-track-wrap {
  overflow: hidden;
  width: 100%;
}

.carousel-track {
  display: flex;
  transition: transform 0.38s cubic-bezier(0.4,0,0.2,1);
  will-change: transform;
}

.carousel-slide {
  flex-shrink: 0;
  width: 100%;
}

.carousel-slide img {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
  background: #0d0d0d;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  backdrop-filter: blur(6px);
  transition: background 0.15s;
  z-index: 10;
}
.carousel-btn:hover { background: rgba(255,255,255,0.28); }
.carousel-btn svg { width: 20px; height: 20px; }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }
.carousel-btn.hidden-btn { display: none; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 12px;
  background: #0d0d0d;
}
.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.carousel-dot.active {
  background: #fff;
  width: 18px;
  border-radius: 3px;
}

.carousel-counter {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* ─── Lightbox upgrade ─────────────────────────────────────────────────────── */
.lightbox-counter {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  pointer-events: none;
}

/* ─── Drop Zone ────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--moss-mid);
  border-radius: 14px;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.18s;
  background: var(--paper2);
  text-align: center;
}
.drop-zone:hover {
  border-color: var(--moss);
  background: var(--moss-light);
}
.drop-zone.drag-over {
  border-color: var(--moss);
  background: var(--moss-light);
  transform: scale(1.01);
  box-shadow: 0 0 0 4px rgba(45,90,39,0.10);
}
.drop-zone > svg {
  width: 36px;
  height: 36px;
  color: var(--moss-mid);
  transition: color 0.18s;
}
.drop-zone:hover > svg,
.drop-zone.drag-over > svg {
  color: var(--moss);
}
.drop-zone-text {
  font-size: 14px;
  color: var(--ink3);
}
.drop-zone-text em {
  font-style: normal;
  color: var(--moss);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.drop-zone-hint {
  font-size: 12px;
  color: var(--ink4);
}

/* edit-img-grid: 改为 flex wrap，去掉固定 add 按钮 */
.edit-img-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ─── Tag Input (edit page) ────────────────────────────────────────────────── */
.tag-input-wrap {
  border: 1px solid var(--paper3);
  border-radius: 12px;
  background: var(--paper2);
  padding: 8px 10px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-input-wrap:focus-within {
  border-color: var(--moss-mid);
  box-shadow: 0 0 0 3px rgba(45,90,39,0.08);
}

.tag-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.tag-selected-list:empty { margin-bottom: 0; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--moss);
  color: #fff;
  border-radius: 16px;
  padding: 3px 10px 3px 11px;
  font-size: 12.5px;
  font-weight: 500;
}
.tag-chip-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  line-height: 1;
  font-size: 15px;
  transition: color 0.12s;
}
.tag-chip-remove:hover { color: #fff; }

.tag-input-row { display: flex; align-items: center; }
.tag-input {
  border: none;
  background: none;
  outline: none;
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
  padding: 2px 0;
}
.tag-input::placeholder { color: var(--ink4); }

.tag-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(26,42,26,0.10);
  z-index: 200;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

.tag-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--ink);
  transition: background 0.12s;
}
.tag-dropdown-item:hover,
.tag-dropdown-item.active { background: var(--moss-light); }
.tag-dropdown-item .tag-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tag-dropdown-create {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--moss);
  font-weight: 500;
  border-top: 1px solid var(--paper3);
  transition: background 0.12s;
}
.tag-dropdown-create:hover { background: var(--moss-light); }
.tag-dropdown-create svg { width: 15px; height: 15px; flex-shrink: 0; }
.tag-dropdown-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--ink4);
  text-align: center;
}

/* ─── Drop zone pick buttons ───────────────────────────────────────────────── */
.drop-zone-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.drop-zone-pick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--paper);
  border: 1px solid var(--paper4);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink2);
  cursor: pointer;
  font-family: 'Noto Sans SC', sans-serif;
  transition: all 0.15s;
}
.drop-zone-pick-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.drop-zone-pick-btn:hover { background: var(--moss-light); border-color: var(--moss-mid); color: var(--moss); }

/* ─── Video thumb in edit grid ─────────────────────────────────────────────── */
.edit-video-thumb {
  width: 90px;
  height: 90px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  background: #111;
  flex-shrink: 0;
}
.edit-video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.video-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.video-play-icon svg {
  width: 28px;
  height: 28px;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* ─── Video in detail carousel ─────────────────────────────────────────────── */
.carousel-video {
  width: 100%;
  max-height: 520px;
  background: #0d0d0d;
  display: block;
  outline: none;
}

/* ─── Lightbox toolbar & rotation ──────────────────────────────────────────── */
.lightbox-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 10;
}

.lightbox-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  transition: background 0.15s, color 0.15s;
}
.lightbox-tool-btn:hover { background: rgba(255,255,255,0.25); color: #fff; }
.lightbox-tool-btn svg { width: 18px; height: 18px; }

/* override old close position since it's now in toolbar */
.lightbox-close {
  position: static !important;
  top: auto !important;
  right: auto !important;
}

.lightbox-content {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 88vh;
}

#lightbox-img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  user-select: none;
}

#lightbox-video {
  max-width: 90vw;
  max-height: 88vh;
  border-radius: 4px;
  background: #000;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  outline: none;
}

/* ─── Carousel video fullscreen btn ────────────────────────────────────────── */
.carousel-fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
  z-index: 5;
}
.carousel-fullscreen-btn:hover { background: rgba(0,0,0,0.7); }
.carousel-fullscreen-btn svg { width: 16px; height: 16px; }

/* ─── Download Page ────────────────────────────────────────────────────────── */
.download-hero {
  text-align: center;
  padding: 28px 0 20px;
}
.download-logo {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 36px;
  color: var(--moss);
  margin-bottom: 6px;
}
.download-tagline {
  font-size: 13px;
  color: var(--ink4);
}

.download-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card-bg);
  border: 1px solid var(--paper3);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--card-shadow);
}
.download-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,42,26,0.10);
}
.download-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.download-icon svg { width: 22px; height: 22px; }
.download-info { flex: 1; }
.download-name { font-size: 15px; font-weight: 500; color: var(--ink); margin-bottom: 3px; }
.download-desc { font-size: 12px; color: var(--ink4); }
.download-arrow { width: 18px; height: 18px; color: var(--ink4); flex-shrink: 0; }

.download-qr-wrap { flex-shrink: 0; }
.download-qr-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink4);
}

.download-tip {
  text-align: center;
  font-size: 12px;
  color: var(--ink4);
  margin-top: 20px;
  padding-bottom: 40px;
}

/* ─── Draggable FAB ────────────────────────────────────────────────────────── */
.fab-drag {
  position: fixed;
  right: 28px;
  bottom: 36px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--moss);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(45,90,39,0.45);
  cursor: grab;
  z-index: 300;
  user-select: none;
  touch-action: none;
  transition: box-shadow 0.15s, background 0.15s;
}
.fab-drag:hover { background: var(--moss-dark); box-shadow: 0 6px 28px rgba(45,90,39,0.5); }
.fab-drag:active { cursor: grabbing; }
.fab-drag svg { width: 28px; height: 28px; color: #fff; pointer-events: none; }
.fab-drag.hidden { display: none; }

/* ─── Nav restructure ──────────────────────────────────────────────────────── */
#nav-actions-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-extra-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.nav-persistent {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  border-left: 1px solid var(--paper3);
  margin-left: 6px;
  padding-left: 8px;
}

/* 常驻图标按钮（无文字） */
.nav-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink3);
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.nav-icon-btn svg { width: 18px; height: 18px; }
.nav-icon-btn:hover { background: var(--paper3); color: var(--moss); }

/* 详情页编辑/删除 — 图标+文字小按钮 */
.nav-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  background: none;
  font-size: 13px;
  font-family: 'Noto Sans SC', sans-serif;
  cursor: pointer;
  color: var(--ink2);
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-action-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.nav-action-btn:hover { background: var(--paper3); }
.nav-action-btn.danger { color: var(--danger); }
.nav-action-btn.danger:hover { background: #fdf0ee; }

/* 移动端：隐藏文字只留图标 */
@media (max-width: 500px) {
  .nav-action-btn span { display: none; }
  .nav-action-btn { padding: 6px 8px; }
  .save-btn { padding: 6px 14px; font-size: 13px; }
}

/* ─── Carousel video control buttons ───────────────────────────────────────── */
.carousel-video-btns {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  z-index: 5;
}
.carousel-video-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  backdrop-filter: blur(4px);
  transition: background 0.15s;
}
.carousel-video-btn:hover { background: rgba(0,0,0,0.7); }
.carousel-video-btn svg { width: 15px; height: 15px; }
