
/* ==============================
   VARIABLES — Light Blue Family
   ============================== */
:root {
  /* 朱砂 accent scale */
  --accent-50: #F6E7E4;
  --accent-100: #EACDC7;
  --accent-200: #D9A69E;
  --accent-300: #C8796F;
  --accent-500: #C0362C;
  --accent-600: #AD3329;
  --accent-700: #A92E24;
  --accent-800: #8F261D;
  --accent-900: #6E1D17;
  --accent-glass: rgba(192, 54, 44, 0.08);
  --bg-glow: rgba(192, 54, 44, 0.05);

  /* Surfaces — 纸色 */
  --bg-page: #EFEFE9;
  --bg-card: #FAF9F4;
  --bg-surface: #FAF9F4;
  --bg-elevated: #FAF9F4;
  --bg-input: #FAF9F4;

  /* Text — 墨色 */
  --text-primary: #26282B;
  --text-secondary: #6F7477;
  --text-muted: #A3A5A0;
  --text-on-primary: #FBF6EC;

  /* Borders & Shadows */
  --border: #DFDBD0;
  --border-light: #EBE7DD;
  --shadow-xs: 0 1px 2px rgba(38, 40, 43, 0.04);
  --shadow-sm: 0 1px 4px rgba(38, 40, 43, 0.05), 0 2px 8px rgba(38, 40, 43, 0.04);
  --shadow: 0 2px 8px rgba(38, 40, 43, 0.06), 0 4px 16px rgba(38, 40, 43, 0.05);
  --shadow-lg: 0 8px 30px rgba(38, 40, 43, 0.08), 0 2px 8px rgba(38, 40, 43, 0.05);
  --shadow-xl: 0 12px 40px rgba(38, 40, 43, 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;
  --font-note: 'LXGW WenKai', 'KaiTi', 'STKaiti', 'PingFang SC', serif;

  /* Status */
  --danger: #B03A30;
  --danger-bg: #F6E7E4;
  --warning: #9A6B15;
  --warning-bg: #F4EDD8;
  --success: #3E7A45;
  --star: #C0362C;
  --star-bg: #F6E7E4;

}

/* ==============================
   DARK MODE — System & Manual
   ============================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* 暖墨（油烟墨） */
    --accent-50: #3A2622;
    --accent-100: #4A2F29;
    --accent-200: #6E443B;
    --accent-300: #A65A4E;
    --accent-500: #D8614F;
    --accent-600: #C95547;
    --accent-700: #C14F41;
    --accent-800: #A54336;
    --accent-900: #7F3228;
    --accent-glass: rgba(224, 106, 92, 0.14);
    --bg-glow: rgba(224, 106, 92, 0.07);

    --bg-page: #181512;
    --bg-card: #211D19;
    --bg-surface: #211D19;
    --bg-elevated: #26211D;
    --bg-input: #26211D;

    --text-primary: #EAE2D3;
    --text-secondary: #A79E92;
    --text-muted: #6B635B;
    --text-on-primary: #1B1513;

    --border: #2E2924;
    --border-light: #27231F;

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

    --danger: #E07366;
    --danger-bg: #3A2622;
    --warning: #D0A34E;
    --warning-bg: #3A321E;
    --success: #7DB583;
    --star: #D8614F;
    --star-bg: #3A2622;
  }
}

/* Manual override takes precedence */
:root[data-theme="dark"] {
  /* 暖墨（油烟墨）— 手动深色 */
  --accent-50: #3A2622;
  --accent-100: #4A2F29;
  --accent-200: #6E443B;
  --accent-300: #A65A4E;
  --accent-500: #D8614F;
  --accent-600: #C95547;
  --accent-700: #C14F41;
  --accent-800: #A54336;
  --accent-900: #7F3228;
  --accent-glass: rgba(224, 106, 92, 0.14);
  --bg-glow: rgba(224, 106, 92, 0.07);

  --bg-page: #181512;
  --bg-card: #211D19;
  --bg-surface: #211D19;
  --bg-elevated: #26211D;
  --bg-input: #26211D;

  --text-primary: #EAE2D3;
  --text-secondary: #A79E92;
  --text-muted: #6B635B;
  --text-on-primary: #1B1513;

  --border: #2E2924;
  --border-light: #27231F;

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

  --danger: #E07366;
  --danger-bg: #3A2622;
  --warning: #D0A34E;
  --warning-bg: #3A321E;
  --success: #7DB583;
  --star: #D8614F;
  --star-bg: #3A2622;
}

/* Light-mode override — force light even when system is dark */
/* ==============================
   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%, var(--bg-glow) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, var(--bg-glow) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, var(--bg-glow) 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;
}

/* Keyboard focus */
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-300);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==============================
   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-seal,
.seal,
.login-logo-seal {
  background-color: var(--accent-500);
  background-image:
    radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.28), transparent 42%),
    radial-gradient(circle at 72% 76%, rgba(0, 0, 0, 0.22), transparent 48%);
  color: var(--text-on-primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 2px 6px rgba(0, 0, 0, 0.18);
}

.app-logo-seal {
  width: 38px;
  height: 38px;
  border-radius: 6px 8px 7px 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-logo);
  font-size: 19px;
  letter-spacing: 0.02em;
  transform: rotate(-3deg);
  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(--accent-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%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.search-input {
  width: 100%;
  padding: 10px 44px 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(--accent-300);
  box-shadow: 0 0 0 4px var(--accent-glass);
  background: var(--bg-input);
}

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

.search-kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 7px;
  background: var(--bg-surface);
  font-family: var(--font-body);
  pointer-events: none;
}

/* ==============================
   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 svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.btn-header.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
}

.btn-header:hover {
  background: var(--accent-50);
  border-color: var(--accent-200);
  color: var(--accent-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(--accent-500);
  color: var(--text-on-primary);
  box-shadow: 0 1px 4px rgba(192, 54, 44, 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(--accent-glass);
  color: var(--accent-700);
  transition: all var(--transition-fast);
}

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

/* Floating Add Button */
.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--accent-500);
  color: var(--text-on-primary);
  padding: 8px 18px 8px 9px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: all var(--transition);
  flex-shrink: 0;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-new:hover {
  background: var(--accent-700);
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.2);
}

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

.btn-new-seal {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transform: rotate(-3deg);
}

.btn-new-seal svg {
  width: 16px;
  height: 16px;
}

/* ==============================
   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;
  text-align: center;
}

.empty-sheet {
  min-width: 270px;
  padding: 28px 32px;
  background: var(--bg-card);
  border: 1.5px dashed var(--text-muted);
  border-radius: 8px;
  box-shadow: var(--shadow-xs);
}

.empty-title {
  font-family: var(--font-note);
  font-size: 17px;
  color: var(--text-primary);
}

.empty-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.empty-rule {
  margin-top: 18px;
  border-bottom: 1px solid var(--border);
  opacity: 0.7;
}

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

/* 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; }

.note-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px) rotate(-0.15deg);
  border-color: var(--text-muted);
}

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

/* Starred card — 状态由朱印表达，边框仅轻微呼应 */
.note-card.starred-card {
  border-color: var(--accent-200);
}

.note-card.archived {
  opacity: 0.8;
}

/* 朱印「藏」与灰章「已归档」 */
.seal {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-logo);
  font-size: 17px;
  border-radius: 5px 7px 6px 8px;
  transform: rotate(-5deg);
  pointer-events: none;
}

.stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  padding: 3px 9px 2px;
  border: 1.5px solid var(--text-muted);
  color: var(--text-muted);
  border-radius: 4px;
  font-family: var(--font-logo);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  transform: rotate(-7deg);
  pointer-events: none;
  background: var(--bg-card);
}

/* Card image */
.note-card-image {
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: var(--accent-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: 15px;
  line-height: 1.75;
  font-family: var(--font-note);
  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;
}

.note-card.starred-card .note-card-text {
  padding-right: 42px;
}

.note-card.archived .note-card-text {
  padding-right: 88px;
}

/* 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;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.note-card:hover .note-card-actions,
.note-card:focus-within .note-card-actions {
  opacity: 1;
}

.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 svg {
  width: 16px;
  height: 16px;
}

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

.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 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 34px;
  padding: 14px 2px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.status-btn svg {
  width: 14px;
  height: 14px;
}

.status-btn:hover {
  border-color: var(--accent-300);
  color: var(--accent-500);
  background: var(--accent-50);
}


/* ==============================
   MODAL OVERLAY
   ============================== */
.dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  width: min(560px, calc(100vw - 36px));
  margin: auto; /* 恢复 UA 居中（全局 reset 会清零 margin） */
  padding: 24px;
  box-shadow: var(--shadow-xl);
}

.dialog::backdrop {
  background: rgba(13, 16, 18, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.dialog[open] {
  animation: dialogIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-title::before {
  content: '';
  width: 8px;
  height: 20px;
  background: var(--accent-500);
  border-radius: 2px;
  transform: rotate(3deg);
  opacity: 0.85;
}

/* Dialog textarea */
.dialog-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-note);
  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-input);
  margin-top: 16px;
}

.dialog-textarea:focus {
  border-color: var(--accent-300);
  box-shadow: 0 0 0 4px var(--accent-glass);
  background: var(--bg-input);
}

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

/* Dialog actions */
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* 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(--accent-500);
  color: var(--text-on-primary);
  box-shadow: 0 2px 8px rgba(192, 54, 44, 0.25);
}

.btn-primary:hover {
  background: var(--accent-700);
  box-shadow: 0 4px 12px rgba(192, 54, 44, 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-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.detail-head .dialog-title {
  margin-bottom: 0;
}

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

.detail-text {
  font-family: var(--font-note);
  font-size: 15.5px;
  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);
  padding-top: var(--space-lg);
}

.detail-actions .btn-star-state {
  color: var(--star);
  border-color: var(--star);
  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 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-actions .btn svg {
  width: 15px;
  height: 15px;
}

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

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

/* ==============================
   CONFIRM DIALOG
   ============================== */
.confirm-dialog {
  width: min(400px, calc(100vw - 36px));
  text-align: center;
}

.confirm-dialog .dialog-title {
  justify-content: center;
}

.confirm-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 12px 0 22px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

/* ==============================
   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);
}

/* ==============================
   LOGIN PAGE
   ============================== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 44px 38px 38px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  text-align: center;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-logo-seal {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-logo);
  font-size: 20px;
  border-radius: 6px 8px 7px 9px;
  transform: rotate(-3deg);
}

.login-logo-word {
  font-family: var(--font-logo);
  font-size: 26px;
  letter-spacing: 0.14em;
  color: var(--text-primary);
  line-height: 1;
}

.login-logo-dot {
  color: var(--accent-500);
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-weight: 300;
  letter-spacing: 0.18em;
}

.login-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-body);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.login-input:focus {
  border-color: var(--accent-300);
  box-shadow: 0 0 0 4px var(--accent-glass);
}

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

.login-btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent-500);
  color: var(--text-on-primary);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

.login-btn:hover {
  background: var(--accent-700);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  display: none;
  background: var(--danger-bg);
  border-radius: 8px;
  padding: 8px 12px;
}

.login-error.show {
  display: block;
}

/* ==============================
   ANIMATIONS
   ============================== */
@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);
  }
}

/* ==============================
   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;
  }

}

/* ==============================
   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-seal {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  .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.btn-icon {
    width: 36px;
    padding: 0;
  }

  .search-kbd {
    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 {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(78px, calc(env(safe-area-inset-bottom) + 70px));
    z-index: 60;
    width: 54px;
    height: 54px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.26);
  }

  .btn-new-seal {
    width: 32px;
    height: 32px;
  }

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

  /* 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-actions {
    opacity: 1;
  }

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

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

  .empty-sheet {
    min-width: 0;
    width: 100%;
    max-width: 320px;
  }

  /* Dialog: bottom sheet on mobile */
  .dialog {
    width: 100%;
    border-radius: 16px 16px 0 0;
    margin: auto 0 0;
    padding: var(--space-xl);
  }

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

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

  .confirm-dialog {
    max-width: 90vw;
  }

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

}

/* ==============================
   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));
    }
  }

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