@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Caveat:wght@400;600;700&family=Space+Grotesk:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700;800;900&family=Barlow+Condensed:wght@500;600;700;800;900&family=Stardos+Stencil:wght@400;700&display=swap');

/* ═══════════════════════ 皮肤变量 ═════════════════════════════════════════ */
:root, [data-theme="default"] {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --border-light: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --radius: 8px;

  /* 锌版印刷常量（两套皮肤下不变） */
  --rz-bg: #C8B99A;
  --rz-bg-dark: #B8A98A;
  --rz-green: #008F4D;
  --rz-black: #1A1A1A;
  --rz-white: #F4EFE6;
}

[data-theme="retro"] {
  --primary: #1A1A1A;
  --primary-hover: #008F4D;
  --success: #008F4D;
  --error: #C5554A;
  --warning: #D4893B;
  --background: #C8B99A;
  --surface: #F4EFE6;
  --text: #1A1A1A;
  --text-secondary: #6B5F52;
  --border: rgba(26,26,26,0.3);
  --border-light: rgba(26,26,26,0.15);
  --shadow: 3px 3px 0 rgba(26,26,26,0.15);
  --radius: 0;
}

/* ====== Retro: 排版 ====== */
[data-theme="retro"] body {
  font-family: 'Space Grotesk', -apple-system, 'Segoe UI', sans-serif;
}
[data-theme="retro"] h1, [data-theme="retro"] h2, [data-theme="retro"] h3,
[data-theme="retro"] .home-logo, [data-theme="retro"] .section-title {
  font-family: 'Bebas Neue', 'Arial Narrow', 'Impact', sans-serif;
  letter-spacing: 1px;
}

/* ====== Retro: 直角 ====== */
[data-theme="retro"] .card, [data-theme="retro"] .btn, [data-theme="retro"] .input,
[data-theme="retro"] .textarea, [data-theme="retro"] select, [data-theme="retro"] .tag,
[data-theme="retro"] .modal, [data-theme="retro"] .ai-panel, [data-theme="retro"] .auth-card,
[data-theme="retro"] .settings-section, [data-theme="retro"] .mgmt-item,
[data-theme="retro"] .media-item, [data-theme="retro"] .lock-card, [data-theme="retro"] .tab {
  border-radius: 0;
}

/* ====== Retro: 粗黑边框 ====== */
[data-theme="retro"] .card { border: 3px solid var(--text); }
[data-theme="retro"] .btn-outline { border-width: 3px; }
[data-theme="retro"] .input, [data-theme="retro"] .textarea, [data-theme="retro"] select {
  border-width: 2px; border-color: var(--text);
}
[data-theme="retro"] .input:focus, [data-theme="retro"] .textarea:focus,
[data-theme="retro"] select:focus { border-color: var(--primary-hover); }
[data-theme="retro"] .auth-card { border: 3px solid var(--text); }
[data-theme="retro"] .modal { border: 3px solid var(--text); }
[data-theme="retro"] .ai-panel { border: 3px solid var(--text); border-bottom: none; }

/* ====== Retro: 状态色 ====== */
[data-theme="retro"] .btn-outline:hover { background: var(--primary); color: var(--surface); }
[data-theme="retro"] .card:hover { border-color: var(--text); }
[data-theme="retro"] .tag { border-width: 2px; }

/* ====== 新粗野主义皮肤：颜色变量 ====== */
[data-theme="raw"] {
  --primary: #0a0a0a;
  --primary-hover: #333333;
  --success: #4a7c59;
  --error: #c0392b;
  --warning: #e5a83e;
  --background: #f5f5f5;
  --surface: #ffffff;
  --text: #0a0a0a;
  --text-secondary: #555555;
  --border: #0a0a0a;
  --border-light: #0a0a0a;
  --shadow: 6px 6px 0 rgba(10,10,10,0.15);
  --radius: 0;
}

[data-theme="raw"] body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 500; }
[data-theme="raw"] h1, [data-theme="raw"] h2, [data-theme="raw"] h3,
[data-theme="raw"] .home-logo, [data-theme="raw"] .section-title { font-weight: 900; text-transform: uppercase; letter-spacing: -0.02em; }

[data-theme="raw"] .card { border: 3px solid var(--text); border-radius: 0; box-shadow: 6px 6px 0 rgba(10,10,10,0.15); }
[data-theme="raw"] .btn { border-radius: 0; font-weight: 700; }
[data-theme="raw"] .btn-outline { border: 3px solid var(--text); box-shadow: 4px 4px 0 var(--text); }
[data-theme="raw"] .btn-outline:hover { box-shadow: 2px 2px 0 var(--text); transform: translate(2px,2px); }
[data-theme="raw"] .input, [data-theme="raw"] .textarea, [data-theme="raw"] select { border-radius: 0; border: 3px solid var(--text); }
[data-theme="raw"] .auth-card { border-radius: 0; border: 3px solid var(--text); box-shadow: 6px 6px 0 var(--text); }
[data-theme="raw"] .settings-section { border-radius: 0; border: 3px solid var(--text); box-shadow: 4px 4px 0 var(--text); }
[data-theme="raw"] .modal { border-radius: 0; border: 3px solid var(--text); box-shadow: 8px 8px 0 var(--text); }
[data-theme="raw"] .ai-panel { border-radius: 0; border: 3px solid var(--text); }
[data-theme="raw"] .tag { border-radius: 0; border-width: 2px; }
[data-theme="raw"] .tag--life { border-color: #4a7c59; color: #4a7c59; }
[data-theme="raw"] .tag--work { border-color: #0a0a0a; }
[data-theme="raw"] .tag--idea { border-color: #e5a83e; color: #e5a83e; }
[data-theme="raw"] .tag--todo { border-color: #c0392b; color: #c0392b; }
[data-theme="raw"] .tab { border-radius: 0; }
[data-theme="raw"] .fab { border-radius: 4px; font-weight: 700; }
[data-theme="raw"] .toast { border: 3px solid var(--text); border-radius: 0; }
[data-theme="raw"] .lock-card { border: 3px solid var(--text); border-radius: 0; box-shadow: 6px 6px 0 rgba(10,10,10,0.15); }
[data-theme="raw"] .compose-note-item { border-width: 2px; border-radius: 0; }
[data-theme="raw"] .compose-bar { border-top: 3px solid var(--text); }
[data-theme="raw"] .theme-option { border-radius: 0; border-width: 3px; }

/* ====== 珊瑚暖调皮肤：颜色变量 ====== */
[data-theme="coral"] {
  --primary: #E85D5D;
  --primary-hover: #D44A4A;
  --success: #2D8A6E;
  --error: #E85D5D;
  --warning: #e5a83e;
  --background: #F5F0E8;
  --surface: #ffffff;
  --text: #1A1A1A;
  --text-secondary: #6B6B6B;
  --border: #d0c8b8;
  --border-light: #d0c8b8;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 6px;
}

[data-theme="coral"] body { font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif; }
[data-theme="coral"] h1, [data-theme="coral"] h2, [data-theme="coral"] h3,
[data-theme="coral"] .home-logo, [data-theme="coral"] .section-title {
  font-family: 'Bebas Neue', 'Arial Narrow', sans-serif; letter-spacing: 1px;
}

[data-theme="coral"] .card:hover { border-color: var(--primary); background: rgba(232,93,93,0.03); }
[data-theme="coral"] .btn-outline:hover { background: var(--primary); color: #fff; }
[data-theme="coral"] .input:focus, [data-theme="coral"] .textarea:focus, [data-theme="coral"] select:focus { border-color: var(--primary); }
[data-theme="coral"] .ai-style-btn:hover { border-color: var(--primary); background: rgba(232,93,93,0.06); color: var(--primary); }
[data-theme="coral"] .tab--active { color: var(--primary); border-bottom-color: var(--primary); }
[data-theme="coral"] .section-title { color: var(--primary); }
[data-theme="coral"] .toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
[data-theme="coral"] .compose-note-item:has(input:checked) { border-color: var(--primary); background: rgba(232,93,93,0.06); }
[data-theme="coral"] .theme-option.active { border-color: var(--primary); background: rgba(232,93,93,0.06); color: var(--primary); }

/* ====== 模版拓印皮肤：颜色变量 ====== */
[data-theme="stencil"] {
  --primary: #0a0a0a;
  --primary-hover: #A06A3C;
  --success: #2D7E73;
  --error: #C73B7A;
  --warning: #EE7A2E;
  --background: #E2DCC9;
  --surface: #F4EFE0;
  --text: #0a0a0a;
  --text-secondary: rgba(0,0,0,0.5);
  --border: rgba(0,0,0,0.2);
  --border-light: rgba(0,0,0,0.1);
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 14px;
}

[data-theme="stencil"] body { font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif; }
[data-theme="stencil"] h1, [data-theme="stencil"] h2, [data-theme="stencil"] h3,
[data-theme="stencil"] .home-logo, [data-theme="stencil"] .section-title {
  font-family: 'Stardos Stencil', 'Bebas Neue', serif; font-weight: 700; letter-spacing: -0.01em;
}

[data-theme="stencil"] .btn { border-radius: 14px; }
[data-theme="stencil"] .card { border-radius: 18px; }
[data-theme="stencil"] .auth-card { border-radius: 18px; }
[data-theme="stencil"] .settings-section { border-radius: 18px; }
[data-theme="stencil"] .input, [data-theme="stencil"] .textarea, [data-theme="stencil"] select { border-radius: 12px; }
[data-theme="stencil"] .tag { border-radius: 10px; }
[data-theme="stencil"] .ai-panel { border-radius: 18px 18px 0 0; }
[data-theme="stencil"] .modal { border-radius: 18px; }
[data-theme="stencil"] .lock-card { border-radius: 18px; }
[data-theme="stencil"] .compose-note-item { border-radius: 14px; }
[data-theme="stencil"] .theme-option { border-radius: 14px; }

[data-theme="stencil"] .card:hover { border-color: var(--primary-hover); background: rgba(160,106,60,0.04); }
[data-theme="stencil"] .btn-outline:hover { background: var(--primary-hover); color: #fff; }
[data-theme="stencil"] .ai-style-btn:hover { border-color: var(--primary-hover); background: rgba(160,106,60,0.06); }
[data-theme="stencil"] .tab--active { color: var(--primary-hover); border-bottom-color: var(--primary-hover); }
[data-theme="stencil"] .toggle input:checked + .toggle-slider { background: var(--primary-hover); border-color: var(--primary-hover); }
[data-theme="stencil"] .compose-note-item:has(input:checked) { border-color: var(--primary-hover); background: rgba(160,106,60,0.06); }
[data-theme="stencil"] .theme-option.active { border-color: var(--primary-hover); background: rgba(160,106,60,0.06); color: var(--primary-hover); }

/* ═══════════════════════ RESET ════════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

input, textarea, select, button {
  font-family: inherit; font-size: inherit; color: inherit;
}

input[type="text"], input[type="email"], input[type="password"], textarea {
  -webkit-appearance: none; appearance: none;
  width: 100%; padding: 10px; border: 1px solid #ddd;
  border-radius: 4px; font-size: 16px;
  background: var(--surface); color: var(--text);
}

input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary);
}

button {
  -webkit-appearance: none; appearance: none; cursor: pointer; border: none;
}

select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

a, button, [onclick] { -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--background); color: var(--text); line-height: 1.6; min-height: 100vh;
  -webkit-overflow-scrolling: touch; -webkit-text-size-adjust: 100%;
}

/* ═══════════════════════ BUTTONS ══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: var(--radius); font-size: 15px; font-weight: 500;
  cursor: pointer; transition: all 0.2s; gap: 4px;
}

.btn-primary {
  background: var(--primary); color: white;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
  background: transparent; color: var(--primary); border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-ghost {
  background: transparent; color: var(--text-secondary); border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--border-light); color: var(--text); }

.btn-danger {
  background: none; border: none; color: var(--error); font-size: 14px;
  cursor: pointer; padding: 8px 12px;
}
.btn-danger:hover { text-decoration: underline; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════ LAYOUT ═══════════════════════════════════════════ */
#app {
  max-width: 640px; margin: 0 auto; padding: 24px 20px;
  padding-bottom: 100px; min-height: 100vh;
}

/* ═══════════════════════ TOAST ════════════════════════════════════════════ */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-100px);
  background: var(--text); color: var(--surface); padding: 10px 24px;
  border-radius: var(--radius); font-size: 0.8rem; z-index: 999;
  transition: transform 0.3s ease; pointer-events: none; white-space: nowrap;
  letter-spacing: 0.04em;
}
.toast--show { transform: translateX(-50%) translateY(0); }

[data-theme="retro"] .toast { border: 2px solid var(--text); }

/* ═══════════════════════ ANIMATIONS ═══════════════════════════════════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.fade-in { animation: fadeIn 0.4s ease both; }

/* ═══════════════════════ HOME PAGE ════════════════════════════════════════ */
.home-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.home-brand { display: flex; flex-direction: column; }
.home-logo { font-size: 1.5rem; font-weight: 700; color: var(--text); letter-spacing: 0.03em; }
.home-tagline { font-size: 0.75rem; color: var(--text-secondary); letter-spacing: 0.05em; }
.home-actions { display: flex; align-items: center; gap: 8px; }
.home-user { font-size: 0.8rem; color: var(--text-secondary); }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 10px 20px; font-size: 0.9rem; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s;
}
.tab--active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
  display: inline-block; background: var(--border-light); color: var(--text-secondary);
  padding: 0 6px; border-radius: 10px; font-size: 0.7rem; margin-left: 4px;
}

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; align-items: stretch; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: all 0.2s; overflow: hidden;
}
.card:hover { border-color: var(--primary); }
.card-body { flex: 1; padding: 14px 16px; cursor: pointer; min-width: 0; }
.card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; color: var(--text); }
.card-text {
  font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.card-time { font-size: 0.7rem; color: var(--text-secondary); }
.card-delete {
  display: flex; align-items: flex-start; padding: 10px 12px; background: none;
  border: none; color: var(--text-secondary); font-size: 1rem; cursor: pointer;
  opacity: 0.5; transition: opacity 0.2s;
}
.card-delete:hover { opacity: 1; color: var(--error); }

/* Tags */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius);
  font-size: 0.7rem; font-weight: 500; border: 1px solid var(--border);
  letter-spacing: 0.04em;
}
.tag--life { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.tag--work { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
.tag--idea { color: #ca8a04; border-color: #fde68a; background: #fefce8; }
.tag--todo { color: #dc2626; border-color: #fecaca; background: #fef2f2; }
.tag--ai { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }

[data-theme="retro"] .tag--life { color: #008F4D; border-color: #008F4D; background: rgba(0,143,77,0.08); }
[data-theme="retro"] .tag--work { color: #1A1A1A; border-color: #1A1A1A; background: rgba(0,0,0,0.06); }
[data-theme="retro"] .tag--idea { color: #D4893B; border-color: #D4893B; background: rgba(212,137,59,0.08); }
[data-theme="retro"] .tag--todo { color: #C5554A; border-color: #C5554A; background: rgba(197,85,74,0.08); }
[data-theme="retro"] .tag--ai { color: #6B5F52; border-color: #6B5F52; background: rgba(107,95,82,0.08); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-secondary); }
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.85rem; }

/* FAB */
.fab-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 12px; z-index: 100; }
.fab {
  width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 1.4rem; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2); transition: all 0.2s;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.fab--primary { background: var(--primary); color: #fff; }
.fab--secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); }
.fab--theme { background: var(--surface); color: var(--text); border: 2px solid var(--border); font-size: 1rem; }

[data-theme="retro"] .fab { border-radius: 4px; }

/* ═══════════════════════ AUTH PAGES ═══════════════════════════════════════ */
.auth-page {
  display: flex; align-items: center; justify-content: center; min-height: 80vh;
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 12px;
  padding: 36px 28px; box-shadow: var(--shadow); animation: fadeInUp 0.5s ease;
}
.auth-card h2 {
  font-size: 1.4rem; text-align: center; margin-bottom: 4px; color: var(--text);
}
.auth-subtitle { text-align: center; color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 24px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 0.8rem; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.auth-field .input { width: 100%; }
.auth-actions { margin-top: 20px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 0.8rem; color: var(--text-secondary); }
.auth-link a { color: var(--primary); cursor: pointer; text-decoration: none; }
.auth-link a:hover { text-decoration: underline; }

/* ═══════════════════════ NOTE EDITOR ══════════════════════════════════════ */
.note-page { max-width: 640px; margin: 0 auto; }
.note-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.note-header-title { font-weight: 600; font-size: 0.95rem; color: var(--text-secondary); }
.note-header-actions { display: flex; gap: 4px; align-items: center; }
.note-header-actions .btn { font-size: 0.75rem; }
.note-body { display: flex; flex-direction: column; gap: 12px; }
.note-field { width: 100%; }
.note-field-row { display: flex; gap: 8px; }
.note-field-row .input { flex: 1; }
.note-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-toolbar .select { padding: 8px 28px 8px 10px; font-size: 0.8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.note-textarea {
  width: 100%; min-height: 200px; padding: 14px; font-size: 1rem; line-height: 2;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); resize: vertical;
  font-family: 'Noto Serif SC', Georgia, 'Times New Roman', serif;
}

/* ═══════════════════════ AI PANEL (bottom slide-up) ═══════════════════════ */
.ai-panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.25); z-index: 200;
  display: none;
}
.ai-panel-overlay--show { display: block; }
.ai-panel {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
  width: 100%; max-width: 640px; background: var(--surface); z-index: 201;
  border-radius: 12px 12px 0 0; box-shadow: 0 -2px 16px rgba(0,0,0,0.12);
  padding: 20px; transition: transform 0.3s ease;
}
.ai-panel--open { transform: translateX(-50%) translateY(0); }
.ai-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.ai-panel-header h3 { font-size: 1rem; color: var(--text); }
.ai-panel-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ai-style-btn {
  padding: 10px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: 0.85rem; cursor: pointer;
  transition: all 0.2s; text-align: center;
}
.ai-style-btn:hover { border-color: var(--primary); background: #f0f7ff; color: var(--primary); }

[data-theme="retro"] .ai-style-btn:hover { border-color: var(--primary-hover); background: rgba(0,143,77,0.06); color: var(--text); }

/* ═══════════════════════ MEDIA GRID ═══════════════════════════════════════ */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.media-item {
  position: relative; border: 1px solid var(--border-light);
  overflow: hidden; aspect-ratio: 1; border-radius: var(--radius);
}
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item.media-audio {
  grid-column: 1 / -1; aspect-ratio: auto; padding: 8px 12px;
  display: flex; align-items: center; gap: 8px;
}
.media-item.media-audio audio { flex: 1; max-width: 100%; }
.media-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px;
  border: none; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff;
  font-size: 0.7rem; cursor: pointer; display: flex; align-items: center;
  justify-content: center; line-height: 1; z-index: 1;
}
.media-indicator { font-size: 0.7rem; }
.recording { color: var(--error); animation: pulse 1s ease infinite; }

/* ═══════════════════════ ARTICLE PAGE ═════════════════════════════════════ */
.article-page { max-width: 640px; margin: 0 auto; }
.article-content { margin-bottom: 24px; }
.article-head { margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.article-title { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.article-meta { font-size: 0.8rem; color: var(--text-secondary); }
.article-body {
  font-size: 1rem; line-height: 2; white-space: pre-wrap; color: var(--text);
  font-family: 'Noto Serif SC', Georgia, serif;
}
.article-edit { margin-top: 16px; }
.article-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }

/* ═══════════════════════ COMPOSE PAGE ═════════════════════════════════════ */
.compose-page { max-width: 640px; margin: 0 auto; }
.compose-mode-tabs { display: flex; gap: 0; margin-bottom: 12px; }
.compose-filters { margin-bottom: 12px; }
.compose-filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.compose-filter-row label { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; }
.compose-filter-row .input,
.compose-filter-row .select { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 0.85rem; }
.compose-select-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.compose-note-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; margin-bottom: 80px; }
.compose-note-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: all 0.2s;
}
.compose-note-item:hover { border-color: var(--primary); }
.compose-note-item:has(input:checked) { border-color: var(--primary); background: #f0f7ff; }
.compose-note-check { width: 18px; height: 18px; cursor: pointer; flex-shrink: 0; accent-color: var(--primary); }
.compose-note-info { flex: 1; min-width: 0; }
.compose-note-title { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text); }
.compose-note-meta { display: block; font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }
.compose-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 640px; display: flex; justify-content: space-between;
  align-items: center; padding: 14px 20px; background: var(--surface);
  border-top: 1px solid var(--border); font-size: 0.9rem; z-index: 50;
}
.compose-result-text { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.8; }

[data-theme="retro"] .compose-note-item:has(input:checked) { background: rgba(0,0,0,0.04); }
[data-theme="retro"] .compose-bar { border-top: 2px solid var(--text); }

/* ═══════════════════════ MODAL ════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300; display: none;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 90%; max-width: 520px; max-height: 80vh; background: var(--surface);
  border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 301; display: flex; flex-direction: column;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ═══════════════════════ SETTINGS PAGE ════════════════════════════════════ */
.settings-page { max-width: 640px; margin: 0 auto; }
.settings-content { display: flex; flex-direction: column; gap: 16px; }
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; box-shadow: var(--shadow);
}
.section-title {
  font-size: 0.85rem; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 12px;
}
.settings-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 0.9rem;
}
.settings-item + .settings-item { border-top: 1px solid var(--border-light); }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 22px;
  transition: 0.3s; border: 1px solid var(--border);
}
.toggle-slider::before {
  content: ''; position: absolute; height: 16px; width: 16px; left: 2px; bottom: 2px;
  background: #fff; border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); border-color: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Theme selector */
.theme-options { display: flex; gap: 8px; margin-top: 8px; }
.theme-option {
  flex: 1; padding: 10px; border: 2px solid var(--border); border-radius: var(--radius);
  text-align: center; cursor: pointer; transition: all 0.2s; background: var(--surface);
  font-size: 0.85rem; font-weight: 500;
}
.theme-option:hover { border-color: var(--primary); }
.theme-option.active { border-color: var(--primary); background: #f0f7ff; color: var(--primary); }

[data-theme="retro"] .theme-option.active { background: rgba(0,0,0,0.06); color: var(--text); }

/* ═══════════════════════ LOCK SCREEN ═════════════════════════════════════ */
.lock-overlay {
  position: fixed; inset: 0; background: var(--background); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.3s ease;
}
.lock-card {
  width: 100%; max-width: 320px; padding: 32px 24px; text-align: center;
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow);
}
.lock-icon { font-size: 2.5rem; margin-bottom: 16px; }
.lock-title { font-size: 1.2rem; color: var(--text); margin-bottom: 20px; letter-spacing: 0.03em; }
.lock-input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 1rem; text-align: center;
  background: var(--surface); color: var(--text); outline: none;
  letter-spacing: 0.15em;
}
.lock-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.lock-error { font-size: 0.75rem; color: var(--error); margin-top: 8px; min-height: 1.2em; }

[data-theme="retro"] .lock-card { border: 3px solid var(--text); }

/* ═══════════════════════ LIST MANAGEMENT ═════════════════════════════════ */
.mgmt-list { display: flex; flex-direction: column; gap: 6px; }
.mgmt-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--background); border: 1px solid var(--border-light);
  border-radius: var(--radius); font-size: 0.85rem; font-weight: 300;
}
.mgmt-item-name { flex: 1; }
.mgmt-item-actions { display: flex; gap: 4px; }
.mgmt-add-row { display: flex; gap: 8px; margin-top: 8px; }
.mgmt-add-row .input { flex: 1; }
.mgmt-badge {
  display: inline-block; padding: 1px 6px; font-size: 0.65rem;
  color: var(--text-secondary); border: 1px solid var(--border-light);
  border-radius: var(--radius); margin-left: 8px; letter-spacing: 0.05em;
}

/* ═══════════════════════ RESPONSIVE ═══════════════════════════════════════ */
@media (max-width: 480px) {
  #app { padding: 16px 14px; padding-bottom: 90px; }
  .auth-card { padding: 28px 18px; }
  .note-textarea { min-height: 160px; font-size: 0.95rem; }
  .ai-panel-styles { grid-template-columns: repeat(2, 1fr); }
  .note-header-actions .btn { padding: 4px 8px; font-size: 0.7rem; }
}

@media (min-width: 768px) {
  .card-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .note-textarea { min-height: 300px; }
  .compose-note-list { max-height: calc(100vh - 300px); }
}

/* ═══════════════════════ iOS SAFARI FIXES ═════════════════════════════════ */
@supports (-webkit-touch-callout: none) {
  input[type="text"], input[type="email"], input[type="password"], textarea { font-size: 16px; }
}
