:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-strong: #f0f6f7;
  --text: #172026;
  --muted: #63727a;
  --faint: #8b989f;
  --line: #d9e2e5;
  --accent: #147d79;
  --accent-strong: #0d6461;
  --accent-soft: #e4f4f2;
  --blue: #2768b5;
  --warning: #b35a12;
  --error: #b72b31;
  --shadow: 0 18px 48px rgba(26, 45, 55, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.25;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.icon-button,
.primary-button,
.secondary-button,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.primary-button {
  padding: 0 16px;
  background: var(--accent);
  color: white;
}

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

.wide {
  width: 100%;
}

button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.date-input,
input,
select {
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 28px 44px;
}

.setup-panel,
.content-panel,
.compare-panel,
.week-panel,
.summary-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.setup-panel {
  align-self: start;
  overflow: hidden;
}

.panel-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.content-head,
.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h1,
.content-head h3,
.summary-strip h2 {
  margin: 0;
  line-height: 1.25;
}

.section-heading h1 {
  font-size: 20px;
}

.content-head h3 {
  margin-top: 3px;
  font-size: 18px;
}

.summary-strip h2 {
  margin-top: 4px;
  font-size: 24px;
}

.summary-strip p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--faint);
}

.status-dot.ok {
  background: var(--accent);
}

.status-dot.error {
  background: var(--error);
}

.search-form label,
.field-grid span,
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.search-form.is-hidden {
  display: none;
}

.search-form label,
.field-grid span {
  margin-bottom: 8px;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.school-results {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 360px;
  overflow: auto;
}

.school-option {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.school-option strong,
.selected-card strong {
  font-size: 15px;
}

.school-option small,
.selected-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.school-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chosen-school {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.chosen-school strong,
.chosen-school small {
  display: block;
}

.chosen-school strong {
  font-size: 15px;
}

.chosen-school small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.selected-card {
  display: grid;
  gap: 6px;
  padding: 20px;
  background: var(--surface-strong);
}

.selected-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.summary-strip {
  min-height: 116px;
  padding: 22px;
}

.metric-row {
  display: flex;
  gap: 10px;
}

.metric {
  min-width: 104px;
  padding: 12px 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric strong {
  margin-top: 5px;
  font-size: 20px;
}

.message {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8ed;
  color: var(--warning);
  font-size: 14px;
}

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

.content-panel,
.compare-panel,
.week-panel {
  min-width: 0;
  padding: 20px;
}

.meal-content {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.meal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.meal-details {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.meal-accordion {
  display: grid;
  gap: 8px;
}

.accordion-item {
  background: var(--surface-strong);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
}

.accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.accordion-trigger svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  transition: transform 180ms ease;
}

.accordion-item.open .accordion-trigger svg {
  transform: rotate(180deg);
}

.accordion-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease;
}

.accordion-panel-inner {
  padding: 0 12px 12px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.accordion-item.open .accordion-panel-inner {
  opacity: 1;
}

.accordion-panel pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  line-height: 1.6;
}

@media (prefers-reduced-motion: reduce) {
  .accordion-trigger svg,
  .accordion-panel,
  .accordion-panel-inner {
    transition: none;
  }
}

.timetable-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.period-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.period {
  display: grid;
  place-items: center;
  height: 100%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.subject {
  padding: 0 14px;
  font-weight: 700;
}

.week-panel {
  display: grid;
  gap: 18px;
}

.compare-panel {
  display: grid;
  gap: 18px;
}

.compare-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.class-compare-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.class-column {
  min-width: 150px;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.class-column.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.class-column h4 {
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
  font-size: 14px;
}

.class-column.selected h4 {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.class-periods {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  list-style: none;
}

.class-periods li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.mini-period {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
  font-size: 12px;
}

.class-empty {
  margin: 0;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segment {
  min-height: 34px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 39, 47, 0.08);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  min-height: 238px;
  overflow-x: auto;
}

.day-column {
  min-width: 150px;
  min-height: 210px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

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

.day-column h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.day-column p,
.day-column ul {
  margin: 0;
  padding: 0;
}

.day-column p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.day-column ul {
  display: grid;
  gap: 6px;
  list-style: none;
}

.day-column li {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.loading {
  opacity: 0.7;
  pointer-events: none;
}

@media (max-width: 980px) {
  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .date-input {
    flex: 1 1 160px;
  }

  .layout,
  .today-grid {
    grid-template-columns: 1fr;
  }

  .setup-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .brand strong {
    font-size: 16px;
  }

  .summary-strip,
  .section-heading,
  .content-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-row,
  .metric {
    width: 100%;
  }

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

  .search-row {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
