:root {
  color-scheme: light;
  --surface-1: #fdfbf7;
  --surface-page: #f6f1e8;
  --text-primary: #1c1a16;
  --text-secondary: #5a5347;
  --text-muted: #938a79;
  --gridline: #e3dac8;
  --baseline: #c7bca5;
  --border: rgba(42, 33, 20, 0.12);
  --series-1: #0f6e7d;
  --series-1-soft: #d3ece9;
  --status-good: #1a9173;
  --status-critical: #c05a3f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #16201f;
    --surface-page: #0e1716;
    --text-primary: #f1ece0;
    --text-secondary: #c7beac;
    --text-muted: #948b79;
    --gridline: #2a3533;
    --baseline: #3c4745;
    --border: rgba(255, 250, 240, 0.1);
    --series-1: #3fb6c4;
    --series-1-soft: #1c4347;
    --status-good: #36c29a;
    --status-critical: #e07a5f;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #16201f;
  --surface-page: #0e1716;
  --text-primary: #f1ece0;
  --text-secondary: #c7beac;
  --text-muted: #948b79;
  --gridline: #2a3533;
  --baseline: #3c4745;
  --border: rgba(255, 250, 240, 0.1);
  --series-1: #3fb6c4;
  --series-1-soft: #1c4347;
  --status-good: #36c29a;
  --status-critical: #e07a5f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.view {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

.muted {
  color: var(--text-secondary);
}

h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0;
}

h2 {
  font-size: 18px;
  font-weight: 650;
  margin: 0 0 4px;
}

button {
  font-family: inherit;
  font-size: 15px;
  border-radius: 10px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--series-1);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--status-critical);
  border-color: var(--status-critical);
  margin-right: auto;
}

input,
textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Login */

#login-view:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.google-btn {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.error {
  color: var(--status-critical);
  font-size: 13px;
}

.user-label {
  font-size: 12px;
  margin: 2px 0 0;
}

/* Topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 20px;
  position: sticky;
  top: 0;
  background: var(--surface-page);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* Goal cards */

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.goal-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.goal-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.goal-name {
  font-size: 16px;
  font-weight: 650;
}

.goal-target {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.goal-description {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 8px 0 0;
  white-space: pre-wrap;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 6px;
  font-size: 16px;
}

/* Today block */

.today-block {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface-page);
  border: 1px solid var(--border);
}

.today-block.status-partial {
  background: var(--series-1-soft);
}

.today-block.status-met,
.today-block.status-over {
  background: color-mix(in srgb, var(--status-good) 16%, var(--surface-1));
  border-color: color-mix(in srgb, var(--status-good) 45%, var(--border));
}

.today-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.today-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.today-count {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.today-block.status-met .today-count,
.today-block.status-over .today-count {
  color: var(--status-good);
}

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

.today-actions .btn-primary {
  padding: 10px 20px;
}

.today-undo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  padding: 0;
}

/* Note */

.note-row {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.note-input {
  min-height: 44px;
  resize: vertical;
  font-size: 13px;
}

.note-save {
  font-size: 12px;
  padding: 6px 12px;
}

/* Week strip */

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.week-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 0;
  border-radius: 8px;
  background: var(--surface-page);
  cursor: pointer;
  user-select: none;
}

.week-day-label {
  font-size: 10px;
  color: var(--text-muted);
}

.week-day-num {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}

.week-day.status-partial {
  background: var(--series-1-soft);
}

.week-day.status-met,
.week-day.status-over {
  background: var(--status-good);
}

.week-day.status-met .week-day-num,
.week-day.status-over .week-day-num,
.week-day.status-met .week-day-label,
.week-day.status-over .week-day-label {
  color: #fff;
}

.week-day.is-selected {
  box-shadow: 0 0 0 2px var(--series-1);
}

.week-day.is-today::after {
  content: "";
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--series-1);
}

.week-day.status-met.is-today::after,
.week-day.status-over.is-today::after {
  background: #fff;
}

.week-day.is-future {
  opacity: 0.35;
  cursor: default;
}

.has-note-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

/* Month toggle */

.month-toggle-row {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.month-toggle {
  font-size: 13px;
  padding: 6px 14px;
}

/* Weekly summary */

.week-summary {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
}

.progress-message {
  color: var(--text-secondary);
}

.progress-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Calendar */

.calendar {
  margin-top: 14px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calendar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-page);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.cal-day-blank {
  background: transparent;
  cursor: default;
}

.cal-day.status-partial {
  background: var(--series-1-soft);
  color: var(--text-primary);
}

.cal-day.status-met,
.cal-day.status-over {
  background: var(--status-good);
  color: #fff;
  font-weight: 600;
}

.cal-day.is-selected {
  box-shadow: 0 0 0 2px var(--series-1);
}

.cal-day.is-today::after {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--series-1);
}

.cal-day.status-met.is-today::after,
.cal-day.status-over.is-today::after {
  background: #fff;
}

.cal-day.is-future {
  opacity: 0.35;
  cursor: default;
}

.cal-day-over-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  line-height: 16px;
  border-radius: 8px;
  background: var(--series-1);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.empty-state {
  text-align: center;
  padding: 48px 0;
}

/* Dialog */

dialog {
  border: none;
  border-radius: 16px;
  padding: 20px;
  width: calc(100% - 32px);
  max-width: 420px;
  background: var(--surface-1);
  color: var(--text-primary);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row label {
  flex: 1;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
