
/* ==============================
   VARIABLES — Light Blue Family
   ============================== */
:root {
  /* Blue palette (kept original, expanded) */
  --blue-50: #e3f2fd;
  --blue-100: #bbdefb;
  --blue-200: #90caf9;
  --blue-300: #64b5f6;
  --blue-500: #42a5f5;
  --blue-600: #1e88e5;
  --blue-700: #1976d2;
  --blue-800: #1565c0;
  --blue-900: #0d47a1;
  --blue-glass: rgba(66, 165, 245, 0.08);

  /* Text */
  --text-primary: #1a2332;
  --text-secondary: #546e7a;
  --text-muted: #90a4ae;
  --text-on-primary: #ffffff;

  /* Surfaces */
  --bg-page: #f0f6fc;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;

  /* Borders & Shadows */
  --border: #dce5ed;
  --border-light: #e8edf3;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.1);

  /* Radii */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-3xl: 32px;

  /* Typography */
  --font-logo: 'ZCOOL QingKe HuangYou', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;

  /* Status */
  --danger: #e53935;
  --danger-bg: #ffebee;
  --warning: #f9a825;
  --warning-bg: #fff8e1;
  --success: #43a047;
  --star: #f9a825;
  --star-bg: #fff8e1;
}

/* ==============================
   DARK MODE — System & Manual
   ============================== */
@media (prefers-color-scheme: dark) {
  :root {
    --text-primary: #e3edf5;
    --text-secondary: #90a8be;
    --text-muted: #5a7a94;

    --bg-page: #0d1620;
    --bg-card: #162230;
    --bg-surface: #162230;

    --border: #1e3044;
    --border-light: #1a293b;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.5);

    --blue-glass: rgba(92, 158, 230, 0.12);

    --danger-bg: #3e1a1a;
    --warning-bg: #3e3510;
    --star-bg: #3e3510;
  }
}

/* Manual override takes precedence */
:root.dark-mode {
  --text-primary: #e3edf5;
  --text-secondary: #90a8be;
  --text-muted: #5a7a94;

  --bg-page: #0d1620;
  --bg-card: #162230;
  --bg-surface: #162230;

  --border: #1e3044;
  --border-light: #1a293b;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.5);

  --blue-glass: rgba(92, 158, 230, 0.12);

  --danger-bg: #3e1a1a;
  --warning-bg: #3e3510;
  --star-bg: #3e3510;
}

/* Light-mode override — force light even when system is dark */
:root.light-mode {
  --text-primary: #1a2332;
  --text-secondary: #546e7a;
  --text-muted: #90a4ae;

  --bg-page: #f0f6fc;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;

  --border: #dce5ed;
  --border-light: #e8edf3;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.1);

  --blue-glass: rgba(66, 165, 245, 0.08);

  --danger-bg: #ffebee;
  --warning-bg: #fff8e1;
  --star-bg: #fff8e1;
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(66, 165, 245, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(100, 181, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(66, 165, 245, 0.03) 0%, transparent 50%);
  background-attachment: fixed;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
  pointer-events: none;
  z-index: 0;
}

/* ==============================
   UTILITY
   ============================== */
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ==============================
   APP LAYOUT
   ============================== */
.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-lg) 100px;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ==============================
   HEADER
   ============================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  padding: var(--space-sm) 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  user-select: none;
}

.app-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(66, 165, 245, 0.3);
  flex-shrink: 0;
}

.app-logo-text {
  font-family: var(--font-logo);
  font-size: 22px;
  color: var(--text-primary);
  letter-spacing: 2px;
  line-height: 1;
}

.app-logo-dot {
  color: var(--blue-500);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ==============================
   SEARCH BAR
   ============================== */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-family: var(--font-body);
  background: var(--bg-surface);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

.search-input:focus {
  border-color: var(--blue-300);
  box-shadow: 0 0 0 4px var(--blue-glass);
  background: #fff;
}

.search-wrapper:focus-within .search-icon {
  color: var(--blue-500);
}

/* ==============================
   HEADER BUTTONS
   ============================== */
.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-header:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

.btn-header:active {
  transform: scale(0.96);
}

/* ==============================
   TAB BAR
   ============================== */
.tab-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  padding-bottom: 0;
  position: relative;
}

.tab-group {
  display: flex;
  background: var(--bg-surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  flex: 1;
  max-width: fit-content;
}

.tab-btn {
  position: relative;
  padding: 9px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: calc(var(--radius) - 4px);
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--blue-500);
  color: var(--text-on-primary);
  box-shadow: 0 1px 4px rgba(66, 165, 245, 0.3);
}

.tab-btn .count {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--blue-glass);
  color: var(--blue-700);
  transition: all var(--transition-fast);
}

.tab-btn.active .count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Floating Add Button */
.btn-new {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 12px rgba(66, 165, 245, 0.35);
  transition: all var(--transition);
  flex-shrink: 0;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-new:hover {
  transform: scale(1.06) translateY(-1px);
  box-shadow: 0 6px 20px rgba(66, 165, 245, 0.4);
}

.btn-new:active {
  transform: scale(0.94);
}

/* ==============================
   NOTES GRID
   ============================== */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  min-height: 200px;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 60px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-lg);
  opacity: 0.4;
}

.empty-state-text {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  max-width: 260px;
}

/* ==============================
   NOTE CARD
   ============================== */
.note-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* First-load staggered entrance (added via JS flag) */
.note-card-enter {
  animation: cardIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.note-card-enter:nth-child(1) { animation-delay: 0ms; }
.note-card-enter:nth-child(2) { animation-delay: 40ms; }
.note-card-enter:nth-child(3) { animation-delay: 80ms; }
.note-card-enter:nth-child(4) { animation-delay: 120ms; }
.note-card-enter:nth-child(5) { animation-delay: 150ms; }
.note-card-enter:nth-child(6) { animation-delay: 180ms; }
.note-card-enter:nth-child(7) { animation-delay: 210ms; }
.note-card-enter:nth-child(8) { animation-delay: 240ms; }

/* Blue accent bar at top of card */
.note-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--blue-300), var(--blue-500));
  opacity: 0.6;
  transition: opacity var(--transition);
}

.note-card:hover::before {
  opacity: 1;
}

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

.note-card:active {
  transform: translateY(-1px);
}

/* Starred card accent */
.note-card.starred-card {
  border-color: #ffe082;
}

.note-card.starred-card::before {
  background: linear-gradient(90deg, var(--star), #ffb300);
  opacity: 0.8;
}

/* Card image */
.note-card-image {
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: var(--blue-50);
  flex-shrink: 0;
}

.note-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.note-card:hover .note-card-image img {
  transform: scale(1.04);
}

/* Card body */
.note-card-body {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.note-card-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

/* Card footer */
.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-light);
}

.note-card-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 300;
}

/* Card actions */
.note-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.note-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.note-card-actions button:hover {
  background: var(--blue-50);
  color: var(--blue-700);
}

.note-card-actions .btn-star {
  font-size: 17px;
}

.note-card-actions .btn-star.starred {
  color: var(--star);
}

.note-card-actions .btn-star:not(.starred):hover {
  color: var(--star);
  background: var(--star-bg);
}

.note-card-actions .btn-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ==============================
   STORAGE INDICATOR
   ============================== */
.storage-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-light);
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 12px;
  color: var(--text-muted);
}



/* ==============================
   MODAL OVERLAY
   ============================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 40, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: var(--space-lg);
  animation: overlayIn 0.2s ease both;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
}

/* Modal scrollbar */
.modal-content::-webkit-scrollbar {
  width: 4px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}
.modal-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.modal-title-icon {
  font-size: 20px;
}

/* Modal textarea */
.modal-content textarea {
  width: 100%;
  min-height: 150px;
  padding: var(--space-md) var(--space-lg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: var(--font-body);
  resize: vertical;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--text-primary);
  line-height: 1.7;
  background: var(--bg-page);
}

.modal-content textarea:focus {
  border-color: var(--blue-300);
  box-shadow: 0 0 0 4px var(--blue-glass);
  background: #fff;
}

.modal-content textarea::placeholder {
  color: var(--text-muted);
  font-weight: 300;
}

/* Modal actions */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--blue-500);
  color: var(--text-on-primary);
  box-shadow: 0 2px 8px rgba(66, 165, 245, 0.25);
}

.btn-primary:hover {
  background: var(--blue-700);
  box-shadow: 0 4px 12px rgba(66, 165, 245, 0.3);
}

.btn-cancel {
  background: var(--bg-page);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-cancel:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-on-primary);
}

.btn-danger:hover {
  background: #c62828;
}

/* ==============================
   DETAIL MODE
   ============================== */
.detail-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.detail-header .modal-title {
  margin-bottom: 0;
}

.detail-time {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 300;
  white-space: nowrap;
}

.detail-text {
  font-size: 15px;
  line-height: 1.85;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: var(--space-xl);
  max-height: 50vh;
  max-height: 50dvh;
  overflow-y: auto;
  padding: var(--space-xs) 0;
}

.detail-text::-webkit-scrollbar {
  width: 4px;
}
.detail-text::-webkit-scrollbar-track {
  background: transparent;
}
.detail-text::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-lg);
}

.detail-actions .btn-star-detail {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.detail-actions .btn-star-detail:hover {
  background: var(--star-bg);
  border-color: #ffe082;
  color: var(--star);
}

.detail-actions .btn-star-detail.starred {
  color: var(--star);
  border-color: #ffe082;
  background: var(--star-bg);
}

.detail-actions .btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

.detail-actions .btn:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

.detail-actions .spacer {
  flex: 1;
}

/* ==============================
   CONFIRM DIALOG
   ============================== */
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 40, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: var(--space-lg);
  animation: overlayIn 0.2s ease both;
}

.confirm-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  text-align: center;
}

.confirm-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.confirm-content p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xl);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
}

/* ==============================
   TOAST
   ============================== */
.toast {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 10px 28px;
  background: rgba(26, 35, 50, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 400;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(16px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

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

/* ==============================
   RESPONSIVE — TABLET (768-1023px)
   ============================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .app {
    padding: var(--space-xl) var(--space-2xl) 100px;
  }

  .notes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-lg);
  }

  .search-wrapper {
    max-width: 300px;
  }

  .btn-header .label {
    display: inline;
  }
}

/* ==============================
   RESPONSIVE — MOBILE (<768px)
   ============================== */
@media (max-width: 767px) {
  .app {
    padding: var(--space-md) var(--space-md) 80px;
  }

  /* Header: stack logo, push actions to own row */
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
  }

  .app-logo-text {
    font-size: 19px;
  }

  .app-logo-icon {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .header-actions {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }

  .search-wrapper {
    max-width: none;
    flex: 1;
  }

  .btn-header {
    padding: 8px 12px;
    font-size: 12px;
  }

  .btn-header .label {
    display: none;
  }

  /* Tab bar: pill style compresses */
  .tab-group {
    max-width: none;
    flex: 1;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 9px 12px;
    font-size: 13px;
  }

  .btn-new {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  /* Grid: single column */
  .notes-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Card adjustments for touch */
  .note-card {
    border-radius: var(--radius-sm);
  }

  .note-card-image {
    height: 140px;
  }

  .note-card-body {
    padding: var(--space-md) var(--space-md) var(--space-sm);
  }

  .note-card-footer {
    padding: var(--space-sm) var(--space-md) var(--space-md);
  }

  /* Larger touch targets on mobile */
  .note-card-actions button {
    width: 38px;
    height: 38px;
  }

  .note-card-text {
    -webkit-line-clamp: 3;
  }

  .empty-state {
    padding: 60px 20px 40px;
  }

  .empty-state-icon {
    font-size: 40px;
  }

  /* Modal: bottom sheet on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: var(--space-xl);
    max-width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    animation: modalSlideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

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

  .modal-content textarea {
    min-height: 120px;
    font-size: 16px; /* prevent iOS zoom on focus */
  }

  .detail-text {
    max-height: 40vh;
    max-height: 40dvh;
  }

  .confirm-content {
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    max-width: 90vw;
  }

  /* Toast position adjustment for mobile */
  .toast {
    bottom: 70px;
    font-size: 13px;
    padding: 9px 22px;
  }

  .storage-bar {
    padding: var(--space-xs) var(--space-md);
    font-size: 11px;
  }
}

/* ==============================
   RESPONSIVE — DESKTOP (≥1024px)
   ============================== */
@media (min-width: 1024px) {
  .notes-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-xl);
  }

  .note-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-3px);
  }
}

/* ==============================
   RESPONSIVE — LARGE DESKTOP (≥1400px)
   ============================== */
@media (min-width: 1400px) {
  .app {
    max-width: 1200px;
  }

  .notes-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ==============================
   DARK MODE PREFERENCE (honor system)
   ============================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==============================
   SAFE AREA INSETS (notch devices)
   ============================== */
@supports (padding: max(0px)) {
  .app {
    padding-left: max(var(--space-lg), env(safe-area-inset-left));
    padding-right: max(var(--space-lg), env(safe-area-inset-right));
    padding-bottom: max(100px, env(safe-area-inset-bottom));
  }

  @media (max-width: 767px) {
    .app {
      padding-left: max(var(--space-md), env(safe-area-inset-left));
      padding-right: max(var(--space-md), env(safe-area-inset-right));
      padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 10px));
    }
  }

  .modal-content {
    padding-bottom: max(var(--space-2xl), calc(env(safe-area-inset-bottom) + var(--space-md)));
  }

  .storage-bar {
    padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  }
}
