:root {
  color-scheme: light;
  --bg: #f5f7f7;
  --surface: #ffffff;
  --surface-strong: #edf5f3;
  --text: #192324;
  --muted: #627172;
  --brand: #285e61;
  --brand-strong: #174245;
  --accent: #d9893d;
  --danger: #a73c3c;
  --border: #d9dfdc;
  --shadow: 0 14px 36px rgba(35, 48, 49, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(18px, 4vw, 44px);
  background: rgba(247, 244, 238, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.25rem, 2vw, 1.85rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.form-actions,
.quick-actions,
.compact-actions,
.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 44px) 36px;
}

.sidebar {
  position: sticky;
  top: 100px;
  align-self: start;
  display: grid;
  gap: 8px;
}

.nav-button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
}

.nav-button:hover,
.nav-button.active {
  background: var(--surface);
  color: var(--brand-strong);
  border-color: var(--border);
  box-shadow: 0 8px 22px rgba(35, 48, 49, 0.06);
}

.content {
  min-width: 0;
}

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

.summary-card {
  min-height: 112px;
  padding: 20px;
  display: grid;
  align-content: space-between;
}

.summary-label {
  color: var(--muted);
  font-weight: 700;
}

.summary-card strong {
  font-size: 2rem;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-heading h2 {
  font-size: clamp(1.05rem, 1.5vw, 1.35rem);
}

.steps {
  display: grid;
  gap: 12px;
}

.steps div {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.steps strong {
  display: block;
  margin-bottom: 4px;
}

.steps p,
.muted {
  color: var(--muted);
}

.steps p,
.muted,
.card-text,
.quiz-item p {
  margin: 0;
  line-height: 1.55;
}

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

.form-grid label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.full-span {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfefd;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 46px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  min-height: 180px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(40, 94, 97, 0.13);
}

.search-input {
  max-width: 280px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 850;
}

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

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

.secondary-button,
.ghost-button {
  color: var(--brand-strong);
  background: var(--surface-strong);
  border-color: var(--border);
}

.danger-button {
  color: #ffffff;
  background: var(--danger);
}

.list,
.quiz-list {
  display: grid;
  gap: 12px;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.item-card,
.quiz-item {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfefd;
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.item-card h3,
.quiz-item h3 {
  margin: 0;
  font-size: 1rem;
}

.meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.card-text {
  color: #384647;
}

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

.small-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--brand-strong);
  font-weight: 800;
}

.quiz-options {
  display: grid;
  gap: 6px;
  padding-left: 20px;
  margin: 0;
}

.answer {
  color: var(--brand-strong);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--brand-strong);
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 900px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    display: block;
    padding-bottom: 92px;
  }

  .sidebar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 253, 250, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
  }

  .nav-button {
    min-height: 44px;
    padding: 0 8px;
    text-align: center;
    font-size: 0.82rem;
  }

  .summary-grid,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: grid;
  }

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

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .sidebar,
  .questionForm,
  .compact-actions,
  .toast,
  #dashboardView,
  #materialsView,
  #settingsView {
    display: none !important;
  }

  .layout,
  .content,
  .active-view {
    display: block;
    padding: 0;
  }

  .panel,
  .quiz-item {
    box-shadow: none;
    border-color: #cccccc;
  }
}
