/* Preview and settings guide. */

/* ---------- Preview ---------- */
.preview-pane {
  grid-area: canvas;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.preview-pane > .canvas-strip {
  grid-column: 1 / -1;
}
.preview-pane > .preview {
  grid-column: 2;
  grid-row: 2;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.toggle {
  min-height: var(--control-h);
  min-width: 44px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.toggle:last-child {
  border-right: 0;
}
.toggle[aria-pressed="true"] {
  background: var(--surface-hover);
  color: var(--text);
  box-shadow: inset 0 -2px var(--accent);
}

/* Shares the preview's cell, floating over the top of the result. */
.restored-note {
  grid-column: 2;
  grid-row: 2;
  z-index: 3;
  align-self: start;
  justify-self: center;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  max-width: calc(100% - 16px);
  margin-top: 8px;
  padding: 6px 6px 6px 12px;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.3);
}
.restored-note[hidden] {
  display: none;
}

/* ---------- Settings guide dialog ---------- */
.guide-dialog {
  width: min(900px, calc(100% - 28px));
}
/* Long guides scroll; keep Close reachable without scrolling to the end. */
.guide-dialog .dialog-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -20px -20px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-3);
}

.guide-dialog-content > h2 {
  margin: 0 0 12px;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  line-height: 16px;
  font-weight: 600;
}

.guide-dialog-content a {
  color: var(--accent);
  text-underline-offset: 2px;
}
.guide-dialog-content a:hover {
  color: var(--accent-hover);
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 16px;
}

.help-settings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 16px 24px;
  margin: 0 0 20px;
}

.help-settings dt {
  font-size: var(--fs-md);
  font-weight: 600;
  margin-bottom: 2px;
}

.help-settings dd {
  margin: 0;
  font-size: var(--fs-md);
  line-height: 20px;
  color: var(--text-dim);
}

.help-grid h3 {
  margin: 0 0 4px;
  font-size: var(--fs-md);
}

.help-grid p {
  margin: 0;
  font-size: var(--fs-md);
  color: var(--text-dim);
}

.help-grid em {
  font-style: normal;
  color: var(--text);
}

.help-grid .support-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  text-decoration: none;
}

.help-grid .support-link:hover {
  text-decoration: underline;
}

.preview {
  position: relative;
  min-height: 0;
  height: auto;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  cursor: grab;
  touch-action: none;
}

/* The pane clips overflow, so an outer ring would be cut off. */
.preview:focus-visible {
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 0;
}

.selection-actions {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  display: flex;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 6px;
  transform: translateX(-50%);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--surface-3);
  box-shadow: var(--shadow-2);
}
.selection-actions[hidden],
.selection-actions [hidden] {
  display: none;
}
/* 44px touch targets (Apple HIG); also comfortable with a mouse. */
.selection-actions .button {
  min-height: 44px;
  min-width: 64px;
  padding-inline: 14px;
}

.preview.panning {
  cursor: grabbing;
}

.preview.erasing,
.preview.blob-filling,
.preview.blob-picking,
.preview.smoothing {
  cursor: none;
}
.preview.selecting {
  cursor: crosshair;
}
/* Boxed + or - beside the crosshair: Shift adds, Alt/Option subtracts. */
.preview.selecting.sel-add {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Cpath d='M8 1v14M1 8h14' stroke='%23000' stroke-width='3'/%3E%3Cpath d='M8 1v14M1 8h14' stroke='%23fff' stroke-width='1'/%3E%3Crect x='14.5' y='14.5' width='10' height='10' fill='%23fff' stroke='%23000'/%3E%3Cpath d='M19.5 16.5v6M16.5 19.5h6' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E")
      8 8,
    crosshair;
}
.preview.selecting.sel-subtract {
  cursor:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26'%3E%3Cpath d='M8 1v14M1 8h14' stroke='%23000' stroke-width='3'/%3E%3Cpath d='M8 1v14M1 8h14' stroke='%23fff' stroke-width='1'/%3E%3Crect x='14.5' y='14.5' width='10' height='10' fill='%23fff' stroke='%23000'/%3E%3Cpath d='M16.5 19.5h6' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E")
      8 8,
    crosshair;
}

/* Space held: the Hand tool overrides every cleanup tool cursor. */
.preview.space-pan,
.preview.space-pan.selecting.sel-add,
.preview.space-pan.selecting.sel-subtract {
  cursor: grab;
}
.preview.space-pan.panning,
.preview.space-pan.panning.selecting.sel-add,
.preview.space-pan.panning.selecting.sel-subtract {
  cursor: grabbing;
}
.preview.space-pan .eraser-cursor {
  visibility: hidden;
}
