:root {
  color-scheme: dark;
  --bg: #0b1116;
  --surface: #121b22;
  --surface-2: #18242c;
  --line: #2a3943;
  --text: #f1f5f6;
  --muted: #9aaab3;
  --cyan: #63d6d0;
  --yellow: #f2c66d;
  --coral: #f08b78;
  --green: #86c99a;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, textarea, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; padding-bottom: 78px; }
.topbar, .location-band, .calendar-section, .insight-band { padding-left: max(20px, calc((100vw - 980px) / 2)); padding-right: max(20px, calc((100vw - 980px) / 2)); }
.topbar { min-height: 84px; display: grid; grid-template-columns: 40px 1fr 40px; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); background: #101820; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; background: var(--yellow); color: #111; border-radius: 50%; font-size: 22px; }
.eyebrow, .section-label { margin: 0 0 4px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
h2 { margin: 0; font-size: 20px; letter-spacing: 0; }
p { line-height: 1.55; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: transparent; border-radius: 6px; cursor: pointer; font-size: 20px; }
.icon-button:hover { background: var(--surface-2); }

.location-band { display: flex; justify-content: space-between; gap: 24px; align-items: end; padding-top: 24px; padding-bottom: 22px; background: #101820; }
.location-button { border: 0; padding: 0; background: transparent; font-size: 20px; font-weight: 750; display: flex; gap: 8px; align-items: center; cursor: pointer; text-align: left; }
.quick-summary { color: var(--muted); text-align: right; font-size: 14px; }
.quick-summary strong { display: block; color: var(--cyan); font-size: 18px; }
.data-status { margin: 14px auto 0; width: min(980px, calc(100% - 40px)); display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.status-dot.loading { background: var(--yellow); }
.status-dot.error { background: var(--coral); }

.calendar-section { padding-top: 26px; padding-bottom: 28px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.month-controls { display: flex; gap: 8px; align-items: center; }
.secondary-button, .primary-button { min-height: 40px; border-radius: 6px; padding: 0 16px; cursor: pointer; font-weight: 700; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.month-indicator { min-width: 72px; height: 40px; display: grid; place-items: center; color: var(--text); font-size: 14px; font-weight: 800; }
.primary-button { border: 1px solid var(--cyan); background: var(--cyan); color: #071313; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; color: var(--muted); font-size: 12px; margin: 20px 0 12px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.chance-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.excellent { background: var(--cyan); }
.good { background: var(--green); }
.caution { background: var(--yellow); }
.poor { background: #68747b; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays { color: var(--muted); font-size: 12px; text-align: center; padding: 0 0 8px; }
.calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.day-cell { position: relative; min-height: 104px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px; background: #0e161b; text-align: left; cursor: pointer; overflow: hidden; }
.day-cell:hover, .day-cell:focus-visible { background: var(--surface-2); outline: 2px solid var(--cyan); outline-offset: -2px; }
.day-cell.outside { opacity: .28; }
.day-cell.weekend .day-number { color: var(--yellow); }
.day-cell.selected { background: #16272b; }
.day-cell.today { background: #15262a; box-shadow: inset 0 0 0 2px var(--cyan); }
.day-number { font-size: 13px; color: var(--muted); }
.today-label { position: absolute; top: 8px; right: 8px; padding: 2px 5px; border-radius: 3px; background: var(--cyan); color: #071313; font-size: 9px; font-weight: 800; }
.day-score { margin-top: 7px; font-size: 22px; font-weight: 800; }
.day-score.excellent-text { color: var(--cyan); }
.day-score.good-text { color: var(--green); }
.day-score.caution-text { color: var(--yellow); }
.day-score.poor-text { color: #7e8b92; }
.day-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag { padding: 2px 5px; border: 1px solid var(--line); border-radius: 3px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.tag.alert { border-color: #6d4d3d; color: #f0b08c; }
.tag.moon { border-color: #6a6546; color: var(--yellow); }

.insight-band { display: grid; grid-template-columns: 76px 1fr; gap: 18px; align-items: center; padding-top: 22px; padding-bottom: 26px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #121b22; }
.insight-band p:last-child { margin: 6px 0 0; color: var(--muted); }
.moon-visual { width: 68px; aspect-ratio: 1; border-radius: 50%; background: #e9dfb6; box-shadow: inset -20px 0 0 #27313a; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; height: 68px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: rgba(11,17,22,.96); backdrop-filter: blur(12px); z-index: 10; }
.nav-item { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-content: center; gap: 3px; font-size: 11px; }
.nav-item span { font-size: 20px; }
.nav-item.active { color: var(--cyan); }

dialog { color: var(--text); }
.sheet-dialog { width: min(620px, 100%); max-height: 90vh; border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 20px; background: var(--surface); margin: auto auto 0; overflow: auto; }
.compact-dialog { width: min(520px, 100%); }
.sheet-dialog::backdrop { background: rgba(0,0,0,.68); }
.sheet-handle { width: 42px; height: 4px; border-radius: 2px; background: #4a5961; margin: -8px auto 18px; }
.sheet-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.score-hero { display: grid; grid-template-columns: 84px 1fr; gap: 18px; align-items: center; margin: 22px 0; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.score-ring { width: 76px; aspect-ratio: 1; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 7px solid var(--cyan); }
.score-ring strong { font-size: 25px; line-height: 1; }
.score-ring span { color: var(--muted); font-size: 11px; }
.chance-title { font-weight: 800; font-size: 19px; margin: 0 0 4px; }
.score-hero p:last-child { margin: 0; color: var(--muted); }
.condition-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.condition-item { border: 1px solid var(--line); border-radius: 6px; padding: 14px; background: #101820; }
.condition-item header { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.condition-item strong { display: block; margin-top: 8px; font-size: 16px; }
.condition-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.note-field { display: grid; gap: 8px; margin-top: 18px; font-weight: 700; font-size: 13px; }
.note-field textarea { resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: #0c1318; color: var(--text); }
.sheet-actions { display: flex; justify-content: end; gap: 10px; margin-top: 18px; }
.location-options, .saved-notes { display: grid; gap: 8px; margin-top: 18px; }
.location-option, .saved-note { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 14px; background: #101820; text-align: left; cursor: pointer; }
.location-option strong, .saved-note strong { display: block; }
.location-option span, .saved-note span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.range-field { margin-top: 22px; display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; font-weight: 700; }
.range-field input { grid-column: 1 / -1; width: 100%; accent-color: var(--cyan); }
.range-field output { color: var(--cyan); }
.support-copy { color: var(--muted); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #eef4f4; color: #101820; padding: 10px 14px; border-radius: 6px; font-weight: 700; transition: .2s ease; z-index: 30; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 680px) {
  .topbar, .location-band, .calendar-section, .insight-band { padding-left: 16px; padding-right: 16px; }
  .location-band { align-items: start; flex-direction: column; gap: 12px; }
  .quick-summary { text-align: left; }
  .data-status { width: calc(100% - 32px); }
  .day-cell { min-height: 82px; padding: 7px; }
  .day-score { font-size: 18px; margin-top: 5px; }
  .day-tags { margin-top: 5px; }
  .tag { font-size: 9px; padding: 1px 3px; }
  .condition-list { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .eyebrow { display: none; }
  .topbar { min-height: 68px; }
  .section-heading { align-items: start; }
  .month-indicator { min-width: 52px; }
  .legend { gap: 8px 12px; }
  .day-cell { min-height: 72px; }
  .day-tags .tag:nth-child(n+2) { display: none; }
  .insight-band { grid-template-columns: 56px 1fr; }
  .moon-visual { width: 52px; }
}
