/* ==========================================================================
   StarWhiteNote - Modern Minimalist Design System (Apple / Notion Aesthetic)
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Minimalist Light Palette */
  --bg-app: #f9fafb;
  --bg-card: #ffffff;
  --bg-card-hover: #ffffff;
  --bg-subtle: #f3f4f6;
  --bg-muted: #e5e7eb;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --border-focus: #111827;

  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-inverse: #ffffff;

  --accent-primary: #111827;
  --accent-primary-hover: #000000;
  --accent-blue: #2563eb;
  --accent-blue-light: #eff6ff;
  --accent-green: #10b981;
  --accent-green-light: #ecfdf5;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fffbeb;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 40px -8px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.05);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-dark {
  /* Minimalist Dark Palette */
  --bg-app: #090a0b;
  --bg-card: #121316;
  --bg-card-hover: #18191d;
  --bg-subtle: #1a1b1f;
  --bg-muted: #27282d;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #f4f4f5;

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-inverse: #090a0b;

  --accent-primary: #f4f4f5;
  --accent-primary-hover: #ffffff;
  --accent-blue: #3b82f6;
  --accent-blue-light: #1e293b;
  --accent-green: #10b981;
  --accent-green-light: #064e3b;
  --accent-amber: #f59e0b;
  --accent-amber-light: #451a03;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.8);
}

/* ================= Base Reset ================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ================= Navbar ================= */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all var(--transition-fast);
}

body.theme-dark .navbar {
  background-color: rgba(9, 10, 11, 0.85);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}

.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.2));
}

.logo-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  background-color: var(--bg-subtle);
  padding: 0.2rem;
  border-radius: var(--radius-full);
}

.nav-tab {
  background: none;
  border: none;
  padding: 0.38rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-tab:hover {
  color: var(--text-primary);
}

.nav-tab.active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  width: 250px;
  transition: width var(--transition-normal);
}

.search-box:focus-within {
  width: 310px;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 0.45rem 1rem 0.45rem 2.2rem;
  font-size: 0.85rem;
  background-color: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.search-box input:focus {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}

body.theme-dark .search-box input:focus {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ================= Main Content Container ================= */
.main-content {
  flex: 1;
  max-width: 1160px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem 1.5rem;
}

/* ================= Minimalist Stats Strip ================= */
.stats-strip {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1.25rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
}

.stat-indicator {
  width: 7px;
  height: 7px;
  background-color: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--accent-green-light);
}

.stat-label {
  color: var(--text-muted);
  font-weight: 400;
}

.stat-num {
  font-weight: 600;
  color: var(--text-primary);
}

.stat-divider {
  color: var(--border-strong);
  font-size: 0.9rem;
  user-select: none;
}

.stat-pill-highlight {
  margin-left: auto;
}

.stat-badge {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.01em;
}

.cdn-pill {
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.cdn-pill:hover {
  transform: translateY(-1px);
}

.cdn-pill:hover .stat-badge {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}

.cdn-status-dot {
  width: 7px;
  height: 7px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulse-dot 2.4s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    transform: scale(1.1);
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ================= Tags Filter Bar ================= */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.tags-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tags-list {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  user-select: none;
}

.tag-pill:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background-color: var(--bg-subtle);
}

.tag-pill.active {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
  font-weight: 600;
}

.note-counter-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ================= Notes Grid ================= */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

/* Note Card */
.note-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
  position: relative;
}

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

.note-card-header {
  margin-bottom: 0.85rem;
}

.note-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
}

.note-tags {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.badge-tag {
  background-color: var(--bg-subtle);
  color: var(--text-secondary);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.badge-tag:hover {
  background-color: var(--text-primary);
  color: var(--text-inverse);
}

.note-date {
  color: var(--text-muted);
}

.note-title {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.note-title:hover {
  color: var(--accent-blue);
}

.note-card-body {
  flex: 1;
  margin-bottom: 1.1rem;
  cursor: pointer;
}

.note-content-preview {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Card Images Strip */
.note-card-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.note-thumb-wrapper {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.note-thumb-wrapper:hover {
  transform: scale(1.02);
  border-color: var(--border-strong);
}

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

.note-thumb-more {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  backdrop-filter: blur(2px);
}

/* Bound Documents */
.note-card-docs {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}

.bound-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.bound-doc-item:hover {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.bound-doc-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
}

.bound-doc-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.bound-doc-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bound-doc-name {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bound-doc-size {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.bound-doc-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.btn-xs {
  font-size: 0.76rem;
  padding: 0.25rem 0.65rem;
}

.btn-sm {
  font-size: 0.84rem;
  padding: 0.4rem 0.95rem;
}

.btn-primary {
  background-color: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background-color: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

/* Card Footer */
.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  margin-top: auto;
}

.note-stats {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* ================= Guide & Settings View ================= */
.guide-container, .share-container {
  max-width: 920px;
  margin: 0 auto;
}

.notice-card, .share-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.5rem;
}

.notice-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.notice-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

.guide-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.guide-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

.step-badge {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.65rem;
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 0.85rem;
}

.guide-card h3 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.65rem;
}

.guide-card p, .guide-card ul {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guide-card ul {
  padding-left: 1.2rem;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.card-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.text-muted {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.access-url-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  gap: 0.75rem;
}

.url-text {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--accent-blue);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tips-content {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.tip-step strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.tip-step p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ================= Modals ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.2rem;
  line-height: 1;
  transition: color var(--transition-fast);
}

.close-btn:hover {
  color: var(--text-primary);
}

/* Note Reader Modal */
.modal-reader {
  max-width: 760px;
}

.reader-header-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.reader-body {
  padding: 2rem 2rem 1.5rem 2rem;
  overflow-y: auto;
}

.reader-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.reader-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 2rem;
}

.reader-section-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reader-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.reader-img-card {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.reader-img-card:hover {
  transform: scale(1.02);
  border-color: var(--border-strong);
}

.reader-img-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  display: block;
}

.reader-footer {
  padding: 0.85rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* File Preview Modal */
.modal-preview {
  max-width: 980px;
  width: 95vw;
  height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.preview-header {
  padding: 0.85rem 1.5rem;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.preview-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.preview-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}

.preview-size {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  margin-left: 0.35rem;
  font-weight: 500;
}

.modal-preview.is-fullscreen {
  max-width: 100vw !important;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 !important;
}

.modal-preview.is-fullscreen .preview-body {
  padding: 3rem 1.5rem !important;
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

#previewFullscreenBtn, #previewHeaderActionBtn {
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  transition: all var(--transition-fast);
}

#previewFullscreenBtn:hover, #previewHeaderActionBtn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--text-primary);
  transform: translateY(-1px);
}

#previewFullscreenBtn svg, #previewHeaderActionBtn svg {
  flex-shrink: 0;
  stroke: currentColor;
}

.preview-body {
  flex: 1;
  background-color: #3f4347;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 1rem;
}

.preview-modal-footer {
  padding: 0.85rem 1.5rem;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 1rem;
}

.preview-hint {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#previewDownloadBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background-color: #2563eb !important;
  color: #ffffff !important;
  padding: 0.5rem 1.25rem !important;
  border-radius: var(--radius-full) !important;
  font-size: 0.85rem !important;
  font-weight: 500 !important;
  text-decoration: none !important;
  border: none !important;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35) !important;
  cursor: pointer;
}

#previewDownloadBtn:hover {
  background-color: #1d4ed8 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45) !important;
}

/* Word Viewer Container */
.docx-render-container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0;
}

#docxTarget {
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
}

/* Single elegant paper sheet for Word */
.docx-wrapper {
  background: transparent !important;
  padding: 0 !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

.docx-wrapper > section.docx,
#docxTarget > section.docx,
#docxTarget .docx {
  background-color: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.45) !important;
  border-radius: 4px !important;
  max-width: 820px !important;
  width: 100% !important;
  min-height: 520px !important;
  padding: 3.5rem 4rem !important;
  margin: 0 auto 2rem auto !important;
  box-sizing: border-box !important;
  line-height: 1.8 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif !important;
}

/* Excel Viewer Container */
.excel-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background-color: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.excel-sheet-tabs {
  display: flex;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.35rem 0.5rem;
  gap: 0.35rem;
  overflow-x: auto;
}

.excel-sheet-tab {
  background: none;
  border: 1px solid transparent;
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
}

.excel-sheet-tab.active {
  background-color: var(--bg-card);
  color: var(--accent-green);
  font-weight: 600;
  border-color: var(--border-subtle);
}

.excel-table-scroll {
  flex: 1;
  overflow: auto;
  padding: 1rem;
}

.excel-table-scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.excel-table-scroll th, .excel-table-scroll td {
  border: 1px solid var(--border-subtle);
  padding: 0.45rem 0.75rem;
  text-align: left;
}

.excel-table-scroll th {
  background-color: var(--bg-subtle);
  font-weight: 600;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.toast {
  background-color: var(--text-primary);
  color: var(--text-inverse);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.loading-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ================= Image Preview with Wheel Zoom ================= */
.image-zoom-container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #2b2e31;
  border-radius: 6px;
  user-select: none;
  touch-action: none;
}

.image-zoom-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.image-zoom-viewport:active {
  cursor: grabbing;
}

.zoomable-image {
  max-width: 92%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

.zoomable-image.smooth-transition {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating Zoom Toolbar */
.image-zoom-toolbar {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(18, 20, 24, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: #f3f4f6;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.08);
}

.zoom-btn:active {
  transform: scale(0.95);
}

.zoom-btn-text {
  width: auto;
  padding: 0 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.12);
}

.zoom-btn-text:hover {
  background: rgba(255, 255, 255, 0.25);
}

.zoom-level-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e5e7eb;
  padding: 0 0.35rem;
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

/* ================= Mobile & Responsive (< 768px) ================= */
@media (max-width: 768px) {
  /* Navbar */
  .navbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
  }

  .nav-left {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    width: 100%;
  }

  .logo {
    justify-content: flex-start;
  }

  .logo-title {
    font-size: 1.05rem;
  }

  .logo-subtitle {
    font-size: 0.72rem;
  }

  .nav-tabs {
    width: 100%;
    display: flex;
    padding: 0.2rem;
  }

  .nav-tab {
    flex: 1;
    text-align: center;
    justify-content: center;
    padding: 0.45rem 0.5rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .nav-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
  }

  .search-box {
    width: 100% !important;
    max-width: 100%;
    order: 1;
  }

  .search-box:focus-within {
    width: 100% !important;
  }

  #themeToggleBtn {
    order: 2;
    flex-shrink: 0;
  }

  #shareSiteBtn {
    order: 3;
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  #githubRepoLink {
    order: 4;
    flex: 1;
    text-align: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }

  /* Main Container */
  .main-content {
    padding: 0.85rem 0.85rem 3rem 0.85rem;
  }

  /* Minimalist Stats Strip */
  .stats-strip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .stats-strip::-webkit-scrollbar {
    display: none;
  }

  .stat-pill {
    flex-shrink: 0;
    font-size: 0.8rem;
    gap: 0.35rem;
  }

  .stat-divider {
    flex-shrink: 0;
  }

  .stat-pill-highlight {
    margin-left: 0;
    flex-shrink: 0;
  }

  .stat-badge {
    font-size: 0.74rem;
  }

  /* Section Toolbar & Tags */
  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .tags-filter-bar {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 3px;
  }

  .tags-filter-bar::-webkit-scrollbar {
    display: none;
  }

  .tags-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    width: max-content;
  }

  .tag-pill {
    flex-shrink: 0;
    padding: 0.32rem 0.75rem;
    font-size: 0.8rem;
  }

  .toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  /* Notes Grid & Cards */
  .notes-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .note-card {
    padding: 1.1rem;
    border-radius: var(--radius-md);
  }

  .note-title {
    font-size: 1.08rem;
  }

  .note-content-preview {
    font-size: 0.86rem;
    line-height: 1.6;
  }

  .note-card-images {
    gap: 0.4rem;
    margin-bottom: 0.9rem;
  }

  .bound-doc-item {
    padding: 0.5rem 0.7rem;
  }

  .bound-doc-name {
    font-size: 0.82rem;
    max-width: 160px;
  }

  .bound-doc-actions {
    gap: 0.3rem;
  }

  .bound-doc-actions .btn {
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
  }

  /* Guide Page */
  .guide-steps-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .guide-card {
    padding: 1.2rem;
  }

  /* Modals Overlay & Body */
  .modal-overlay {
    padding: 0;
  }

  .modal-card {
    max-height: 100dvh;
    height: 100dvh;
    width: 100vw;
    border-radius: 0;
    border: none;
  }

  /* Note Reader Modal */
  .modal-reader {
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }

  .reader-body {
    padding: 1.25rem 1rem 1rem 1rem;
  }

  .reader-title {
    font-size: 1.25rem;
    margin-bottom: 0.85rem;
  }

  .reader-content {
    font-size: 0.9rem;
    line-height: 1.68;
    margin-bottom: 1.5rem;
  }

  .reader-images-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .reader-footer {
    padding: 0.75rem 1rem;
  }

  /* File Preview Modal */
  .modal-preview {
    max-width: 100vw;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .preview-header {
    padding: 0.65rem 0.85rem;
  }

  .preview-title {
    max-width: 42vw;
    font-size: 0.86rem;
  }

  .preview-header-actions {
    gap: 0.35rem;
  }

  #previewFullscreenBtn, #previewHeaderActionBtn {
    padding: 0.25rem 0.55rem;
    font-size: 0.76rem;
  }

  .preview-body {
    padding: 0.5rem;
  }

  .preview-modal-footer {
    padding: 0.65rem 0.85rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  #previewDownloadBtn {
    width: 100%;
    justify-content: center;
    font-size: 0.88rem;
    padding: 0.55rem 1rem;
  }

  .preview-hint {
    font-size: 0.74rem;
    text-align: center;
    justify-content: center;
  }

  /* Image Zoom Toolbar on Mobile */
  .image-zoom-toolbar {
    bottom: 0.85rem;
    padding: 0.3rem 0.55rem;
    gap: 0.35rem;
  }

  .zoom-btn {
    width: 30px;
    height: 30px;
    font-size: 0.88rem;
  }

  .zoom-btn-text {
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }

  /* Share Site Modal Dialog on Mobile */
  #shareSiteModal .modal-card {
    height: auto;
    max-height: 90dvh;
    border-radius: var(--radius-lg);
    margin: 1rem;
    width: calc(100vw - 2rem);
    border: 1px solid var(--border-strong);
  }
}

/* Extra small mobile screens (<= 480px) */
@media (max-width: 480px) {
  .logo-title {
    font-size: 0.98rem;
  }
  .logo-subtitle {
    display: none;
  }
  .bound-doc-name {
    max-width: 120px;
  }
  .note-card-meta {
    font-size: 0.74rem;
  }
  .badge-tag {
    font-size: 0.68rem;
    padding: 0.12rem 0.45rem;
  }
}
