:root {
  --ink: #2d2a26;
  --paper: #fdf8f2;
  --paper-raised: #ffffff;
  --line: #ece3d6;
  --muted: #8a8175;
  --accent: #e07a5f;
  --accent-tint: #fbe7e0;
  --familial: #4caf50;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(45,42,38,.06), 0 8px 28px rgba(45,42,38,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f0ece5; --paper: #1c1a17; --paper-raised: #26221d;
    --line: #3a352d; --muted: #a49a8c; --accent: #ef8f74; --accent-tint: #3a2820;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: -apple-system, 'Segoe UI', Inter, sans-serif; background: var(--paper); color: var(--ink); }
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; font-weight: 700; margin: 0 0 4px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; flex: 1; }
input, select, textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-raised); color: var(--ink); }
.screen { min-height: 100vh; }

/* LOGIN */
#screen-login { display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--paper-raised); border-radius: 20px; box-shadow: var(--shadow); padding: 40px 34px; width: 100%; max-width: 360px; text-align: center; }
.login-emoji { font-size: 46px; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
#login-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-error { color: #c0392b; font-size: 13px; margin: 0; }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 999px; padding: 11px 20px; font-weight: 700; cursor: pointer; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; color: var(--ink); }
.btn-danger { background: #fbe7e0; color: #c0392b; border: none; border-radius: 999px; padding: 9px 16px; cursor: pointer; font-weight: 600; }
.btn-fab { background: var(--accent); color: #fff; border: none; border-radius: 999px; width: 38px; height: 38px; font-size: 20px; cursor: pointer; line-height: 1; }

/* TOPBAR */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; background: var(--paper-raised); border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-family: Georgia, serif; font-weight: 700; font-size: 19px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.search-input { width: 200px; }

.content { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.panel-sub { font-size: 12px; color: var(--muted); font-weight: 400; font-family: inherit; }

/* UPCOMING */
.upcoming-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upcoming-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; background: var(--paper); cursor: pointer; }
.upcoming-item:hover { background: var(--accent-tint); }
.upcoming-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.upcoming-name { font-weight: 700; flex: 1; }
.upcoming-date { color: var(--muted); font-size: 13px; }
.upcoming-age { font-size: 12px; color: var(--accent); font-weight: 700; }
.upcoming-empty { color: var(--muted); font-size: 13.5px; font-style: italic; padding: 10px 0; }
.alert-toggle { flex-shrink: 0; width: 16px; height: 16px; cursor: pointer; }
.alert-toggle:disabled { cursor: not-allowed; opacity: .35; }

/* YEAR NAV */
.scope-filter { display: flex; gap: 8px; margin-bottom: 6px; }
.scope-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.year-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.year-nav h2 { flex: 1; text-align: center; min-width: 140px; }
.view-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* MONTH LIST VIEW */
.month-list { display: flex; flex-direction: column; gap: 6px; }
.month-entry { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); }
.month-entry-day { font-family: Georgia, serif; font-weight: 700; font-size: 18px; width: 30px; text-align: center; }
.month-entry-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.month-entry-name { flex: 1; font-weight: 600; cursor: pointer; }
.month-entry-notconfirmed { font-size: 11px; color: #c0392b; }
.month-empty { color: var(--muted); font-size: 13.5px; font-style: italic; padding: 14px 0; text-align: center; }

/* YEAR GRID VIEW */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; }
.year-grid-month { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.year-grid-month h4 { margin: 0 0 8px; font-family: Georgia, serif; }
.year-grid-item { font-size: 12.5px; display: flex; align-items: center; gap: 6px; padding: 2px 0; }
.year-grid-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* MODAL */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,18,15,.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal { background: var(--paper-raised); border-radius: 16px; padding: 28px; width: 100%; max-width: 480px; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto; }
#form-entry, #modal-settings .modal { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 12px; }
.checkbox-label { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-label input { width: auto; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.spacer { flex: 1; }
.status-badge { background: #fde9d0; color: #a15c00; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center; margin: 0; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .search-input { flex: 1; width: auto; }
  .form-row { flex-direction: column; }
}
