:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-muted: #fbfaf6;
  --border: #e5e2d8;
  --text: #2a2a28;
  --text-muted: #7a766c;
  --accent: #1d9e75;
  --accent-soft: #d8efe5;
  --accent-text: #0f6b4e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 14px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(29, 158, 117, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181a;
    --surface: #1f2225;
    --surface-muted: #25292d;
    --border: #2e3338;
    --text: #e7e5dd;
    --text-muted: #9a968a;
    --accent: #2eb588;
    --accent-soft: #1f3a32;
    --accent-text: #6fd3ad;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

header {
  margin-bottom: 28px;
}

header h1 {
  margin: 0 0 4px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

/* Progress */
.progress {
  margin: 22px 0 32px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.progress-label strong {
  color: var(--text);
  font-weight: 600;
}

.progress-bar {
  height: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.35s ease;
  border-radius: 999px;
}

/* Week cards */
.week {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.week-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.week-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.week-title .week-num {
  color: var(--accent-text);
  font-weight: 700;
  margin-right: 8px;
}

.week-total {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sessions */
.sessions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "check label toggle"
    "check notes notes";
  gap: 8px 12px;
  padding: 12px 14px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: opacity 0.2s ease;
}

.session.done {
  opacity: 0.65;
}

.session.done .session-label {
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
  color: var(--text-muted);
}

/* Custom checkbox */
.session-check {
  grid-area: check;
  align-self: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.session-check:hover {
  border-color: var(--accent);
}

.session-check:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.session-check[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.session-check[aria-checked="true"]::after {
  content: "";
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.session-label {
  grid-area: label;
  align-self: center;
  font-size: 15px;
  font-weight: 500;
}

.session-label .session-num {
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.session-toggle-notes {
  grid-area: toggle;
  align-self: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.session-toggle-notes:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.session-toggle-notes:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.session-notes-wrap {
  grid-area: notes;
  display: none;
  margin-top: 4px;
}

.session-notes-wrap.open {
  display: block;
}

.session-notes {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.session-notes:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.session-notes-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
}

.notes-status {
  font-style: italic;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.notes-status.visible {
  opacity: 1;
}

.notes-count {
  font-variant-numeric: tabular-nums;
}

.notes-count.over {
  color: #c0392b;
}

/* Footer */
footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

footer p {
  margin: 4px 0;
}

/* Loading / error states */
.state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.state.error {
  color: #c0392b;
}

@media (max-width: 520px) {
  .wrap {
    padding: 20px 14px 60px;
  }
  header h1 {
    font-size: 24px;
  }
  .week {
    padding: 16px 14px;
  }
  .session {
    padding: 10px 12px;
  }
  .session-label {
    font-size: 14px;
  }
}
