/* SINGAM: shared visual system for every dashboard section. */
:root {
  color-scheme: dark;
  --bg: #0B0D0B;
  --panel: #191C18;
  --surface: #111510;
  --line: #494332;
  --gold: #D9B76E;
  --gold-light: #F0D494;
  --text: #F4F0E8;
  --muted: #A8A99F;
  --radius: 18px;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 280px; background: var(--bg); }
body { margin: 0; background: radial-gradient(ellipse at 85% 0, #D9B76E09, transparent 42rem), var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; transition: background-color .18s, border-color .18s, color .18s, box-shadow .18s; }
button:disabled { cursor: default; }
button:disabled:not(.calendar-day):not(.day-column) { color: var(--muted); background: var(--surface); }
:where(button, a, input, select):focus-visible { outline: 2px solid var(--gold-light); outline-offset: 4px; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; vertical-align: middle; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-size: clamp(21px, 2.1vw, 26px); font-weight: 600; letter-spacing: -.6px; line-height: 1.3; }
h3 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.gold { color: var(--gold); }
.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: 2.1px; }

/* Brand and hero */
.topbar { max-width: 1280px; margin: auto; padding: 25px 48px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; gap: 14px; align-items: center; font-size: 24px; font-weight: 750; letter-spacing: 5px; }
.brand small { display: block; color: var(--muted); font-size: 8px; font-weight: 500; letter-spacing: 2px; }
.lion { flex: 0 0 48px; object-fit: contain; }
.local-badge { color: var(--muted); font-size: 10px; letter-spacing: 1.5px; }
.local-badge i { display: inline-block; width: 6px; height: 6px; margin-right: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px #D9B76E50; }
main { max-width: 1232px; margin: auto; padding: 0 48px; }
.intro { display: flex; align-items: center; justify-content: space-between; gap: 30px; padding: 58px 0 42px; }
h1 { margin: 0 0 21px; font-size: clamp(35px, 4.3vw, 58px); font-weight: 550; letter-spacing: -2px; line-height: 1.13; }
h1 em { font-family: Georgia, "Times New Roman", serif; color: var(--gold); font-weight: 400; }
.intro .muted { margin-bottom: 0; }
.hero-portrait { flex: 0 0 242px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.hero-portrait img { display: block; width: 242px; height: 242px; border: 2px solid var(--gold); border-radius: 50%; object-fit: cover; object-position: center; background: var(--panel); box-shadow: 0 0 0 4px #D9B76E08, 0 14px 36px #0005; }
.hero-portrait small { color: var(--gold); font-size: 7px; letter-spacing: 1.5px; text-align: center; }

/* Matching dashboard cards */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stat, .panel, .quote-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px #0002; }
.stat { min-height: 182px; padding: 25px 28px; position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; top: 0; left: 28px; right: 28px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.stat > span { color: var(--muted); font-size: 10px; letter-spacing: 1.6px; }
.stat strong { display: block; margin: 6px 0; color: var(--gold-light); font-size: 43px; font-weight: 500; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); font-size: 12px; }
.stat strong small { font-size: 16px; }
.track { height: 5px; margin: 13px 0; overflow: hidden; border-radius: 6px; background: #34382E; }
.track > div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #AA8646, var(--gold-light)); transition: width .3s; }
.habit-section { margin: 42px 0 30px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 23px; }
h2 span { display: inline-block; vertical-align: middle; margin-left: 7px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 7px; background: #D9B76E0D; color: var(--gold); font-size: 12px; }

/* Controls share explicit dark surfaces and readable foreground colors. */
.primary, .secondary, .danger, .import-label { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 11px 19px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-weight: 650; line-height: 1.4; text-align: center; }
.primary { background: linear-gradient(120deg, var(--gold-light), var(--gold)); border-color: var(--gold); color: #17180F; box-shadow: 0 4px 16px #D9B76E10; }
.secondary, .import-label { color: var(--text); background: #252A22; }
.danger { background: #6E302D; color: #FFF4EC; border-color: #B96B60; }
.icon-button { min-width: 44px; min-height: 44px; padding: 6px 10px; background: var(--surface); color: var(--gold); font-size: 20px; }
.text-button { padding: 4px 10px; background: transparent; color: var(--gold); border-color: transparent; font-size: 12px; }
.date-toolbar { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); margin-bottom: 12px; }
.date-toolbar > div { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.date-toolbar strong { font-size: 13px; font-weight: 600; }
#habit-list { display: grid; gap: 10px; }
.habit-row { display: flex; align-items: center; gap: 17px; padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); transition: border-color .18s, background-color .18s; }
.habit-row.completed { background: #1C2119; border-color: #675C3B; }
.check { appearance: none; -webkit-appearance: none; display: grid; place-content: center; flex: 0 0 30px; width: 30px; height: 30px; margin: 0; background: var(--surface); border: 1px solid #A08A59; border-radius: 9px; cursor: pointer; }
.check:checked { background: var(--gold); border-color: var(--gold); }
.check:checked::after { content: ""; width: 7px; height: 13px; border: solid #17180F; border-width: 0 2px 2px 0; transform: translateY(-2px) rotate(45deg); }
.habit-info { flex: 1; min-width: 0; }
.habit-name { margin: 0; color: var(--text); font-size: 16px; font-weight: 550; overflow-wrap: anywhere; }
.completed .habit-name { color: var(--muted); text-decoration: line-through; text-decoration-color: #A8A99F80; }
.habit-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 11px; }
.streak { color: var(--gold); }
.row-actions { display: flex; gap: 7px; }
.row-actions .icon-button { min-width: 58px; font-size: 12px; color: var(--text); background: #252A22; }
.empty { padding: 40px 20px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; background: var(--panel); }
.empty p { color: var(--muted); }
.empty img { margin-bottom: 6px; }

/* Weekly rhythm */
.bottom-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }
.panel, .quote-panel { min-width: 0; padding: 30px; }
#week-range { color: var(--muted); font-size: 11px; text-align: right; }
.week-chart { display: flex; justify-content: space-between; align-items: stretch; gap: 12px; height: 162px; }
.day-column { display: flex; flex: 1; flex-direction: column; align-items: center; gap: 8px; min-width: 0; padding: 8px 3px; border-color: transparent; border-radius: 9px; background: transparent; color: var(--muted); font-size: 11px; line-height: 1.4; }
.day-column[aria-pressed="true"] { background: #D9B76E0B; border-color: #A08A59; }
.day-column.today { color: var(--gold-light); }
.day-column:disabled { color: #92988A; background: #111510; }
.bar-space { display: flex; align-items: flex-end; flex: 1; min-height: 0; width: 100%; max-width: 32px; border-radius: 5px; background: #2C3228; overflow: hidden; }
.bar-fill { width: 100%; border-radius: 5px; background: linear-gradient(0deg, #A98543, var(--gold)); transition: height .3s; }
.day-column.today .bar-fill { background: linear-gradient(0deg, var(--gold), var(--gold-light)); }
.chart-caption { margin: 18px 0 0; color: var(--muted); font-size: 11px; }
.quote-panel { display: flex; flex-direction: column; justify-content: center; background: radial-gradient(ellipse at top right, #D9B76E0D, transparent 80%), var(--panel); }
.quote-mark { height: 36px; color: var(--gold); font: 64px/1 Georgia, serif; }
.quote-panel > p { margin: 20px 0 24px; font: italic 25px/1.45 Georgia, serif; color: var(--text); }
.quote-panel .eyebrow { margin-bottom: 0; font-size: 9px; }
.v2-section { margin-top: 26px; }
.v2-section > .muted { max-width: 78ch; margin: 12px 0 24px; font-size: 13px; }

/* Monthly history: colors stay explicit in every state, including disabled days. */
.calendar-nav { display: flex; align-items: center; justify-content: center; gap: 12px; }
.calendar-nav strong { min-width: 145px; color: var(--gold-light); text-align: center; font-size: 14px; font-weight: 600; }
.calendar-weekdays, .calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.calendar-weekdays { margin: 0 0 10px; color: var(--muted); text-align: center; font-size: 11px; font-weight: 600; }
.calendar-day { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 0; min-height: 100px; padding: 12px 6px; border: 1px solid #4D503E; border-radius: 11px; background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.calendar-day strong { color: inherit; font-size: 17px; font-weight: 600; }
.calendar-day small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.calendar-day[aria-current="date"] strong { text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 5px; }
.calendar-day.full { background: #24291C; border-color: #9C834B; box-shadow: inset 0 -3px var(--gold); }
.calendar-day.full small { color: #E2CB97; }
.calendar-day[aria-pressed="true"] { background: #3A3120; border-color: var(--gold-light); box-shadow: inset 0 0 0 1px var(--gold-light); color: #FFF4D9; }
.calendar-day[aria-pressed="true"] small { color: #EAD7AE; }
.calendar-day:disabled { color: #969D8D; background: #141812; border-color: #353B2F; border-style: dashed; }
.calendar-day:disabled small { color: #969D8D; }
#day-details { margin-top: 24px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 13px; overflow-wrap: anywhere; }
#day-details h3 { margin: 0 0 12px; color: var(--gold-light); font-size: 14px; }
#day-details ul { margin: 0; padding-left: 20px; color: var(--text); }
#day-details li { padding: 4px 0; }
#day-details li::marker { color: var(--gold); }

/* Achievement shields use the existing original lion artwork. */
.badges { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.badge { position: relative; padding: 24px; border: 1px solid #4D503E; border-radius: 14px; background: var(--surface); }
.badge::before { content: ""; display: block; width: 38px; height: 44px; margin-bottom: 18px; border: 1px solid #7C7E6E; border-radius: 12px 12px 18px 18px; background: url("logo.svg") center / 32px no-repeat, #242820; filter: grayscale(1); }
.badge h3 { margin: 0 0 16px; color: #C6C8BA; font-size: 16px; }
.badge p { margin: 12px 0; color: var(--text); font-size: 12px; }
.badge small { display: block; color: var(--muted); font-size: 12px; line-height: 1.6; }
.badge.unlocked { border-color: #A48A50; background: linear-gradient(135deg, #D9B76E0F, transparent), var(--surface); }
.badge.unlocked::before { border-color: var(--gold); background-color: #3A3120; filter: none; box-shadow: 0 0 24px #D9B76E12; }
.badge.unlocked h3 { color: var(--gold-light); }
progress { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 5px; overflow: hidden; background: #353C2F; accent-color: var(--gold); }
progress::-webkit-progress-bar { background: #353C2F; border-radius: 5px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #A98543, var(--gold-light)); border-radius: 5px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 5px; }

/* Settings and dialogs */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; margin-top: 24px; }
.settings-grid > div { min-width: 0; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.settings-grid h3 { margin: 0 0 18px; color: var(--gold-light); }
.settings-grid p { margin: 14px 0 0; font-size: 12px; line-height: 1.8; }
.settings-grid label { display: block; margin-bottom: 8px; color: var(--text); font-size: 12px; }
.button-group { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
input:not(.check), select { width: 100%; min-width: 0; min-height: 46px; padding: 12px 14px; border: 1px solid #76765F; border-radius: 9px; background: #0E120D; color: var(--text); }
input::placeholder { color: var(--muted); opacity: 1; }
input[type="time"] { max-width: 230px; color-scheme: dark; }
input[type="file"] { font-size: 12px; padding: 10px; }
input[type="file"]::file-selector-button { margin-right: 10px; padding: 9px 12px; border: 1px solid #8F7A4D; border-radius: 6px; background: #2D3023; color: var(--gold-light); font: inherit; cursor: pointer; }
.settings-grid .import-label { display: inline-flex; margin: 0; color: var(--text); font-size: 13px; cursor: pointer; }
#install-app, #update-app { margin-top: 16px; }
:where(#reminder-status, #backup-status, #pwa-status):not(:empty) { padding-left: 12px; border-left: 2px solid var(--gold); color: var(--gold-light); }
footer { display: flex; justify-content: space-between; gap: 16px; padding: 34px 0; color: var(--muted); font-size: 11px; }
dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 28px; border: 1px solid #9B8149; border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: 0 24px 90px #0009; }
dialog::backdrop { background: #030603CB; backdrop-filter: blur(7px); }
dialog .section-heading { margin-bottom: 14px; }
dialog label { display: block; margin: 20px 0 8px; font-size: 13px; color: var(--text); }
dialog p { font-size: 13px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.warning { margin-bottom: 24px; padding: 16px 20px; border: 1px solid var(--gold); border-radius: 12px; background: #302919; color: #F0D494; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

@media (hover: hover) {
  button:not(:disabled):hover, .import-label:hover { border-color: var(--gold); background-color: #353622; color: var(--gold-light); }
  .primary:not(:disabled):hover { background: var(--gold-light); color: #17180F; box-shadow: 0 5px 22px #D9B76E24; }
  .danger:not(:disabled):hover { background: #873C35; border-color: #E5A091; color: #FFF4EC; }
  .habit-row:hover { border-color: #8C784C; }
  .calendar-day:not(:disabled):hover { border-color: var(--gold); background: #34301F; color: var(--text); }
  .brand:hover { color: var(--gold-light); }
}
@media (max-width: 900px) {
  main { padding: 0 28px; }
  .topbar { padding: 22px 28px; }
  .hero-portrait { flex-basis: 192px; }
  .hero-portrait img { width: 192px; height: 192px; }
  .hero-portrait small { font-size: 7px; letter-spacing: 1px; }
  .stat { padding: 22px 18px; }
  .panel, .quote-panel { padding: 24px; }
  .badges { gap: 12px; }
  .badge { padding: 18px; }
  .settings-grid { gap: 16px; }
  .settings-grid > div { padding: 18px; }
}
@media (max-width: 650px) {
  main { padding: 0 16px; }
  .topbar { padding: 18px 16px; }
  .brand { font-size: 20px; letter-spacing: 4px; gap: 10px; }
  .brand small { font-size: 7px; letter-spacing: 1.5px; }
  .local-badge { font-size: 0; }
  .local-badge i { margin: 0; }
  .intro { flex-wrap: wrap; gap: 24px; padding: 34px 0 30px; }
  .intro > div:first-child { flex: 1 1 100%; }
  h1 { font-size: clamp(32px, 8.7vw, 48px); letter-spacing: -1.3px; }
  .intro .muted { font-size: 13px; }
  .intro .eyebrow { font-size: 9px; letter-spacing: 1.5px; }
  .hero-portrait { flex: 0 0 100%; gap: 14px; }
  .hero-portrait img { width: clamp(144px, 42vw, 180px); height: auto; aspect-ratio: 1; }
  .hero-portrait small { font-size: 8px; letter-spacing: 1px; }
  .stats { gap: 8px; }
  .stat { min-height: 155px; padding: 17px 10px; border-radius: 12px; }
  .stat::before { left: 12px; right: 12px; }
  .stat > span { display: block; min-height: 32px; font-size: 10px; letter-spacing: .4px; }
  .stat strong { font-size: 28px; margin: 3px 0 8px; }
  .stat strong small { font-size: 12px; }
  .stat > small { display: block; font-size: 10px; line-height: 1.5; }
  .track { margin: 10px 0; }
  .habit-section { margin-top: 30px; }
  .section-heading { flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
  h2 { font-size: 21px; }
  .primary, .secondary, .danger, .import-label { padding: 11px 14px; }
  .date-toolbar { gap: 8px; padding: 8px; }
  .date-toolbar > div { flex-wrap: wrap; gap: 0; }
  .date-toolbar strong { font-size: 12px; }
  .habit-row { gap: 12px; padding: 16px 12px; }
  .habit-name { font-size: 14px; }
  .habit-meta { gap: 4px 10px; font-size: 10px; }
  .row-actions { flex-direction: column; gap: 6px; }
  .row-actions .icon-button { min-width: 54px; padding: 6px 8px; font-size: 11px; }
  .bottom-grid, .badges, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .panel, .quote-panel { padding: 20px 16px; border-radius: 14px; }
  .quote-panel > p { font-size: 24px; }
  .week-chart { gap: 6px; }
  .v2-section { margin-top: 20px; }
  .calendar-nav { width: 100%; justify-content: space-between; gap: 6px; }
  .calendar-nav strong { min-width: 0; font-size: 14px; }
  .calendar-weekdays, .calendar { gap: 4px; }
  .calendar-weekdays { font-size: 10px; }
  .calendar-day { min-height: 79px; padding: 8px 1px; gap: 5px; border-radius: 7px; }
  .calendar-day strong { font-size: 14px; }
  .calendar-day small { font-size: 10px; }
  .calendar-day:disabled small { max-width: 100%; font-size: 10px; overflow-wrap: anywhere; }
  #day-details { padding: 16px; }
  .badge { padding: 22px; }
  .badge::before { float: right; margin: 0 0 12px 10px; }
  .badge small { clear: both; }
  .settings-grid { gap: 14px; margin-top: 18px; }
  .settings-grid > div { padding: 18px 14px; }
  footer { flex-direction: column; gap: 7px; padding: 28px 0; }
  dialog { padding: 22px; }
}
@media (max-width: 360px) {
  main { padding: 0 12px; }
  .calendar-weekdays, .calendar { gap: 3px; }
  .calendar-day small { font-size: 9px; }
  .calendar-day:disabled small { font-size: 9px; }
  .panel, .quote-panel { padding: 18px 12px; }
  .stat { padding: 15px 8px; }
  .stat strong { font-size: 25px; }
}
@media (prefers-reduced-motion: no-preference) {
  .intro, .stats { animation: arrive .45s ease-out both; }
  @keyframes arrive { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Authentication uses the existing black-and-gold theme. */
.auth-panel { width: min(480px, calc(100% - 32px)); margin: 48px auto; }
.auth-panel h1 { font-size: clamp(30px, 6vw, 40px); letter-spacing: -1px; }
.auth-panel label { display: block; margin: 18px 0 8px; font-size: 13px; }
.auth-panel .primary { width: 100%; margin-top: 22px; }
.auth-panel p { font-size: 13px; }
#auth-status { color: var(--gold-light); overflow-wrap: anywhere; }
.account-controls { display: flex; align-items: center; gap: 12px; min-width: 0; }
#account-email { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .account-controls { flex: 1 1 100%; justify-content: space-between; }
}
