:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-muted: #eef2f6;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-text: #ffffff;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --danger-border: #fecdca;
  --danger-hover: #fee4e2;
  --header-bg: rgba(255, 255, 255, 0.92);
  --toast-bg: #18212f;
  --toast-text: #ffffff;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111416;
  --surface: #191d20;
  --surface-strong: #202529;
  --surface-muted: #252b30;
  --text: #edf1f3;
  --muted: #a5afb7;
  --line: #343b41;
  --primary: #2a9d8f;
  --primary-dark: #238579;
  --primary-text: #ffffff;
  --danger: #ff8a80;
  --danger-bg: #3a2020;
  --danger-border: #633333;
  --danger-hover: #4a2727;
  --header-bg: rgba(25, 29, 32, 0.94);
  --toast-bg: #edf1f3;
  --toast-text: #111416;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary);
  color: var(--primary-text);
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

button.secondary:hover {
  background: var(--surface-muted);
}

button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.hidden {
  display: none !important;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px clamp(16px, 4vw, 40px);
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.app-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.header-actions input[type="date"] {
  width: 150px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 22px auto 60px;
}

.login-panel,
.status-strip,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  margin-bottom: 16px;
  padding: 14px;
}

.inline-form,
.todo-form {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr auto;
  gap: 10px;
}

.inline-form {
  grid-template-columns: 1fr auto;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 22px;
  overflow: hidden;
}

.status-strip > div {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.status-strip > div:last-child {
  border-right: 0;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

section {
  margin-bottom: 22px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.module-card {
  min-height: 154px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.module-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: 0 0 auto;
}

.module-card h3 {
  margin: 0;
  font-size: 16px;
}

.module-card p {
  min-height: 44px;
  margin: 10px 0 12px;
  color: var(--muted);
}

.module-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.module-edit {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.panel {
  padding: 16px;
}

.todo-list {
  display: grid;
  gap: 12px;
}

.todo-form {
  margin-bottom: 12px;
}

.todo-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.todo-item.done .todo-title {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

.todo-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.todo-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.todo-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.todo-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.daily-checklist-module {
  margin: 4px 0 0;
  border-top: 3px solid var(--module-color);
  padding-top: 10px;
}

.daily-checklist-module-heading,
.daily-checklist-module-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.daily-checklist-module-heading {
  justify-content: space-between;
  margin-bottom: 8px;
}

.daily-checklist-module-heading h3 {
  margin: 0;
  font-size: 16px;
}

.daily-checklist-module-heading > span {
  color: var(--muted);
  font-size: 12px;
}

.daily-checklist-group {
  margin-top: 12px;
}

.daily-checklist-group h4 {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
}

.checklist-row.daily-checklist-row {
  grid-template-columns: 24px minmax(0, 1fr);
}

.note-read,
.review-read {
  min-height: 80px;
  color: var(--muted);
  white-space: pre-wrap;
}

.note-form,
.review-form {
  display: grid;
  gap: 10px;
}

.review-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.review-form label span {
  color: var(--text);
  font-weight: 650;
}

.rating-row {
  grid-template-columns: 70px 120px;
  align-items: center;
}

.week-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.progress-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-bar {
  height: 100%;
  width: 0;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(124px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.day-column {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.day-column.active {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.day-heading {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.week-task {
  margin: 0 0 8px;
  padding-left: 8px;
  border-left: 3px solid var(--line);
  overflow-wrap: anywhere;
  font-size: 13px;
}

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

.checklist-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.checklist-tabs button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.checklist-tabs button:hover {
  background: var(--surface-muted);
}

.checklist-tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}

.checklist-list {
  display: grid;
  gap: 24px;
}

.checklist-group {
  margin: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.checklist-heading {
  margin-bottom: 10px;
}

.checklist-heading p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.checklist-heading h3 {
  margin: 0;
  font-size: 16px;
}

.checklist-type-label {
  margin: 14px 0 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}

.checklist-row {
  display: grid;
  grid-template-columns: 24px minmax(220px, 1fr) minmax(140px, 180px) minmax(220px, 0.8fr);
  align-items: start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-muted);
}

.checklist-toggle {
  width: 18px;
  height: 18px;
  margin-top: 9px;
  padding: 0;
}

.checklist-item-text {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
}

.checklist-row.done .checklist-item-text {
  color: var(--muted);
  text-decoration: line-through;
}

.checklist-note {
  min-height: 42px;
}

.empty {
  margin: 14px 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  border-radius: 8px;
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .module-grid,
  .week-progress {
    grid-template-columns: 1fr 1fr;
  }

  .checklist-row {
    grid-template-columns: 24px minmax(0, 1fr) minmax(140px, 180px);
  }

  .checklist-note {
    grid-column: 2 / -1;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 20px, 1180px);
    margin-top: 14px;
  }

  .module-grid,
  .status-strip,
  .week-progress,
  .inline-form,
  .todo-form {
    grid-template-columns: 1fr;
  }

  .status-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-strip > div:last-child {
    border-bottom: 0;
  }

  .todo-item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .todo-actions {
    grid-column: 2;
  }

  .checklist-row {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .checklist-mastery,
  .checklist-note {
    grid-column: 2;
  }
}
