:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --ink: #202421;
  --muted: #667069;
  --line: #dfe5df;
  --accent: #1f6f68;
  --accent-strong: #15514c;
  --warm: #d98535;
  --danger: #b43b3b;
  --soft: #eef5f3;
  --shadow: 0 18px 45px rgba(35, 47, 43, 0.09);
  font-family: "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(460px, 540px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  overflow-y: auto;
}

.brand {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.25;
}

.brand p,
.toolbar p,
.empty-state span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(31, 42, 39, 0.04);
}

.section-head,
.toolbar,
.toolbar-actions,
.actions {
  display: flex;
  align-items: center;
}

.section-head,
.toolbar {
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: 12px;
}

h2 {
  font-size: 16px;
}

.field-grid {
  display: grid;
  gap: 8px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.basic-settings {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.field-grid.doc-settings {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.field-grid.four {
  grid-template-columns: 78px 72px 72px 1fr;
}

.specialist-main-fields {
  grid-template-columns: 1fr 120px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 111, 104, 0.18);
  outline-offset: 1px;
  border-color: var(--accent);
}

.inline-check {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--ink);
  font-size: 14px;
}

.inline-check input {
  width: 17px;
  height: 17px;
}

.rows {
  display: grid;
  gap: 8px;
}

.row {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfb;
}

.total-line {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.subject-row {
  grid-template-columns: 1fr 78px 34px;
  align-items: center;
}

.stacked {
  padding-right: 42px;
}

.icon-button,
.remove {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
}

.add-subject-button {
  height: 34px;
  padding: 0 12px;
  border-color: #c36d21;
  border-radius: 7px;
  background: var(--warm);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.add-subject-button:hover {
  background: #c06f28;
}

.remove {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: var(--danger);
}

.corner {
  position: absolute;
  top: 10px;
  right: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  font-size: 13px;
}

.chip input {
  width: 15px;
  height: 15px;
}

.chip:has(input:disabled) {
  color: #9aa39b;
  background: #f2f4f1;
}

.actions {
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding-top: 12px;
  background: #fbfcfa;
}

.save-actions {
  position: static;
  padding-top: 8px;
}

.save-actions .secondary {
  flex: 1;
}

button {
  height: 42px;
  border-radius: 7px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  flex: 1;
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-strong);
}

#saveSchedule {
  flex: 1;
  border-color: #c36d21;
  background: var(--warm);
  color: white;
}

#saveSchedule:hover {
  background: #c06f28;
}

.secondary {
  padding: 0 14px;
  border-color: var(--line);
  background: white;
  color: var(--ink);
}

.small {
  height: 36px;
  min-width: 74px;
  font-size: 14px;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  overflow: auto;
  padding: 26px 32px;
}

.toolbar {
  margin-bottom: 18px;
}

.toolbar h2 {
  font-size: 24px;
}

.toolbar-actions {
  gap: 8px;
}

.saved-schedules {
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.saved-schedules-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.saved-schedules-head strong {
  font-size: 14px;
}

.saved-schedules-head span {
  color: var(--muted);
  font-size: 12px;
}

.saved-schedule-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.saved-schedule-item {
  height: 32px;
  border: 1px solid #b9c7c2;
  border-radius: 6px;
  background: #fff;
  color: #1d3935;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.saved-schedule-empty {
  color: var(--muted);
  font-size: 13px;
}

.warnings {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f0c98e;
  border-radius: 8px;
  background: #fff7ea;
  color: #71511d;
  line-height: 1.5;
}

.tables {
  display: block;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed #cbd5cf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.schedule-document {
  width: var(--schedule-document-width, 794px);
  margin: 0 auto;
  padding: 8px;
  background: white;
  color: #000;
  box-shadow: 0 12px 32px rgba(20, 24, 22, 0.08);
}

.doc-header {
  border: 1px solid #000;
  margin-bottom: 6px;
  padding: 8px 0 10px;
  text-align: center;
}

.doc-year {
  padding-left: 14px;
  text-align: left;
  font-size: 17px;
}

.doc-year span {
  color: #c40000;
  text-decoration: underline;
}

.doc-title {
  margin: 4px 0;
  font-size: 28px;
  letter-spacing: 6px;
}

.doc-title span {
  letter-spacing: 1px;
}

.doc-range {
  font-size: 15px;
}

.doc-table-block {
  min-width: 0;
}

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

.specialist-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 70px;
}

.doc-table-title {
  height: 22px;
  border: 1px solid #000;
  border-bottom: 0;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}

.doc-note {
  margin: 7px 0 0;
  font-size: 14px;
}

.timetable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.timetable th,
.timetable td {
  border: 1px solid #000;
  padding: 0 2px;
  text-align: center;
  vertical-align: middle;
}

.timetable th {
  height: 21px;
  background: white;
  color: #000;
  font-size: 13px;
}

.timetable td {
  height: 26px;
  font-weight: 700;
  line-height: 1.25;
  word-break: keep-all;
}

.period {
  width: 30px;
  color: #000;
  font-weight: 800;
  background: white;
}

.cell-sub {
  display: block;
}

.editable-cell {
  cursor: text;
}

.editable-cell:focus {
  outline: 2px solid rgba(31, 111, 104, 0.28);
  outline-offset: -2px;
  background: #f8fffb;
}

.cell-meta {
  display: none;
}

.specialist-cell {
  background: white;
  color: #000;
  font-weight: 900;
}

.fixed-cell {
  background: white;
  color: #000;
}

.closed-cell {
  background: #d9d9d9;
  color: transparent;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    overflow-y: visible;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .brand {
    grid-template-columns: 44px 1fr;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .field-grid.three,
  .field-grid.four,
  .specialist-main-fields,
  .field-grid.basic-settings,
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

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

  .class-grid,
  .specialist-grid {
    grid-template-columns: 1fr;
  }

  .doc-title {
    font-size: 22px;
  }
}

@media print {
  .sidebar,
  .toolbar-actions,
  .warnings {
    display: none;
  }

  .app {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .class-table {
    break-inside: avoid;
    box-shadow: none;
  }
}
