/* 아하수학 판서 도구 — 지면 엔진과 독립적으로 동작한다. */
.aha-note-launch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: #2f6fca;
  background: #eef5ff;
  color: #174f9f;
}

.aha-note-launch::before {
  content: '✎';
  font-size: 17px;
  line-height: 1;
}

.aha-note-launch[aria-pressed='true'] {
  border-color: #225eae;
  background: #225eae;
  color: #fff;
}

.aha-note-panel {
  position: fixed;
  z-index: 58;
  top: 72px;
  right: 14px;
  width: min(560px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid #d5deec;
  border-radius: 16px;
  background: rgb(255 255 255 / 97%);
  color: #21262f;
  box-shadow: 0 16px 48px rgb(33 38 47 / 22%);
  backdrop-filter: blur(14px);
}

.aha-note-panel__top,
.aha-note-panel__row,
.aha-note-panel__tools,
.aha-note-panel__colors,
.aha-note-panel__sizes,
.aha-note-panel__actions {
  display: flex;
  align-items: center;
}

.aha-note-panel__top {
  gap: 10px;
  margin-bottom: 10px;
}

.aha-note-panel__title {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
}

.aha-note-panel__title b {
  font-size: 14px;
  letter-spacing: -.02em;
}

.aha-note-status {
  overflow: hidden;
  color: #65717d;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aha-note-close {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-content: center;
  border: 1px solid #dce2ea;
  border-radius: 50%;
  background: #fff;
  color: #57616d;
  font: 700 20px/1 system-ui, sans-serif;
  cursor: pointer;
}

.aha-note-panel__row {
  justify-content: space-between;
  gap: 10px;
}

.aha-note-panel__row + .aha-note-panel__row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf0f4;
}

.aha-note-panel__tools,
.aha-note-panel__actions {
  gap: 6px;
}

.aha-note-tool,
.aha-note-action {
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid #d8dee7;
  border-radius: 10px;
  background: #fff;
  color: #303944;
  font: 750 12px/1 var(--font, system-ui, sans-serif);
  cursor: pointer;
  white-space: nowrap;
}

.aha-note-tool[aria-pressed='true'] {
  border-color: #225eae;
  background: #225eae;
  color: #fff;
  box-shadow: 0 5px 14px rgb(34 94 174 / 20%);
}

.aha-note-action:disabled {
  opacity: .38;
  cursor: default;
}

.aha-note-action--clear {
  border-color: #efd0ca;
  color: #a23f31;
}

.aha-note-action--clear[data-confirm='true'] {
  border-color: #bf392d;
  background: #bf392d;
  color: #fff;
}

.aha-note-panel__style {
  display: flex;
  align-items: center;
  gap: 12px;
}

.aha-note-panel__colors,
.aha-note-panel__sizes {
  gap: 5px;
}

.aha-note-color,
.aha-note-size {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-content: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #f5f7fa;
  cursor: pointer;
}

.aha-note-color::before {
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgb(34 40 48 / 18%);
  content: '';
}

.aha-note-size::before {
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: #263241;
  content: '';
}

.aha-note-color[aria-pressed='true'],
.aha-note-size[aria-pressed='true'] {
  border-color: #225eae;
  background: #eaf2ff;
  box-shadow: inset 0 0 0 1px #225eae;
}

.aha-note-canvas {
  position: absolute;
  z-index: 25;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
  touch-action: auto;
}

html[data-aha-note-mode='pen'] .aha-note-canvas,
html[data-aha-note-mode='eraser'] .aha-note-canvas {
  pointer-events: auto;
  touch-action: none;
}

html[data-aha-note-mode='pen'] .aha-note-canvas { cursor: crosshair; }
html[data-aha-note-mode='eraser'] .aha-note-canvas { cursor: cell; }

html[data-aha-note-mode='pen'] .sheet.aha-note-active,
html[data-aha-note-mode='eraser'] .sheet.aha-note-active {
  outline: 3px solid rgb(34 94 174 / 42%);
  outline-offset: 3px;
}

.aha-note-toast {
  position: fixed;
  z-index: 59;
  left: 50%;
  bottom: max(78px, calc(64px + env(safe-area-inset-bottom)));
  translate: -50% 10px;
  max-width: calc(100vw - 28px);
  padding: 10px 15px;
  border-radius: 999px;
  background: rgb(31 39 49 / 94%);
  color: #fff;
  font: 750 12px/1.45 var(--font, system-ui, sans-serif);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, translate .18s;
  white-space: nowrap;
}

.aha-note-toast[data-show='true'] {
  translate: -50% 0;
  opacity: 1;
}

@media (max-width: 640px) {
  .aha-note-panel {
    left: 8px;
    right: 8px;
    width: auto;
    padding: 10px;
    border-radius: 14px;
  }

  .aha-note-panel__row {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .aha-note-panel__tools,
  .aha-note-panel__actions,
  .aha-note-panel__style {
    justify-content: space-between;
  }

  .aha-note-panel__tools .aha-note-tool,
  .aha-note-panel__actions .aha-note-action {
    flex: 1 1 0;
  }

  .aha-note-tool,
  .aha-note-action {
    min-height: 42px;
    padding-inline: 8px;
  }

  .aha-note-color,
  .aha-note-size {
    width: 38px;
    height: 38px;
  }
}

@media print {
  .aha-note-launch,
  .aha-note-panel,
  .aha-note-canvas,
  .aha-note-toast {
    display: none !important;
  }
}
