:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --surface: #ffffff;
  --surface-strong: #fdfbf5;
  --text: #20231f;
  --muted: #697064;
  --line: #dcded3;
  --accent: #21695d;
  --accent-strong: #174b42;
  --accent-soft: #dcece7;
  --gold: #ad7b28;
  --danger: #a23b3b;
  --shadow: 0 14px 40px rgba(43, 48, 39, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 16px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.2;
}

.status-pill,
.mode-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.status-pill {
  min-width: 96px;
  padding: 8px 12px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 18px;
  align-items: end;
}

.metric {
  min-width: 68px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0;
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

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

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(320px, 1fr) minmax(280px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.workspace.view-course .groups-panel,
.workspace.view-lessons .section-panel,
.workspace.view-lessons .groups-panel,
.workspace.view-groups .section-panel,
.workspace.view-groups .lessons-panel,
.workspace.view-groups .lesson-panel {
  display: none;
}

.workspace.view-lessons {
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 0.9fr);
}

.workspace.view-groups {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  min-height: 520px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.search-input {
  width: 100%;
  height: 40px;
  margin-bottom: 12px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.list,
.lesson-grid,
.group-list {
  display: grid;
  gap: 8px;
}

.list {
  max-height: 420px;
  overflow: auto;
  padding-right: 2px;
}

.section-button,
.lesson-card,
.task-link,
.group-nav-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.section-button {
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.group-nav-button {
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.group-nav-button strong {
  font-size: 15px;
  line-height: 1.3;
}

.group-nav-button span {
  color: var(--muted);
  font-size: 12px;
}

.section-button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.section-button strong {
  font-size: 14px;
  line-height: 1.25;
}

.section-button span {
  color: var(--muted);
  font-size: 12px;
}

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

.lesson-card {
  min-height: 112px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.lesson-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.lesson-card h3 {
  min-height: 42px;
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.35;
}

.mode-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
}

.lesson-details {
  display: grid;
  gap: 14px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.source-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

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

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

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

.task-link {
  display: block;
  padding: 10px;
  color: var(--text);
  text-decoration: none;
}

.group-list {
  max-height: 460px;
  overflow: auto;
  padding-right: 2px;
}

.group-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.group-item h3 {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.3;
}

.group-meta,
.group-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.group-description {
  margin-top: 6px;
}

.back-button,
.invite-button,
.invite-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

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

.invite-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.invite-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

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

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

  .workspace.view-lessons,
  .workspace.view-groups {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .list {
    max-height: 320px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

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

  .status-pill {
    width: 100%;
  }

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

  .metric {
    padding-left: 0;
    border-left: 0;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tab-button {
    padding: 0 8px;
  }
}
