:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #18202a;
  --muted: #687385;
  --line: #d9dee7;
  --line-strong: #b7c0cf;
  --accent: #245c57;
  --accent-2: #8b3d56;
  --warn-bg: #fff8e8;
  --warn-line: #e2b84f;
  --ok-bg: #edf8f3;
  --draft-bg: #fff1f4;
  --shadow: 0 12px 35px rgba(24, 32, 42, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  font-size: 18px;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef3f2 0, rgba(238, 243, 242, 0) 330px),
    var(--bg);
}

.plan-caption { width: min(1240px, calc(100% - 32px)); margin: 0 auto 16px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.plan-info { color: var(--muted); font-size: 16px; line-height: 1.5; }
.plan-info summary { cursor: pointer; }

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(36, 92, 87, 0.25);
  outline-offset: 2px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(440px, 0.95fr);
  gap: 24px;
  align-items: end;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 16px;
}

.title-block h1,
.day-head h2 {
  margin: 0;
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-line {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.controls {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.controls input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef1f5;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.source-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 16px;
}

.source-strip > div {
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.source-strip strong {
  display: block;
  margin-bottom: 3px;
  font-size: 14px;
}

.source-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 18px;
}

.day-layout,
.week-layout,
.program-layout {
  display: grid;
  gap: 16px;
}

.day-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.day-head h2 {
  max-width: 760px;
  font-size: 30px;
}

.day-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.day-meta span,
.topic-count {
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f9fafc;
  font-size: 13px;
  font-weight: 700;
}

.limit-box {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  background: var(--warn-line);
}

.limit-box p {
  margin: 0;
  padding: 13px;
  color: #5c4820;
  background: var(--warn-bg);
  font-size: 13px;
  line-height: 1.35;
}

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

.lesson-card {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.lesson-card.compact {
  grid-template-columns: 1fr;
}

.lesson-time {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #f0f3f7;
}

.lesson-card.compact .lesson-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-right: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.lesson-time span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #fff;
  background: var(--accent-2);
  font-weight: 800;
}

.lesson-time strong {
  font-size: 16px;
  line-height: 1.2;
}

.lesson-time em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.lesson-content {
  min-width: 0;
  padding: 16px;
}

.lesson-card.compact .lesson-content {
  padding: 12px;
}

.lesson-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 14px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-badge.official {
  color: #1d5a43;
  background: var(--ok-bg);
}

.source-badge.draft {
  color: #7f2438;
  background: var(--draft-bg);
}

.subject-block {
  padding: 13px 0 3px;
  border-top: 1px solid var(--line);
}

.lesson-meta-row + .subject-block {
  border-top: 0;
  padding-top: 0;
}

.subject-title,
.subject-panel-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.subject-title h3,
.subject-panel h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.lesson-card.compact .subject-title h3 {
  font-size: 15px;
}

.subject-title p,
.subject-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.subject-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--subject-color);
}

.topic-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0 0 0 22px;
}

.topic-list li {
  padding-left: 3px;
  line-height: 1.45;
}

.topic-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: baseline;
}

.topic-heading span {
  display: inline;
}

.topic-heading small {
  display: inline-flex;
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--muted);
  background: #eef1f5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: 1px;
}

.topic-details {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding: 10px 11px;
  border-left: 3px solid var(--subject-color);
  border-radius: 0 8px 8px 0;
  background: #f7f9fc;
}

.topic-details.compact {
  padding: 9px 10px;
}

.topic-details p {
  margin: 0;
  color: #3a4554;
  font-size: 18px;
  line-height: 1.65;
}

.topic-details strong {
  color: var(--ink);
}

.lesson-card.compact .topic-details p {
  font-size: 18px;
}

.study-points { margin: 0; padding-left: 24px; font-size: 18px; line-height: 1.65; }
.study-points li { margin-bottom: 8px; overflow-wrap: anywhere; }
.topic-details { gap: 12px; padding: 16px; }
.topic-heading { font-size: 21px; font-weight: 600; overflow-wrap: anywhere; }
.topic-details .guide-label { font-size: 16px; color: var(--muted); }
.source-evidence { font-size: 18px; overflow-wrap: anywhere; }
.source-evidence summary { cursor: pointer; color: var(--accent); padding: 8px 0; }
.source-evidence p { margin-top: 12px; white-space: pre-wrap; }
.homework-status { border-top: 1px solid var(--line); padding-top: 12px; }
.subject-title h3, .subject-panel h3, .lesson-card.compact .subject-title h3 { font-size: 22px; }
.note-field, .lesson-meta-row { font-size: 16px; }
.note-field textarea { font-size: 18px; line-height: 1.5; }
.controls input { font-size: 16px; }

.note-field {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.note-field textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fcfdff;
}

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

.week-day {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
}

.week-day-head {
  display: grid;
  gap: 2px;
  min-height: 70px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.week-day-head strong {
  font-size: 16px;
}

.week-day-head span {
  color: var(--muted);
  font-size: 13px;
}

.program-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.subject-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.subject-panel-head {
  justify-content: space-between;
}

.subject-panel .source-badge {
  flex: 0 0 auto;
}

.topic-count {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
}

.program-topics {
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.empty {
  margin: 0;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

.empty.compact {
  padding: 13px;
  font-size: 13px;
}

.footer {
  position: static;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto 16px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.footer button {
  padding: 0 14px;
  white-space: nowrap;
  font-weight: 700;
}

.footer span {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .segmented {
    grid-column: 1 / -1;
  }

  .source-strip,
  .limit-box,
  .program-grid {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 680px) {
  .topbar,
  .source-strip,
  .app-shell {
    width: min(100% - 20px, 1240px);
  }

  .topbar {
    padding-top: 16px;
  }

  .title-block h1 {
    font-size: 28px;
  }

  .controls,
  .source-strip,
  .limit-box,
  .week-grid,
  .program-grid {
    grid-template-columns: 1fr;
  }

  .day-head {
    display: grid;
    padding: 16px;
  }

  .day-meta {
    justify-content: flex-start;
  }

  .lesson-card {
    grid-template-columns: 1fr;
  }

  .lesson-time {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .lesson-content {
    padding: 14px;
  }

  .footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: calc(100% - 20px);
  }

  .footer button {
    padding: 0 10px;
    font-size: 14px;
  }

  .footer span {
    grid-column: 1 / -1;
    margin-right: 0;
    order: 2;
    text-align: center;
  }
}

@media print {
  body {
    background: #fff;
  }

  .controls,
  .source-strip,
  .footer,
  .note-field {
    display: none;
  }

  .topbar,
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .day-head,
  .lesson-card,
  .subject-panel {
    box-shadow: none;
    break-inside: avoid;
  }
}
