:root {
  --bg: #f3ede2;
  --panel: rgba(255, 250, 242, 0.82);
  --panel-strong: rgba(255, 248, 237, 0.97);
  --board: #f9f3e8;
  --paper-line: rgba(32, 74, 119, 0.16);
  --paper-grid: rgba(99, 118, 123, 0.14);
  --ink: #17324d;
  --muted: #73685c;
  --accent: #c96a3c;
  --accent-strong: #ad5028;
  --danger: #a83d34;
  --shadow: 0 22px 48px rgba(59, 43, 31, 0.14);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --hand-font: "Segoe Print", "Bradley Hand", "KaiTi", "STKaiti", cursive;
  --ui-font: "Trebuchet MS", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--ui-font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(246, 212, 180, 0.9), transparent 35%),
    radial-gradient(circle at right 20%, rgba(203, 228, 218, 0.7), transparent 28%),
    linear-gradient(160deg, #efe4d2 0%, #f7f1e7 48%, #ede5d8 100%);
}

button,
input,
textarea,
[contenteditable="true"] {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
}

summary {
  list-style: none;
  cursor: pointer;
}

summary::-webkit-details-marker {
  display: none;
}

.app-shell {
  min-height: 100vh;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.top-toolbar {
  position: sticky;
  top: 12px;
  z-index: 30;
  padding: 10px 12px;
  border-radius: 26px;
  background: rgba(255, 250, 243, 0.76);
  border: 1px solid rgba(117, 94, 72, 0.1);
  box-shadow: 0 14px 34px rgba(59, 43, 31, 0.08);
  backdrop-filter: blur(14px);
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar-tools {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid rgba(117, 94, 72, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 6px 16px rgba(59, 43, 31, 0.05);
}

.tool-control,
.toolbar-menu {
  position: relative;
}

.formula-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid rgba(117, 94, 72, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 6px 16px rgba(59, 43, 31, 0.05);
}

.insert-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid rgba(117, 94, 72, 0.1);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 6px 16px rgba(59, 43, 31, 0.05);
}

.tool-icon-btn,
.toolbar-trigger,
.toolbar-shortcut,
.tool-btn,
.surface-btn,
.template-card,
.formula-chip,
.insert-chip,
.ghost-btn,
.accent-btn,
.danger-btn {
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.tool-icon-btn,
.toolbar-trigger,
.toolbar-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.82);
  border: 1px solid rgba(117, 94, 72, 0.1);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 6px 16px rgba(59, 43, 31, 0.05);
  user-select: none;
}

.tool-icon-btn {
  justify-content: center;
  width: 46px;
  min-width: 46px;
  padding: 0;
  color: rgba(23, 50, 77, 0.76);
  overflow: hidden;
}

.toolbar-trigger {
  position: relative;
  padding-right: 34px;
}

.toolbar-trigger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 15px;
  width: 7px;
  height: 7px;
  margin-top: -6px;
  border-right: 1.5px solid rgba(23, 50, 77, 0.54);
  border-bottom: 1.5px solid rgba(23, 50, 77, 0.54);
  transform: rotate(45deg);
  transition: transform 180ms ease, margin-top 180ms ease;
}

.tool-icon-btn:hover,
.toolbar-trigger:hover,
.toolbar-shortcut:hover,
.tool-btn:hover,
.surface-btn:hover,
.template-card:hover,
.formula-chip:hover,
.insert-chip:hover,
.ghost-btn:hover,
.accent-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(59, 43, 31, 0.1);
}

.tool-icon-btn.active {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.18), rgba(245, 227, 208, 0.95));
  border-color: rgba(201, 106, 60, 0.38);
  color: var(--accent-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 10px 20px rgba(201, 106, 60, 0.12);
}

.tool-control.is-open .tool-icon-btn {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(247, 235, 221, 0.96));
  border-color: rgba(201, 106, 60, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84),
    0 12px 22px rgba(201, 106, 60, 0.14);
}

.toolbar-menu[open] .toolbar-trigger {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.12), rgba(247, 235, 221, 0.92));
  border-color: rgba(201, 106, 60, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 10px 22px rgba(59, 43, 31, 0.08);
}

.toolbar-menu[open] .toolbar-trigger::after {
  margin-top: -1px;
  transform: rotate(225deg);
}

.toolbar-name {
  font-weight: 700;
}

.toolbar-value {
  color: var(--muted);
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.tool-flyout {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  z-index: 4;
  width: min(196px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.98);
  border: 1px solid rgba(117, 94, 72, 0.14);
  box-shadow: 0 18px 36px rgba(59, 43, 31, 0.16);
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(0, 8px) scale(0.96);
  transform-origin: 18% 0;
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms ease;
}

.tool-flyout::before {
  content: "";
  position: absolute;
  left: 20px;
  top: -7px;
  width: 14px;
  height: 14px;
  background: rgba(255, 248, 239, 0.98);
  border-left: 1px solid rgba(117, 94, 72, 0.14);
  border-top: 1px solid rgba(117, 94, 72, 0.14);
  transform: rotate(45deg);
}

.tool-control.is-open .tool-flyout {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(0, 0) scale(1);
}

.tool-flyout__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tool-flyout__name {
  font-weight: 700;
}

.tool-flyout__value {
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.tool-range {
  width: 100%;
  accent-color: var(--accent-strong);
}

.toolbar-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  width: min(300px, calc(100vw - 40px));
  padding: 14px;
  border-radius: var(--radius-lg);
  background: rgba(255, 248, 239, 0.96);
  border: 1px solid rgba(117, 94, 72, 0.12);
  box-shadow: 0 18px 38px rgba(59, 43, 31, 0.16);
  backdrop-filter: blur(12px);
}

.toolbar-popover--wide {
  width: min(344px, calc(100vw - 40px));
}

.toolbar-popover--narrow {
  width: min(236px, calc(100vw - 40px));
}

.toolbar-copy {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.88rem;
}

.toolbar-copy--compact {
  margin: 10px 0 0;
  font-size: 0.8rem;
}

.toolbar-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.image-edit-strip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.9);
  border: 1px solid rgba(42, 111, 95, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 6px 16px rgba(59, 43, 31, 0.06);
}

.image-edit-strip[hidden] {
  display: none;
}

.image-edit-status {
  max-width: min(42vw, 260px);
  padding: 0 8px 0 10px;
  color: rgba(23, 50, 77, 0.78);
  font-size: 0.84rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.formula-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px 0 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255, 251, 246, 0.98), rgba(248, 241, 232, 0.92));
  border: 1px solid rgba(117, 94, 72, 0.12);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 8px 18px rgba(59, 43, 31, 0.06);
}

.formula-chip.active {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(246, 233, 218, 0.98));
  border-color: rgba(201, 106, 60, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84),
    0 10px 20px rgba(201, 106, 60, 0.12);
}

.formula-chip.active .formula-chip__symbol {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.28), rgba(247, 228, 206, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 5px 12px rgba(201, 106, 60, 0.16);
}

.formula-chip__symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(244, 227, 209, 0.96));
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 4px 10px rgba(201, 106, 60, 0.12);
}

.formula-chip__label {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.insert-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 0 15px 0 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(251, 246, 240, 0.98), rgba(245, 236, 226, 0.92));
  border: 1px solid rgba(164, 122, 92, 0.14);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 8px 18px rgba(59, 43, 31, 0.06);
}

.insert-chip.active {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.18), rgba(246, 232, 215, 0.98));
  border-color: rgba(201, 106, 60, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84),
    0 10px 20px rgba(201, 106, 60, 0.12);
}

.insert-chip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(247, 231, 212, 0.98));
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 4px 10px rgba(201, 106, 60, 0.12);
}

.insert-chip__label {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.insert-chip--textbox .insert-chip__icon {
  font-size: 0.86rem;
}

.text-style-section + .text-style-section {
  margin-top: 14px;
}

.text-style-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.text-style-range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.text-style-range-head .text-style-label {
  margin-bottom: 0;
}

.text-style-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-style-chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 251, 246, 0.96);
  border: 1px solid rgba(117, 94, 72, 0.12);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 6px 14px rgba(59, 43, 31, 0.05);
}

.text-style-chip.active {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(246, 233, 218, 0.98));
  border-color: rgba(201, 106, 60, 0.34);
  color: var(--accent-strong);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.84),
    0 10px 20px rgba(201, 106, 60, 0.12);
}

.text-color-swatch {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--swatch);
  border: 3px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(117, 94, 72, 0.16);
}

.text-color-swatch.active::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(201, 106, 60, 0.75);
  border-radius: 50%;
}

.floating-text-toolbar {
  position: fixed;
  z-index: 80;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 16px);
  padding: 7px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(117, 94, 72, 0.14);
  box-shadow:
    0 12px 28px rgba(39, 45, 52, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  color: #354252;
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.floating-text-toolbar.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.floating-text-toolbar__group,
.floating-text-toolbar__colors {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.floating-text-toolbar__divider {
  width: 1px;
  height: 26px;
  background: rgba(66, 78, 92, 0.14);
}

.floating-text-toolbar__btn {
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  background: transparent;
  color: #354252;
  font-weight: 700;
  line-height: 1;
}

.floating-text-toolbar__btn:hover,
.floating-text-toolbar__btn.active {
  background: rgba(23, 50, 77, 0.08);
  color: var(--ink);
}

.floating-text-toolbar__btn--icon {
  font-family: var(--ui-font);
}

.floating-text-toolbar__value {
  min-width: 44px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.floating-text-toolbar__swatch {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--swatch);
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px rgba(66, 78, 92, 0.14);
}

.floating-text-toolbar__swatch.active::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid rgba(201, 106, 60, 0.78);
}

.toolbar-meta {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.tool-grid,
.background-grid,
.template-list,
.toolbar-action-list {
  display: grid;
  gap: 8px;
}

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

.tool-btn,
.surface-btn,
.template-card {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(117, 94, 72, 0.12);
  background: rgba(255, 251, 246, 0.95);
  color: var(--ink);
}

.tool-btn.active,
.surface-btn.active {
  background: linear-gradient(135deg, rgba(201, 106, 60, 0.16), rgba(245, 227, 208, 0.95));
  border-color: rgba(201, 106, 60, 0.38);
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 70px;
}

.tool-btn small {
  color: var(--muted);
}

.tool-icon-svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-swatch {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--swatch);
  border: 3px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 0 0 1px rgba(117, 94, 72, 0.16);
}

.color-swatch.active::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(201, 106, 60, 0.75);
  border-radius: 50%;
}

.template-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.template-name {
  font-weight: 700;
}

.template-preview {
  color: var(--muted);
  font-family: var(--hand-font);
}

.ghost-btn,
.accent-btn,
.danger-btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 700;
}

.toolbar-shortcut {
  justify-content: center;
  padding: 0 15px;
  font-size: 0.94rem;
}

.ghost-btn {
  background: rgba(255, 251, 246, 0.96);
  border: 1px solid rgba(117, 94, 72, 0.12);
  color: var(--ink);
}

.accent-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff7f0;
}

.danger-btn {
  background: linear-gradient(135deg, #c25a4f, #98392f);
  color: #fff7f0;
}

.wide-btn {
  width: 100%;
}

.toolbar-shortcut--danger {
  background: rgba(168, 61, 52, 0.12);
  border: 1px solid rgba(168, 61, 52, 0.14);
  color: var(--danger);
}

.ghost-btn:disabled,
.danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.workspace {
  flex: 1;
  min-height: 0;
}

.board-stage {
  min-height: 0;
}

.board-frame {
  padding: 10px;
  border-radius: calc(var(--radius-xl) + 6px);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.06)),
    linear-gradient(160deg, rgba(135, 110, 82, 0.15), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
}

.board-surface {
  position: relative;
  min-height: max(660px, 74vh, calc(100vh - 194px));
  overflow: hidden;
  border-radius: calc(var(--radius-xl) + 2px);
  border: 1px solid rgba(117, 94, 72, 0.14);
  background-color: var(--board);
}

.board-surface.ruled {
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.22)),
    linear-gradient(to bottom, transparent 0, transparent 41px, var(--paper-line) 42px);
  background-size: 100% 100%, 100% 42px;
}

.board-surface.grid {
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.14)),
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px);
  background-size: 100% 100%, 38px 38px, 38px 38px;
}

.board-surface.dots {
  background-image:
    radial-gradient(circle, rgba(92, 104, 111, 0.26) 1.2px, transparent 1.2px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.2));
  background-size: 22px 22px, 100% 100%;
}

.board-surface.plain {
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.22));
}

#whiteboard,
.widget-layer {
  position: absolute;
  inset: 0;
}

#whiteboard {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.board-surface[data-tool="select"] #whiteboard {
  cursor: crosshair;
}

.widget-layer {
  pointer-events: none;
}

.board-surface.is-preview-active #whiteboard,
.board-surface.is-preview-active .tool-preview,
.board-surface.is-preview-active .tool-preview * {
  cursor: none !important;
}

.tool-preview {
  --preview-x: 0px;
  --preview-y: 0px;
  --preview-width: 46px;
  --preview-height: 22px;
  --preview-edge: 5px;
  --preview-tip: 14px;
  --preview-ferrule: 10px;
  --preview-offset-x: 12px;
  --preview-offset-y: 18px;
  --preview-rotation: -30deg;
  --preview-ink: var(--ink);
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  width: var(--preview-width);
  height: var(--preview-height);
  opacity: 0;
  pointer-events: none;
  transform:
    translate3d(
      calc(var(--preview-x) - var(--preview-offset-x)),
      calc(var(--preview-y) - var(--preview-offset-y)),
      0
    )
    rotate(var(--preview-rotation));
  transform-origin: 20% 84%;
  transition: opacity 120ms ease;
  will-change: transform, opacity;
}

.tool-preview.is-visible {
  opacity: 1;
}

.tool-preview__shadow {
  position: absolute;
  left: 8%;
  right: 10%;
  bottom: -30%;
  height: 44%;
  border-radius: 999px;
  background: radial-gradient(circle at center, rgba(59, 43, 31, 0.2), transparent 72%);
  filter: blur(5px);
}

.tool-preview__brush,
.tool-preview__eraser {
  position: absolute;
  inset: 0;
  display: none;
}

.tool-preview[data-tool="brush"] {
  transform-origin: 16% 82%;
}

.tool-preview[data-tool="eraser"] {
  transform-origin: 50% 78%;
}

.tool-preview[data-tool="brush"] .tool-preview__brush,
.tool-preview[data-tool="eraser"] .tool-preview__eraser {
  display: block;
}

.tool-preview__brush-tip,
.tool-preview__brush-ferrule,
.tool-preview__brush-handle,
.tool-preview__eraser-body,
.tool-preview__eraser-edge {
  position: absolute;
}

.tool-preview__brush-tip {
  left: 0;
  top: 50%;
  width: var(--preview-tip);
  height: calc(var(--preview-height) * 0.72);
  transform: translateY(-50%);
  clip-path: polygon(0 50%, 38% 0, 100% 16%, 100% 84%, 38% 100%);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 44%),
    linear-gradient(135deg, var(--preview-ink), rgba(22, 18, 16, 0.94));
  box-shadow:
    inset -2px 0 0 rgba(255, 255, 255, 0.18),
    0 3px 8px rgba(59, 43, 31, 0.18);
}

.tool-preview__brush-ferrule {
  left: calc(var(--preview-tip) - 1px);
  top: 50%;
  width: var(--preview-ferrule);
  height: calc(var(--preview-height) * 0.62);
  transform: translateY(-50%);
  border-radius: 6px;
  background: linear-gradient(135deg, #dde5ea, #94a8b4 52%, #5d7280);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 2px 4px rgba(59, 43, 31, 0.14);
}

.tool-preview__brush-handle {
  left: calc(var(--preview-tip) + var(--preview-ferrule) - 2px);
  right: 0;
  top: 50%;
  height: calc(var(--preview-height) * 0.46);
  transform: translateY(-50%);
  border-radius: 999px;
  background: linear-gradient(90deg, #7b4d29 0%, #b66f39 46%, #e3b16e 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 8px 14px rgba(59, 43, 31, 0.18);
}

.tool-preview__brush-handle::after {
  content: "";
  position: absolute;
  right: 12%;
  top: 18%;
  bottom: 18%;
  width: 18%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0));
}

.tool-preview__eraser-body {
  inset: 0;
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 247, 240, 0.98), rgba(235, 205, 191, 0.95));
  border: 1px solid rgba(139, 97, 76, 0.18);
  box-shadow:
    0 12px 18px rgba(59, 43, 31, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.tool-preview__eraser-body::before {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  top: 24%;
  bottom: 24%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(201, 106, 60, 0.2), rgba(201, 106, 60, 0.06));
}

.tool-preview__eraser-edge {
  inset: auto 10% calc(var(--preview-edge) * -0.72) 10%;
  height: var(--preview-edge);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(123, 144, 151, 0.88), rgba(83, 101, 109, 0.96));
  box-shadow:
    0 4px 10px rgba(59, 43, 31, 0.14),
    0 0 0 1px rgba(76, 96, 106, 0.12);
}

.math-widget {
  position: absolute;
  width: 172px;
  min-height: 146px;
  padding: 18px 16px 14px;
  border-radius: 22px;
  background: rgba(255, 248, 239, 0.28);
  border: 1px dashed rgba(138, 111, 84, 0.22);
  box-shadow: 0 12px 28px rgba(59, 43, 31, 0.08);
  backdrop-filter: blur(2px);
  pointer-events: auto;
  user-select: auto;
  cursor: grab;
}

.math-widget:active {
  cursor: grabbing;
}

.math-widget .widget-field {
  cursor: text;
}

.math-widget.selected {
  border-color: rgba(201, 106, 60, 0.68);
  box-shadow: 0 18px 34px rgba(201, 106, 60, 0.12);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: rgba(76, 62, 50, 0.76);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  user-select: none;
}

.widget-grip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--danger);
  font-weight: 700;
  user-select: none;
}

.math-body {
  position: relative;
  font-family: var(--hand-font);
  color: var(--ink);
}

.math-widget--text {
  background:
    linear-gradient(180deg, rgba(255, 250, 245, 0.92), rgba(255, 245, 236, 0.86)),
    radial-gradient(circle at top right, rgba(201, 106, 60, 0.08), transparent 32%);
  border: 1px solid rgba(188, 131, 94, 0.34);
  box-shadow:
    0 18px 34px rgba(59, 43, 31, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(6px);
}

.math-widget--text::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 18px;
  border: 1.5px solid rgba(201, 106, 60, 0.22);
  pointer-events: none;
}

.math-widget--note {
  min-height: 54px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.math-widget--note.selected {
  border-color: transparent;
  box-shadow: none;
}

.math-widget--text {
  min-height: 186px;
  padding: 14px 14px 12px;
}

.math-widget--text .widget-header {
  margin-bottom: 8px;
  padding: 0 4px;
  color: rgba(111, 74, 52, 0.86);
  letter-spacing: 0.12em;
}

.math-widget--text .widget-grip {
  font-size: 0.74rem;
}

.math-widget--text .widget-delete {
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.76),
    0 4px 10px rgba(59, 43, 31, 0.08);
}

.math-widget--note::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  border: 1px dashed rgba(201, 106, 60, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.math-widget--note.selected::before,
.math-widget--note:focus-within::before {
  opacity: 1;
}

.math-widget--note .math-body {
  padding: 0;
}

.math-widget--text .math-body {
  height: calc(100% - 40px);
  padding: 5px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 251, 247, 0.4)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 48%);
  border: 1px solid rgba(201, 106, 60, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -1px 0 rgba(201, 106, 60, 0.06);
}

.text-note-shell {
  height: 100%;
  min-height: 42px;
  padding: 6px 10px;
}

.text-note-input {
  width: 100%;
  min-height: 42px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-color, var(--ink));
  font-size: var(--text-size, 34px);
  font-weight: var(--text-weight, 500);
  line-height: 1.55;
  outline: none;
  overflow: hidden;
  cursor: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  caret-color: var(--text-color, var(--ink));
}

.text-widget-shell {
  position: relative;
  display: flex;
  height: 100%;
  min-height: 100%;
  padding: 16px 14px 12px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.12)),
    linear-gradient(90deg, rgba(201, 106, 60, 0.08), rgba(201, 106, 60, 0)),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 33px,
      rgba(23, 50, 77, 0.08) 34px,
      rgba(23, 50, 77, 0.08) 35px
    );
  border: 1px solid rgba(183, 127, 92, 0.18);
  overflow: hidden;
}

.text-widget-shell::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 10px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(201, 106, 60, 0.22), rgba(201, 106, 60, 0));
  opacity: 0.8;
}

.text-widget-input {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 8px 6px 0;
  border: none;
  background: transparent;
  color: var(--text-color, var(--ink));
  font-size: var(--text-size, 28px);
  font-weight: var(--text-weight, 500);
  line-height: 2.05;
  outline: none;
  overflow: auto;
  cursor: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
  caret-color: var(--text-color, var(--ink));
}

.text-note-input.is-empty::before,
.text-widget-input.is-empty::before {
  content: attr(data-placeholder);
  color: rgba(23, 50, 77, 0.26);
  pointer-events: none;
}

.text-inline-style {
  color: inherit;
}

.text-font--hand {
  font-family: var(--hand-font);
}

.text-font--neat {
  font-family: var(--ui-font);
}

.text-font--title {
  font-family: "Georgia", "Times New Roman", "STSong", serif;
  letter-spacing: 0.03em;
}

.is-underlined {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.16em;
}

.widget-resize-handle {
  position: absolute;
  right: 16px;
  bottom: 14px;
  width: 26px;
  height: 26px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.94), rgba(242, 227, 212, 0.96));
  border: 1px solid rgba(201, 106, 60, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 8px 18px rgba(59, 43, 31, 0.1);
  touch-action: none;
}

.widget-resize-handle::before,
.widget-resize-handle::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 11px;
  height: 2px;
  border-radius: 999px;
  background: rgba(201, 106, 60, 0.74);
  transform-origin: right center;
  transform: rotate(-45deg);
}

.widget-resize-handle::after {
  right: 10px;
  bottom: 10px;
  width: 8px;
  opacity: 0.8;
}

.widget-resize-handle--note {
  right: -4px;
  bottom: -4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.math-widget--note.selected .widget-resize-handle--note,
.math-widget--note:focus-within .widget-resize-handle--note {
  opacity: 1;
  pointer-events: auto;
}

.widget-resize-handle--note::before,
.widget-resize-handle--note::after {
  right: 4px;
  bottom: 4px;
}

.widget-resize-handle--note::after {
  right: 7px;
  bottom: 7px;
}

.math-widget .widget-resize-handle {
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.math-widget.selected .widget-resize-handle,
.math-widget:hover .widget-resize-handle,
.math-widget:focus-within .widget-resize-handle {
  opacity: 1;
  pointer-events: auto;
}

.math-widget .widget-resize-handle:hover {
  transform: scale(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.82),
    0 10px 20px rgba(59, 43, 31, 0.14);
}

.math-widget .widget-resize-handle--nw {
  top: -9px;
  left: -9px;
  cursor: nwse-resize;
}

.math-widget .widget-resize-handle--ne {
  top: -9px;
  right: -9px;
  cursor: nesw-resize;
}

.math-widget .widget-resize-handle--sw {
  bottom: -9px;
  left: -9px;
  cursor: nesw-resize;
}

.math-widget .widget-resize-handle--se {
  right: -9px;
  bottom: -9px;
  cursor: nwse-resize;
}

.math-widget .widget-resize-handle::before,
.math-widget .widget-resize-handle::after {
  left: 50%;
  top: 50%;
  right: auto;
  bottom: auto;
  width: 11px;
  height: 2px;
  background: rgba(173, 80, 40, 0.82);
  transform-origin: center;
}

.math-widget .widget-resize-handle::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.math-widget .widget-resize-handle::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.math-widget .widget-resize-handle--ne::before,
.math-widget .widget-resize-handle--sw::before {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.math-widget .widget-resize-handle--ne::after,
.math-widget .widget-resize-handle--sw::after {
  transform: translate(-50%, -50%) rotate(45deg);
}

.math-widget--image {
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(23, 50, 77, 0.08);
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
}

.math-widget--image.selected {
  border-color: rgba(201, 106, 60, 0.62);
  box-shadow: 0 16px 28px rgba(59, 43, 31, 0.12);
}

.math-widget--image.image-selected {
  border-color: rgba(42, 111, 95, 0.68);
  box-shadow: 0 16px 30px rgba(42, 111, 95, 0.14);
}

.math-widget--image .math-body--image {
  width: 100%;
  height: 100%;
  font-family: var(--ui-font);
}

.image-widget-shell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(239, 230, 218, 0.42)),
    repeating-conic-gradient(rgba(23, 50, 77, 0.08) 0% 25%, transparent 0% 50%) 0 0 / 18px 18px;
  box-shadow:
    0 12px 26px rgba(59, 43, 31, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.58);
  cursor: grab;
}

.math-widget--image:active .image-widget-shell {
  cursor: grabbing;
}

.board-surface[data-tool="select"] .math-widget--image,
.board-surface[data-tool="select"] .math-widget--image .image-widget-shell,
.board-surface[data-tool="select"] .math-widget--image:active .image-widget-shell {
  cursor: copy;
}

.board-surface[data-tool="select"] .math-widget--image.image-selected,
.board-surface[data-tool="select"] .math-widget--image.image-selected .image-widget-shell {
  cursor: grab;
}

.board-surface[data-tool="select"] .math-widget--image.image-selected:active .image-widget-shell {
  cursor: grabbing;
}

.math-widget--image.selected .image-widget-shell {
  outline: 2px solid rgba(201, 106, 60, 0.68);
  outline-offset: 3px;
}

.math-widget--image.image-selected .image-widget-shell {
  outline: 2px solid rgba(42, 111, 95, 0.72);
  outline-offset: 3px;
}

.math-widget--image.image-selected::after {
  content: "已选";
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(42, 111, 95, 0.9);
  color: #fff;
  font-family: var(--ui-font);
  font-size: 0.72rem;
  font-weight: 700;
  box-shadow: 0 6px 12px rgba(23, 50, 77, 0.18);
  pointer-events: none;
}

.math-widget--image.selected::after {
  background: rgba(201, 106, 60, 0.94);
}

.math-widget--image.selected.image-selected {
  border-color: rgba(201, 106, 60, 0.68);
}

.math-widget--image.selected.image-selected .image-widget-shell {
  outline-color: rgba(201, 106, 60, 0.78);
}

.image-widget-img {
  position: absolute;
  left: var(--image-render-left, 0%);
  top: var(--image-render-top, 0%);
  width: var(--image-render-width, 100%);
  height: var(--image-render-height, 100%);
  object-fit: fill;
  user-select: none;
  pointer-events: none;
}

.image-widget-shell.is-cropping .image-widget-img {
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.78;
}

.image-widget-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: rgba(23, 50, 77, 0.5);
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.42);
}

.image-tool-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.image-tool-btn:hover,
.image-tool-btn.active {
  background: rgba(201, 106, 60, 0.16);
  color: var(--accent-strong);
}

.image-tool-btn--wide {
  min-width: 42px;
}

.image-tool-divider {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: rgba(117, 94, 72, 0.18);
}

.image-crop-frame {
  position: absolute;
  z-index: 3;
  min-width: 18px;
  min-height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  box-shadow:
    0 0 0 999px rgba(23, 50, 77, 0.28),
    0 0 0 1px rgba(173, 80, 40, 0.74),
    0 10px 20px rgba(23, 50, 77, 0.16);
  cursor: move;
  touch-action: none;
}

.image-crop-frame::before,
.image-crop-frame::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.image-crop-frame::before {
  inset: 33.333% 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.78);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.78);
}

.image-crop-frame::after {
  inset: 0 33.333%;
  border-left: 1px dashed rgba(255, 255, 255, 0.78);
  border-right: 1px dashed rgba(255, 255, 255, 0.78);
}

.image-crop-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(245, 224, 207, 0.98));
  border: 1px solid rgba(173, 80, 40, 0.54);
  box-shadow: 0 6px 14px rgba(23, 50, 77, 0.18);
  touch-action: none;
}

.image-crop-handle::before,
.image-crop-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: rgba(173, 80, 40, 0.84);
  transform-origin: center;
}

.image-crop-handle::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.image-crop-handle::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.image-crop-handle--nw {
  left: -12px;
  top: -12px;
  cursor: nwse-resize;
}

.image-crop-handle--ne {
  right: -12px;
  top: -12px;
  cursor: nesw-resize;
}

.image-crop-handle--sw {
  left: -12px;
  bottom: -12px;
  cursor: nesw-resize;
}

.image-crop-handle--se {
  right: -12px;
  bottom: -12px;
  cursor: nwse-resize;
}

.widget-resize-handle--image {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(227, 238, 240, 0.96));
  border-color: rgba(42, 111, 95, 0.32);
}

.widget-resize-handle--image::before,
.widget-resize-handle--image::after {
  background: rgba(42, 111, 95, 0.84);
}

.board-surface.is-exporting .widget-header,
.board-surface.is-exporting .widget-delete,
.board-surface.is-exporting .widget-resize-handle,
.board-surface.is-exporting .image-crop-frame,
.board-surface.is-exporting .tool-preview {
  display: none !important;
}

.board-surface.is-exporting .math-widget.selected {
  border-color: rgba(138, 111, 84, 0.22);
  box-shadow: 0 12px 28px rgba(59, 43, 31, 0.08);
}

.board-surface.is-exporting .math-widget--image,
.board-surface.is-exporting .math-widget--image.selected {
  border-color: transparent;
  box-shadow: none;
}

.board-surface.is-exporting .math-widget--image.selected .image-widget-shell {
  outline: none;
}

.board-surface.is-exporting .math-widget--image.image-selected::after {
  display: none;
}

.board-surface.is-exporting .image-widget-shell.is-cropping .image-widget-img {
  left: var(--image-render-left, 0%);
  top: var(--image-render-top, 0%);
  right: auto;
  bottom: auto;
  width: var(--image-render-width, 100%);
  height: var(--image-render-height, 100%);
  opacity: 1;
}

.export-preview-modal[hidden] {
  display: none !important;
}

.export-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
}

.export-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 31, 38, 0.42);
  backdrop-filter: blur(6px);
}

.export-preview-panel {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 250, 243, 0.98);
  border: 1px solid rgba(117, 94, 72, 0.16);
  box-shadow: 0 28px 64px rgba(23, 31, 38, 0.24);
}

.export-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.export-preview-header h2 {
  margin: 0 0 5px;
  font-size: 1.12rem;
  line-height: 1.25;
}

.export-preview-copy,
.export-preview-meta {
  margin: 0;
  color: rgba(23, 50, 77, 0.68);
  font-size: 0.9rem;
  line-height: 1.5;
}

.export-preview-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.84);
  color: var(--danger);
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.74),
    0 6px 14px rgba(59, 43, 31, 0.08);
}

.export-preview-frame {
  min-height: 220px;
  max-height: min(480px, 58vh);
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgba(117, 94, 72, 0.14);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(239, 230, 218, 0.42)),
    repeating-conic-gradient(rgba(23, 50, 77, 0.08) 0% 25%, transparent 0% 50%) 0 0 / 20px 20px;
  overflow: auto;
}

.export-preview-image {
  display: block;
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
  filter: drop-shadow(0 14px 22px rgba(23, 31, 38, 0.16));
}

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

.calc-layout {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calc-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: end;
  gap: 10px;
}

.op-slot {
  display: block;
  min-height: 1px;
}

.inline-operator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  line-height: 1;
  transform: rotate(-4deg);
  min-height: 36px;
}

.calc-divider {
  height: 3px;
  margin-left: 34px;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.72);
  transform: rotate(-1deg);
}

.digit-track {
  display: block;
}

.widget-field {
  user-select: text;
}

.math-input {
  width: 100%;
  padding: 0 6px 2px;
  padding-right: calc(6px + var(--digit-shift, 0px));
  border: none;
  border-bottom: 1px dashed rgba(23, 50, 77, 0.18);
  background: transparent;
  color: inherit;
  font-family: var(--hand-font);
  font-size: 1.55rem;
  text-align: right;
  outline: none;
}

.math-input::placeholder,
.text-widget-input::placeholder,
.text-note-input::placeholder {
  color: rgba(23, 50, 77, 0.26);
}

.digit-track--wide .math-input {
  font-size: 1.65rem;
}

.digit-track--partial .math-input {
  font-size: 1.55rem;
}

.digit-track--short {
  margin-left: 0;
}

.division-quotient-track {
  position: relative;
}

.division-quotient-track--hint-dot::after {
  content: ".";
  position: absolute;
  right: 4px;
  top: 50%;
  color: inherit;
  font-family: var(--hand-font);
  font-size: 1.8rem;
  line-height: 1;
  transform: translateY(-34%) rotate(-6deg);
  opacity: 0.78;
  pointer-events: none;
}

.digit-track--step .math-input {
  font-size: 1.45rem;
}

.carry-strip {
  display: grid;
  grid-template-columns: repeat(var(--carry-columns, 1), 18px);
  justify-content: end;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  margin-top: -3px;
}

.carry-slot {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.carry-slot--hidden {
  visibility: hidden;
  pointer-events: none;
}

.carry-gap {
  width: 18px;
  height: 18px;
  display: inline-flex;
}

.math-input--carry {
  padding: 0;
  width: 100%;
  height: 18px;
  min-height: 18px;
  border: 1px solid rgba(201, 106, 60, 0.6);
  border-radius: 3px;
  font-size: 0.86rem;
  line-height: 1;
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
}

.math-widget--multiplication .calc-row--carry {
  margin-top: -2px;
  margin-bottom: -1px;
}

.multiplication-partials {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: -1px;
}

.calc-row--partial + .calc-row--partial {
  margin-top: -1px;
}

.calc-divider--partial-sum {
  margin-top: -1px;
}

.calc-row--carry.is-hidden {
  display: none;
}

.division-layout {
  width: max-content;
}

.division-main {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.division-top-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 2px;
}

.division-top-spacer {
  flex: 0 0 auto;
}

.division-work {
  position: relative;
  flex: 0 0 auto;
  min-height: 110px;
  padding: 14px 0 0 14px;
  border-left: 3px solid rgba(23, 50, 77, 0.72);
}

.division-work::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.72);
  transform: rotate(-1.5deg);
}

.division-work .math-input {
  margin-bottom: 6px;
}

.division-dividend {
  margin-top: 2px;
}

.division-dividend .math-input {
  padding-left: 2px;
  text-align: left;
}

.division-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.division-step {
  padding-left: var(--indent, 0px);
  width: max-content;
  max-width: 100%;
}

.division-follow {
  margin-top: -2px;
}

.division-step.is-hidden,
.division-follow.is-hidden {
  display: none;
}

.division-rule {
  width: 100%;
  height: 3px;
  margin: 2px 0 4px;
  border-radius: 999px;
  background: rgba(23, 50, 77, 0.72);
  transform: rotate(-1deg);
}

@media (max-width: 920px) {
  .board-surface {
    min-height: max(620px, 68vh, calc(100vh - 220px));
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 10px;
  }

  .top-toolbar {
    top: 8px;
    padding: 12px;
  }

  .toolbar-row {
    gap: 8px;
  }

  .toolbar-tools,
  .formula-strip,
  .insert-strip,
  .image-edit-strip,
  .toolbar-menu {
    flex: 1 1 calc(50% - 8px);
  }

  .toolbar-tools {
    justify-content: center;
    width: 100%;
  }

  .formula-strip {
    width: 100%;
    justify-content: center;
  }

  .insert-strip {
    width: 100%;
    justify-content: center;
  }

  .formula-chip {
    flex: 1 1 calc(33.333% - 8px);
    justify-content: center;
  }

  .insert-chip {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .toolbar-trigger {
    width: 100%;
    justify-content: space-between;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    flex: 1 1 100%;
  }

  .image-edit-strip {
    width: 100%;
    justify-content: center;
  }

  .toolbar-shortcut {
    width: 100%;
  }

  .toolbar-shortcut--danger {
    grid-column: span 2;
  }

  .toolbar-popover,
  .toolbar-popover--wide,
  .toolbar-popover--narrow {
    width: min(320px, calc(100vw - 28px));
  }

  .export-preview-modal {
    padding: 12px;
  }

  .export-preview-panel {
    padding: 14px;
    max-height: calc(100vh - 24px);
  }

  .export-preview-frame {
    min-height: 180px;
    max-height: 48vh;
    padding: 12px;
  }

  .export-preview-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .export-preview-actions .ghost-btn,
  .export-preview-actions .accent-btn {
    width: 100%;
  }

  .tool-flyout {
    width: min(220px, calc(100vw - 28px));
  }

  .board-surface {
    min-height: max(580px, 64vh, calc(100vh - 252px));
  }
}
