* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --board-bg: #143f2e;
  --board-grid: rgba(255, 255, 255, 0.085);
  color: #172033;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #e7ebf0;
}

body {
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.file-picker {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.load-status {
  max-width: 180px;
  overflow: hidden;
  color: #475569;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.h-screen {
  height: 100vh;
}

.overflow-hidden {
  overflow: hidden;
}

.app-shell {
  width: 100vw;
  background: #0b5f4a;
}

.workspace {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.sidebar {
  height: 100%;
  background: #f8fafc;
  border-right: 1px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: width 260ms ease, transform 260ms ease, opacity 200ms ease;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 12px;
}

.sidebar.open {
  width: 25%;
  min-width: 320px;
  opacity: 1;
}

.sidebar.closed {
  width: 0;
  min-width: 0;
  transform: translateX(-12px);
  opacity: 0;
}

.sidebar-head {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #dbe3ed;
  background: #f8fafc;
}

.eyebrow {
  margin: 0 0 2px;
  color: #0f766e;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar h1 {
  margin: 0;
  font-size: 23px;
  line-height: 1;
}

.icon-button,
.icon-tool,
.reopen-button {
  width: 42px;
  height: 42px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #172033;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.icon-tool.text-tool {
  width: auto;
  min-width: 72px;
  padding: 0 10px;
  white-space: nowrap;
}

.reopen-button {
  position: absolute;
  z-index: 30;
  top: 14px;
  left: 14px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.right-reopen-button {
  position: absolute;
  z-index: 80;
  top: 14px;
  right: 14px;
  min-width: 64px;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
  font-weight: 900;
}

.panel {
  margin: 0 10px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  flex: 0 0 auto;
}

.media-panel {
  order: 70;
  min-height: auto;
}

.media-panel .section-title {
  margin-bottom: 0;
  cursor: pointer;
}

.media-panel .section-title::after {
  content: "펼치기";
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.media-panel.expanded .section-title {
  margin-bottom: 9px;
}

.media-panel.expanded .section-title::after {
  content: "접기";
}

.media-panel:not(.expanded) #youtubeUrl,
.media-panel:not(.expanded) .check-row,
.media-panel:not(.expanded) #mediaFrame {
  display: none;
}

.sidebar .panel:has(#subjectButtons) {
  order: 80;
}

.sidebar .panel:has(#subjectButtons) .section-title {
  margin-bottom: 0;
  cursor: pointer;
}

.sidebar .panel:has(#subjectButtons):not(.expanded) #subjectButtons,
.sidebar .panel:has(#subjectButtons):not(.expanded) #unitInput,
.sidebar .panel:has(#subjectButtons):not(.expanded) #autoFillLessonButton,
.sidebar .panel:has(#subjectButtons):not(.expanded) .check-row,
.sidebar .panel:has(#subjectButtons):not(.expanded) #productList {
  display: none;
}

.sidebar .panel:has(#subjectButtons) .section-title::after {
  content: "펼치기";
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.sidebar .panel:has(#subjectButtons).expanded .section-title::after {
  content: "접기";
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-weight: 800;
}

.section-title small {
  margin-left: auto;
  color: #64748b;
}

.text-input,
.word-row input,
.template-select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f8fafc;
  outline: none;
}

.template-select {
  width: auto;
  min-width: 138px;
  height: 40px;
  background: #ffffff;
  color: #172033;
  font-weight: 800;
}

.text-input:focus,
.word-row input:focus {
  border-color: #0f766e;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.workbook-picker {
  display: grid;
  gap: 8px;
}

.workbook-picker > #workbookTypeInput { order: 1; }
.workbook-picker > .workbook-meta-grid { order: 2; }
.workbook-picker > #workbookExamFields { order: 3; }
.workbook-picker > #workbookPresetSelect { order: 4; }
.workbook-picker > #workbookNameInput { order: 5; }
.workbook-picker > #workbookKeyPreview { order: 6; }
.workbook-picker > #workbookPreparationPanel { order: 7; }

.workbook-picker .template-select {
  width: 100%;
}

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

.workbook-meta-grid > #workbookCurriculumInput { order: 1; }
.workbook-meta-grid > #workbookSchoolLevelSelect { order: 2; }
.workbook-meta-grid > #workbookGradeInput { order: 3; }
.workbook-meta-grid > #workbookSemesterSelect { order: 4; }
.workbook-meta-grid > #workbookPublisherInput {
  order: 5;
  grid-column: 1 / -1;
}

.workbook-key-preview {
  display: block;
  padding: 7px 8px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.workbook-type-first {
  width: 100%;
  min-height: 38px;
  border-color: #0f766e;
  background: #f0fdfa;
  color: #065f46;
  font-weight: 900;
}

.workbook-exam-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  background: #f0f9ff;
}

.workbook-exam-fields[hidden],
.workbook-exam-fields > [hidden] {
  display: none;
}

.workbook-exam-fields .template-select,
.workbook-exam-fields .text-input {
  width: 100%;
  min-width: 0;
}

.workbook-preparation-panel {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #dbe3ed;
}

.workbook-analysis-shortcut {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 900;
}

.workbook-preparation-panel[hidden] {
  display: none;
}

.workbook-preparation-copy {
  display: grid;
  gap: 3px;
}

.workbook-preparation-copy strong {
  color: #172033;
  font-size: 13px;
}

.workbook-preparation-copy small,
#workbookPreparationNote {
  color: #64748b;
  font-size: 11px;
  line-height: 1.45;
}

.workbook-preparation-alert {
  padding: 11px 12px;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fff1f2;
  color: #991b1b;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
}

.workbook-preparation-alert[data-tone="notice"] {
  border-color: #d97706;
  background: #fffbeb;
  color: #92400e;
}

.workbook-candidate-panel {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 2px solid #2563eb;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
}

.workbook-candidate-panel small { line-height: 1.45; }
.workbook-candidate-panel #workbookCandidateList { display: grid; gap: 6px; }
.workbook-candidate-panel button { width: 100%; text-align: left; }
.workbook-candidate-panel[hidden],
.workbook-preparation-alert[hidden] { display: none; }

.workbook-ocr-mode {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 11px;
  font-weight: 900;
}

.workbook-ocr-mode .template-select {
  width: 100%;
  min-width: 0;
  height: 32px;
  font-size: 11px;
}

.workbook-custom-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 6px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.workbook-custom-range[hidden] {
  display: none;
}

.workbook-custom-range label {
  display: grid;
  gap: 3px;
}

.workbook-custom-range input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 7px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #172033;
  font: inherit;
}

.workbook-preparation-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
}

#workbookPreparationStatus[data-state="ready"] {
  color: #047857;
}

#workbookPreparationStatus[data-state="running"] {
  color: #0f766e;
}

#workbookPreparationBar {
  width: 100%;
  height: 7px;
  accent-color: #0f766e;
}

.workbook-preparation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.workbook-preparation-actions .tiny-button {
  min-height: 32px;
  border-color: #0f766e;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 900;
}

.workbook-preparation-actions .tiny-button.secondary {
  background: #ffffff;
  color: #475569;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: #334155;
  font-size: 14px;
}

.media-frame {
  width: 100%;
  min-height: 260px;
  overflow: hidden;
  border-radius: 8px;
  background: #eef3f8;
  border: 1px solid #dbe4ee;
}

.youtube-layer {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0f172a;
}

.media-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.media-badge {
  position: absolute;
  z-index: 2;
  top: 8px;
  left: 8px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.94);
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.media-idle {
  min-height: 116px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 16px;
  text-align: center;
  color: #334155;
}

.media-idle strong {
  font-size: 18px;
}

.media-idle span,
.media-idle small {
  color: #64748b;
}

.fallback-slide {
  min-height: 210px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #ffffff;
}

.fallback-slide strong {
  font-size: 23px;
  margin-bottom: 8px;
}

.fallback-slide p {
  margin: 0;
  line-height: 1.5;
}

.fallback-slide.emerald {
  background: linear-gradient(135deg, #047857, #0f766e);
}

.fallback-slide.sky {
  background: linear-gradient(135deg, #0369a1, #0891b2);
}

.fallback-slide.amber {
  background: linear-gradient(135deg, #b45309, #ca8a04);
}

.slide-controls {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.dot {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

.dot.active {
  background: #ffffff;
}

.video-queue {
  display: grid;
  gap: 8px;
  padding: 9px;
}

.video-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid #dbe4ee;
  border-radius: 8px;
  background: #ffffff;
  padding: 9px;
}

.video-card.primary {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.video-card div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.video-card strong,
.video-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-card strong {
  color: #0f172a;
  font-size: 14px;
}

.video-card span {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.video-card button {
  min-height: 34px;
  border: 1px solid #0f766e;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  padding: 0 9px;
}

.video-recommend-title {
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  padding: 2px 2px 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.segmented button,
.layout-toggle button,
.load-mode-toggle button,
.tool-button,
.market-button,
.procure-button,
.modal-actions button,
.tiny-button {
  min-height: 40px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #172033;
  border-radius: 8px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
}

.segmented button.active,
.layout-toggle button.active,
.load-mode-toggle button.active,
.tool-button.active,
.icon-tool.active {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.tool-button.recording {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
  animation: recordPulse 1.1s ease-in-out infinite;
}

.tool-button.twin-action {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.tool-button.twin-action:hover {
  background: #dcfce7;
}

@keyframes recordPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(220, 38, 38, 0);
  }
}

.icon-button:disabled,
.icon-tool:disabled,
.tool-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.material-source-panel {
  order: 1;
  min-height: 420px;
  flex: 0 0 min(64vh, 620px);
  display: flex;
  flex-direction: column;
}

.material-source-title {
  min-height: 30px;
}

.material-clear-button {
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.material-clear-button:hover {
  border-color: #ef4444;
  background: #fef2f2;
  color: #b91c1c;
}

.material-controls {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 8px;
}

.material-controls .load-accordion,
.material-controls .url-accordion {
  min-width: 0;
  width: 100%;
}

.material-controls .load-accordion summary,
.material-controls .url-accordion summary {
  width: 100%;
  min-height: 36px;
  justify-content: center;
  padding: 0 7px;
  font-size: 12px;
  white-space: nowrap;
}

.material-controls .workbook-analysis-shortcut {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0 5px;
  font-size: 12px;
  white-space: nowrap;
}

.material-controls .load-menu,
.material-controls .url-loader {
  position: absolute;
  z-index: 90;
  top: calc(100% + 5px);
  width: calc(300% + 10px);
  min-width: 0;
  margin-top: 0;
}

.material-controls .load-menu {
  left: 0;
}

.material-controls .url-loader {
  right: 0;
}

.material-dock {
  position: relative;
  flex: 1;
  min-height: 300px;
  overflow: auto;
  display: grid;
  place-items: stretch;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #e5e7eb;
}

.material-dock.crop-cursor {
  cursor: crosshair;
}

.material-dock.crop-cursor .pdf-canvas-wrap,
.material-dock.crop-cursor .pdf-page-canvas {
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.material-dock .empty-state {
  min-height: 260px;
  background: #f8fafc;
}

.material-select-rect {
  position: absolute;
  z-index: 50;
  border: 2px solid #14b8a6;
  background: rgba(20, 184, 166, 0.14);
  pointer-events: none;
}

.material-dock .loaded-document,
.material-dock .loaded-image,
.material-dock .pdf-shell,
.material-dock .deck-shell,
.material-dock .office-fallback,
.material-dock .url-frame-shell {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
}

.material-dock .pdf-shell {
  border-width: 0;
  border-radius: 8px;
  box-shadow: none;
}

.material-dock .loaded-image {
  object-fit: contain;
  background: #ffffff;
}

.product-card {
  display: flex;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px;
  background: #fbfdff;
}

.product-thumb {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  font-size: 24px;
  font-weight: 900;
}

.product-copy {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 4px;
}

.product-copy span {
  color: #64748b;
  font-size: 13px;
}

.market-button,
.procure-button {
  width: 100%;
  min-height: 34px;
  font-size: 13px;
}

.procure-button {
  color: #075985;
  border-color: #7dd3fc;
  background: #e0f2fe;
}

.capture-panel {
  order: 20;
  flex: 0 0 auto;
  min-height: auto;
  display: flex;
  flex-direction: column;
}

.capture-panel .section-title {
  margin-bottom: 0;
  cursor: pointer;
}

.capture-panel .section-title::after {
  content: "펼치기";
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.capture-panel.expanded .section-title {
  margin-bottom: 9px;
}

.capture-panel.expanded .section-title::after {
  content: "접기";
}

.capture-panel:not(.expanded) .capture-list,
.capture-panel:not(.expanded) .mathlo-draft-panel {
  display: none;
}

.capture-list {
  min-height: 180px;
  max-height: 260px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.capture-card {
  margin: 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.capture-card img {
  width: 100%;
  height: 94px;
  object-fit: contain;
  background: #f8fafc;
  display: block;
}

.capture-card figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  font-size: 12px;
}

.mathlo-draft-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.mathlo-draft-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mathlo-draft-preview {
  min-height: 84px;
  max-height: 150px;
  margin: 8px 0 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
}

.tiny-button {
  min-height: 26px;
  padding: 0 7px;
  font-size: 12px;
}

.empty-state {
  height: 100%;
  min-height: 120px;
  display: grid;
  place-items: center;
  text-align: center;
  color: #64748b;
  padding: 14px;
}

.empty-state.compact {
  min-height: 180px;
  grid-column: 1 / -1;
}

.lesson-area {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0b5f4a;
  transition: width 260ms ease;
}

.lesson-area.with-sidebar {
  width: 75%;
}

.lesson-area.full {
  width: 100%;
}

.toolbar {
  position: absolute;
  z-index: 75;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 34vw);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  background: #f8fafc;
  border-left: 1px solid #cbd5e1;
  box-shadow: -16px 0 34px rgba(15, 23, 42, 0.14);
  overflow-x: hidden;
  overflow-y: auto;
  transition: transform 240ms ease, opacity 180ms ease;
}

.toolbar.closed {
  transform: translateX(calc(100% + 18px));
  opacity: 0;
  pointer-events: none;
}

.right-tools-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  border-bottom: 1px solid #dbe3ed;
  padding-bottom: 10px;
  order: -100;
}

.toolbar .boardlo-service-nav {
  order: -90;
}

.toolbar .workbook-accordion {
  order: -80;
  scroll-margin-top: 12px;
}

.right-tools-head strong {
  color: #0f172a;
  font-size: 18px;
  font-weight: 950;
}

.boardlo-service-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.boardlo-service-nav a,
.boardlo-service-nav button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.boardlo-service-nav button {
  cursor: pointer;
}

.boardlo-service-nav a:first-child {
  background: #0f766e;
  border-color: #0f766e;
  color: #ffffff;
}

.boardlo-fullscreen-controls {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 8px;
  right: 8px;
}

:fullscreen .boardlo-fullscreen-controls {
  display: block;
}

.boardlo-fullscreen-controls button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.toolbar button,
.toolbar summary,
.layout-ratio-group,
.template-select {
  white-space: nowrap;
}

.toolbar .load-accordion,
.toolbar .url-accordion,
.toolbar .workbook-accordion,
.toolbar .theme-accordion,
.toolbar .layout-ratio-group,
.toolbar .template-select,
.toolbar .tool-button {
  width: 100%;
}

.toolbar .tool-button,
.toolbar .template-select {
  min-height: 38px;
}

.toolbar .load-menu,
.toolbar .url-loader,
.toolbar .workbook-picker,
.toolbar .theme-options {
  position: static;
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  box-shadow: none;
}

.toolbar .theme-options {
  grid-template-columns: 1fr 1fr;
}

.toolbar .layout-ratio-group {
  display: grid;
  gap: 7px;
}

.toolbar .layout-toggle,
.toolbar .load-mode-toggle {
  width: 100%;
}

.toolbar .url-input {
  min-width: 0;
}

.toolbar .print-action {
  margin-left: 0;
}

.ink-dock {
  width: 132px;
  max-height: calc(100% - 112px);
  position: absolute;
  z-index: 72;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 6px;
  padding: 38px 8px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: rgba(238, 243, 247, 0.96);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
  overflow-x: visible;
  overflow-y: auto;
}

.ink-dock.dock-free {
  right: auto;
  bottom: auto;
}

.ink-dock.collapsed {
  width: 48px;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  gap: 0;
  padding: 0;
  overflow: visible;
}

.ink-dock.collapsed > :not(.floating-tools-head) {
  display: none;
}

.lesson-area.pdf-zoom-open .ink-dock {
  isolation: isolate;
  z-index: 200;
}

.ink-dock.dragging {
  cursor: grabbing;
  z-index: 210;
}

.floating-tools-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 8px;
  border-bottom: 1px solid #dbe3ed;
  border-radius: 12px 12px 0 0;
  background: #ffffff;
  color: #172033;
  cursor: grab;
  touch-action: none;
  user-select: none;
  z-index: 2;
}

.floating-tools-head:active {
  cursor: grabbing;
}

.floating-tools-head strong {
  font-size: 12px;
  font-weight: 950;
}

.floating-tools-head span {
  color: #64748b;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.floating-tools-head .ink-dock-drag-label {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 18px;
  line-height: 1;
}

.floating-tools-head button {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #172033;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  padding: 0;
}

.ink-dock.collapsed .floating-tools-head {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 10px;
}

.ink-dock.collapsed .floating-tools-head strong,
.ink-dock.collapsed .ink-dock-drag-label {
  display: none;
}

.ink-dock.collapsed .floating-tools-head button {
  width: 40px;
  height: 40px;
  position: relative;
  z-index: 3;
  border-color: #0f766e;
  background: #f0fdfa;
  color: #0f766e;
  font-size: 22px;
  touch-action: manipulation;
}

.utility-panel {
  position: absolute;
  right: 18px;
  bottom: 92px;
  z-index: 70;
  width: min(360px, calc(100% - 36px));
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  color: #172033;
  padding: 12px;
}

.utility-panel.timer-bottom-right {
  right: 18px;
  bottom: 92px;
  left: auto;
  top: auto;
  transform: none;
}

.utility-panel.timer-bottom-left {
  left: 18px;
  bottom: 92px;
  right: auto;
  top: auto;
  transform: none;
}

.utility-panel.timer-top-left {
  left: 18px;
  top: 82px;
  right: auto;
  bottom: auto;
  transform: none;
}

.utility-panel.timer-top-right {
  right: 18px;
  top: 82px;
  left: auto;
  bottom: auto;
  transform: none;
}

.utility-panel.timer-top-center {
  left: 50%;
  top: 82px;
  right: auto;
  bottom: auto;
  transform: translateX(-50%);
}

.utility-panel.timer-center {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
}

.utility-panel.timer-free {
  right: auto;
  bottom: auto;
  transform: none;
}

.utility-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  cursor: grab;
  user-select: none;
}

.utility-panel header:active {
  cursor: grabbing;
}

.utility-panel header strong {
  font-weight: 900;
}

.utility-panel header button {
  width: 32px;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
}

.utility-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.audio-controls,
.timer-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.audio-controls button,
.timer-controls button {
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font-weight: 900;
  cursor: pointer;
}

.audio-controls button:disabled {
  cursor: default;
  opacity: 0.45;
}

.utility-status {
  margin-top: 8px;
  border-radius: 8px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  padding: 8px;
}

.timer-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.timer-position-controls {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.timer-position-controls:not(.expanded) {
  min-height: 40px;
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  padding: 0 10px;
}

.timer-position-controls:not(.expanded)::before {
  content: "위치";
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.timer-position-controls:not(.expanded)::after {
  content: attr(data-current-position);
  justify-self: end;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
}

.timer-position-controls:not(.expanded) button {
  display: none;
}

.timer-position-controls.expanded {
  position: absolute;
  z-index: 120;
  top: 48px;
  left: 12px;
  right: 12px;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 7px;
}

.timer-position-controls.expanded::before {
  content: "위치 선택";
  grid-column: 1 / -1;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.timer-position-controls button {
  min-height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.timer-position-controls.expanded button {
  min-height: 36px;
  font-size: 12px;
}

.timer-position-controls button.active {
  border-color: #4338ca;
  background: #4338ca;
  color: #ffffff;
}

.timer-inputs label {
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}

.timer-inputs input {
  width: 100%;
  height: 40px;
  margin-top: 4px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 18px;
  font-weight: 900;
  padding: 0 8px;
}

.timer-display {
  margin-top: 10px;
  border-radius: 12px;
  background: #eef2ff;
  color: #4338ca;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 46px;
  font-weight: 900;
  text-align: center;
  padding: 12px;
}

.timer-display.done {
  background: #fff1f2;
  color: #be123c;
}

.tool-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.ink-dock .icon-tool,
.ink-dock .icon-tool.text-tool {
  width: 100%;
  min-width: 0;
  height: 34px;
  justify-content: flex-start;
  padding: 0 7px;
  font-size: 11px;
  line-height: 1.1;
}

.ink-dock .icon-tool:not(.text-tool) {
  justify-content: center;
}

.ink-dock .quick-color-tool {
  min-height: 34px;
  justify-content: center;
  border-color: color-mix(in srgb, var(--quick-color) 44%, #cbd5e1);
  background: color-mix(in srgb, var(--quick-color) 12%, #ffffff);
}

.ink-dock .quick-color-tool.active {
  border-color: var(--quick-color);
  background: color-mix(in srgb, var(--quick-color) 24%, #ffffff);
  box-shadow: inset 0 0 0 2px var(--quick-color), 0 8px 18px color-mix(in srgb, var(--quick-color) 22%, transparent);
}

.ink-dock .twin-quick-tool {
  border-color: #86efac;
  background: #ecfdf5;
  color: #166534;
}

.ink-dock .twin-quick-tool:hover {
  border-color: #16a34a;
  background: #dcfce7;
}

.quick-color-dot {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex: 0 0 22px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--quick-color);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28);
}

.ink-dock .color-tool {
  justify-content: flex-start;
}

.current-color-dot {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 18px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--current-ink-color, #ef4444);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.28);
}

.ink-dock .tool-group {
  order: 1;
}

.ink-dock #penWidthControl {
  order: 3;
}

.ink-dock #eraserWidthControl {
  order: 4;
}

.ink-dock .math-tools-launcher {
  order: 5;
}

.ink-dock .shape-accordion {
  order: 6;
}

.ink-dock .construction-accordion {
  order: 7;
}

.ink-dock .shape-accordion summary,
.ink-dock .tool-slider {
  width: 100%;
}

.math-tools-launcher {
  border-top: 1px solid #cbd5e1;
  padding-top: 6px;
}

.ink-dock .math-tools-button {
  border-color: #5eead4;
  background: #f0fdfa;
  color: #0f766e;
  font-weight: 950;
}

.math-tools-popover {
  width: min(230px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  position: fixed;
  z-index: 140;
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.24);
  overflow: visible;
}

.math-tools-popover[hidden] {
  display: none;
}

.math-tools-popover > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 950;
}

.math-tools-popover > header button {
  width: 28px;
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #475569;
  font-size: 18px;
  cursor: pointer;
}

.math-tools-popover > .shape-accordion > summary {
  width: 100%;
  height: 36px;
}

.theme-accordion {
  position: relative;
  flex: 0 0 auto;
}

.theme-accordion summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-weight: 900;
  padding: 0 12px;
  list-style: none;
}

.theme-accordion summary::-webkit-details-marker {
  display: none;
}

.theme-accordion[open] summary {
  border-color: #0f766e;
  color: #0f766e;
}

.theme-options {
  position: absolute;
  z-index: 90;
  top: calc(100% + 8px);
  left: 0;
  min-width: 210px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 9px;
}

.theme-options .tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 7px;
}

.theme-dot {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.22);
}

.theme-dot.green {
  background: #0b5f4a;
}

.theme-dot.blue {
  background: #1e5aa8;
}

.theme-dot.dark {
  background: #1f2933;
}

.theme-dot.paper {
  background: #ffffff;
}

.load-accordion,
.url-accordion,
.workbook-accordion {
  position: relative;
  flex: 0 0 auto;
}

.load-accordion summary,
.url-accordion summary,
.workbook-accordion summary {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-weight: 900;
  padding: 0 12px;
  list-style: none;
}

.load-accordion summary::-webkit-details-marker,
.url-accordion summary::-webkit-details-marker,
.workbook-accordion summary::-webkit-details-marker {
  display: none;
}

.load-accordion[open] summary,
.url-accordion[open] summary,
.workbook-accordion[open] summary {
  border-color: #0f766e;
  color: #0f766e;
}

.load-menu {
  position: absolute;
  z-index: 95;
  top: calc(100% + 8px);
  left: 0;
  width: 290px;
  display: grid;
  gap: 9px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 10px;
}

.load-accordion:not([open]) .load-menu,
.url-accordion:not([open]) .url-loader,
.workbook-accordion:not([open]) .workbook-picker,
.theme-accordion:not([open]) .theme-options,
.shape-accordion:not([open]) .shape-tools {
  display: none;
}

.load-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.load-menu-mode {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.load-menu-mode > span {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.load-menu .load-mode-toggle {
  justify-content: flex-end;
}

.load-menu .load-status {
  max-width: none;
  min-height: 30px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  background: #f8fafc;
  padding: 0 9px;
}

.url-loader {
  position: absolute;
  z-index: 90;
  top: calc(100% + 8px);
  left: 0;
  width: min(440px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 9px;
}

.url-input {
  min-width: 280px;
}

.layout-toggle,
.load-mode-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
}

.layout-ratio-group {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
  padding: 4px;
}

.layout-ratio-group > span {
  color: #475569;
  font-size: 12px;
  font-weight: 900;
  padding-left: 6px;
}

.layout-ratio-group .layout-toggle {
  border: 0;
  padding: 0;
}

.layout-toggle button,
.load-mode-toggle button {
  min-height: 32px;
  padding: 0 10px;
}

.tool-button.subtle {
  color: #475569;
  background: #f8fafc;
}

.color-palette {
  min-height: 42px;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
}

.color-palette::before {
  content: "펜색";
  display: inline-flex;
  align-items: center;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.color-palette.expanded {
  position: fixed;
  display: inline-flex;
  z-index: 160;
  left: var(--fixed-popover-left, calc(100% + 10px));
  top: var(--fixed-popover-top, 40px);
  bottom: auto;
  width: max-content;
  max-width: min(330px, calc(100vw - 24px));
  flex-wrap: wrap;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.color-swatch {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #cbd5e1;
  cursor: pointer;
  padding: 0;
}

.color-swatch.white {
  box-shadow: inset 0 0 0 1px #cbd5e1, 0 0 0 1px #94a3b8;
}

.color-swatch.active {
  box-shadow: 0 0 0 3px #0f766e;
}

.tool-slider {
  min-width: 270px;
  min-height: 84px;
  display: grid;
  grid-template-columns: auto 42px 90px 42px 28px 38px;
  align-items: center;
  gap: 6px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.size-name {
  min-width: 38px;
}

.size-nudge {
  width: 42px;
  height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.size-nudge:active {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.tool-slider input {
  width: 90px;
  accent-color: #0f766e;
}

.tool-slider output {
  color: #475569;
  text-align: right;
}

.pen-kind-options,
.eraser-mode-options,
.size-presets {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.eraser-mode-options {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.pen-kind-options button,
.eraser-mode-options button,
.size-presets button {
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.pen-kind-options button.active,
.eraser-mode-options button.active,
.size-presets button:active {
  border-color: #0f766e;
  background: #ecfdf5;
  color: #0f766e;
}

.size-preview {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background:
    linear-gradient(45deg, rgba(148, 163, 184, 0.22) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(148, 163, 184, 0.22) 25%, transparent 25%),
    #f8fafc;
  background-size: 10px 10px;
  overflow: hidden;
}

.size-preview span {
  width: var(--preview-size, 6px);
  height: var(--preview-size, 6px);
  border-radius: 999px;
  background: var(--preview-color, #ef4444);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18);
}

.eraser-size-preview span {
  background: rgba(255, 255, 255, 0.74);
  border: 2px dashed #64748b;
  box-shadow: none;
}

.size-control:not(.expanded) {
  min-width: 82px;
  min-height: 42px;
  grid-template-columns: auto 30px;
  gap: 8px;
  padding: 5px 10px;
}

.size-control:not(.expanded) .size-nudge,
.size-control:not(.expanded) input,
.size-control:not(.expanded) output,
.size-control:not(.expanded) .pen-kind-options,
.size-control:not(.expanded) .eraser-mode-options,
.size-control:not(.expanded) .size-presets {
  display: none;
}

.size-control:not(.expanded) .size-name {
  min-width: auto;
  color: #172033;
  font-size: 12px;
}

.size-control:not(.expanded) .size-preview {
  width: 30px;
  height: 30px;
}

.size-control.expanded {
  position: fixed;
  z-index: 160;
  width: 326px;
  max-width: calc(100vw - 24px);
  left: var(--fixed-popover-left, calc(100% + 10px));
  top: var(--fixed-popover-top, var(--popover-top, 92px));
  bottom: auto;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.shape-count {
  height: 42px;
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 6px;
  border: 1px solid #d8e0ea;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 8px;
}

.shape-count select {
  height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #f8fafc;
  font-weight: 900;
}

.shape-accordion {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  gap: 8px;
}

.shape-accordion summary {
  height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-weight: 900;
  padding: 0 12px;
  list-style: none;
}

.shape-accordion summary::-webkit-details-marker {
  display: none;
}

.shape-accordion[open] summary {
  border-color: #0f766e;
  color: #0f766e;
}

.shape-tools {
  min-width: min(620px, calc(100vw - 32px));
  max-width: min(720px, calc(100vw - 32px));
  max-height: min(62vh, 560px);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
  padding: 9px;
  overflow: auto;
}

.shape-tool-label {
  flex: 1 0 100%;
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin-top: 4px;
}

.shape-tool-label:first-child {
  margin-top: 0;
}

.shape-accordion[open] .shape-tools {
  position: absolute;
  z-index: 85;
  left: calc(100% + 10px);
  top: 0;
  bottom: auto;
}

.print-action {
  margin-left: auto;
  color: #7c2d12;
  border-color: #fdba74;
  background: #fff7ed;
}

.document-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}

.document-stage.chalk {
  background: #0b5f4a;
}

.document-stage.blue {
  background: #1e5aa8;
}

.document-stage.dark {
  background: #1f2933;
}

.document-stage.paper {
  background: #f8fafc;
}

.split-board-pane {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  bottom: 12px;
  left: 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
}

.document-stage.split-half .split-board-pane,
.document-stage.split-quarter .split-board-pane {
  border: 2px solid rgba(255, 255, 255, 0.42);
  background: rgba(0, 0, 0, 0.04);
}

.document-stage.dark .split-board-pane {
  background: transparent;
}

.document-stage.blue .split-board-pane {
  background: transparent;
}

.document-stage.paper .split-board-pane {
  border-color: transparent;
  background: transparent;
}

.document-stage.split-half .stage-placeholder,
.document-stage.split-quarter .stage-placeholder {
  position: absolute;
  z-index: 2;
  left: 12px;
  top: 12px;
  margin: 0;
  padding: 16px;
  border: 10px solid #ffffff;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

.document-stage.split-half .stage-placeholder,
.document-stage.split-half .loaded-document:not(.blank-page),
.document-stage.split-half .loaded-image {
  height: calc(100% - 24px);
}

.document-stage.split-quarter .stage-placeholder,
.document-stage.split-quarter .loaded-document:not(.blank-page),
.document-stage.split-quarter .loaded-image {
  height: calc(50% - 18px);
}

.document-stage.split-half .stage-placeholder,
.document-stage.split-quarter .stage-placeholder,
.document-stage.split-half .loaded-document:not(.blank-page),
.document-stage.split-quarter .loaded-document:not(.blank-page),
.document-stage.split-half .loaded-image,
.document-stage.split-quarter .loaded-image {
  position: absolute;
  z-index: 2;
  left: 12px;
  top: 12px;
  width: calc(50% - 18px);
  max-width: none;
  max-height: none;
  margin: 0;
}

.document-stage.split-half .loaded-image,
.document-stage.split-quarter .loaded-image {
  object-fit: contain;
}

.document-stage.split-half .pdf-shell,
.document-stage.split-half .deck-shell,
.document-stage.split-half .url-frame-shell,
.document-stage.split-half .office-fallback {
  height: calc(100% - 24px);
}

.document-stage.split-quarter .pdf-shell,
.document-stage.split-quarter .deck-shell,
.document-stage.split-quarter .url-frame-shell,
.document-stage.split-quarter .office-fallback {
  height: calc(50% - 18px);
}

.document-stage.split-half .deck-slide,
.document-stage.split-quarter .deck-slide {
  width: min(100%, 760px);
  max-height: none;
}

.document-stage.split-half .blank-page,
.document-stage.split-quarter .blank-page {
  width: calc(100% - 24px);
}

.loaded-image {
  position: relative;
  z-index: 1;
  width: auto;
  height: auto;
  max-width: calc(100% - 48px);
  max-height: calc(100% - 48px);
  object-fit: contain;
  border: 10px solid #ffffff;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.blank-page {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 24px));
  height: calc(100% - 24px);
  max-height: 1180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  text-align: center;
  overflow: hidden;
}

.blank-page.chalk {
  background: #0b5f4a;
  color: rgba(255, 255, 255, 0.92);
}

.blank-page.blue {
  background: #1e5aa8;
  color: rgba(255, 255, 255, 0.94);
}

.blank-page.dark {
  background: #1f2933;
  color: rgba(255, 255, 255, 0.92);
}

.blank-page.paper {
  background: #ffffff;
  color: #172033;
}

.blank-page.template-blank {
  width: 100%;
  height: 100%;
  max-height: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background-image: none;
}

.document-stage.split-half .blank-page.template-blank,
.document-stage.split-quarter .blank-page.template-blank {
  position: absolute;
  z-index: 2;
  left: 12px;
  top: 12px;
  width: calc(50% - 18px);
  height: calc(50% - 18px);
  min-height: 220px;
  border: 8px solid rgba(255, 255, 255, 0.88);
  border-radius: 4px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.24);
}

.document-stage.split-half .blank-page.template-blank {
  height: calc(100% - 24px);
}

.blank-page.template-grid {
  background-color: #ffffff;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(15, 118, 110, 0.28) 2px, transparent 2px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.28) 2px, transparent 2px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
}

.blank-page.template-isometric {
  background-color: #ffffff;
  background-image:
    radial-gradient(circle, #0f172a 1.65px, transparent 2px),
    radial-gradient(circle, #0f172a 1.65px, transparent 2px);
  background-position: 0 0, 24px 24px;
  background-size: 48px 48px;
}

.blank-page.template-staff {
  background-color: #ffffff;
  background-image: none;
}

.blank-page.template-manuscript {
  background-color: #fffdf7;
  background-image: none;
}

.blank-page.template-korea-map,
.blank-page.template-world-map {
  background-color: #f8fafc;
  background-image:
    linear-gradient(rgba(14, 116, 144, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 116, 144, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
}

.map-board {
  width: min(860px, 80%);
  min-height: 56%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  border: 3px solid rgba(15, 118, 110, 0.6);
  border-radius: 999px 48% 52% 46%;
  color: #0f172a;
  background: rgba(14, 165, 233, 0.12);
}

.world-map-board {
  border-radius: 44% 56% 48% 52%;
}

.map-board strong {
  font-size: clamp(28px, 4vw, 56px);
}

.map-board span,
.staff-label {
  color: #475569;
  font-size: clamp(14px, 1.6vw, 22px);
  font-weight: 900;
}

.staff-paper {
  position: absolute;
  inset: 42px 52px;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 26px;
}

.staff-system {
  display: grid;
  align-content: center;
  gap: 9px;
}

.staff-system i {
  display: block;
  height: 2px;
  background: rgba(15, 23, 42, 0.82);
}

.manuscript-paper {
  position: absolute;
  inset: 36px 40px 58px;
}

.manuscript-rows {
  display: grid;
  align-content: start;
  gap: 18px;
  background: transparent;
}

.manuscript-row {
  height: clamp(62px, 10.5vh, 96px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border-top: 3px solid #e04426;
  border-left: 3px solid #e04426;
}

.manuscript-row i {
  position: relative;
  display: block;
  border-right: 3px solid #e04426;
  border-bottom: 3px solid #e04426;
}

.manuscript-row i::before,
.manuscript-row i::after {
  content: "";
  position: absolute;
  background: rgba(224, 68, 38, 0.2);
}

.manuscript-row i::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
}

.manuscript-row i::after {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
}

.staff-label {
  position: absolute;
  right: 24px;
  bottom: 18px;
}

.pdf-shell {
  position: relative;
  width: min(1120px, calc(100% - 24px));
  height: calc(100% - 24px);
  max-height: 1180px;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 10px solid #ffffff;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.pdf-position-control {
  display: none;
}

.pdf-scroll-strip {
  display: none;
  position: relative;
  z-index: 40;
  min-width: 0;
  grid-template-columns: auto minmax(80px, 1fr) 42px;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 3px 8px;
  border-bottom: 1px solid #dbe3ed;
  background: #f8fafc;
  color: #172033;
  pointer-events: auto;
  touch-action: manipulation;
}

.pdf-scroll-strip span,
.pdf-scroll-strip small {
  font-size: 12px;
  font-weight: 900;
}

.pdf-scroll-strip span {
  color: #64748b;
}

.pdf-scroll-strip small {
  text-align: right;
}

.pdf-scroll-strip input[type="range"] {
  min-width: 0;
  width: 100%;
  accent-color: #0f766e;
  cursor: pointer;
}

.pdf-toolbar {
  position: relative;
  z-index: 40;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 4px 8px;
  border-bottom: 1px solid #dbe3ed;
  background: #f8fafc;
  color: #172033;
  pointer-events: auto;
  touch-action: manipulation;
}

.pdf-file-label {
  display: none;
}

.pdf-file-label span {
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-toolbar button {
  flex: 0 0 auto;
  width: auto;
  min-width: 32px;
  min-height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-weight: 800;
  padding: 0 8px;
}

.pdf-toolbar button.active {
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
}

.pdf-toolbar #openPdfButton {
  display: none;
}

.pdf-page-tools {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pdf-page-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pdf-page-jump {
  min-width: 74px;
  height: 30px;
  display: grid;
  grid-template-columns: 38px auto;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
}

.pdf-page-jump input {
  width: 38px;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.pdf-page-jump span {
  min-width: 0;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.pdf-view-tools {
  position: absolute;
  z-index: 80;
  top: calc(100% + 4px);
  right: 0;
  min-width: 174px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 7px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.pdf-view-menu {
  position: relative;
}

.pdf-view-menu summary {
  width: 32px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  cursor: pointer;
  font-size: 20px;
  font-weight: 900;
  list-style: none;
}

.pdf-view-menu summary::-webkit-details-marker {
  display: none;
}

.pdf-page-nav span,
.pdf-view-tools span {
  min-width: 44px;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.pdf-page-nav button:disabled,
.pdf-view-tools button:disabled {
  cursor: default;
  opacity: 0.45;
}

.pdf-canvas-wrap {
  position: relative;
  z-index: 1;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  padding: 10px 12px 16px;
  background: #ffffff;
}

.document-stage.pdf-pan-mode .pdf-canvas-wrap {
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
}

.document-stage.pdf-pan-mode .pdf-canvas-wrap:active {
  cursor: grabbing;
}

.document-stage.pdf-pan-mode .pdf-page-canvas {
  pointer-events: none;
}

.pdf-page-canvas {
  flex: 0 0 auto;
  margin: 0 auto;
  display: block;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
}

.pdf-render-status {
  position: absolute;
  inset: auto 16px 16px auto;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.84);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  padding: 7px 10px;
}

.pdf-zoom-overlay {
  position: absolute;
  z-index: 90;
  inset: 0;
  pointer-events: none;
}

.pdf-zoom-card {
  position: absolute;
  top: 64px;
  left: 12px;
  width: min(760px, calc(100% - 24px));
  max-height: calc(100% - 76px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  pointer-events: auto;
  resize: both;
  min-width: min(340px, calc(100% - 24px));
  min-height: 260px;
  max-width: calc(100% - 24px);
}

.pdf-zoom-card header {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #dbe3ed;
  background: #f8fafc;
  color: #172033;
  padding: 6px 10px;
}

.pdf-zoom-card header strong {
  font-weight: 900;
}

.pdf-zoom-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.pdf-zoom-title small {
  color: #0f766e;
  font-size: 12px;
  font-weight: 900;
}

.pdf-toolbar #pdfAreaZoomButton {
  border-color: #0f766e;
  background: #ccfbf1;
  color: #115e59;
}

.pdf-toolbar #pdfAreaZoomButton:hover,
.pdf-toolbar #pdfAreaZoomButton.active {
  background: #0f766e;
  color: #ffffff;
}

.pdf-zoom-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pdf-zoom-card header button {
  width: 34px;
  height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.pdf-zoom-canvas-wrap {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #e5e7eb;
  padding: 12px;
}

.pdf-zoom-actions .pdf-zoom-twin-button {
  width: auto;
  min-width: 92px;
  padding: 0 10px;
  border-color: #86efac;
  background: #ecfdf5;
  color: #166534;
  font-size: 12px;
}

.toolbar #twinProblemButton {
  display: none;
}

.pdf-zoom-board {
  position: relative;
  display: inline-grid;
  place-items: center;
  max-width: none;
  max-height: none;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
}

.pdf-zoom-canvas-wrap canvas {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  background: #ffffff;
}

.pdf-zoom-source-canvas {
  grid-area: 1 / 1;
}

.pdf-zoom-canvas-wrap .pdf-zoom-ink-canvas {
  grid-area: 1 / 1;
  position: relative;
  z-index: 2;
  background: transparent;
  cursor: crosshair;
  touch-action: none;
  pointer-events: auto;
}

.pdf-zoom-card p {
  margin: 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
}

.pdf-object {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
  color-scheme: light;
}

.pdf-fallback {
  height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 22px;
  text-align: center;
  color: #334155;
}

.pdf-fallback span {
  max-width: 520px;
  color: #64748b;
  line-height: 1.5;
}

.deck-shell,
.office-fallback {
  position: relative;
  width: min(960px, calc(100% - 48px));
  height: calc(100% - 48px);
  max-height: 1180px;
  overflow: hidden;
  border: 10px solid #ffffff;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

.deck-shell {
  display: grid;
  grid-template-rows: 48px 1fr;
}

.url-frame-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 24px));
  height: calc(100% - 24px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.url-frame-toolbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 9px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.url-frame-toolbar div {
  min-width: 0;
  display: grid;
}

.url-frame-toolbar span {
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-frame-toolbar button {
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-weight: 900;
  padding: 0 12px;
}

.url-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.url-frame-note {
  padding: 7px 12px;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 12px;
  background: #f8fafc;
}

.deck-toolbar {
  position: relative;
  z-index: 40;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border-bottom: 1px solid #dbe3ed;
  background: #f8fafc;
  color: #172033;
}

.deck-file-label {
  min-width: 0;
  display: grid;
}

.deck-toolbar span {
  overflow: hidden;
  color: #64748b;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-page-tools {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.deck-file-actions {
  grid-column: 1 / -1;
  min-width: 0;
}

.deck-file-actions summary {
  width: fit-content;
  margin-left: auto;
  color: #475569;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.deck-file-actions > div {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding-top: 7px;
}

.deck-page-tools button,
.deck-file-actions button,
.office-fallback button {
  min-height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  font-weight: 800;
  padding: 0 10px;
}

.deck-page-tools span {
  min-width: 48px;
  color: #172033;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.deck-slide-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #dbe3ed;
}

.deck-slide {
  position: relative;
  width: min(100%, 900px);
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #ffffff;
  --ppt-font-size: 22px;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
}

.pptx-text,
.pptx-image {
  position: absolute;
}

.pptx-text {
  overflow: hidden;
  color: #111827;
  box-sizing: border-box;
  font-size: calc(var(--ppt-font-size) * var(--shape-font-ratio, 1));
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: keep-all;
  white-space: pre-wrap;
}

.pptx-image {
  object-fit: contain;
}

.pptx-empty,
.office-fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: #334155;
  text-align: center;
}

.office-fallback span {
  max-width: 560px;
  color: #64748b;
  line-height: 1.5;
}

.stage-placeholder {
  display: grid;
  gap: 12px;
  place-items: center;
  color: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.paper .stage-placeholder {
  color: #334155;
}

.stage-placeholder strong {
  font-size: clamp(22px, 2.2vw, 34px);
}

.stage-placeholder span {
  font-size: 15px;
}

.ink-canvas {
  position: absolute;
  inset: 0;
  z-index: 32;
  width: 100%;
  height: 100%;
  touch-action: none;
  pointer-events: none;
  cursor: crosshair;
}

.document-stage.crop-cursor,
.ink-canvas.crop-cursor {
  cursor: cell;
}

.document-stage.marker-cursor,
.ink-canvas.marker-cursor {
  cursor: pointer;
}

.crop-rect {
  position: absolute;
  z-index: 40;
  pointer-events: none;
  border: 2px dashed #facc15;
  background: rgba(250, 204, 21, 0.13);
}

.shape-preview {
  position: absolute;
  inset: 0;
  z-index: 41;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.brush-preview {
  position: absolute;
  z-index: 42;
  pointer-events: none;
  border: 2px solid #ef4444;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.18);
  transform: translate(-50%, -50%);
}

.brush-preview.eraser-preview {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.24);
}

.shape-action-panel {
  position: absolute;
  z-index: 46;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(15, 118, 110, 0.34);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
  padding: 8px;
}

.shape-action-row,
.shape-move-pad {
  display: grid;
  gap: 8px;
}

.shape-action-row {
  grid-template-columns: repeat(3, 1fr);
}

.shape-move-pad {
  grid-template-columns: repeat(4, 1fr);
}

.shape-action-panel button {
  min-width: 62px;
  min-height: 46px;
  border: 1px solid #0f766e;
  border-radius: 10px;
  background: #ecfdf5;
  color: #0f3f37;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.shape-move-pad button {
  min-height: 52px;
  background: #f8fafc;
  color: #172033;
  font-size: 24px;
}

.shape-action-panel button:active {
  background: #0f766e;
  color: #ffffff;
}

.shape-layer {
  position: absolute;
  inset: 0;
  z-index: 29;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.board-shape {
  pointer-events: none;
  cursor: move;
}

.document-stage.shape-select-mode .board-shape {
  pointer-events: auto;
}

.shape-visible {
  fill: rgba(255, 255, 255, 0.04);
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
}

.shape-visible:is(line, polyline, path, ellipse) {
  fill: none;
}

.shape-arrow-head {
  pointer-events: none;
}

.shape-angle-arc {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.shape-hidden-edge {
  stroke-dasharray: 6 6;
  opacity: 0.78;
}

.shape-center-mark {
  pointer-events: none;
}

.shape-center-mark line {
  stroke: #0f766e;
  stroke-width: 2.4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.55));
}

.shape-center-mark circle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
}

.board-shape polygon.shape-visible,
.board-shape rect.shape-visible,
.board-shape circle.shape-visible {
  pointer-events: visiblePainted;
}

.shape-hit {
  stroke: transparent;
  stroke-width: 22;
  fill: none;
  pointer-events: stroke;
}

.shape-selection-box {
  fill: rgba(15, 118, 110, 0.08);
  stroke: #0f766e;
  stroke-width: 2;
  stroke-dasharray: 7 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.shape-selection-box.group {
  fill: rgba(14, 165, 233, 0.08);
  stroke: #0ea5e9;
  stroke-width: 2.5;
  stroke-dasharray: 10 7;
}

.shape-group-label {
  fill: #0369a1;
  stroke: #ffffff;
  stroke-width: 4;
  paint-order: stroke;
  font-size: 14px;
  font-weight: 900;
  pointer-events: none;
  user-select: none;
}

.shape-move-hit {
  fill: rgba(15, 118, 110, 0.01);
  stroke: transparent;
  cursor: move;
  pointer-events: none;
}

.shape-move-hit.group {
  fill: rgba(14, 165, 233, 0.01);
}

.document-stage.shape-select-mode .shape-move-hit {
  pointer-events: auto;
}

.board-shape.group-member .shape-visible {
  filter: drop-shadow(0 0 4px rgba(14, 165, 233, 0.38));
}

.shape-rotate-stem {
  stroke: #0f766e;
  stroke-width: 2;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.shape-rotate-handle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 4;
  cursor: grab;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.25));
  pointer-events: none;
}

.shape-rotate-orbit {
  fill: none;
  stroke: rgba(15, 118, 110, 0.01);
  stroke-width: 50;
  cursor: grab;
  pointer-events: none;
}

.shape-rotate-orbit-guide {
  fill: none;
  stroke: rgba(20, 184, 166, 0.42);
  stroke-width: 2;
  stroke-dasharray: 10 9;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.shape-rotate-hit {
  fill: rgba(15, 118, 110, 0.01);
  stroke: transparent;
  cursor: grab;
  pointer-events: none;
}

.document-stage.shape-select-mode .shape-rotate-handle,
.document-stage.shape-select-mode .shape-rotate-hit,
.document-stage.shape-select-mode .shape-rotate-orbit {
  pointer-events: auto;
}

.shape-rotate-handle:active,
.shape-rotate-hit:active,
.shape-rotate-orbit:active {
  cursor: grabbing;
}

.shape-rotate-step {
  cursor: pointer;
  pointer-events: none;
}

.shape-rotate-step circle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 3;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.25));
}

.shape-rotate-step text {
  fill: #0f766e;
  font-size: 24px;
  font-weight: 900;
  pointer-events: none;
  user-select: none;
}

.document-stage.shape-select-mode .shape-rotate-step {
  pointer-events: auto;
}

.shape-resize-handle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 3;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.22));
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.document-stage.shape-select-mode .shape-resize-handle {
  pointer-events: auto;
}

.shape-line-edit-guide {
  stroke: rgba(20, 184, 166, 0.58);
  stroke-width: 2;
  stroke-dasharray: 8 7;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.shape-line-end-handle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 4;
  cursor: grab;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.22));
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.shape-line-end-handle.start {
  stroke-dasharray: 4 4;
}

.document-stage.shape-select-mode .shape-line-end-handle {
  pointer-events: auto;
}

.shape-line-end-handle:active {
  cursor: grabbing;
}

.shape-resize-n,
.shape-resize-s {
  cursor: ns-resize;
}

.shape-resize-e,
.shape-resize-w {
  cursor: ew-resize;
}

.shape-resize-ne,
.shape-resize-sw {
  cursor: nesw-resize;
}

.shape-resize-nw,
.shape-resize-se {
  cursor: nwse-resize;
}

.shape-preview line,
.shape-preview rect,
.shape-preview circle,
.shape-preview polygon,
.shape-preview path {
  fill: rgba(20, 184, 166, 0.08);
  vector-effect: non-scaling-stroke;
}

.shape-preview-geometry {
  opacity: 0.78;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 9 7;
}

.shape-guide-line {
  stroke-width: 2.5;
  stroke-dasharray: 6 6;
  opacity: 0.9;
  vector-effect: non-scaling-stroke;
}

.shape-start-point {
  fill: #0f766e;
  stroke: #ffffff;
  stroke-width: 3;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.28));
}

.shape-end-point {
  fill: #f97316;
  stroke: #ffffff;
  stroke-width: 3;
}

.shape-preview-label {
  fill: #0f172a;
  stroke: #ffffff;
  stroke-width: 4;
  paint-order: stroke;
  font-size: 13px;
  font-weight: 900;
}

.group-select-marquee {
  fill: rgba(14, 165, 233, 0.12);
  stroke: #0ea5e9;
  stroke-width: 2.5;
  stroke-dasharray: 9 6;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.group-select-label {
  fill: #0369a1;
  stroke: #ffffff;
  stroke-width: 4;
  paint-order: stroke;
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
  user-select: none;
}

.construction-tools {
  min-width: min(430px, calc(100vw - 32px));
}

.construction-badge {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
  padding: 0 12px;
}

.construction-radius-guide {
  fill: none;
  stroke: rgba(20, 184, 166, 0.7);
  stroke-width: 2;
  stroke-dasharray: 8 7;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.construction-measure-line,
.construction-compass-leg {
  stroke: rgba(15, 118, 110, 0.9);
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.construction-arc {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.construction-point circle {
  fill: #ffffff;
  stroke: #0f766e;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 5px rgba(15, 23, 42, 0.25));
}

.construction-point text,
.construction-label {
  fill: #0f172a;
  stroke: #ffffff;
  stroke-width: 4;
  paint-order: stroke;
  font-size: 13px;
  font-weight: 900;
  pointer-events: none;
  user-select: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.58);
}

.crossword-modal {
  position: relative;
  width: min(1120px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
  padding: 18px;
}

.twin-problem-modal {
  position: relative;
  width: min(1080px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.32);
  padding: 18px;
}

.twin-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-right: 48px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 14px;
}

.twin-modal-head h2 {
  margin: 2px 0 0;
  font-size: 24px;
}

.twin-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.twin-modal-actions button {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #172033;
  padding: 0 12px;
  font-weight: 800;
}

.twin-modal-actions button:disabled {
  cursor: default;
  opacity: 0.45;
}

.twin-summary {
  margin: 14px 0;
  padding: 10px 12px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  background: #f0f9ff;
  color: #075985;
  font-weight: 800;
}

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

.twin-problem-card {
  border: 1px solid #e2e8f0;
  border-left-width: 5px;
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
}

.twin-problem-card.ready {
  border-left-color: #16a34a;
}

.twin-problem-card.review {
  border-left-color: #f59e0b;
}

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

.twin-problem-card small {
  color: #64748b;
  font-weight: 700;
}

.twin-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 8px;
  padding: 0 8px;
  background: #ecfdf5;
  color: #166534;
  font-size: 12px;
  font-weight: 900;
}

.twin-problem-card.review .twin-badge {
  background: #fffbeb;
  color: #92400e;
}

.twin-original,
.twin-generated,
.twin-review-note {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.twin-generated {
  margin-top: 8px;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.twin-review-note {
  margin-top: 8px;
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
  font-weight: 800;
}

.twin-original strong,
.twin-generated strong {
  display: block;
  margin-bottom: 4px;
  color: #0f172a;
}

.twin-original p,
.twin-generated p {
  margin: 0 0 6px;
  line-height: 1.45;
}

.twin-original span,
.twin-generated span {
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  display: grid;
  place-items: center;
}

.modal-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.crossword-editor h2 {
  margin: 4px 0 14px;
}

.word-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 7px;
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.crossword-preview {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  overflow: auto;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.crossword-grid {
  display: grid;
  gap: 2px;
}

.cross-cell {
  width: 38px;
  height: 38px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: transparent;
  font-weight: 900;
}

.cross-cell.filled {
  background: #ffffff;
  border: 1px solid #334155;
}

.cell-number {
  position: absolute;
  top: 2px;
  left: 3px;
  color: #0f172a;
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.cell-number:has(+ .cell-letter) {
  max-width: 25px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-letter {
  display: block;
  padding-top: 5px;
}

.hint-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 18px;
  width: 100%;
}

.hint-groups h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.hint-list {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}

.print-only {
  display: none;
}

.print-sheet {
  color: #111827;
  background: #ffffff;
}

.exam-header,
.exam-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.exam-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.exam-header p {
  margin: 0;
}

.exam-id {
  border: 1px solid #111827;
  padding: 8px 12px;
  font-weight: 800;
}

.exam-items {
  margin-top: 24px;
}

.exam-item {
  break-inside: avoid;
  margin-bottom: 18px;
}

.exam-item h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.exam-item img {
  max-width: 100%;
  max-height: 240px;
  object-fit: contain;
  border: 1px solid #d1d5db;
}

.answer-space {
  height: 120px;
  border-bottom: 1px solid #cbd5e1;
}

.exam-footer {
  margin-top: 24px;
  align-items: flex-end;
  page-break-inside: avoid;
}

.qr-box {
  width: 80px;
  height: 80px;
  border: 2px solid #111827;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.no-print-items {
  margin-top: 48px;
  font-size: 18px;
}

@media (max-width: 1080px) {
  .sidebar.open {
    width: 36%;
  }

  .lesson-area.with-sidebar {
    width: 64%;
  }

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

@media (max-width: 820px) {
  .workspace {
    position: relative;
  }

  .sidebar.open {
    position: absolute;
    z-index: 50;
    width: min(92vw, 380px);
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.2);
  }

  .lesson-area.with-sidebar,
  .lesson-area.full {
    width: 100%;
  }

  .toolbar {
    width: min(86vw, 320px);
    padding: 12px;
  }

  .ink-dock {
    width: 128px;
    max-height: calc(100% - 96px);
    left: 14px;
    bottom: 14px;
  }

  .print-action {
    margin-left: 0;
  }
}
