:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #d7e0ec;
  --soft-line: #e8eef6;
  --accent: #2563eb;
  --ok: #15803d;
  --bad: #b91c1c;
  --shadow: 0 18px 45px rgba(18, 32, 56, 0.1);
  --small-shadow: 0 8px 24px rgba(18, 32, 56, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.1), transparent 34%),
    linear-gradient(135deg, #f7fafc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  appearance: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  background: rgba(255, 255, 255, 0.88);
  border-right: 1px solid rgba(215, 224, 236, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  box-shadow: var(--small-shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(135deg, #172033, #2563eb);
  font-weight: 800;
  letter-spacing: 0.04em;
}

h1,
h2,
p {
  margin: 0;
}

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

.brand p,
.eyebrow {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.filter-block {
  margin-top: 18px;
}

.filter-block h2 {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.subject-tabs,
.segmented {
  display: grid;
  gap: 8px;
}

.subject-tabs button,
.segmented button,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.subject-tabs button {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.subject-tabs button.active,
.segmented button.active {
  border-color: rgba(37, 99, 235, 0.45);
  background: #eef5ff;
  color: #153e9f;
}

.subject-tabs button:hover,
.segmented button:hover,
.utility-button:hover,
.secondary-button:hover {
  border-color: rgba(37, 99, 235, 0.38);
  background: #f8fbff;
}

.subject-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

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

.segmented button {
  cursor: pointer;
}

select {
  padding: 0 12px;
}

.switch {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  color: var(--text);
}

.utility-button,
.primary-button,
.secondary-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  text-align: center;
}

.utility-button + .utility-button {
  margin-top: 8px;
}

.danger-button {
  border-color: #fecaca;
  background: #fff8f8;
  color: var(--bad);
}

.file-button input {
  display: none;
}

.main {
  min-width: 0;
  padding: 30px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
  padding: 20px 22px;
  border: 1px solid rgba(215, 224, 236, 0.85);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--small-shadow);
  backdrop-filter: blur(12px);
}

.toolbar h2 {
  margin-top: 4px;
  font-size: 30px;
  letter-spacing: 0;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span,
.question-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
}

.questions {
  display: grid;
  gap: 16px;
}

.add-panel {
  display: block;
}

.add-panel[hidden],
.questions[hidden],
[hidden] {
  display: none !important;
}

.question-form {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.question-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.question-form input,
.question-form select,
.question-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
}

.question-form input:focus,
.question-form select:focus,
.question-form textarea:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.question-form input,
.question-form select {
  min-height: 42px;
  padding: 0 12px;
}

.question-form textarea {
  min-height: 70px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.6;
}

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

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

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.image-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button {
  width: auto;
  min-width: 120px;
  padding: 0 16px;
}

.primary-button {
  border-color: #172033;
  background: linear-gradient(135deg, #172033, #2563eb);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
}

.question-card {
  position: relative;
  padding: 20px;
  border: 1px solid rgba(215, 224, 236, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.edit-question {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
}

.edit-question:hover {
  border-color: #172033;
  color: #172033;
}

.question-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-right: 42px;
}

.question-meta .verified {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--ok);
}

.question-meta .pending {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.stem,
.explanation,
.option div {
  line-height: 1.75;
}

.stem {
  font-size: 16px;
}

.stem img,
.explanation img,
.option img {
  max-width: 100%;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.stem table,
.explanation table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  overflow: auto;
}

td,
th {
  border: 1px solid var(--line);
  padding: 8px;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover {
  border-color: rgba(37, 99, 235, 0.38);
  background: #f8fbff;
}

.option > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #eef5ff;
  color: #1d4ed8;
  font-weight: 800;
}

.option.correct {
  border-color: #86efac;
  background: #f0fdf4;
}

.option.wrong {
  border-color: #fecaca;
  background: #fef2f2;
}

.feedback {
  margin-top: 12px;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
}

.feedback.ok {
  background: #dcfce7;
  color: var(--ok);
}

.feedback.bad {
  background: #fee2e2;
  color: var(--bad);
}

.explanation {
  display: none;
  margin-top: 14px;
  border: 1px solid #dbeafe;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 12px 14px;
  background: #f8fbff;
}

.explanation.show {
  display: block;
}

.answer-line {
  margin-bottom: 8px;
  font-weight: 800;
}

.source-path {
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 42px 28px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--muted);
  text-align: center;
  box-shadow: var(--small-shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 18px;
  }

  .toolbar {
    display: grid;
  }

  .stats {
    justify-content: flex-start;
  }

  .form-grid,
  .choice-fields {
    grid-template-columns: 1fr;
  }

  .form-actions {
    display: grid;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
