:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #eef2ec;
  --border: #d3d9d0;
  --text: #20251f;
  --muted: #647064;
  --accent: #265f46;
  --accent-strong: #1d4935;
  --accent-soft: #e2eee7;
  --danger: #9e2f2f;
  --warning: #75580d;
  --shadow: 0 12px 32px rgba(33, 43, 31, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

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

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.2rem;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.header-actions,
.view-toolbar,
.filter-actions,
.tabs,
.week-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-message {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.status-message[data-type="success"] {
  border-color: #a9c7b6;
  background: #edf7f0;
  color: #24553c;
}

.status-message[data-type="error"] {
  border-color: #d8aaa4;
  background: #fff0ed;
  color: var(--danger);
}

.empty-state {
  margin-bottom: 18px;
}

.has-data .empty-state {
  display: none;
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 32px;
  border: 2px dashed #aeb8ab;
  border-radius: 8px;
  background: var(--surface);
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-title {
  margin-bottom: 8px;
  font-size: 1.3rem;
  font-weight: 750;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.main-panel,
.filter-panel,
.debug-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.main-panel,
.filter-panel {
  padding: 18px;
}

.view-toolbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.tabs {
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}

.tabs button {
  min-height: 32px;
  border: 0;
  background: transparent;
}

.tabs button.is-active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(32, 37, 31, 0.12);
}

.week-controls button {
  width: 38px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.view-heading {
  margin-bottom: 16px;
}

.view-heading p,
.panel-heading p,
.event-card p,
.empty-message {
  color: var(--muted);
}

.schedule-list {
  display: grid;
  gap: 14px;
}

.event-list {
  display: grid;
  gap: 8px;
}

.event-card {
  display: grid;
  grid-template-columns: 105px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--item-color, var(--border));
  border-radius: 8px;
  background: #fbfcfa;
}

.event-card time {
  color: var(--accent-strong);
  font-weight: 750;
  white-space: nowrap;
}

.event-card h3 {
  overflow-wrap: anywhere;
}

.event-card p {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
}

.day-section {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.day-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.day-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.day-heading h3 {
  margin-bottom: 0;
}

.day-heading span {
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-message {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.filter-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.filter-panel-header,
.filter-section-heading,
.filter-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-panel-header h2,
.filter-panel-header p {
  margin-bottom: 0;
}

.filter-panel-header p {
  color: var(--muted);
  font-size: 0.9rem;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.filter-panel-body {
  display: grid;
  gap: 12px;
}

.filter-section {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.filter-section-toggle {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  text-align: left;
}

.filter-section-heading {
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.filter-section-heading span,
.filter-section-toggle span {
  font-weight: 700;
}

.filter-section-heading small,
.filter-section-toggle small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  text-align: right;
}

.filter-section-toggle::after {
  content: "-";
  color: var(--muted);
  font-weight: 800;
}

.filter-section.is-collapsed .filter-section-toggle::after {
  content: "+";
}

.filter-section-body {
  display: grid;
  gap: 10px;
}

.search-input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}

.course-list {
  display: grid;
  gap: 6px;
  max-height: 430px;
  overflow: auto;
  padding-right: 2px;
}

.course-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--item-color, var(--border));
  border-radius: 6px;
  background: #fbfcfa;
}

.color-filter-list {
  display: grid;
  gap: 6px;
}

.color-row {
  display: grid;
  grid-template-columns: auto 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfa;
}

.color-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--swatch-color, transparent);
}

.color-row small {
  color: var(--muted);
}

.course-row span {
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}

.course-row strong {
  font-weight: 650;
}

.course-row em {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: normal;
}

.course-row small {
  color: var(--muted);
}

.debug-toggle,
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.switch-row {
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
}

.debug-panel {
  margin-top: 18px;
  padding: 18px;
}

.debug-panel pre {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 6px;
  background: #17201b;
  color: #dce9df;
  font-size: 0.82rem;
}

.is-busy {
  cursor: progress;
}

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

  .app-header,
  .content-layout {
    grid-template-columns: 1fr;
  }

  .app-header,
  .header-actions {
    align-items: stretch;
  }

  .app-header,
  .header-actions,
  .content-layout {
    display: grid;
  }

  .filter-panel {
    position: static;
  }
}

@media (max-width: 560px) {
  .view-toolbar,
  .day-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs button,
  .header-actions button,
  .filter-actions button {
    width: 100%;
  }

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