.lesson-whiteboard {
  position: relative;
  z-index: 4;
  margin: 18px 0;
  color: #171b33;
  font-family: inherit;
}

.whiteboard-tab {
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid #e0e2eb;
  border-radius: 10px;
  padding: 0 15px;
  color: #5144ba;
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 36, 61, .08);
  font: 700 14px/1 inherit;
  cursor: pointer;
}

.whiteboard-tab span { font-size: 18px; }

.whiteboard-panel {
  overflow: hidden;
  border: 1px solid #e0e2eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 34px rgba(31, 36, 61, .07);
}

.whiteboard-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 9px 14px;
  border-bottom: 1px solid #e7e9f0;
  background: #f8f8fc;
}

.whiteboard-panel > header > div {
  display: flex;
  align-items: center;
  gap: 11px;
}

.whiteboard-panel > header > div > span {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: #6758d8;
  box-shadow: 0 5px 14px rgba(103, 88, 216, .22);
  font-size: 18px;
}

.whiteboard-panel strong {
  display: block;
  color: #171b33;
  font-size: 16px;
  font-weight: 750;
}

.whiteboard-panel nav {
  display: flex;
  gap: 6px;
}

.whiteboard-panel nav button,
.whiteboard-tools button {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid #dfe2ec;
  border-radius: 10px;
  color: #4b526b;
  background: #fff;
  font: 600 13px/1 inherit;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}

.whiteboard-panel button:hover {
  border-color: #b7b0ef;
  color: #5144ba;
  background: #f5f3ff;
}

.whiteboard-panel button:active { transform: translateY(1px); }

.whiteboard-panel button:focus-visible {
  outline: 3px solid rgba(103, 88, 216, .2);
  outline-offset: 2px;
}

.whiteboard-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid #e7e9f0;
  background: #fff;
}

.whiteboard-tools [data-board-tool="text"],
.whiteboard-tools [data-board-tool="pen"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding-inline: 14px;
}

.whiteboard-tools [data-board-tool][aria-pressed="true"] {
  color: #fff;
  border-color: #6758d8;
  background: #6758d8;
  box-shadow: 0 5px 14px rgba(103, 88, 216, .18);
}

.whiteboard-tools .board-color {
  position: relative;
  width: 40px;
  padding: 0;
}

.whiteboard-tools .board-color::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--pen);
}

.whiteboard-tools .board-color.active {
  border-color: #6758d8;
  box-shadow: 0 0 0 3px rgba(103, 88, 216, .13);
}

.whiteboard-tools [data-board-clear] {
  margin-left: auto;
  padding-inline: 13px;
  color: #8e4050;
}

.whiteboard-surface {
  position: relative;
  min-height: 280px;
  margin: 12px;
  overflow: hidden;
  border: 1px solid #dfe2ec;
  border-radius: 11px;
  background-color: #fdfdff;
  background-image:
    linear-gradient(rgba(103, 88, 216, .075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(103, 88, 216, .075) 1px, transparent 1px);
  background-size: 28px 28px;
  box-shadow: inset 0 1px 4px rgba(23, 27, 51, .035);
}

.whiteboard-editor,
.whiteboard-surface canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.whiteboard-editor {
  z-index: 1;
  overflow: auto;
  padding: 20px 22px;
  color: #171b33;
  background: transparent;
  font: 18px/1.65 inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: 0;
  cursor: text;
}

.whiteboard-editor:focus { box-shadow: inset 0 0 0 2px rgba(103, 88, 216, .22); }

.whiteboard-surface canvas {
  z-index: 2;
  touch-action: none;
  cursor: crosshair;
}

.lesson-whiteboard[data-tool="text"] .whiteboard-surface canvas {
  pointer-events: none;
  cursor: default;
}

.lesson-whiteboard:not([data-tool="text"]) .whiteboard-editor {
  pointer-events: none;
  user-select: none;
}

.lesson-whiteboard[data-mode="zero"] {
  display: flex;
  justify-content: flex-end;
  margin-block: 10px;
}

.lesson-whiteboard[data-mode="zero"] .whiteboard-tab { display: flex; }
.lesson-whiteboard[data-mode="zero"] .whiteboard-panel { display: none; }
.lesson-whiteboard[data-mode="compact"] .whiteboard-surface { min-height: 280px; }
.lesson-whiteboard[data-mode="full"] .whiteboard-surface { height: min(68vh, 740px); }

.grammar-presentation .lesson-whiteboard[data-mode="full"] {
  position: fixed;
  inset: 12px;
  z-index: 100;
  margin: 0;
}

.grammar-presentation .lesson-whiteboard[data-mode="full"] .whiteboard-panel {
  display: flex;
  height: 100%;
  flex-direction: column;
}

.grammar-presentation .lesson-whiteboard[data-mode="full"] .whiteboard-surface {
  height: auto;
  min-height: 0;
  flex: 1;
}

@media (max-width: 680px) {
  .whiteboard-panel > header { align-items: center; }
  .whiteboard-panel > header > div > span { display: none; }
  .whiteboard-panel nav button { min-width: 38px; }
  .whiteboard-tools { gap: 6px; padding: 8px; }
  .whiteboard-tools [data-board-clear] { margin-left: 0; }
  .whiteboard-surface { min-height: 360px; margin: 8px; }
  .whiteboard-editor { padding: 16px; font-size: 16px; }
}
