.board-shell { max-width: 1440px; }
.board-shell .product-section { padding: 32px 0 48px; }
.board-workspace { overflow: hidden; border-radius: 18px; }
.board-workspace .shared-board { gap: 14px; padding: 20px; }
.board-title-wrap { display: grid; gap: 2px; min-width: 190px; }
.board-title-input {
  width: min(420px, 42vw); padding: 2px 5px; margin: -3px -5px 0; border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: var(--ink); font: inherit; font-size: 15px; font-weight: 700;
}
.board-title-input:hover, .board-title-input:focus { border-color: var(--line); background: #fff; outline: none; }
.board-title-input:focus { box-shadow: 0 0 0 3px rgba(255, 149, 0, .13); }
.board-save-status { min-height: 14px; color: var(--ink-faint); font-size: 11px; }
.board-head-actions { flex-wrap: wrap; justify-content: flex-end; }

.margin-board-bar {
  display: grid; grid-template-columns: minmax(250px, 1fr) minmax(220px, .8fr) auto;
  align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid #ddd1ff;
  border-radius: 12px; background: linear-gradient(105deg, #f7f3ff, #fffaf4);
}
.margin-board-copy { display: flex; align-items: center; gap: 11px; min-width: 0; }
.margin-board-copy > div { display: grid; min-width: 0; }
.margin-board-copy strong { color: var(--ink); font-size: 14px; }
.margin-board-copy span:last-child { color: var(--ink-soft); font-size: 12px; line-height: 1.35; }
.margin-spark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 10px; background: #8b5cf6; color: #fff; font-size: 18px;
}
.margin-board-bar .form-control { min-width: 0; }
.margin-board-bar .btn { border: 0; cursor: pointer; white-space: nowrap; }
.margin-board-bar .btn:disabled { opacity: .55; cursor: wait; }

.board-studio {
  display: grid; grid-template-columns: 74px minmax(0, 1fr); min-height: 560px;
  overflow: hidden; border: 1px solid var(--line); border-radius: 14px;
  background: #f4f5f6; box-shadow: inset 0 1px 0 #fff;
}
.board-tool-rail {
  position: relative; z-index: 3; display: flex; flex-direction: column; flex-wrap: nowrap;
  align-items: stretch; gap: 8px; padding: 10px 8px; overflow-y: auto;
  border-right: 1px solid var(--line); background: rgba(255,255,255,.96);
}
.board-tool-group { display: grid; gap: 3px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.board-tool-group:last-child { padding: 0; border: 0; }
.board-history-tools { margin-top: auto; }
.board-tool {
  display: grid; place-items: center; gap: 1px; min-height: 41px; padding: 3px 2px;
  border: 0; border-radius: 9px; color: var(--ink-soft); background: transparent;
  font: inherit; cursor: pointer; transition: color .12s ease, background .12s ease, transform .12s ease;
}
.board-tool:hover:not(:disabled) { color: var(--ink); background: var(--paper-warm); }
.board-tool.selected { color: #fff; background: var(--ink); }
.board-tool:active:not(:disabled) { transform: scale(.96); }
.board-tool:focus-visible { outline: 3px solid rgba(232,89,12,.24); outline-offset: -1px; }
.board-tool:disabled { opacity: .3; cursor: default; }
.board-tool b { height: 21px; font-size: 20px; font-weight: 550; line-height: 21px; }
.board-tool span { font-size: 9px; font-weight: 700; line-height: 1; }
.board-tool-rail .board-colors {
  display: grid; grid-template-columns: repeat(2, 22px); justify-content: center;
  gap: 7px; padding: 2px 0 10px; border-bottom: 1px solid var(--line);
}
.board-tool-rail .board-colors button { width: 21px; height: 21px; }

.board-canvas-viewport { position: relative; overflow: auto; min-width: 0; min-height: 0; }
/* Zoom is the shell's width; aspect-ratio keeps the board square with the
   viewBox, so the SVG rescales itself and no transform maths is needed. */
.board-canvas-shell {
  position: relative; width: var(--board-zoom, 100%); min-width: 640px; margin: 0 auto;
  aspect-ratio: 5 / 3; background: #fff;
}
.board-workspace .board-canvas-shell .whiteboard {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0;
}
/* Margin's marks are click-through everywhere else so its animation never
   swallows a pointer; here the eraser hit-tests the DOM and needs to find them. */
.board-canvas-shell .margin-tutor-mark { pointer-events: auto; }
.board-text-editor {
  position: absolute; z-index: 5; width: min(230px, 28%); min-width: 150px; min-height: 80px;
  padding: 11px 12px; resize: none; border: 2px solid var(--accent-bright); border-radius: 9px;
  background: rgba(255,255,255,.97); box-shadow: 0 10px 28px rgba(16,24,40,.18);
  color: var(--ink); font: 600 16px/1.35 inherit; outline: 0;
}
.board-text-editor.note { background: #fff6c7; }
.board-text-editor[hidden] { display: none; }
.board-zoom {
  position: sticky; z-index: 6; left: calc(100% - 148px); bottom: 14px;
  display: grid; grid-template-columns: 36px 58px 36px; align-items: center;
  width: 130px; margin: -58px 14px 14px auto; padding: 4px;
  border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.94);
  box-shadow: 0 6px 18px rgba(16,24,40,.12); backdrop-filter: blur(8px);
}
.board-zoom button { height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 22px; cursor: pointer; }
.board-zoom button:hover:not(:disabled) { background: var(--paper-warm); }
.board-zoom button:disabled { color: var(--ink-faint); cursor: default; }
.board-zoom output { text-align: center; color: var(--ink-soft); font-size: 12px; font-weight: 750; }

.board-studio-shell:fullscreen,
.board-studio-shell.expanded {
  z-index: 1000; width: 100%; height: 100%; max-height: none; padding: 16px;
  grid-template-rows: auto auto minmax(0, 1fr); background: #fff;
}
.board-studio-shell.expanded { position: fixed; inset: 0; }
.board-studio-shell:fullscreen .board-studio,
.board-studio-shell.expanded .board-studio { min-height: 0; height: 100%; }
.board-studio-shell:fullscreen .board-canvas-shell,
.board-studio-shell.expanded .board-canvas-shell { min-height: 100%; }
body:has(.board-studio-shell.expanded) { overflow: hidden; }

.board-ended-card { max-width: 620px; text-align: center; }
.board-ended-card .btn { margin-top: 24px; }
.board-history { padding: 10px 0 54px; }
.board-history-head { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.board-history-head h2 { margin: 4px 0 0; font-size: 23px; }
.board-history-head > span { color: var(--ink-soft); font-size: 13px; }
.board-history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.board-history-card {
  display: grid; gap: 7px; min-height: 112px; padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); text-align: left; cursor: pointer; box-shadow: 0 3px 12px rgba(35, 25, 10, .04);
}
.board-history-card:hover { border-color: #efb86e; transform: translateY(-1px); }
.board-history-card strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.board-history-card span { color: var(--ink-soft); font-size: 12px; }
.board-history-card b { margin-top: auto; color: var(--accent); font-size: 12px; }
.board-history-empty { grid-column: 1 / -1; margin: 0; padding: 20px; border: 1px dashed var(--line); border-radius: 12px; color: var(--ink-soft); text-align: center; }
.board-history-dialog { width: min(1040px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: 18px; box-shadow: 0 24px 80px rgba(20, 13, 5, .28); }
.board-history-dialog::backdrop { background: rgba(29, 22, 15, .48); backdrop-filter: blur(3px); }
.board-history-dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.board-history-dialog-head h2 { margin: 4px 0; }
.board-history-dialog-head p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.history-board-canvas { position: relative; }
.history-board-canvas .board-count { display: block; margin-bottom: 8px; text-align: right; }
/* The saved-board dialog still sizes its canvas directly; only the live board
   is a studio shell that stretches its SVG to fill. */
.history-board-canvas .whiteboard { height: min(60vh, 600px); cursor: default; }

@media (max-width: 760px) {
  .board-shell { padding: 0 12px; }
  .board-title-input { width: 58vw; }
  .board-history-head { display: grid; }
  .board-history-dialog { padding: 16px; }
  .board-shell .product-section { padding-top: 18px; }
  .board-workspace .shared-board { padding: 14px; }
  .board-head { align-items: flex-start; }
  .board-head-actions { gap: 6px; }
  .board-count { width: 100%; text-align: right; }
  .margin-board-bar { grid-template-columns: 1fr; }
  .board-studio { grid-template-columns: 1fr; grid-template-rows: auto minmax(520px, 1fr); }
  .board-tool-rail {
    flex-direction: row; align-items: center; gap: 5px; padding: 7px; overflow-x: auto;
    overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .board-tool-group { display: flex; gap: 2px; padding: 0 6px 0 0; border: 0; border-right: 1px solid var(--line); }
  .board-history-tools { margin: 0; }
  .board-tool { min-width: 43px; min-height: 43px; }
  .board-tool span { display: none; }
  .board-tool-rail .board-colors {
    display: flex; flex: 0 0 auto; padding: 0 7px 0 0; border: 0; border-right: 1px solid var(--line);
  }
  .board-canvas-shell { min-width: 720px; }
  .board-studio-shell:fullscreen, .board-studio-shell.expanded { padding: 8px; }
  .board-studio-shell:fullscreen .margin-board-bar,
  .board-studio-shell.expanded .margin-board-bar { display: none; }
}
