/* ======================================================
   Page Plan — Mid Demo Theme (v1 look + polished)
   - Pages stay SQUARE (no rounded corners)
   - Side panel blocks/cards get rounded corners
   - Header top bar highlighted; inner meta row lighter
   - Small side buttons (24px) consistent
   - Background/Slot selector styled as buttons (small)
   - No duplicated theme blocks / no conflicting :root
   ====================================================== */

/* ---------- Tokens ---------- */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f7f9ff;

  --text: #0f172a;
  --muted: #64748b;

  --border: #e5e7eb;
  --border-2: #cbd5e1;
  --border-strong: #94a3b8;

  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 10px 22px rgba(15, 23, 42, 0.12);

  --ring: 0 0 0 3px rgba(37, 99, 235, 0.30);

  --r: 10px;
  /* rounded cards */
  --r-btn: 6px;
  /* rounded buttons */
  --btn-h-side: 24px;
  /* small side buttons */
  --btn-h-head: 26px;
  /* slightly bigger header buttons */
  /* --- Page thumbnail sizing (used for responsive + future zoom) --- */
  --page-w: 140px;
  --page-h: 175px;
  --page-w-double: 280px;
  --plan-col-min: 420px;
  --page-label-font: 13px;
}

/* ---------- Base ---------- */
html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);

  /* Prevent the whole page from scrolling */
  overflow: hidden;

  /* Stack header + app vertically */
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* critical so hidden always wins */

* {
  box-sizing: border-box;
}

/* ---------- Header (top highlighted, inner row lighter) ---------- */
.top {
  background: linear-gradient(180deg, #eef4ff 0%, #ffffff 80%);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px 8px 12px;
  box-shadow: var(--shadow-sm);
}

.meta {
  display: flex;
  align-items: center;
  column-gap: 8px;
  row-gap: 20px;
  flex-wrap: wrap;

  /* more room for floating .hf-label */
  min-height: 56px;
  padding: 18px 10px 10px 10px;

  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: visible;
}

/* header field labels */
.hf {
  position: relative;
}

.hf-label {
  position: absolute;
  top: -14px;
  left: 6px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  padding: 0 2px;
  pointer-events: none;

  text-transform: uppercase;
  letter-spacing: 0.06em;
}


/* Cover pages toggle: keep header label on one line */
.hf.cover-pages-field {
  min-width: 122px;
}

.hf.cover-pages-field .hf-label {
  white-space: nowrap;
}

/* Center spread toggle in header */
.cs-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}

.cs-opt input {
  margin: 0;
}

/* header inputs */
.meta input:not([type="range"]) {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--border-2);
  background: #fff;
}

.meta input:focus {
  outline: none;
  box-shadow: var(--ring);
  border-color: rgba(37, 99, 235, 0.45);
}

/* header buttons (a bit bigger than side buttons) */
.meta button {
  height: var(--btn-h-head);
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: box-shadow .12s ease, transform .06s ease;
}

.meta button:hover {
  box-shadow: var(--ring);
}

.meta button:active {
  transform: translateY(1px);
}

.meta button.history-btn {
  width: var(--btn-h-head);
  min-width: var(--btn-h-head);
  padding: 0;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.meta button.history-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

.meta button.history-btn:disabled:hover {
  box-shadow: none;
}

/* locked header behavior (keep your existing logic working) */
.top.locked .meta input:not([type="range"]) {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  visibility: hidden;
  pointer-events: none;
}

.top.locked .hf {
  display: none;
}

.top.locked #editBtn {
  visibility: visible !important;
}

/* ================================
Zoom control (header)
================================ */
.zoom-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--btn-h-head);
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 0;
  margin-left: auto;
  /* keep it right-aligned */
}

.zoom-label {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.zoom-pct {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.85;

  min-width: 52px;
  /* gives the % some breathing room */
  text-align: center;
  /* centers between slider and reset */
  margin: 0 8px;
  /* equal space left/right */
}

#zoomRange {
  width: 110px;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;

  -webkit-appearance: none;
  appearance: none;
}

/* Reset button styled like a link */
#zoomResetBtn {
  height: auto !important;
  padding: 2 !important;
  border: 0 !important;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;

  font-size: 11px;
  color: rgba(20, 28, 48, 0.72);
  /* darker than % label */
  text-decoration: none;
  cursor: pointer;
}

#zoomResetBtn:hover {
  color: rgba(15, 23, 42, 0.90);
  box-shadow: none !important;
}

.user-prefs-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

 .meta button.user-prefs-btn {
  width: 30px;
  min-width: 30px;
  height: var(--btn-h-head);
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--accent);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .06s ease;
}

.meta button.user-prefs-btn:hover,
.meta button.user-prefs-btn:focus {
  box-shadow: none;
  background: var(--accent-soft);
}

.meta button.user-prefs-btn:active {
  transform: translateY(1px);
}

.user-prefs-icon {
  width: 21px;
  height: 21px;
  display: block;
  fill: currentColor;
}

.user-prefs-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 142px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-md);
}

.user-prefs-menu-title {
  padding: 4px 8px 7px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  white-space: nowrap;
}

.meta .user-prefs-menu button {
  display: block;
  width: 100%;
  height: 24px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  font-size: 12px;
  border-radius: 4px;
}

.meta .user-prefs-menu button:hover {
  background: var(--accent-soft);
  box-shadow: none;
}

/* WebKit track: thin grey with thin blue fill */
#zoomRange::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0/ var(--zoom-fill, 0%) 100% no-repeat,
    rgba(37, 99, 235, 0.22);
}

/* WebKit thumb */
#zoomRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #fff;
  margin-top: -4px;
  /* center on 2px track */
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.9);
}

/* Firefox: separate track + progress */
#zoomRange::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.22);
  border: none;
}

#zoomRange::-moz-range-progress {
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

#zoomRange::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.9);
}

#zoomRange:hover {
  opacity: 1;
}

/* ================================
Help button: round ? icon (header)
================================ */

/* Help button: blue filled circle + white ? */
.meta button.help-btn {
  width: var(--btn-h-head);
  min-width: var(--btn-h-head);
  height: var(--btn-h-head);
  padding: 0 !important;
  border-radius: 999px !important;

  background: #2197f1;
  /* matches your icon blue */
  border: 1px solid #2197f1;
  color: #ffffff;

  font-weight: 800;
  font-size: 18px;
  line-height: 1;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  box-shadow: none;
}

/* No ring on hover (keep it clean like the icon) */
.meta button.help-btn:hover {
  box-shadow: none;
  filter: brightness(0.98);
}



/* ---------- Language picker ---------- */
.lang-picker-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.lang-picker-label {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta select.lang-picker {
  height: var(--btn-h-head);
  min-width: 82px;
  padding: 0 28px 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
}

.top.locked .lang-picker-wrap {
  display: inline-flex !important;
}
/* ---------- Warning ---------- */
.warn {
  margin-top: 6px;
  color: #b91c1c;
  font-size: 13px;
}

/* ---------- Issue summary ---------- */
.issue-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  background: #dfeaff;
  /* slightly stronger than header */
  border-bottom: 1px solid var(--border);
}

.issue-summary strong {
  font-weight: 700;
}

#summaryTitle {
  font-weight: 600;
  font-size: 20px;
}

#summaryMeta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

#saveState {
  font-size: 12px;
  font-style: italic;
  font-weight: 500;
  margin-left: 10px;
  white-space: nowrap;
  opacity: 0.9;

  /* Default = Saved (blue) */
  color: var(--accent);
}

/* Unsaved changes = red */
#saveState.is-unsaved {
  color: #b91c1c;
}

/* ---------- App layout ---------- */
#app {
  display: flex;
  flex: 1;
  min-height: 0;
  /* important: allows inner scrolling properly */
  overflow: hidden;
  position: relative;
}

#planWrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  z-index: 1;
  min-height: 0;
}

#planScroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Keep the native page-area scrollbar visible from the top, including its arrow/control area. */
#planWrapper::after {
  display: none;
}

#plan {
  flex: 1;
  padding: 24px 24px 12px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--plan-col-min), 1fr));
  gap: 20px;
}

/* Full-width row break inside #plan grid (forces new row) */
.plan-break {
  grid-column: 1 / -1;
  height: 15px;
  /* adjust spacing between groups */
}

.spread,
.single {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Center spread should occupy a full grid row and be centered */
.center-spread {
  grid-column: 1 / -1;
  /* span full grid width */
  justify-content: center;
  /* center the spread inside the full row */
}

/* Center spread: show as ONE double-width page */
.center-spread {
  gap: 0;
  /* override the normal spread gap */
}

/* Hide the second page of the center spread */
.center-spread .hidden-center-right {
  display: none;
}

/* Make the first page wrapper double width */
.page-wrapper.double-page .page {
  width: var(--page-w-double);
  /* 2 * 140 */
}

.page-wrapper.double-page .page-label {
  max-width: var(--page-w-double);
  /* label matches double width */
}

/* ---------- Pages MUST be square ---------- */
.page {
  width: var(--page-w);
  height: var(--page-h);
  background: #fff;
  border: 1px solid var(--border-strong);
  position: relative;
  cursor: pointer;
  border-radius: 0 !important;
  /* must stay square */
}

.page-content {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0 !important;
}

.page-content img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-select-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-wrapper.selected .page-select-area {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.page-wrapper.selected.has-page-note {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.page-wrapper.selected.has-page-note .page-select-area {
  outline: none;
}

.page-label {
  margin-top: 0px;
  width: 100%;
  max-width: var(--page-w);
  padding: 4px 0;
  font-size: var(--page-label-font);
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  color: var(--text);
  position: relative;
  border-radius: 0 !important;
  /* must stay square */
}

/* Page label background tinted by Status (Draft stays white) */
.page-label[data-status="Proof"] {
  background: rgba(245, 158, 11, 0.14);
}

.page-label[data-status="Approved"] {
  background: rgba(16, 185, 129, 0.14);
}

.page-label[data-status="IPS ready"] {
  background: rgba(37, 99, 235, 0.14);
}

/* Alert icon inside page label (right side) */
.page-label .label-alert {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  opacity: 0.85;

  /* Allow native tooltip on hover */
  pointer-events: auto;
  cursor: help;
}

.page-note-text {
  width: 100%;
  max-width: var(--page-w);
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.25;
  color: var(--muted);
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: text;
  padding: 1px 3px;
  border-radius: var(--r-btn);
}

.page-note-text:focus {
  outline: none;
  box-shadow: var(--ring);
  background: #fff;
}

.page-wrapper.double-page .page-note-text {
  max-width: var(--page-w-double);
}

/* ---------- Puzzle grid ---------- */
.page-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.page-grid .grid-line {
  position: absolute;
  background: rgba(37, 99, 235, 0.35);
}

.page-slot {
  position: absolute;
  border: 1px dashed rgba(37, 99, 235, 0.50);
  background: rgba(37, 99, 235, 0.06);
  overflow: hidden;
  cursor: pointer;
  pointer-events: auto;
  border-radius: 0 !important;
  /* keep crisp */
}

.page-slot img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.page-slot.active {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.slot-label {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 2px 6px;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-strong);
  color: var(--text);
  z-index: 1;
  pointer-events: auto;
  cursor: text;
  border-radius: var(--r-btn);
  user-select: text;
}
.slot-label:focus {
  outline: none;
  box-shadow: var(--ring);
  background: #ffffff;
}


/* ---------- Side panel ---------- */
.side-panel-toggle {
  position: absolute;
  top: 14px;
  right: 420px;
  transform: none;
  z-index: 5;

  width: 30px;
  height: 38px;
  padding: 0;

  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: var(--panel);
  color: var(--muted);
  box-shadow: none;

  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.side-panel-toggle:hover {
  color: var(--text);
  background: var(--panel-soft);
  box-shadow: none;
}

.side-panel-toggle:focus {
  box-shadow: none;
}

#app.side-panel-collapsed .side {
  display: none;
}

#app.side-panel-collapsed .side-panel-toggle {
  right: 0;
  transform: none;
  border-right: 1px solid var(--border);
  border-radius: 10px 0 0 10px;
}

.side {
  width: 420px;
  min-width: 420px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 2;
}

.side h2 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 600;
}

/* Status chips (workflow style: dot + underline, not "buttons") */


.status-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 2px 0 4px 0;
}


.status-row {
  display: flex;
  gap: 10px;
  margin: 6px 0 12px 0;
  flex-wrap: wrap;
}

/* neutral baseline: no button border, no shadow */
.status-chip {
  height: 22px;
  padding: 0 8px 0 6px;
  font-size: 11px;
  border-radius: 999px;

  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;

  display: inline-flex;
  align-items: center;
  gap: 6px;

  /* subtle “tab” underline */
  box-shadow: inset 0 -2px 0 rgba(203, 213, 225, 0.9);
}

/* small status dot */
.status-chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.45);
  /* default dot */
}

/* hover: subtle fill + slightly stronger underline (no outer stroke) */
.status-chip:not(.active):hover {
  background: rgba(37, 99, 235, 0.06);
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.22);
}

/* keep active state stable on hover (no "jump" in look) */
.status-chip.active:hover {
  filter: brightness(0.99);
}

/* active: stronger underline + slightly darker text */
.status-chip.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(15, 23, 42, 0.03);
}

/* semantic colors (dot + underline, still professional) */
.status-chip.active[data-status="Draft"] {
  box-shadow: inset 0 -2px 0 rgba(100, 116, 139, 0.55);
}

.status-chip.active[data-status="Draft"]::before {
  background: rgba(100, 116, 139, 0.85);
}

.status-chip.active[data-status="Proof"] {
  box-shadow: inset 0 -2px 0 rgba(245, 158, 11, 0.70);
}

.status-chip.active[data-status="Proof"]::before {
  background: rgba(245, 158, 11, 0.95);
}

.status-chip.active[data-status="Approved"] {
  box-shadow: inset 0 -2px 0 rgba(16, 185, 129, 0.70);
}

.status-chip.active[data-status="Approved"]::before {
  background: rgba(16, 185, 129, 0.95);
}

.status-chip.active[data-status="IPS ready"] {
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.70);
}

.status-chip.active[data-status="IPS ready"]::before {
  background: rgba(37, 99, 235, 0.95);
}

/* Optional: subtle meaning colors (still professional) */
.status-chip.active[data-status="Draft"] {
  background: rgba(100, 116, 139, 0.10);
}

.status-chip.active[data-status="Proof"] {
  background: rgba(245, 158, 11, 0.14);
}

.status-chip.active[data-status="Approved"] {
  background: rgba(16, 185, 129, 0.14);
}

.status-chip.active[data-status="IPS ready"] {
  background: rgba(37, 99, 235, 0.14);
}

/* tags */
.page-tags {
  display: flex;
  gap: 6px;
  margin: 10px 0 12px 0;
  flex-wrap: wrap;
}

.treat-spread-block {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: -4px 0 12px 0;
  padding: 0;
  background: #ffffff;
}

.treat-spread-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.treat-spread-block input {
  margin: 0;
}

.treat-spread-help {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.treated-spread {
  gap: 0;
}

.treated-spread .hidden-center-right {
  display: none;
}

.tag-btn.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* side blocks/cards (rounded corners improvement) */
.side-block {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  padding: 12px;
  margin-top: 10px;
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}

/* ================================
Custom grid (Layout → Custom…)
================================ */
.custom-grid-controls {
  margin-top: 6px;
}

.custom-grid-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-grid-label {
  font-size: 12px;
  color: var(--muted);
}

.custom-grid-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.custom-grid-canvas {
  margin-top: 10px;
  width: 100%;
  height: 150px;
  aspect-ratio: auto;
  border: 1px solid var(--border-strong);
  background: #fff;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

/* base cells grid */
.custom-grid-cells {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 0;
}

.custom-grid-cell {
  border: 1px solid rgba(37, 99, 235, 0.25);
  background: transparent;
}

/* slot overlay (merged rectangles) */
.custom-grid-slot {
  position: absolute;
  border: 1px dashed rgba(37, 99, 235, 0.55);
  background: rgba(37, 99, 235, 0.06);
  box-sizing: border-box;
  pointer-events: none;
  /* IMPORTANT: allow drag events to reach grid cells */
}

.custom-grid-slot .slot-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  border-radius: var(--r-btn);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border-strong);
  color: var(--text);
}

/* drag selection overlay */
.custom-grid-selection {
  position: absolute;
  border: 2px solid rgba(37, 99, 235, 0.65);
  background: rgba(37, 99, 235, 0.08);
  pointer-events: none;
}

.block-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px 0;
  color: var(--text);
}

/* template row */
.template-row {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  /* allow children to shrink */
}


.template-row input {
  flex: 1 1 auto;
  min-width: 0;
  /* allow shrink inside flex row */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.template-row select {
  /* lock the control width so it doesn't grow with long option text */
  flex: 0 0 160px;
  /* fixed column */
  width: 160px;

  /* keep truncation */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  box-sizing: border-box;
}


/* inputs/selects in side */
.side input,
.side select {
  border: 1px solid var(--border-2);
  background: #fff;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--r-btn);
}

.side input:focus,
.side select:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* side buttons: small + consistent */
.side button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: box-shadow .12s ease;
}

.side button:hover {
  box-shadow: var(--ring);
}

/* Structure button active indicator (soft green) */
#structureBtn.is-active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

/* linked row wraps */
.linked-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#linked {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
}

/* unlink + clear buttons gentle danger */
#unlinkBtn,
#deleteTemplateBtn,
#clearPageBtn,
#clearAllBtn {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

/* apply/clear image keep size */
.btn-short {
  height: var(--btn-h-side);
  padding: 0 10px;
}

/* Header button dividers (subtle vertical line + gap) */
.btn-divider {
  width: 1px;
  height: 18px;
  background: var(--border-2);
  opacity: 0.7;
  margin: 0 8px;
  align-self: center;
  flex: 0 0 auto;
}

/* ---------- Games table overflow fix (important) ---------- */
.side table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.side th,
.side td {
  border: 1px solid var(--border);
  padding: 6px;
  font-size: 12px;
  word-wrap: break-word;
}

.side td input {
  width: 100%;
  min-width: 0;
}

/* ---------- Image target selector as button chips (small) ---------- */
.image-target {
  display: flex;
  gap: 8px;
  margin: 6px 0 10px 0;
  font-size: 11px;
}

.image-target .seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.image-target .seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.image-target .seg span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--btn-h-side);
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  background: #fff;
  color: var(--text);
}

.image-target .seg input:checked+span {
  border-color: var(--border-strong);
  background: var(--t-neutral, #f1f5f9);
  font-weight: 600;
}

/* ---------- Side actions bar ---------- */
.side-actions {
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
}

/* ---------- Structure panel ---------- */
.structure-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 40%;
  background: #fff;
  overflow: visible;
  border-top: 1px solid var(--border);
  z-index: 10;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.structure-panel-resizer {
  position: absolute;
  left: 0;
  right: 0;
  top: -4px;
  height: 8px;
  cursor: ns-resize;
  z-index: 8;
}

.structure-panel-resizer:hover {
  background: rgba(37, 99, 235, 0.12);
}

.structure-toolbar {
  position: relative;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.structure-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.structure-columns-btn {
  height: var(--btn-h-head);
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
}

.structure-columns-btn:hover {
  box-shadow: var(--ring);
}

.structure-toolbar .structure-icon-btn {
  width: 30px;
  min-width: 30px;
  height: var(--btn-h-head);
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, transform .06s ease;
}

.structure-toolbar .structure-icon-btn:hover,
.structure-toolbar .structure-icon-btn:focus {
  box-shadow: none;
  background: var(--accent-soft);
}

.structure-toolbar .structure-icon-btn:active {
  transform: translateY(1px);
}

.structure-settings-btn {
  color: var(--accent);
}

.structure-settings-icon {
  width: 19px;
  height: 19px;
  display: block;
  fill: currentColor;
}

.structure-close-btn {
  color: rgba(71, 85, 105, 0.9);
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.structure-close-btn:hover,
.structure-close-btn:focus {
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08) !important;
}


.structure-columns-menu {
  position: fixed;
  top: auto;
  left: auto;
  min-width: 360px;
  padding: 8px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  background: #fff;
  box-shadow: var(--shadow-md);
  z-index: 20;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.structure-columns-menu::-webkit-scrollbar {
  width: 10px;
}

.structure-columns-menu::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.45);
  border-radius: 999px;
  border: 2px solid #fff;
}

.structure-columns-menu::-webkit-scrollbar-track {
  background: transparent;
}

.structure-columns-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 2px 4px 8px;
}

.structure-column-option {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(120px, 1.15fr) 70px;
  gap: 8px;
  align-items: center;
  padding: 4px;
  border-radius: var(--r-btn);
}

.structure-column-option:hover {
  background: #f8fafc;
}

.structure-column-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  cursor: pointer;
}


.structure-column-label-input {
  height: 24px;
  min-width: 0;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  padding: 0 6px;
  font-size: 12px;
}

.structure-column-label-input::placeholder {
  color: rgba(100, 116, 139, 0.65);
}

.structure-column-width {
  height: 24px;
  width: 70px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-btn);
  padding: 0 6px;
  font-size: 12px;
}

.structure-panel table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.structure-panel th,
.structure-panel td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  font-size: 12px;
}

.structure-panel thead th {
  position: sticky;
  top: 0;
  background: #eef4ff;
  z-index: 2;
}

.structure-panel tbody tr:nth-child(odd) td {
  background: #f8fafc;
}

.structure-panel tbody tr.structure-status-proof td {
  background: #fff3df;
}

.structure-panel tbody tr.structure-status-approved td {
  background: #e8f7ef;
}

.structure-panel tbody tr.structure-status-ips-ready td {
  background: #eaf1ff;
}

.structure-panel td.cell-edit {
  padding: 0;
}

.structure-panel .cell-input {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font: inherit;
  color: inherit;
  box-sizing: border-box;
}

.structure-panel .cell-input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.18);
  background: #fff;
}

/* sort arrows */
.structure-panel th {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 22px;
}

.structure-th-label {
  display: inline-block;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.structure-th-label-input {
  width: calc(100% - 10px);
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: #fff;
  outline: none;
}

.structure-col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}

.structure-col-resizer:hover {
  background: rgba(37, 99, 235, 0.16);
}

body.is-resizing-structure-column,
body.is-resizing-structure-column * {
  cursor: col-resize !important;
  user-select: none !important;
}

body.is-resizing-structure-panel,
body.is-resizing-structure-panel * {
  cursor: ns-resize !important;
  user-select: none !important;
}

.structure-panel th.active.asc::after {
  content: "▲";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.65;
}

.structure-panel th.active.desc::after {
  content: "▼";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  opacity: 0.65;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content {
  background: #fff;
  padding: 16px;
  border-radius: var(--r);
  min-width: 280px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.modal-content h3 {
  margin: 0 0 6px 0;
}

.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

/* ================================
Repeat Pattern dialog: smaller body text (title unchanged)
================================ */
#repeatDialog #repeatConfirmText {
  font-size: 13px;
  line-height: 1.25;
  color: var(--text);
}

/* Keep the bluish note readable but still small */
#repeatDialog .repeat-note {
  font-size: 12px;
  line-height: 1.25;
}

/* ================================
Repeat Pattern dialog: partial pattern note (bluish)
================================ */
.repeat-note {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.10);
  color: #1d4ed8;
  border-radius: var(--r-btn);
  font-size: 12px;
  line-height: 1.25;
}

/* Buttons row at the bottom of the Repeat dialog */
#repeatDialog .repeat-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* Make these buttons match your side/export buttons */
#repeatDialog .repeat-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
}

#repeatDialog .repeat-actions button:hover {
  box-shadow: var(--ring);
}

/* focus consistency */
button:focus,
input:focus,
select:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* Responsive thumbnails for smaller laptop screens (14") */
@media (max-width: 1440px) {
  :root {
    --page-w: 125px;
    --page-h: 156px;
    --page-w-double: 250px;
    --plan-col-min: 380px;
    --page-label-font: 12px;
  }
}

/* responsive */

@media (max-width: 1100px) {
  .side {
    width: 360px;
    min-width: 360px;
  }

  #planWrapper {
    margin-right: 30px;
  }

  #app.side-panel-collapsed #planWrapper {
    margin-right: 0;
  }

  .side-panel-toggle {
    right: 360px;
  }

  #plan {
    grid-template-columns: repeat(auto-fit, minmax(var(--plan-col-min), 1fr));
  }
}


/* Games: push Apply button slightly lower */
#applyGamesBtn {
  margin-top: 10px;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 80ms ease;
}

/* brief "Applied" flash */
#applyGamesBtn.just-applied {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}


/* ================================
   Export dialog: match side button styling
   ================================ */

#exportDialog .modal-content {
  border-radius: var(--r);
  padding: 10px 16px 14px 16px;
}

/* Make export buttons look like side panel buttons */
#exportDialog .export-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;

  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;

  width: 100%;
  text-align: center;
}

/* PDF options dialog: match Export dialog button styling */
#pdfExportDialog .export-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  width: 100%;
  text-align: center;
}

#pdfExportDialog .export-actions button:hover {
  box-shadow: var(--ring);
}

#pdfExportDialog .export-actions button:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* PDF Cancel button: same subtle “danger/exit” look */
#pdfExportCancelBtn {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

/* Same hover/focus behavior */
#exportDialog .export-actions button:hover {
  box-shadow: var(--ring);
}

#exportDialog .export-actions button:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* Optional: make Cancel feel like a “danger/exit” action (subtle) */
#exportCancelBtn {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

/* ================================
Page color swatches + free text UI
- Swatches are square, no "ring" hover behavior
================================ */
.color-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(8, 18px);
  gap: 7px;
  align-items: center;
  width: max-content;
  max-width: 100%;
}

.slot-alpha-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.slot-alpha-label,
.slot-alpha-pct {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.slot-alpha-pct {
  min-width: 42px;
  text-align: right;
}

#slotBgAlphaRange,
#pageBgAlphaRange {
  flex: 1 1 auto;
  min-width: 0;
  height: 14px;
  padding: 0;
  border: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

#slotBgAlphaRange::-webkit-slider-runnable-track,
#pageBgAlphaRange::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.22);
}

#slotBgAlphaRange::-webkit-slider-thumb,
#pageBgAlphaRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #fff;
  margin-top: -4px;
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.9);
}

#slotBgAlphaRange::-moz-range-track,
#pageBgAlphaRange::-moz-range-track {
  height: 2px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.22);
  border: none;
}

#slotBgAlphaRange::-moz-range-progress,
#pageBgAlphaRange::-moz-range-progress {
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
}

#slotBgAlphaRange::-moz-range-thumb,
#pageBgAlphaRange::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(203, 213, 225, 0.9);
}

.color-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  cursor: pointer;
  background: #fff;
  /* overridden inline via JS too */
  box-shadow: none !important;
}

/* Transparent swatch: white with red diagonal slash */
.color-swatch.no-color {
  position: relative;
  background: #ffffff;
}

.color-swatch.no-color::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg,
      transparent 46%,
      #ff0000 46%,
      #ff0000 54%,
      transparent 54%);
  pointer-events: none;
}

/* Remove the general side-button hover ring for swatches */
.side button.color-swatch:hover {
  box-shadow: none !important;
}

/* Active selection indicator */
.color-swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Free text textarea */
.free-text-row {
  margin-top: 10px;
}

#freeTextInput {
  width: 100%;
  min-height: 54px;
  resize: vertical;
  font-size: 12px;
  line-height: 1.25;
}

/* ================================
Warning message (textarea + label icon)
================================ */

#alertInput {
  width: 100%;
  min-height: 44px;
  resize: vertical;
  font-size: 12px;
  line-height: 1.25;
}

/* ================================
Free text rendered on page thumbnail (centered)
================================ */

.page-free-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  pointer-events: none;
  white-space: pre-wrap;
  /* keeps line breaks */
  z-index: 5;
}

/* Page grid remains below free text so page text stays readable over slots/images. */
.page-grid {
  z-index: 2;
}

/* ================================
Side panel section reordering
================================ */
.side-panel-reorder-item {
  position: relative;
}

.side-panel-drag-handle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 20px;
  padding: 0 !important;
  border: 1px solid var(--border-2) !important;
  background: rgba(255, 255, 255, 0.86) !important;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1;
  cursor: grab;
  box-shadow: none !important;
  opacity: 0.65;
  z-index: 2;
}

.side-panel-reorder-item:hover > .side-panel-drag-handle,
.side-panel-drag-handle:focus {
  opacity: 1;
}

.side-panel-drag-handle:active {
  cursor: grabbing;
}

.side-panel-reorder-item.side-panel-dragging {
  opacity: 0.55;
}

.side-panel-reorder-item.side-panel-drag-over-before::before,
.side-panel-reorder-item.side-panel-drag-over-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  z-index: 3;
}

.side-panel-reorder-item.side-panel-drag-over-before::before {
  top: -7px;
}

.side-panel-reorder-item.side-panel-drag-over-after::after {
  bottom: -7px;
}

#sideActions.side-panel-reorder-item {
  padding-top: 26px;
}

/* ================================
Compact color picker popovers
================================ */
.side-block {
  position: relative;
}

.color-picker-toggle {
  width: 72px;
  min-width: 72px;
  height: var(--btn-h-side) !important;
  padding: 0 7px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: #fff !important;
}

.color-picker-preview {
  position: relative;
  width: 44px;
  height: 18px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: #fff;
  display: inline-block;
  overflow: hidden;
}

.color-picker-preview.no-color::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg,
      transparent 46%,
      #ff0000 46%,
      #ff0000 54%,
      transparent 54%);
  pointer-events: none;
}

.color-picker-arrow {
  font-size: 10px;
  color: var(--muted);
  line-height: 1;
}

.color-picker-popover {
  position: absolute;
  left: 12px;
  top: 52px;
  z-index: 75;
  padding: 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  background: #fff;
  box-shadow: var(--shadow-md);
  max-width: calc(100% - 24px);
}

.color-picker-popover.palette-grid {
  grid-template-columns: repeat(8, 18px);
}

/* ================================
Latest PDF/export dialog button overrides restored
================================ */
/* ================================
   Export dialog: match side button styling
   ================================ */

#exportDialog .modal-content {
  border-radius: var(--r);
  padding: 10px 16px 14px 16px;
}

/* Make export buttons look like side panel buttons */
#exportDialog .export-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;

  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;

  width: 100%;
  text-align: center;
}

/* PDF options dialog: match Export dialog button styling */
#pdfExportDialog .export-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  width: 100%;
  text-align: center;
}

#pdfExportDialog .export-actions button:hover {
  box-shadow: var(--ring);
}

#pdfExportDialog .export-actions button:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* PDF dialog footer: Back + Cancel on one line */
#pdfExportDialog .pdf-export-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

/* PDF Back button: soft neutral/blue, flat app-style */
#pdfExportDialog .export-actions #pdfExportBackBtn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
  font-weight: 500;
}

#pdfExportDialog .export-actions #pdfExportBackBtn:hover,
#pdfExportDialog .export-actions #pdfExportBackBtn:focus {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* PDF Cancel button: soft red action, flat app-style */
#pdfExportDialog .export-actions #pdfExportCancelBtn {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #b91c1c;
  font-weight: 500;
}

#pdfExportDialog .export-actions #pdfExportCancelBtn:hover,
#pdfExportDialog .export-actions #pdfExportCancelBtn:focus {
  background: #ffe4e6;
  border-color: #fda4af;
}

/* Same hover/focus behavior */
#exportDialog .export-actions button:hover {
  box-shadow: var(--ring);
}

#exportDialog .export-actions button:focus {
  outline: none;
  box-shadow: var(--ring);
}

/* Optional: make Cancel feel like a “danger/exit” action (subtle) */
#exportCancelBtn {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

/* Main Export dialog Cancel button: match PDF Cancel button style */
#exportDialog .export-actions #exportCancelBtn {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #b91c1c;
  font-weight: 500;
}

#exportDialog .export-actions #exportCancelBtn:hover,
#exportDialog .export-actions #exportCancelBtn:focus {
  background: #ffe4e6;
  border-color: #fda4af;
}

/* PDF export mode description hint */
#pdfExportDialog .pdf-export-content {
  position: relative;
}

.pdf-export-hint {
  position: absolute;
  top: var(--pdf-hint-top, 64px);
  left: calc(100% + 12px);
  width: 280px;
  min-height: 82px;
  padding: 12px 13px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-md);
  color: var(--text);
  z-index: 80;
}

.pdf-export-hint::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -7px;
  width: 12px;
  height: 12px;
  border-left: 1px solid rgba(37, 99, 235, 0.22);
  border-bottom: 1px solid rgba(37, 99, 235, 0.22);
  background: rgba(255, 255, 255, 0.96);
  transform: rotate(45deg);
}

.pdf-export-hint strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  line-height: 1.25;
  color: #1d4ed8;
}

.pdf-export-hint span {
  display: block;
  font-size: 12px;
  line-height: 1.38;
  color: var(--muted);
}

@media (max-width: 840px) {
  .pdf-export-hint {
    position: static;
    width: 100%;
    min-height: auto;
    margin-top: 10px;
  }

  .pdf-export-hint::before {
    display: none;
  }
}

/* Export button highlight */
#exportBtn {
  background: #e0f2fe;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 500;
}

#exportBtn:hover {
  background: #dbeafe;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

#exportBtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

/* ================================
Tutorial button + visible highlight system
================================ */
.meta button.tutorial-btn {
  width: var(--btn-h-head);
  min-width: var(--btn-h-head);
  height: var(--btn-h-head);
  padding: 0 !important;
  border-radius: 999px !important;
  background: #fff7cc;
  border: 1px solid #fde68a;
  color: #b45309;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.meta button.tutorial-btn:hover,
.meta button.tutorial-btn:focus-visible {
  background: #fef3c7;
  border-color: #fbbf24;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.tutorial-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.tutorial-dim {
  position: fixed;
  background: transparent;
  pointer-events: auto;
}

.tutorial-highlight {
  position: fixed;
  border: 3px solid #60a5fa;
  border-radius: 14px;
  box-shadow:
    0 0 0 9999px rgba(15, 23, 42, 0.46),
    0 0 0 1px rgba(255, 255, 255, 0.95),
    0 0 0 6px rgba(96, 165, 250, 0.18),
    0 14px 30px rgba(15, 23, 42, 0.22);
  pointer-events: none;
}

.tutorial-card {
  position: fixed;
  width: min(360px, calc(100vw - 24px));
  padding: 14px 14px 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}

.tutorial-step-count {
  margin-bottom: 6px;
  color: #2563eb;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tutorial-title {
  margin: 0 0 8px 0;
  font-size: 18px;
  line-height: 1.2;
  color: var(--text);
}

.tutorial-body {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tutorial-dots {
  display: flex;
  gap: 6px;
  margin: 12px 0;
}

.tutorial-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #e2e8f0;
}

.tutorial-dot.active {
  background: #2563eb;
}

.tutorial-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tutorial-actions button {
  height: 28px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--r-btn);
  border: 1px solid var(--border-2);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.tutorial-actions button:hover,
.tutorial-actions button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.tutorial-actions .tutorial-next {
  border-color: #93c5fd;
  background: #e0f2fe;
  color: #1d4ed8;
}

.tutorial-actions .tutorial-back:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}

/* ================================
   Export package dialog
   ================================ */
#exportDialog .export-actions #exportPackageBtn {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
  font-weight: 550;
}

#exportDialog .export-actions #exportPackageBtn:hover,
#exportDialog .export-actions #exportPackageBtn:focus {
  background: #bae6fd;
  border-color: #38bdf8;
}

#exportPackageDialog .package-export-content {
  border-radius: var(--r);
  padding: 10px 16px 14px 16px;
  min-width: 330px;
}

.package-export-intro {
  margin: 0 0 10px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.package-export-options {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}

.package-export-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--btn-h-side);
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}

.package-export-options input {
  margin: 0;
}

#exportPackageDialog .package-export-footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
}

#exportPackageDialog .package-export-footer-actions button {
  height: var(--btn-h-side);
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-2);
  background: #fff;
  border-radius: var(--r-btn);
  cursor: pointer;
  width: 100%;
  text-align: center;
}

#exportPackageDialog .package-export-footer-actions button:hover,
#exportPackageDialog .package-export-footer-actions button:focus {
  box-shadow: var(--ring);
}

#exportPackageDialog .package-export-footer-actions #packageCreateBtn {
  background: #e0f2fe;
  border-color: #93c5fd;
  color: #1d4ed8;
  font-weight: 550;
}

#exportPackageDialog .package-export-footer-actions #packageCreateBtn:hover,
#exportPackageDialog .package-export-footer-actions #packageCreateBtn:focus {
  background: #dbeafe;
  border-color: #60a5fa;
}

#exportPackageDialog .package-export-footer-actions #packageBackBtn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
  font-weight: 500;
}

#exportPackageDialog .package-export-footer-actions #packageBackBtn:hover,
#exportPackageDialog .package-export-footer-actions #packageBackBtn:focus {
  background: #e2e8f0;
  border-color: #94a3b8;
}

#exportPackageDialog .package-export-footer-actions #packageCancelBtn {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #b91c1c;
  font-weight: 500;
}

#exportPackageDialog .package-export-footer-actions #packageCancelBtn:hover,
#exportPackageDialog .package-export-footer-actions #packageCancelBtn:focus {
  background: #ffe4e6;
  border-color: #fda4af;
}
