:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #eef2f7;
  --line: #d8dee8;
  --text: #1f2937;
  --muted: #64748b;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --primary-soft: #d8f3ee;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --warning: #b7791f;
  --warning-soft: #fff3c4;
  --point: #7c3aed;
  --point-soft: #ede9fe;
  --focus: #2563eb;
  --shadow: 0 8px 26px rgba(15, 23, 42, 0.09);
  --radius: 8px;
  --nav-width: 232px;
}

body.nav-open .side-nav {
  transform: translateX(0);
}

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

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.brand small,
.eyebrow,
.meta-text {
  color: var(--muted);
}

.nav-list {
  display: grid;
  gap: 7px;
  padding: 18px 0;
}

.nav-item,
.bottom-nav button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 10px 12px;
}

.nav-item.active,
.bottom-nav button.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.nav-note {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fafafa;
}

.main-column {
  min-width: 0;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.top-bar h1 {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 0.83rem;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.menu-toggle {
  display: none;
}

.app-main {
  padding: 22px;
  padding-bottom: 92px;
}

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

.two-pane {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel,
.list-item,
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.panel {
  padding: 16px;
}

.panel-title-row,
.toolbar,
.row,
.item-actions,
.form-actions,
.folder-row,
.question-actions,
.stats-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-title-row {
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel h2,
.panel h3 {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0;
}

.panel p {
  line-height: 1.6;
}

.toolbar {
  margin-bottom: 12px;
}

.toolbar.sticky-tools {
  position: sticky;
  top: 78px;
  z-index: 7;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.input,
.textarea,
.select,
.editable {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
}

.textarea {
  line-height: 1.6;
}

.editable {
  min-height: 148px;
  overflow: auto;
}

.input.compact,
.select.compact {
  width: auto;
  min-width: 150px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field label,
.check-row {
  font-weight: 700;
}

.hint,
.empty-state,
.small-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.empty-state {
  padding: 22px;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius);
  background: #ffffff;
  text-align: center;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 13px;
  font-weight: 700;
}

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

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

.secondary-button {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

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

.ghost-button {
  background: transparent;
  color: var(--primary-strong);
}

.icon-button {
  min-width: 44px;
  padding: 9px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

.button-group {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
}

.button-group button {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  padding: 8px 12px;
}

.button-group button:last-child {
  border-right: 0;
}

.button-group button.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
}

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

.list-item {
  padding: 14px;
}

.list-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.item-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  margin: 0 0 5px;
  font-size: 1rem;
  letter-spacing: 0;
}

.excerpt {
  margin: 0;
  color: #334155;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #334155;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.o {
  background: #dcfce7;
  color: #166534;
}

.badge.x {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.triangle {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.collection {
  background: var(--point-soft);
  color: var(--point);
}

.item-actions {
  margin-top: 12px;
}

.item-actions button,
.small-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 7px 9px;
  color: var(--text);
}

.small-button.danger {
  border-color: #fecaca;
  color: var(--danger);
}

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

.folder-row {
  justify-content: space-between;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.folder-row.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.split-buttons {
  display: inline-flex;
  gap: 4px;
}

.quiz-card {
  max-width: 900px;
  margin-inline: auto;
}

.question-text {
  margin: 12px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 1.12rem;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ox-button {
  min-height: 72px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 1.5rem;
  font-weight: 900;
}

.ox-button.o {
  border-color: #86efac;
  color: #166534;
}

.ox-button.x {
  border-color: #fca5a5;
  color: #b42318;
}

.answer-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #ffffff;
}

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

.answer-box.wrong {
  border-color: #fca5a5;
  background: #fff7ed;
}

.marked-wrong {
  background: #fee2e2;
  color: #991b1b;
  border-bottom: 2px solid #ef4444;
}

.marked-point {
  background: #fef08a;
}

.marked-underline {
  text-decoration: underline 2px #2563eb;
  text-underline-offset: 3px;
}

.rich-output {
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.rich-output p {
  margin: 0 0 10px;
}

.rich-output ul,
.rich-output ol {
  margin: 8px 0 8px 22px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  overflow: hidden;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f8fafc;
}

.image-card .image-body {
  padding: 9px;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.46);
}

.modal-root.open {
  display: flex;
}

.modal-panel {
  width: min(720px, 100%);
  max-height: min(85vh, 760px);
  overflow: auto;
  padding: 18px;
}

.modal-panel h2 {
  margin-top: 0;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 22px;
  border-bottom: 1px solid #fde68a;
  background: #fffbeb;
}

.hidden {
  display: none !important;
}

.bottom-nav {
  display: none;
}

.danger-zone {
  border-color: #fecaca;
  background: #fff8f7;
}

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

.stats-row {
  align-items: stretch;
}

.stats-row .stat-card {
  flex: 1 1 150px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}


.order-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.order-control strong {
  min-width: 92px;
}

.order-move-label {
  font-weight: 700;
}

.order-control .order-target {
  width: 96px;
  min-width: 96px;
}

.order-control .hint {
  flex: 1 1 220px;
}
