:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --line: #d9ded6;
  --text: #20241f;
  --muted: #6c7668;
  --green: #2f6f4f;
  --green-soft: #e4efe8;
  --red: #b44735;
  --yellow: #d89a2b;
  --blue: #386fa4;
  --shadow: 0 12px 32px rgba(32, 36, 31, 0.08);
}

[hidden] { display: none !important; }
#exportDialog { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
#exportDialog::backdrop { background: #0006; }
#exportForm { display: grid; gap: 20px; min-width: 0; }
#exportForm h2 { font-size: 20px; margin: 0; }
#exportSummary { margin: -12px 0 0; }
.export-modes { margin: 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: 14px; }
.export-modes legend { padding: 0 0 8px; font-size: 13px; color: var(--muted); }
.export-modes label, .export-checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.export-modes input, .export-checkbox input { min-height: 0; margin: 0; width: 18px; height: 18px; accent-color: var(--green); }
#exportForm .field input { width: 100%; min-width: 0; }
#exportForm .editor-actions { margin-top: 0; }
#exportError { color: var(--red); font-size: 14px; margin: 0; }
a.nav-item { display: flex; align-items: center; text-decoration: none; }
.login-layer { position: fixed; inset: 0; background: #f4f6f8; z-index: 100; display: grid; place-items: center; padding: 20px; }
.login-layer form { width: min(100%, 380px); background: white; border: 1px solid #d9ded6; border-radius: 8px; padding: 28px; display: grid; gap: 24px; }
.notice:not(:empty) { position: fixed; bottom: 16px; right: 16px; max-width: min(460px, calc(100% - 32px)); z-index: 110; padding: 16px; background: #fff; color: #20241f; border: 1px solid #386fa4; border-radius: 8px; box-shadow: 0 4px 18px #0002; }
.management-section { border-top: 1px solid var(--line); padding: 24px 0; }
.management-section h2 { font-size: 20px; margin: 0 0 20px; }
.management-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; max-width: 960px; align-items: end; }
.management-form input, .management-form select, .management-form textarea { width: 100%; min-width: 0; }
.student-tools { display: flex; align-items: end; gap: 16px; margin-top: 24px; flex-wrap: wrap; }
.student-tools select { min-width: 200px; }
.class-record { border-top: 1px solid var(--line); padding: 24px 0; }
.class-record header { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.class-record h3 { margin: 0; font-size: 18px; }
.class-record p { white-space: pre-wrap; }
.class-photos { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0; }
.class-photos figure { margin: 0; width: min(220px, 100%); }
.class-photos img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 6px; background: #e8edf2; }
.class-photos figcaption { margin: 8px 0; }
.photo-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.photo-form input { width: 100%; min-width: 0; }
.selected-photo { max-width: 100%; max-height: 480px; object-fit: contain; display: block; margin-bottom: 20px; }
button, p, h1, h2, h3, figcaption { overflow-wrap: anywhere; }
main .editor { border: none; border-radius: 0; box-shadow: none; background: transparent; }
.book-preview .preview-item { border: none; border-radius: 0; border-bottom: 1px solid var(--line); background: transparent; }
@media (max-width: 600px) {
  .management-form { grid-template-columns: minmax(0, 1fr); }
  .layout { padding: 16px; }
  .topbar { align-items: start; flex-wrap: wrap; }
  h1 { font-size: 22px; }
  .photo-form .field { width: 100%; }
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: grid;
  grid-template-columns: 224px 1fr;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.sidebar {
  background: #273529;
  color: #fff;
  padding: 20px 16px;
  min-height: 100vh;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: #f2c14e;
  color: #243022;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.68);
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  width: 100%;
  min-height: 42px;
  text-align: left;
  padding: 0 12px;
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.layout {
  min-width: 0;
  padding: 24px;
}

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

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

h1 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.primary-button,
.ghost-button {
  border: 1px solid var(--green);
  min-height: 40px;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
}

.primary-button:disabled,
.ghost-button:disabled {
  border-color: var(--line);
  background: #eef1ec;
  color: var(--muted);
  cursor: not-allowed;
}

.primary-button {
  background: var(--green);
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--green);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.toolbar label {
  display: grid;
  gap: 6px;
  min-width: 160px;
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

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

.question-list {
  display: grid;
  gap: 10px;
}

.question-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--yellow);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  box-shadow: none;
}

.question-card.stored {
  border-left-color: var(--green);
}

.question-card.active {
  box-shadow: var(--shadow);
  border-color: var(--green);
}

.question-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}

.badge.pending {
  background: #fff1d6;
  color: #8a5d13;
}

.question-card h2 {
  font-size: 15px;
  line-height: 1.45;
  margin: 0 0 10px;
}

.meta {
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
}

.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 520px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.panel-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.section-title p {
  font-size: 13px;
}

.book-preview {
  display: grid;
  gap: 10px;
}

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

.preview-item strong,
.preview-item small {
  display: block;
}

.preview-item p {
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
}

.preview-item small,
.reminder-list small {
  color: var(--muted);
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

textarea {
  resize: vertical;
  min-height: 92px;
}

.editor-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.editor-actions.flush-left {
  justify-content: flex-start;
}

.reminder-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.reminder-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.reminder-list article {
  border-left: 4px solid var(--blue);
  background: #f7fafc;
  border-radius: 8px;
  padding: 12px;
}

.reminder-list strong,
.reminder-list small {
  display: block;
}

.reminder-list p {
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 8px;
}

.empty-state {
  min-height: 480px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-state.compact {
  min-height: 120px;
  padding: 14px;
}

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

  .sidebar {
    min-height: auto;
  }

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

  .metrics,
  .workbench,
  .editor-grid,
  .reminder-form {
    grid-template-columns: 1fr;
  }
}
