/* designer-pro-core.css — shared Pro chrome for BOTH /designerpro-in-order.html
   and /designerpro-any-order.html. Loaded on top of /css/main.css (never
   edited) — only additive Pro-only classes live here, nothing here overrides
   or duplicates a Free Designer selector. Page-specific tweaks (In Order vs.
   Any Order) live in their own designer-pro-in-order.css / designer-pro-any-order.css. */

.pro-topbar-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: #fff; background: var(--color-ink); border-radius: 999px; padding: 2px 8px;
  margin-left: 8px; vertical-align: middle;
}

.pro-mode-switch { font-size: 12px; color: var(--color-muted); text-decoration: none; }
.pro-mode-switch:hover { color: var(--color-accent); }

/* ---- Collapsible "PRO STYLE" panel ---- */
.pro-style-panel {
  border: 1px solid var(--color-line); border-radius: var(--radius);
  background: var(--color-paper); margin: 16px 0; overflow: hidden;
}
.pro-style-panel-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: none; border: none; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 14px; color: var(--color-ink);
}
.pro-style-panel-toggle .pro-chevron { transition: transform 0.15s ease; }
.pro-style-panel.is-collapsed .pro-chevron { transform: rotate(-90deg); }
.pro-style-panel-body { padding: 4px 16px 16px; display: grid; gap: 14px; }
.pro-style-panel.is-collapsed .pro-style-panel-body { display: none; }

.pro-field { display: flex; flex-direction: column; gap: 5px; }
.pro-field > span { font-size: 13px; color: var(--color-muted); }
.pro-field select, .pro-field input[type="number"] {
  padding: 8px 10px; border: 1px solid var(--color-line); border-radius: 8px;
  font: inherit; background: var(--color-paper);
}
.pro-field-row { display: flex; gap: 12px; flex-wrap: wrap; }
/* The author `display: flex` above beats the browser's own [hidden] rule, so
   the Classic-only fields (palette select, tint) stayed visible — and inert —
   while a styled theme was active. Restore [hidden] for them. */
.pro-field[hidden], .pro-toggle-row[hidden] { display: none; }
.pro-style-hint { margin: 0; }
.pro-field-row .pro-field { flex: 1; min-width: 140px; }

.pro-toggle-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.pro-btn-distribute { align-self: flex-start; }

/* ---- Theme select: small color-chip prefix rendered via <select> option
   groups (native selects can't show swatches cross-browser, so the visible
   swatch strip below mirrors the currently selected theme). ---- */
.pro-theme-preview { display: flex; gap: 4px; margin-top: 4px; }
.pro-theme-preview span {
  width: 16px; height: 16px; border-radius: 4px;
  /* Theme Preview fix (Any Order UX Rescue V1, 2026-09-19): the original
     near-invisible rgba(0,0,0,0.08) border made a white/near-white/pale-gray
     swatch (e.g. Ink Saver) read as an empty box rather than a deliberate
     color sample. A clearly visible neutral outline fixes this for every
     swatch color without introducing any new decorative color. */
  border: 1px solid var(--color-line);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

/* ---- Visual Mark / Tab Mark (unified curated sticker picker) ----
   UX Cleanup V1 (2026-09-18): one product concept ("Visual Mark" for a
   header, "Tab Mark" for a row/tab) replaces the old None/Icon/Emoji
   toggle -- Lucide vs. Twemoji is an implementation detail the picker no
   longer surfaces. */
.pro-mark-current { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pro-mark-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 8px; border: 1px solid var(--color-line);
  background: var(--color-paper); cursor: pointer; color: var(--color-ink);
}
.pro-mark-btn.is-empty { color: var(--color-muted); font-weight: 500; }
.pro-mark-btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.pro-mark-btn:hover { border-color: var(--color-accent); }

.pro-icon-grid, .pro-sticker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px; max-height: 168px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--color-line); border-radius: 8px; background: var(--color-bg-alt);
}
.pro-icon-btn, .pro-sticker-btn {
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px; background: var(--color-paper);
  cursor: pointer; padding: 4px;
}
.pro-icon-btn svg, .pro-sticker-btn svg { width: 100%; height: 100%; }
.pro-icon-btn.is-selected, .pro-sticker-btn.is-selected { border-color: var(--color-accent); background: var(--color-accent-soft); }
.pro-icon-btn:hover, .pro-sticker-btn:hover { border-color: var(--color-ink); }

.pro-sticker-categories { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.pro-sticker-cat-btn {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--color-line);
  background: var(--color-paper); cursor: pointer; color: var(--color-muted);
}
.pro-sticker-cat-btn.is-selected { background: var(--color-ink); color: #fff; border-color: var(--color-ink); }

/* Floating popover shell shared by the Tab/row sticker picker AND (In Order
   Visual Cleanup V2) the header Visual Mark icon picker -- one small panel
   style for both, clamped inside the viewport by pro-core.js's
   openMarkPopoverShell so it never overflows on mobile. */
.pro-mark-popover {
  position: fixed; z-index: 1100; background: var(--color-paper);
  border: 1px solid var(--color-line); border-radius: 10px; box-shadow: var(--shadow-card-hover);
  padding: 8px; width: 220px; max-width: calc(100vw - 16px);
}
.pro-mark-popover .pro-sticker-grid { max-height: 140px; }
.pro-mark-popover .pro-icon-grid-standalone { max-height: none; border: none; background: none; padding: 0; }

/* ---- Precision Width control ---- */
.pro-width-mode-row { display: flex; gap: 6px; margin-bottom: 6px; }
.pro-width-mode-btn {
  flex: 1; padding: 5px 8px; border: 1px solid var(--color-line); border-radius: 8px;
  background: var(--color-paper); cursor: pointer; font-size: 12px; font-weight: 600;
}
.pro-width-mode-btn.is-selected { border-color: var(--color-ink); background: var(--color-bg-alt); }
.pro-width-manual-row { display: flex; align-items: center; gap: 8px; }
/* P0 fix (2026-09-18): an author `display: flex` rule always wins over the
   browser's UA `[hidden] { display: none }` default, even at equal
   selector specificity -- so the slider/number/Reset row stayed visible
   under Auto despite the `hidden` attribute being set correctly by
   widthControlMarkup/itemWidthControlMarkup. This restores `hidden`. */
.pro-width-manual-row[hidden] { display: none; }
.pro-width-manual-row input[type="range"] { flex: 1; }
.pro-width-manual-row input[type="number"] { width: 68px; }
.pro-width-reset { font-size: 12px; color: var(--color-muted); background: none; border: none; cursor: pointer; text-decoration: underline; padding: 0; }

/* ---- Drag handle (SortableJS) ---- */
.drag-handle {
  /* flex:none (not the default flex:0 1 auto) so this never absorbs the
     flex-shrink negative-space that .goal-summary's flex:1/min-width:0 is
     meant to soak up on narrow screens — without this, a narrow viewport
     pushed nearly all the shrinkage onto this small fixed-content handle
     instead of the title, overflowing the page horizontally. Same fixed-
     size pattern main.css already uses for .goal-order-btns/.goal-card-actions. */
  flex: none;
  cursor: grab; color: var(--color-muted); padding: 2px 4px; user-select: none;
  font-size: 14px; line-height: 1; touch-action: none;
}
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.35; }
.sortable-chosen { background: var(--color-accent-soft); }

/* Below ~420px there isn't room left in the row for a fixed-size drag
   handle without pushing the page into horizontal scroll (goal-card-row's
   other children are already fixed-size via main.css's own flex:none, so
   this was the one shrinkable-in-theory-but-not-in-practice addition) —
   the ▲▼ buttons (kept on every screen size, see CutDone Pro spec 十六:
   "原来的 ▲▼ 可以保留作为 keyboard/accessibility fallback / mobile fallback")
   take over reordering at that width instead of hiding them behind a
   broken layout. */
@media (max-width: 420px) {
  .drag-handle { display: none; }
}

/* ---- Import from Free Designer (UX Cleanup V1, 2026-09-18) ----
   A low-key inline link at the top of the editor, shown ONLY when a
   compatible Free Designer draft was found at load -- not a button that's
   always visible in PRO STYLE (that read as a migration/test feature). */
.free-import-hint {
  font-size: 13px; margin: 0 0 14px; padding: 8px 12px;
  background: var(--color-accent-soft); border-radius: 8px;
}
.free-import-hint a { color: var(--color-accent); font-weight: 600; text-decoration: none; }
.free-import-hint a:hover { text-decoration: underline; }

/* ---- Twemoji attribution (required by CC BY 4.0, see licenses/TWEMOJI.txt) ---- */
.pro-attribution {
  text-align: center; font-size: 11px; color: var(--color-muted); padding: 18px 0 6px;
}
.pro-attribution a { color: inherit; }

/* ---- Style gallery (styled themes, js/pro/styled-themes.js) ----
   A horizontal strip of live thumbnails — each card is the user's own board
   drawn in that style, redrawn as they type. */
.theme-gallery-section { margin: 8px auto 4px; }
.theme-gallery-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.theme-gallery-head .editor-heading { margin: 0; }
.theme-gallery-note { margin: 0; font-size: 13px; color: var(--color-muted); }
.theme-gallery {
  display: flex; gap: 12px; overflow-x: auto; padding: 10px 2px 12px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.theme-card {
  flex: 0 0 auto; width: 200px; scroll-snap-align: start;
  display: flex; flex-direction: column; gap: 6px; padding: 6px;
  border: 1px solid var(--color-line); border-radius: 10px; background: var(--color-paper);
  cursor: pointer; font: inherit; color: var(--color-ink); text-align: left;
}
.theme-card:hover { border-color: var(--color-ink); }
.theme-card.is-selected { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }
.theme-card-thumb { display: block; background: #fff; border-radius: 4px; overflow: hidden; }
.theme-card-thumb svg { display: block; width: 100%; height: auto; }
.theme-card-label { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; font-weight: 600; padding: 0 2px 2px; }
.theme-card-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: #fff; background: var(--color-ink); border-radius: 999px; padding: 1px 7px; }
@media (max-width: 480px) { .theme-card { width: 160px; } }
@media print { .theme-gallery-section { display: none !important; } }

/* Tab icon picker (styled themes) */
.pro-line-icon-popover { max-width: min(340px, calc(100vw - 16px)); }
.pro-line-icon-top { display: flex; gap: 6px; margin-bottom: 8px; }
.pro-line-icon-opt {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--color-line); border-radius: 8px; background: var(--color-paper); cursor: pointer; color: var(--color-ink);
}
.pro-line-icon-opt svg { width: 18px; height: 18px; }
.pro-line-icon-opt.is-selected { border-color: var(--color-accent); background: var(--color-accent-soft); }

/* In Order strip thumbnails are tall and narrow: cap their height. */
.theme-card-strip { width: 150px; }
.theme-card-strip .theme-card-thumb { height: 180px; display: flex; justify-content: center; align-items: flex-start; padding-top: 4px; }
.theme-card-strip .theme-card-thumb svg { width: auto; height: 100%; }

/* Four topbar items (back, mode switch, calibration, paper) wrap onto a
   second line on phones instead of pushing the page into sideways scroll. */
.designer-topbar-inner { flex-wrap: wrap; row-gap: 6px; }

/* ---- Colors (js/pro/pro-color-controls.js) ----
   Native color inputs + hex fields, one row per color role. Sized so the
   whole block fits a 320px phone without sideways scroll, with touch
   targets of at least 36px. */
.pro-colors { display: grid; gap: 10px; border-top: 1px solid var(--color-line); padding-top: 12px; }
.pro-colors-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pro-colors-title { font-size: 13px; font-weight: 700; color: var(--color-ink); }
.pro-colors-reset { font-size: 13px; min-height: 36px; }
.pro-color-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.pro-color-preset {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 10px;
  border: 1px solid var(--color-line); border-radius: 999px; background: var(--color-paper);
  font: inherit; font-size: 12px; font-weight: 600; color: var(--color-ink); cursor: pointer;
}
.pro-color-preset:hover { border-color: var(--color-ink); }
.pro-color-preset.is-selected { border-color: var(--color-accent); box-shadow: 0 0 0 2px var(--color-accent-soft); }
.pro-color-preset-dots { display: inline-flex; }
.pro-color-preset-dots span {
  width: 12px; height: 12px; border-radius: 50%; margin-left: -3px;
  border: 1px solid rgba(0, 0, 0, 0.18);
}
.pro-color-preset-dots span:first-child { margin-left: 0; }
.pro-color-grid { display: grid; gap: 6px; }
.pro-color-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 44px 86px 36px;
  align-items: center; gap: 6px;
}
.pro-color-label { font-size: 13px; color: var(--color-ink); line-height: 1.25; min-width: 0; }
.pro-color-label small { display: block; font-size: 11px; color: var(--color-muted); }
.pro-color-picker {
  width: 44px; height: 36px; padding: 2px; border: 1px solid var(--color-line);
  border-radius: 8px; background: var(--color-paper); cursor: pointer;
}
.pro-color-hex {
  width: 100%; min-width: 0; height: 36px; padding: 0 8px; box-sizing: border-box;
  border: 1px solid var(--color-line); border-radius: 8px; background: var(--color-paper);
  font: 13px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--color-ink);
}
.pro-color-hex[aria-invalid="true"] { border-color: #b3261e; box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.15); }
.pro-color-clear {
  width: 36px; height: 36px; border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--color-muted); font-size: 16px; cursor: pointer;
}
.pro-color-clear:hover { border-color: var(--color-line); color: var(--color-ink); }
/* author display rules beat the UA [hidden] default — keep an empty cell */
.pro-color-clear[hidden] { display: block; visibility: hidden; }
.pro-color-row.is-custom .pro-color-label { font-weight: 600; }
.pro-color-err { grid-column: 1 / -1; font-size: 12px; color: #b3261e; }
.pro-color-err:empty { display: none; }
.pro-colors-hint, .pro-colors-ink { margin: 0; }
@media print { .pro-colors { display: none !important; } }

/* ---- Free / Pro labels (js/pro/pro-tier.js) ----
   Classic is free forever; the PRO badge marks only the premium visual
   layer, so nobody reads the whole Designer as paid. */
.tier-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  border-radius: 999px; padding: 1px 7px; vertical-align: middle; line-height: 1.5;
}
.tier-badge-pro { color: #fff; background: var(--color-ink); }
.tier-badge-free { color: #1d5e37; background: #e3f3e8; }
.theme-card-badge-free { color: #1d5e37; background: #e3f3e8; }
.tier-explainer { margin: 6px 0 0; font-size: 13px; color: var(--color-muted); }
.tier-notice {
  margin-top: 12px; margin-bottom: 4px; padding: 12px 14px; border-radius: 10px;
  background: var(--color-accent-soft); border: 1px solid var(--color-line);
  display: grid; gap: 10px;
}
.tier-notice[hidden] { display: none; }
.tier-notice p { margin: 0; font-size: 14px; }
.tier-notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tier-notice-actions .btn { min-height: 40px; }
@media print { .tier-notice, .tier-explainer { display: none !important; } }

/* ---- Collapsible list + Style panels (js/pro/designer-panels.js) ----
   Both start collapsed: a one-line summary and a clear 44px button, so the
   board preview and Print lead the page. */
.cd-panel {
  border: 1px solid var(--color-line); border-radius: var(--radius);
  background: var(--color-paper); margin: 16px 0; overflow: hidden;
}
.cd-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 16px;
}
.cd-panel-titles { min-width: 0; }
.cd-panel-title { margin: 0; font-size: 15px; font-weight: 700; color: var(--color-ink); letter-spacing: 0; text-transform: none; }
.cd-panel-summary {
  margin: 2px 0 0; font-size: 13px; color: var(--color-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cd-panel-summary .tier-badge { vertical-align: 1px; }
.cd-panel-btn {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--color-ink); background: var(--color-paper); color: var(--color-ink);
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.cd-panel-btn:hover { background: var(--color-ink); color: var(--color-paper); }
.cd-panel-btn:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 2px; }
.cd-panel-arrow { font-size: 11px; }
.cd-panel.is-open > .cd-panel-head { border-bottom: 1px solid var(--color-line); }
.cd-panel-ai {
  display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 600;
  color: var(--color-accent); text-decoration: underline; text-underline-offset: 2px;
}
.cd-panel-ai:hover { color: var(--color-ink); }
/* AI plan sent back from /goal-breakdown (designer-shared.js mountAiPlanInbox) */
.ai-inbox {
  position: fixed; left: 50%; bottom: 16px; z-index: 1000; transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); padding: 14px 16px;
  border: 1px solid var(--color-ink); border-radius: var(--radius);
  background: var(--color-paper); box-shadow: 0 10px 30px rgba(26,19,10,0.18);
}
.ai-inbox[hidden] { display: none; }
.ai-inbox-text { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--color-ink); overflow-wrap: anywhere; }
.ai-inbox-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ai-inbox-actions .btn { min-height: 40px; }
.ai-inbox-link {
  min-height: 40px; padding: 0 8px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--color-muted); text-decoration: underline;
}
@media print { .ai-inbox { display: none !important; } }
#list-panel-body { padding: 14px 16px 16px; }
#list-panel-body[hidden] { display: none; }
/* The styled-themes gallery now lives inside the Style panel body. Its card
   row scrolls sideways; minmax(0,1fr) keeps that max-content row from
   widening the panel's grid column (which pushed the color pickers off the
   right edge). */
.pro-style-panel-body { grid-template-columns: minmax(0, 1fr); }
.pro-style-panel-body > * { min-width: 0; }
.pro-style-panel-body .theme-gallery-section { padding: 0; margin: 0; min-width: 0; }

/* Preview first (Any Order): quick intro → board → cut hint → Pro notice →
   Print / Export → then the (collapsed) editing panels. Print CSS already
   shows only the board, so this is screen-only in effect. */
.designer-main:has(> .ao-preview-section) { display: flex; flex-direction: column; }
.designer-main:has(> .ao-preview-section) > * { width: 100%; box-sizing: border-box; }
.designer-main > .designer-quickstart { order: 1; }
.designer-main > .ao-preview-section { order: 2; }
.designer-main > .hint-precut-box { order: 3; }
.designer-main > .tier-notice { order: 4; }
.designer-main > .designer-footer { order: 5; }
.designer-main > .designer-qr-toggle { order: 6; }
.designer-main > #export-status { order: 7; }
.designer-main > .share-panel { order: 8; }
.designer-main > .ao-editor-section { order: 9; }
.designer-main > .pro-attribution { order: 10; }
/* In Order on phones: the preview column comes before the editor column. */
@media (max-width: 899px) {
  .designer-grid > .designer-preview { order: -1; }
}

/* main.css makes every span in a .field-inline label a block, which stretched
   inline PRO badges into a full-width black bar. */
.field-inline .tier-badge { display: inline-block; margin: 0 0 0 4px; width: auto; }
