:root {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17212b;
  background: #eef2f5;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --border: #d6dee6;
  --border-strong: #cbd7e2;
  --text: #17212b;
  --muted: #607284;
  --accent: #1f7a5a;
  --accent-soft: #edf8f3;
  --warning: #8a4b16;
}

:root[data-theme="blue"] {
  --bg: #eef4f8;
  --accent: #2269a7;
  --accent-soft: #edf5fb;
}

:root[data-theme="slate"] {
  --bg: #f1f3f5;
  --accent: #475569;
  --accent-soft: #f3f5f7;
}

:root[data-theme="contrast"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f5f5f5;
  --border: #1f2937;
  --border-strong: #111827;
  --text: #0b0f14;
  --muted: #303946;
  --accent: #005fcc;
  --accent-soft: #eaf2ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #1f7a5a;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

.brand h1 {
  font-size: 20px;
}

.brand p,
.eyebrow,
.section-label {
  color: #607284;
  color: var(--muted);
}

.section-label {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.auth-panel {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-muted);
}

.auth-form,
.auth-form label {
  display: grid;
  gap: 8px;
}

.auth-form {
  gap: 10px;
}

.auth-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 10px;
  color: inherit;
  font: inherit;
}

.auth-actions,
.user-box {
  display: flex;
  gap: 8px;
}

.auth-actions button,
.user-box button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

#registerButton,
.user-box button {
  background: #fff;
  color: var(--accent);
}

.auth-message {
  min-height: 18px;
  color: var(--warning);
  font-size: 12px;
}

.user-box {
  align-items: center;
  justify-content: space-between;
}

.user-box strong {
  display: block;
  overflow: hidden;
  max-width: 138px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.course-button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

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

.course-name {
  display: block;
  font-weight: 750;
}

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

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 20px;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
}

.header h2 {
  font-size: 22px;
}

.open-link {
  min-width: 76px;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.open-link.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.course-stage {
  position: relative;
  min-height: 0;
  padding: 14px;
}

#courseFrame {
  display: none;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 104px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
}

#courseFrame.visible {
  display: block;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 104px);
  place-content: center;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface-muted);
  text-align: center;
}

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

.empty-state h3 {
  margin-bottom: 6px;
  font-size: 20px;
}

.empty-state p {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-button,
.icon-button,
.settings-form button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
}

.settings-form button[type="submit"] {
  background: var(--accent);
  color: #fff;
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(15 23 42 / 0.32);
}

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  display: grid;
  align-content: start;
  gap: 18px;
  width: min(440px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--border);
  background: var(--surface);
  padding: 18px;
  box-shadow: -14px 0 34px rgb(15 23 42 / 0.18);
}

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

.settings-form {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.settings-form h3 {
  font-size: 16px;
}

.settings-form label {
  display: grid;
  gap: 7px;
}

.settings-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.settings-form input,
.settings-form select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}

.check-row input {
  width: auto;
}

.settings-actions {
  display: flex;
  gap: 8px;
}

.settings-summary,
.settings-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
}

.settings-message.error {
  color: #a13a1b;
}

.settings-message.ok {
  color: var(--accent);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #d6dee6;
  }

  .course-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .open-link,
  .settings-button {
    width: 100%;
  }
}
