:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dfe4ea;
  --line-strong: #cbd3dd;
  --text: #17202b;
  --text-soft: #5f6b7a;
  --accent: #2367d1;
  --accent-soft: #eaf2ff;
  --success: #16845b;
  --danger: #ba3a3a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button,
select,
input[type="date"] {
  cursor: pointer;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1800px, 100%);
  height: 100vh;
  min-height: 620px;
  margin: 0 auto;
  padding: 16px 20px 12px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(230px, 0.8fr) minmax(300px, 1.5fr) auto;
  gap: 28px;
  align-items: center;
  min-height: 68px;
  padding: 0 2px 14px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 2vw, 27px);
  line-height: 1.15;
  letter-spacing: -0.04em;
}

.progress-block {
  width: min(570px, 100%);
  justify-self: center;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 12px;
}

.progress-copy strong {
  color: var(--text);
  font-size: 13px;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 99px;
  background: #dfe5ed;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.header-actions {
  display: flex;
  gap: 7px;
}

.ghost-button,
.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
}

.ghost-button {
  height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}

.ghost-button:hover,
.tab:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.ghost-button.danger:hover {
  border-color: #e8b5b5;
  background: #fff7f7;
  color: var(--danger);
}

main {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.controls {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: var(--surface);
}

.date-control {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

input[type="date"],
select,
.search-control {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

input[type="date"] {
  width: 132px;
  padding: 0 8px;
  color: var(--text);
  font-size: 12px;
}

.week-tabs {
  display: flex;
  gap: 4px;
}

.tab {
  height: 34px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.select-control select {
  min-width: 104px;
  padding: 0 28px 0 10px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.search-control {
  display: flex;
  flex: 1;
  min-width: 190px;
  max-width: 330px;
  align-items: center;
  padding: 0 9px;
}

.search-control:focus-within,
input[type="date"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 103, 209, 0.11);
  outline: none;
}

.search-control svg {
  width: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--text-soft);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-control input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 0 0 7px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.view-summary {
  margin-left: auto;
  padding: 0 4px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.table-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-scroll {
  position: relative;
  height: 100%;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.col-check {
  width: 46px;
}

.col-date {
  width: 124px;
}

.col-title {
  width: 23%;
}

.col-material {
  width: 42%;
}

.col-note {
  width: 26%;
}

thead {
  position: sticky;
  z-index: 2;
  top: 0;
}

th {
  height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #eef2f6;
  color: #465364;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: left;
}

th:not(:last-child),
td:not(:last-child) {
  border-right: 1px solid #edf0f3;
}

td {
  height: 66px;
  padding: 6px 10px;
  border-bottom: 1px solid #e9edf1;
  background: var(--surface);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfcfe;
}

tbody tr.week-start:not(:first-child) td {
  border-top: 2px solid var(--line-strong);
}

tbody tr.completed td {
  background: #f8fbfa;
}

tbody tr.completed .title-text,
tbody tr.completed .material-title {
  color: #87928e;
}

.check-cell {
  padding-right: 6px;
  padding-left: 12px;
}

.check-wrap {
  display: grid;
  width: 22px;
  height: 22px;
  cursor: pointer;
  place-items: center;
}

.check-wrap input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.fake-check {
  display: grid;
  width: 18px;
  height: 18px;
  border: 1.5px solid #aab4c0;
  border-radius: 5px;
  background: white;
  transition: 120ms ease;
  place-items: center;
}

.fake-check::after {
  width: 7px;
  height: 4px;
  border-bottom: 2px solid white;
  border-left: 2px solid white;
  content: "";
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg);
}

.check-wrap input:checked + .fake-check {
  border-color: var(--success);
  background: var(--success);
}

.check-wrap input:checked + .fake-check::after {
  opacity: 1;
}

.check-wrap input:indeterminate + .fake-check {
  border-color: var(--accent);
  background: var(--accent);
}

.check-wrap input:indeterminate + .fake-check::after {
  width: 8px;
  height: 0;
  border: 0;
  border-top: 2px solid white;
  opacity: 1;
  transform: none;
}

.check-wrap input:focus-visible + .fake-check {
  box-shadow: 0 0 0 3px rgba(22, 132, 91, 0.16);
}

.date-main {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.day-meta {
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 700;
}

.week-badge {
  display: inline-block;
  margin-right: 5px;
  color: var(--accent);
}

.title-text {
  overflow: hidden;
  color: #202b38;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.title-sub {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: 11px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-count {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 800;
  vertical-align: 1px;
}

.material-title {
  overflow: hidden;
  color: #2f3c4b;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-checks {
  display: flex;
  max-height: 44px;
  margin-top: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 3px 5px;
}

.topic-check {
  display: inline-flex;
  min-width: 0;
  max-width: 260px;
  height: 16px;
  align-items: center;
  gap: 3px;
  padding: 0 4px 0 2px;
  border-radius: 4px;
  background: #f2f5f8;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 9.5px;
  line-height: 16px;
}

.topic-check:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.topic-check input {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--success);
  cursor: pointer;
}

.topic-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-check.checked span {
  color: #89948f;
  text-decoration: line-through;
}

.note-input {
  display: block;
  width: 100%;
  height: 40px;
  resize: none;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.note-input::placeholder {
  color: #a2acb8;
}

.note-input:hover {
  border-color: var(--line);
  background: white;
}

.note-input:focus {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(35, 103, 209, 0.1);
}

.muted {
  margin-left: 4px;
  color: #8793a1;
  font-size: 9px;
  font-weight: 600;
}

.empty-state {
  position: absolute;
  inset: 36px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  color: var(--text-soft);
}

.empty-state[hidden] {
  display: none;
}

.footer-note {
  display: flex;
  justify-content: space-between;
  padding: 8px 3px 0;
  color: var(--text-soft);
  font-size: 11px;
}

.save-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
  vertical-align: 1px;
}

.toast {
  position: fixed;
  z-index: 5;
  right: 20px;
  bottom: 20px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #18212c;
  box-shadow: var(--shadow);
  color: white;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(7px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .progress-block {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .controls {
    flex-wrap: wrap;
  }

  .search-control {
    max-width: none;
  }

  .view-summary {
    display: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    padding: 10px;
  }

  .brand-block .eyebrow {
    font-size: 10px;
  }

  .ghost-button {
    padding: 0 9px;
  }

  .date-control {
    width: 100%;
    justify-content: space-between;
    padding-right: 0;
    border-right: 0;
  }

  .week-tabs {
    flex: 1 0 100%;
  }

  .tab {
    flex: 1;
    padding: 0 5px;
  }

  .select-control {
    flex: 0 0 auto;
  }

  .search-control {
    min-width: 150px;
  }

  .table-panel {
    height: calc(100vh - 275px);
    min-height: 440px;
  }

  .footer-note span:last-child {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
