/* =========================================================
   creative_toolbar.css  (DROP-IN REPLACEMENT)
   ========================================================= */

/* --- Creative toolbar styling --- */
.th-creative-toolbar{
  background: #ffffff;               /* was rgba(...0.65) */
  border-radius: 24px;
  backdrop-filter: blur(6px);        /* optional */
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  border: 1px solid rgba(239, 88, 156, 0.25);
  /* Wrap to a second row when content exceeds available width (phones with
     9+ tool apps). The row-break spacer below forces a balanced split rather
     than the greedy flex-default; CSS keeps the spacer inert on tablets and
     desktop where the toolbar fits on a single row. */
  flex-wrap: wrap;
  justify-content: center;
}


.th-tool-btn{
  border: none;
  background: transparent;
  /* 44 px meets iOS HIG minimum tap target. */
  width: 44px;
  height: 44px;
  border-radius: 999px;
  padding: 0;
  position: relative; /* anchors .th-tool-badge */
}

/* Member count on the "Select several" button while a group is live
   (group select). Lives on the toolbar so it is never clipped by a
   workspace such as the mandala's stone. */
.th-tool-badge{
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef589c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}
.th-tool-badge[hidden]{ display: none; }

.th-tool-btn i{
  color: #ef589c;
  font-size: 1.25rem;
}

/* Two-row wrap spacer. Inert by default; activated under the phone media
   query below to force a balanced split between top and bottom rows. */
.th-toolbar-rowbreak{
  display: none;
}

.th-tool-icon-img{
  width: 49px;
  height: 49px;
  object-fit: contain;
  vertical-align: middle;
  margin-top: -4px;
  margin-left: -5px;
}

.th-tool-btn:hover{
  background: rgba(239, 88, 156, 0.12);
}

/* Optional: if you later add divider elements */
.th-tool-divider{
  width: 1px;
  height: 22px;
  background: rgba(239, 88, 156, 0.35);
  margin: 0 4px;
}

.th-tool-btn.is-active{
  background: rgba(239, 88, 156, 0.12);
}

/* =========================================================
   Colour panel (manual palette)
   ========================================================= */

/* Make the colour offcanvas tall enough to show palette without scrolling */
#thColourPanel.th-ct-panel{
  --bs-offcanvas-height: min(70vh, 620px);
  border: 0;
}

/* Font panel — sized to its actual content (close X, Text Style title,
   colour swatches, Font dropdown + sample). The dropdown's popover
   list extends BELOW the panel onto the page, so the panel doesn't
   need to reserve space for it. */
#thFontPanel.th-ct-panel {
  --bs-offcanvas-height: min(38vh, 250px);
  border: 0;
  /* Let the dropdown's popover list flow out of the panel rather than
     being clipped — matches the album's inline text picker behaviour. */
  overflow: visible;
}

#thFontPanel .offcanvas-body {
  overflow: visible;
}

.th-font-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.th-font-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.85rem;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.th-font-btn:hover {
  border-color: #ef589c;
  color: #ef589c;
}

.th-font-btn.is-active {
  border-color: #ef589c;
  color: #ef589c;
}

.th-font-btn__name {
  font-size: 0.95rem;
  color: inherit;
}

.th-font-sample {
  font-size: 1.15rem;
  color: #555;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}

.th-ct-panel-body{
  background: #fff;
}



/* Section layout */
.th-ct-section{
  margin-bottom: 1rem;
}

.th-ct-section-title{
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #333;
}

/* Swatch sizing: always square, responsive */
:root{
  --th-swatch: clamp(26px, 3.5vw, 34px);
}

.th-ct-recent-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--th-swatch));
  gap: 6px;
  align-items: start;
}

/* The palette: 25 families of nine (shared_colour_palette.js) as ONE
   continuous sequence. The columns are as many as fit and each stretches a
   little, so every row fills the panel to its right edge with no blank
   slots (only the very last row can be short); the swatches stay square via
   aspect-ratio. A family may run over a row break — the ORDER is what makes
   the palette scannable (2026-11-09). */
.th-ct-palette-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--th-swatch), 1fr));
  gap: 6px;
  align-items: start;
}

.th-ct-palette-grid .th-ct-swatch{
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
}

/* Phones: exactly nine columns, so every row is one family (the neutrals
   included — that is why the neutral family is nine too). */
@media (max-width: 575.98px){
  .th-ct-palette-grid{
    grid-template-columns: repeat(9, 1fr);
  }
}

/* Swatch button */
.th-ct-swatch{
  width: var(--th-swatch);
  height: var(--th-swatch);
  padding: 0;
  margin: 0;
  border-radius: 8px;
  /* Strong enough that white and the palest tints read on the white panel
     (15 % left the white swatch invisible on phones, 2026-11-09). */
  border: 1px solid rgba(0,0,0,0.28);
  cursor: pointer;
  background-clip: padding-box;
  display: block;
}

/* Focus style for keyboard users */
.th-ct-swatch:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

/* Optional: highlight active colour if you add an 'is-active' class in JS later */
.th-ct-swatch.is-active{
  outline: 3px solid rgba(239, 88, 156, 0.85);
  outline-offset: 2px;
}

/* Custom hex entry — understated affordance under the Recent colours row.
   A ghost toggle reveals a compact input; a valid hex is applied + joins the
   per-app recents via colour.js (never the fixed Palette). */
.th-ct-addhex{
  margin-top: 8px;
}

.th-ct-addhex-toggle{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #00537d;
  background: transparent;
  border: 1px solid rgba(0, 83, 125, 0.35);
  border-radius: 999px;
  cursor: pointer;
}

.th-ct-addhex-toggle:hover,
.th-ct-addhex-toggle:focus{
  background: rgba(0, 83, 125, 0.06);
  border-color: rgba(0, 83, 125, 0.55);
}

.th-ct-addhex-form{
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.th-ct-addhex-form[hidden]{
  display: none;   /* the class sets display:flex, so restore hidden explicitly */
}

.th-ct-addhex-hash{
  font-weight: 600;
  color: #00537d;
}

.th-ct-addhex-input{
  width: 8ch;
  max-width: 100%;
  padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  text-transform: uppercase;
  border: 1px solid rgba(0, 83, 125, 0.35);
  border-radius: 8px;
}

.th-ct-addhex-input:focus{
  outline: 3px solid rgba(239, 88, 156, 0.5);
  outline-offset: 1px;
  border-color: rgba(0, 83, 125, 0.55);
}

.th-ct-addhex-apply{
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 1rem;
  color: #fff;
  background: #ef589c;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.th-ct-addhex-apply:hover,
.th-ct-addhex-apply:focus{
  background: #e0448a;
}

.th-ct-addhex-error{
  margin-top: 6px;
  font-size: 0.8rem;
  color: #c0392b;
}


.th-ct-toprow{
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: none !important;
}

/* Top row: close button only variant (bulletproof) */
.th-ct-toprow.th-ct-toprow--solo{
  justify-content: flex-end;
}


@media (max-width: 575.98px){
  .th-creative-toolbar{
    padding-left: 4px !important;
    padding-right: 4px !important;
    padding-top: 2px !important;
    padding-bottom: 2px !important;
    gap: 3px !important; /* reduce from gap-2 */
    row-gap: 4px !important;
  }
  /* Zero only the vertical button margin on phones (keep horizontal at 5 px
     so in-row spacing is unchanged). Combined with row-gap: 4 px above, the
     visible separator between wrapped rows lands at ~4 px rather than the
     ~14 px the global button margin would otherwise produce — tighter
     without reading as cramped. */
  .th-tool-btn{
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }
  /* Reclaim the doubled .container padding on phones. The toolbar template's
     wrapper nests inside base.html's outer .container, so without this
     override the toolbar's effective parent is viewport - 48 px rather than
     viewport - 24 px. The extra 24 px is what lets 6-tool toolbars (poetry,
     peg_board, kaleidoscope, album) fit on a single row at 375 px width. */
  .th-toolbar-wrap{
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  /* Activate the row-break spacer on phones to force the two-row split
     computed in toolbar_config.py (e.g. 5+5 for tree_decoration / canvas,
     5+4 for mandala / flower_arranging). Apps with <= 6 tools never emit
     this spacer so they stay on a single row. */
  .th-toolbar-rowbreak{
    display: block;
    flex-basis: 100%;
    height: 0;
    margin: 0;
    padding: 0;
  }
  /* Compact single-row toolbar (COMPACT_ROW_APPS in toolbar_config.py — the
     album): the buttons shrink to 40 px and drop their side margins so seven
     fit one row on a 360 px phone (7 x 40 + 6 x 3 gap + 8 padding = 320 px),
     rather than wrapping and costing the book a second toolbar row. */
  .th-creative-toolbar--compact{
    /* Stretch the pill almost to the screen edge (its parent is already
       viewport - 24 px) and spread the buttons evenly across it, so each
       tool gets breathing space instead of huddling in a centred cluster. */
    width: calc(100% - 16px);
    justify-content: space-evenly !important;
  }
  .th-creative-toolbar--compact .th-tool-btn{
    width: 40px;
    height: 40px;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  .th-creative-toolbar--compact .th-tool-btn i{
    font-size: 1.15rem;
  }
}



@media (min-height: 800px){
  #thColourPanel.th-ct-panel{
    max-height: 470px;   /* tweakable, but doesn’t force empty space */
  }
}
/* =========================================================
   Background panel (layout + button styles)
   ========================================================= */

#thBackgroundPanel.th-ct-panel{
  --bs-offcanvas-height: min(70vh, 620px);
  border: 0;
}

/* Swatches + buttons on the same row */
.th-bg-recent-row{
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

/* Let swatches take only as much as they need */
.th-bg-recent-grid{
  grid-auto-flow: column;
  grid-auto-columns: var(--th-swatch);
  grid-template-columns: none;     /* overrides earlier grid definition */
  justify-content: start;
}

/* Buttons group sits immediately to the right of the swatches */
.th-bg-actions-inline{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

/* ✅ Restore your original button styling */
.th-bg-btn{
  background: #ef589c;
  border: 1px solid #ef589c;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  white-space: nowrap;
}

.th-bg-btn:hover{
  background: #fff;
  color: #ef589c;
}

.th-bg-btn-outline{
  background: #fff;
  border: 1px solid rgba(239, 88, 156, 0.8);
  color: #ef589c;
  border-radius: 12px;
  padding: 10px 12px;
  white-space: nowrap;
}

.th-bg-btn-outline:hover{
  background: rgba(239, 88, 156, 0.08);
  color: #ef589c;
}

.th-bg-btn,
.th-bg-btn-outline{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

#thSavePanel.th-ct-panel{
  /* Sized to fit the background toggle + THREE action buttons (Album /
     Workshop / Send to a Friend) + the status line without the last
     button touching the panel's bottom edge. */
  --bs-offcanvas-height: min(48vh, 330px);
  border: 0;
}

.th-save-bg-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #888;
  cursor: pointer;
  max-width: 360px;
  width: 100%;
  user-select: none;
}

.th-save-bg-toggle input[type="checkbox"] {
  accent-color: #ef589c;
  width: 15px;
  height: 15px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Album destination line ("to: My Album ▾") — shown only when the user's
   world holds more than one album (ALBUMS_TECHNICAL_SPEC.md §8.3). The
   opened list offers instead-or-as-well ticks + the "+ New Album" row. */
.th-save-dest {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.th-save-dest.hidden { display: none; }

.th-save-dest-toggle {
  border: 0;
  background: transparent;
  font-size: 0.9rem;
  color: #00537d;
  cursor: pointer;
  padding: 2px 6px;
}

.th-save-dest-toggle strong { color: #e01571; }

.th-save-dest-caret { font-size: 0.8rem; }

.th-save-dest-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 83, 125, 0.18);
  border-radius: 12px;
  background: #fdfbf7;
  max-height: 160px;
  overflow-y: auto;
}

.th-save-dest-list.hidden { display: none; }

.th-save-dest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #00537d;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.th-save-dest-row:hover,
.th-save-dest-row:focus {
  background: rgba(239, 88, 156, 0.1);
}

.th-save-dest-row .bi-check-square { color: #ef589c; }

.th-save-dest-new { margin-top: 4px; }

/* Guest join prompt in the save panel slot, and the post-join welcome line */
.th-guest-save-text,
.th-save-resume-note {
  max-width: 420px;
  margin-inline: auto;
}


/* On small screens: stack buttons under swatches but keep near them */
@media (max-width: 520px){
  .th-bg-recent-row{
    align-items: flex-start;
  }

  .th-bg-actions-inline{
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (min-height: 800px){
  #thBackgroundPanel.th-ct-panel{
    max-height: 470px;  /* match colour panel */
  }
}


/* =========================================================
   Guide panel
   ========================================================= */

#thGuidePanel.th-ct-panel{
  --bs-offcanvas-height: min(55vh, 320px);
  border: 0;
}

/* X on its own row */
.th-guide-close-row{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 10px;
}

/* ✅ Grid that sizes columns to content, but stays responsive */
.th-guide-grid{
  display: grid;
  gap: 10px 16px;

  /* Each item gets at least 160px, but can grow to fit its label */
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));

  max-width: 520px;
}

/* Optional: slightly wider spacing on larger screens */
@media (min-width: 768px){
  .th-guide-grid{
    column-gap: 18px;
  }
}

/* Each item: checkbox + label */
.th-guide-item{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

/* The per-app "Snap to guides" toggle sits apart from the pattern list
   (guide.js renders it for the apps in its SNAP_APPS set). The list is a
   grid — span the full row so the divider reads as a separator. */
.th-guide-snap{
  grid-column: 1 / -1;
  margin-top: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0, 83, 125, 0.15);
}

/* Checkbox alignment */
.th-guide-check{
  margin-top: 0;
}

/* ✅ Force single-line labels (no wrapping, no truncation) */
.th-guide-label{
  color: #333;
  white-space: nowrap;
}

/* Hint text should wrap normally */
.th-guide-hint{
  margin-top: 12px;
  padding-top: 0;

  color: #666;
  font-size: 0.9rem;

  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 520px;
}

#thGuidePanel.offcanvas-top{
  /* Bootstrap sets height from --bs-offcanvas-height.
     For this panel we just want a small, tidy height. */
  --bs-offcanvas-height: 170px;   /* tweak: try 150–210 */
}

/* Optional: slightly tighter padding so it feels less "empty" */
#thGuidePanel .offcanvas-body{
  padding-top: 12px;
  padding-bottom: 12px;
}

/* Safety: if you re-add more guide options later, it will scroll instead of growing huge */
#thGuidePanel .offcanvas-body{
  overflow-y: auto;
}

/* =========================================================
   Shape panel
   ========================================================= */

#thShapePanel.th-ct-panel{
  --bs-offcanvas-height: min(90vh, 820px);
  border: 0;
}

.th-shape-row{
  margin-bottom: 10px;
}

.th-shape-block{
  margin-bottom: 14px;
}

.th-shape-title{
  font-weight: 600;
  margin-bottom: 8px;
  color: #333;
}

.th-shape-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, 44px);
  gap: 10px;
  align-items: center;
}

.th-shape-swatch{
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.th-shape-swatch:hover{
  background: rgba(239, 88, 156, 0.06);
}

.th-shape-swatch.is-active{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}



/* =========================
   Recents panel (floating tab + slide-out)
   ========================= */

/* Floating button */
#thRecentsTab.th-recents-tab{
  position: fixed;
  right: 12px;
  top: var(--th-recents-top, 140px);
  z-index: 1205;

  width: 52px;
  height: 52px;
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 25px rgba(0,0,0,0.18);

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

  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#thRecentsTab .th-recents-tab__label{
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.1px;
  color: #ef589c;
  padding: 0 6px;
  text-align: center;
}

#thRecentsTab:focus{
  outline: 2px solid rgba(239, 88, 156, 0.45);
  outline-offset: 3px;
}

@media (max-width: 768px){
  #thRecentsTab.th-recents-tab{
    width: 46px;
    height: 46px;
    right: 10px;
  }
  #thRecentsTab .th-recents-tab__label{
    font-size: 10px;
  }
}
@media (max-width: 480px){
  #thRecentsTab.th-recents-tab{
    width: 44px;
    height: 44px;
    right: 8px;
  }
  #thRecentsTab .th-recents-tab__label{
    font-size: 9.5px;
  }
}

/* Phone treatment of the floating edge discs (Recents right, Delete bar
   left — a mirrored fixed pair at toolbar-bottom + 12px). On screens
   narrower than an iPad mini (744px) the portrait workspace is nearly
   full-bleed, so the strip under the toolbar must be kept clear of
   artwork or the discs sit on its top corners. Two mutually exclusive
   providers of that strip (creative_toolbar.html renders the band as the
   EXACT complement of the app templates' instruction sections):

   1. No .th-instruction rendering → the reserved .th-edge-band spacer.
   2. A .th-instruction rendering (daily home render, WIP load with an
      instruction, staff design mode) → the instruction's own first lines
      occupy the strip, side-padded below so the centred text clears both
      discs (44-46px disc + inset) and just wraps a little earlier.

   Both are real layout height inside/below the header, and the workspace
   sizer counts them: the canvas shrinks a little on short phones rather
   than pushing below the fold — maximally big without scrolling, and the
   same size whichever provider is active (band ≈ instruction first
   lines). Applies to all toolbar apps except mug_painting (its Front/Back
   pill already occupies the strip) and the album (no Recents panel there;
   its Delete bin appears only alongside the visible move bar, whose top
   line holds the strip — see album.css). On wider screens the discs land
   on the workspace's side margins: the band stays inert and the
   instruction needs no padding. */
.th-edge-band { display: none; }
@media (max-width: 743.98px) {
  .th-edge-band { display: block; height: 60px; }
  .th-instruction { padding-inline: 56px; }
}

/* While an offcanvas panel (colour / shape / pen / …) is open, hide the
   floating edge buttons so they don't sit on top of it. They're z-index 1205;
   Bootstrap offcanvas is ~1045, so otherwise they obscure the panel's top
   (close button, the Solid|Outline toggle, the Apply-to pill). Toggled by the
   show / hidden.bs.offcanvas listeners in creative_toolbar.js. */
body.th-panel-open .th-selection-bar,
body.th-panel-open #thRecentsTab {
  opacity: 0;
  pointer-events: none;
}

/* ---- Layers dropdown (z-order menu opened from the Layers tool) ----
   A small popover (not an offcanvas) so the canvas stays visible while the
   user reorders. position: fixed — th_layers_menu.js sets top/left from the
   Layers button's viewport rect at open time. */
.th-layers-menu {
  position: fixed;
  z-index: 1215;            /* above the floating edge buttons (1205) */
  min-width: 184px;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.th-layers-menu[hidden] { display: none; }

.th-layers-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;         /* iOS HIG minimum tap target */
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #00537d;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
}
.th-layers-item i { font-size: 1.15rem; line-height: 1; }
.th-layers-item:hover:not(:disabled),
.th-layers-item:focus-visible:not(:disabled) {
  background: #fde3ef;      /* soft pink */
  color: #ef589c;
}
.th-layers-item:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Backdrop */
#thRecentsBackdrop.th-recents-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 1210;
}
#thRecentsBackdrop.th-recents-backdrop.is-open{
  opacity: 1;
  pointer-events: auto;
}

/* Slide-out panel */
#thRecentsPanel.th-recents-panel{
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(360px, 86vw);
  z-index: 1215;

  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  box-shadow: -10px 0 25px rgba(0,0,0,0.18);

  transform: translateX(110%);
  transition: transform 180ms ease-out;

  padding: 12px 12px 18px;
  overflow: auto;
}
#thRecentsPanel.th-recents-panel.is-open{
  transform: translateX(0);
}

/* Header */
.th-recents-panel__header{
  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 6px 4px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  margin-bottom: 10px;
}

.th-recents-panel__title{
  font-weight: 600;
  color: #444;
}

.th-recents-panel__close{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.9);
  cursor: pointer;
}

/* Rows */
.th-recents-row{
  margin: 12px 0;
}
.th-recents-row__title{
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 6px;
}
/* The "In this piece" sub-row under Recent colours (2026-09-28). */
.th-recents-row__subtitle{
  font-size: 0.8rem;
  color: #666;
  margin: 10px 0 6px;
}
.th-recents-row__grid,
.th-recents-row__guidebar{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Colour/background swatches inside recents (match colour panel: square) */
.th-recents-row__grid .th-ct-swatch{
  width: var(--th-swatch);        /* same sizing system as colour panel */
  height: var(--th-swatch);
  border-radius: 8px;            /* ✅ square-ish like colour panel */
  border: 1px solid rgba(0,0,0,0.15);
  cursor: pointer;
  padding: 0;
  margin: 0;
  display: block;
}

.th-recents-row__grid .th-ct-swatch.is-active{
  outline: 3px solid rgba(239, 88, 156, 0.85);
  outline-offset: 2px;
}

.th-recents-row__grid .th-ct-swatch:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}


/* ✅ Shape swatches in recents: reuse the same sizing as the main shape panel */
.th-recents-row__grid .th-recents-shape-swatch{
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.th-recents-row__grid .th-recents-shape-swatch:hover{
  background: rgba(239, 88, 156, 0.06);
}
.th-recents-row__grid .th-recents-shape-swatch:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}
.th-recents-row__grid .th-recents-shape-swatch svg{
  width: 100%;
  height: 100%;
  display: block;
}

/* Make colour/background rows in recents use the same grid layout as colour panel */
#thRecentsColoursRow,
#thRecentsBackgroundsRow{
  display: grid;
  grid-template-columns: repeat(auto-fill, var(--th-swatch));
  gap: 6px;
  align-items: start;
}


/* Recents panel: guides as checkboxes (match guide panel UX) */
.th-recents-row__guidebar{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.th-recents-guide-item{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.th-recents-guide-check{
  margin-top: 0;
}

.th-recents-guide-label{
  font-size: 0.9rem;
  color: #444;
}

/* Empty hint */
.th-recents-empty{
  font-size: 0.85rem;
  color: #888;
  padding: 6px 0;
}

/* =========================================================
   Shape swatches: label BELOW icon (single source of truth)
   Put this at the VERY END of creative_toolbar.css
   ========================================================= */

/* Shape panel swatches (and any other swatch using label-below) */
.th-shape-swatch.th-shape-swatch--label-below{
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  height: auto;            /* don't hard-fix height */
  min-height: 62px;        /* 44 icon + label space */
  padding: 4px 0 6px;
  gap: 3px;

  overflow: visible;
}

.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__iconbox{
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  line-height: 0;
}

.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__icon svg{
  width: 100%;
  height: 100%;
  display: block;
}

.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__label{
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #333;

  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(0,0,0,0.14);

  max-width: 44px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Make shape grids align nicely with taller items */
.th-shape-grid{
  align-items: start;
}

/* Recents panel: override the more-specific base rule (.th-recents-shape-swatch is 44px tall) */
.th-recents-row__grid .th-recents-shape-swatch.th-shape-swatch--label-below{
  height: auto;
  min-height: 62px;
  padding: 4px 0 6px;
  overflow: visible;

  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  color: #333; /* stop browser default blue */
}

/* =========================================================
   Shape swatches: remove tile border + white fill (panel + recents)
   Put this at the VERY END of creative_toolbar.css
   ========================================================= */

/* Shape panel swatch base */
#thShapePanel .th-shape-swatch{
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Recents panel shape swatches */
#thRecentsPanel .th-recents-shape-swatch{
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* Keep a light hover affordance without a "tile" look */
#thShapePanel .th-shape-swatch:hover,
#thRecentsPanel .th-recents-shape-swatch:hover{
  background: rgba(239, 88, 156, 0.06) !important;
}

/* Keep keyboard focus visible */
#thShapePanel .th-shape-swatch:focus,
#thRecentsPanel .th-recents-shape-swatch:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65) !important;
  outline-offset: 2px !important;
}

/* Label-below: remove the little white pill + border too */
.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__label{
  background: transparent !important;
  border: none !important;
  padding: 2px 0 !important;   /* keep a bit of spacing */
  border-radius: 0 !important;
}

/* =========================================================
   Dynamic shape icon sizing (CSS variable controlled)
   Put at VERY END of creative_toolbar.css
   ========================================================= */

.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__iconbox{
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  line-height: 0;
}

/* ✅ default is 100% (old behaviour), JS can set --th-shape-icon to e.g. 16px */
.th-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__icon svg{
  width: var(--th-shape-icon, 100%);
  height: var(--th-shape-icon, 100%);
  display: block;
}

/* =========================================================
   Shape panel: allow wrap only when the label is the "larger than shown" hint
   ========================================================= */

#thShapePanel .th-shape-swatch__label.th-shape-swatch__label--wrap{
  max-width: 44px;          /* keep same width */
  white-space: normal;      /* allow wrapping */
  overflow: visible;        /* no clipping */
  text-overflow: unset;     /* no ellipsis */
  line-height: 1.1;         /* a bit more readable when wrapped */
  word-break: break-word;   /* safe on narrow width */
}

/* =========================================================
   Recents panel: apply dynamic icon sizing too
   (recents uses .th-recents-shape-swatch, not .th-shape-swatch)
   ========================================================= */

.th-recents-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__icon svg{
  width: var(--th-shape-icon, 100%);
  height: var(--th-shape-icon, 100%);
  display: block;
}

/* =========================================================
   Recents panel: match label font sizing to shape panel
   ========================================================= */

#thRecentsPanel .th-recents-shape-swatch.th-shape-swatch--label-below .th-shape-swatch__label{
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

/* =========================================================
   Pen panel + Pen recents (append to end of creative_toolbar.css)
   ========================================================= */

/* Text panel (canvas + tree_decoration): height fits the textarea, the
   font/size row, and the action button. */
#thTextPanel.offcanvas-top{
  --bs-offcanvas-height: 360px;
  border: 0;
  /* Let the font dropdown's popover list extend below the panel onto the
     page rather than being clipped — same rule as #thFontPanel (poetry),
     so many font samples are visible at once for comparison. */
  overflow: visible;
}

.th-text-input{
  max-width: 360px;
  text-align: center;
}

/* Text panel colour palette: small round swatches in a centred horizontal
   row — matches the album's text style bar and poetry's Text Style panel. */
.th-text-colours{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 420px;
}

.th-text-colours .th-ct-swatch{
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  padding: 0;
  cursor: pointer;
}

.th-text-colours .th-ct-swatch.is-active{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

#thTextPanel .offcanvas-body{
  padding-top: 12px;
  padding-bottom: 12px;
  overflow: visible;
}

#thPenSizePanel.offcanvas-top{
  /* Height fits the Style row — five entries (Pen / Marker / Spray /
     Smudge / Eraser), which wraps to TWO lines on phones — plus the
     Size row (Thin / Medium / Thick). min(48vh, …) keeps very short
     viewports scrollable via the body's overflow-y. If a future variant
     needs a taller or shorter panel, add a class-based override (earlier
     attempts at content-driven height ran afoul of the flex-container's
     interaction with offcanvas positioning). */
  --bs-offcanvas-height: min(48vh, 280px);
  border: 0;
}

/* Pen panel: the Size section (preview strip + slider + marks) needs
   more than Bootstrap's 30vh default; sized to its content, scrolls
   inside on a very short viewport. */
#thPenSizePanel.th-ct-panel{
  --bs-offcanvas-height: min(66vh, 340px);
  border: 0;
}

/* Sketch panel (Lino Print's Pen): two mode buttons, one line of text and
   one button — a short panel sized to that. */
#thSketchPanel.th-ct-panel{
  --bs-offcanvas-height: min(50vh, 232px);
  border: 0;
}

#thSketchPanel .offcanvas-body{
  padding-top: 12px;
  padding-bottom: 12px;
  overflow-y: auto;
}

#thPenSizePanel .offcanvas-body{
  padding-top: 12px;
  padding-bottom: 12px;
  overflow-y: auto;
}

.th-pen-grid{
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Match your button language (similar to bg outline buttons, but smaller) */
.th-pen-btn{
  background: #fff;
  border: 1px solid rgba(239, 88, 156, 0.8);
  color: #ef589c;
  border-radius: 12px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.th-pen-btn:hover{
  background: rgba(239, 88, 156, 0.08);
  color: #ef589c;
}

.th-pen-btn:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

.th-pen-btn.is-active{
  background: #ef589c;
  border-color: #ef589c;
  color: #fff;
}

/* Pen width (2026-09-28): preview strip, slider, named snap marks. */
.th-pen-size{
  max-width: 440px;
  margin: 8px auto 0;
  padding-bottom: 4px; /* the marks never hug the panel's bottom edge */
}

.th-pen-size-head{
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 2px 4px;
}

.th-pen-size-title{
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(0, 83, 125, 0.78);
}

.th-pen-size-value{
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: #00537d;
}

/* The strip is paper-white so colours read as they will on the canvas. */
.th-pen-preview{
  display: block;
  width: 100%;
  height: 56px;
  border: 1px solid rgba(0, 83, 125, 0.18);
  border-radius: 12px;
  background: #fff;
}

/* The slider: a 36 px-tall band around a slim pink track, with a 32 px
   pink thumb (the marks below add to the touch height). The first range
   input in the project. */
.th-pen-range{
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 36px;
  margin: 2px 0 0;
  background: transparent;
  cursor: pointer;
}

.th-pen-range::-webkit-slider-runnable-track{
  height: 6px;
  border-radius: 3px;
  background: rgba(239, 88, 156, 0.28);
}

.th-pen-range::-moz-range-track{
  height: 6px;
  border-radius: 3px;
  background: rgba(239, 88, 156, 0.28);
}

.th-pen-range::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -13px; /* centre the thumb on the 6 px track */
  border-radius: 50%;
  background: #ef589c;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.th-pen-range::-moz-range-thumb{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ef589c;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.th-pen-range:focus-visible{
  outline: none;
}

.th-pen-range:focus-visible::-webkit-slider-thumb{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

.th-pen-range:focus-visible::-moz-range-thumb{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

/* The named widths sit under the track at their slider positions. The
   thumb's centre travels from half a thumb in to half a thumb from the
   end, so a mark at fraction f sits at 16px + f * (100% - 32px). The row
   is pulled up so the ticks start just under the track (the thumb paints
   over a tick it sits on). */
.th-pen-marks{
  position: relative;
  height: 28px;
  margin-top: -8px;
}

.th-pen-mark{
  position: absolute;
  top: 0;
  left: calc(16px + var(--th-mark, 0) * (100% - 32px));
  transform: translateX(-50%);
  margin: 0; /* a general button rule adds 5px of side margin, which shifted every tick off its thumb position */
  padding: 10px 10px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(0, 83, 125, 0.78);
  font-size: 0.85rem;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.th-pen-mark::before{ /* the tick on the track's edge */
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 7px;
  margin-left: -1px;
  background: rgba(239, 88, 156, 0.6);
}

.th-pen-mark.is-active{
  color: #e01571;
  font-weight: 700;
}

.th-pen-mark:focus-visible{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

.th-pen-size-note{
  margin: 8px 0 0;
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: center;
  color: rgba(0, 83, 125, 0.78);
}

/* Recents: pen chips */
.th-recents-pen-chip{
  background: #fff;
  border: 1px solid rgba(239, 88, 156, 0.8);
  color: #ef589c;
  border-radius: 12px;
  padding: 8px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.th-recents-pen-chip:hover{
  background: rgba(239, 88, 156, 0.08);
}

.th-recents-pen-chip.is-active{
  background: #ef589c;
  border-color: #ef589c;
  color: #fff;
}

.th-recents-pen-chip:focus{
  outline: 3px solid rgba(239, 88, 156, 0.65);
  outline-offset: 2px;
}

/* =========================================================
   Flower picker panel swatches
   ========================================================= */

/* Remove the tile border and white fill from flower swatches,
   matching the treatment already applied to shape swatches. */
#thFlowerPanel .th-shape-swatch,
.th-shape-swatch[data-kind="flower"] {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

#thFlowerPanel .th-shape-swatch:hover,
.th-shape-swatch[data-kind="flower"]:hover {
  background: rgba(239, 88, 156, 0.06) !important;
}

#thFlowerPanel .th-shape-swatch:focus,
.th-shape-swatch[data-kind="flower"]:focus {
  outline: 3px solid rgba(239, 88, 156, 0.65) !important;
  outline-offset: 2px !important;
}

/* Slightly more breathing room between flowers in the recents row. */
#thFlowerRecentRow.th-shape-grid {
  gap: 16px;
}

/* Allow non-standard size labels in the recents row to display fully
   rather than being clipped to the 44px swatch width. */
.th-shape-swatch[data-kind="flower"].th-shape-swatch--label-below {
  width: auto;
  min-width: 44px;
}

.th-shape-swatch[data-kind="flower"] .th-shape-swatch__label {
  white-space: nowrap;
  overflow: visible;
  width: max-content;
}


/* ─── Centred narrow panels (desktop only) ─────────────────────────────────
 *
 * On screens ≥ 768 px, shape/pen/guide/font/flower/paper panels float as a
 * centred card rather than stretching full viewport width.  Colour and
 * background panels keep the default full-width layout (they need the space).
 *
 * Bootstrap's offcanvas-top hides with  transform: translateY(-100%)  and
 * shows with  transform: none.  When we shift the panel to the centre with
 * left: 50%, we must fold that translateX(-50%) into both states so the slide
 * animation still works correctly.
 * ─────────────────────────────────────────────────────────────────────────── */
@media (min-width: 768px) {

  /* Shape and flower panels — wider (more columns of swatches) */
  #thShapePanel,
  #thFlowerPanel {
    left: 50%;
    right: auto;
    width: min(640px, 92vw);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    /* hidden state */
    transform: translateX(-50%) translateY(-100%);
  }

  #thShapePanel.show,
  #thFlowerPanel.show {
    transform: translateX(-50%);
  }

  /* Font (Text Style) panel — wider than pen/guide/paper to fit all colour
     swatches on one row (11 × 28 px + 10 × 8 px gaps = 388 px content).
     overflow stays visible (not hidden) so the font-dropdown popover
     can extend below the panel onto the page. */
  #thFontPanel {
    left: 50%;
    right: auto;
    width: min(560px, 92vw);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    /* hidden state */
    transform: translateX(-50%) translateY(-100%);
  }

  #thFontPanel.show {
    transform: translateX(-50%);
  }

  /* Pen, sketch (Lino Print's Pen), guide and paper panels — narrower */
  #thPenSizePanel,
  #thSketchPanel,
  #thGuidePanel,
  #thPaperPanel {
    left: 50%;
    right: auto;
    width: min(480px, 92vw);
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
    /* hidden state */
    transform: translateX(-50%) translateY(-100%);
  }

  #thPenSizePanel.show,
  #thSketchPanel.show,
  #thGuidePanel.show,
  #thPaperPanel.show {
    transform: translateX(-50%);
  }
}

/* =========================================================
   Custom size tile in the shape palette rows
   ========================================================= */

#thShapePanel .th-shape-custom .th-shape-swatch__iconbox{
  padding: 0 3px;
}

.th-shape-custom__input{
  width: 100%;
  max-width: 40px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 6px;
  padding: 2px 2px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #333;
  background: #fff;
}

.th-shape-custom__input:focus{
  outline: 2px solid rgba(239, 88, 156, 0.45);
  outline-offset: 1px;
  border-color: rgba(239, 88, 156, 0.6);
}

.th-shape-custom__input--invalid,
.th-shape-custom__input--invalid:focus{
  border-color: #c62f2f;
  background: #fff4f4;
  outline-color: rgba(198, 47, 47, 0.45);
}

/* Hide native spinner controls — the 44px tile has no room for them */
.th-shape-custom__input::-webkit-outer-spin-button,
.th-shape-custom__input::-webkit-inner-spin-button{
  -webkit-appearance: none;
  margin: 0;
}
.th-shape-custom__input[type=number]{
  -moz-appearance: textfield;
}

/* =========================================================
   Shape panel close X — always reachable.

   The panel fills 90vh on phones with 13 shapes scrolling inside.
   The close-button row sits OUTSIDE .offcanvas-body in the template,
   anchored absolutely to the offcanvas root, so it stays put no
   matter how far the body scrolls. (The earlier position:sticky
   pattern inside .offcanvas-body proved unreliable on iOS PWA
   standalone — viewport shifts from the keyboard or address bar
   could break the stick.) Subtle white pill keeps it readable over
   shape swatches.
   ========================================================= */

#thShapePanel .offcanvas-body{
  /* Reserve space at the top so the first content row ("Recent
     shapes") isn't tucked under the absolutely-positioned close X. */
  padding-top: 52px;
}

#thShapePanel .th-ct-toprow.th-ct-toprow--solo{
  position: absolute;
  top: 8px;
  right: 12px;
  margin: 0;
  padding: 4px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  z-index: 20;
}

/* =========================================================
   Selection action bar — touch-friendly Delete button.

   Floating circular button on the LEFT edge of the screen,
   horizontally aligned with the Recents button on the RIGHT —
   a mirrored peer that doesn't push canvas content vertically as
   it appears and disappears. Visible only while something is
   selected. See templates/includes/selection_action_bar.html and
   static/js/canvas_tools/th_selection_bar.js.

   Visibility uses a positive `is-visible` class rather than a
   `hidden` class — `.hidden` is only defined in album.css (which
   the creative apps don't load) and would also lose a specificity
   fight with any Bootstrap d-* utility on the element.
   ========================================================= */

.th-selection-bar {
  position: fixed;
  /* Mirror Recents (right: 12px). Same vertical position too via
     --th-recents-top so they always read as a horizontal pair. */
  left: 12px;
  top: var(--th-recents-top, 140px);
  z-index: 1205;

  width: 52px;
  height: 52px;
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.18);

  /* Hidden by default; .is-visible flips to flex via the JS update(). */
  display: none;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   STONE PANEL — the Mosaic cutting bench (stone.js)
   ========================================================= */

/* Height fits the whole bench in one glance: close row, title, stone
   stage, hint, and the cutter row — no scrolling. */
#thStonePanel.th-ct-panel {
  --bs-offcanvas-height: min(62vh, 420px);
  border: 0;
}

.th-stone-stage {
  display: flex;
  justify-content: center;
}

.th-stone-stage-svg {
  width: min(165px, 40vw);
  height: auto;
  display: block;
  /* The bench bed: a constant grout-toned backing so white / pale
     stones stay visible for picking — pieces carry no outline and
     their sheen band is white, so on the panel's white background a
     white stone disappears entirely. A shade darker than the board's
     default grout (#e9e3d7) for headroom against the palest palette
     tones. The viewBox's STAGE_PAD already gives the stone breathing
     room inside the backing, cracked spreads included. */
  background: #ded5c3;
  border-radius: 14px;
}

.th-bench-piece {
  cursor: pointer;
  /* Crack-apart: stone.js sets each piece's resting translate; the
     transition animates the slide when a cutter is tapped. */
  transition: transform 0.28s ease;
}

/* Reduced motion: pieces jump straight to their resting spread — the
   translate still applies, only the slide is suppressed (the board's
   settle animation is gated the same way in mosaic.css). */
@media (prefers-reduced-motion: reduce) {
  .th-bench-piece {
    transition: none;
  }
}

.th-stone-hint {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(0, 83, 125, 0.78);
  margin: 0.25rem 0 0.5rem;
}

.th-stone-cutters {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.th-stone-cutter {
  min-width: 56px;
  min-height: 56px;
  padding: 0.3rem 0.4rem;
  border: 1px solid rgba(0, 83, 125, 0.25);
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.th-stone-cutter.is-active {
  border-color: #ef589c;
  box-shadow: 0 0 0 2px rgba(239, 88, 156, 0.25);
}

.th-stone-cutter-pic {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #00537d;
  stroke-width: 1.5;
}

.th-stone-cutter-label {
  font-size: 0.7rem;
}

/* =========================================================
   LIGHT PANEL — the Mosaic light-direction ring dial (light.js)
   ========================================================= */

#thLightPanel.th-ct-panel {
  --bs-offcanvas-height: min(58vh, 380px);
  border: 0;
}

#thLightDial {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.th-light-dial-svg {
  width: min(230px, 55vw);
  height: auto;
  display: block;
  /* A bounded panel control (not a creative surface): the dial claims
     single-finger drags outright so the sun can be dragged smoothly. */
  touch-action: none;
  cursor: pointer;
}

.th-light-hint {
  text-align: center;
  font-size: 0.85rem;
  color: rgba(0, 83, 125, 0.78);
  margin-top: 0.25rem;
}

.th-selection-bar.is-visible {
  display: flex;
}

.th-selection-delete-btn {
  border: none;
  background: transparent;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.th-selection-delete-btn:focus {
  outline: 2px solid rgba(239, 88, 156, 0.45);
  outline-offset: 3px;
}

.th-selection-delete-btn i {
  color: #ef589c;
  font-size: 1.4rem;
}

@media (max-width: 768px) {
  .th-selection-bar {
    width: 46px;
    height: 46px;
    left: 10px;
  }
}

@media (max-width: 480px) {
  .th-selection-bar {
    width: 44px;
    height: 44px;
    left: 8px;
  }
}

/* =========================================================
   Colour tool — Fill | Outline target pill (shape-tool apps).

   Rendered only when toolbar.colour_fill_outline is set, and shown
   (via .is-visible, toggled by colour.js) only while the user is
   working with shapes. Lets a picked colour target a shape's fill
   or its outline. Pink segmented control to match the brand.
   ========================================================= */

.th-ct-target {
  display: none;                 /* shown via .is-visible from colour.js */
  align-items: center;
  gap: 12px;
  margin: 2px 0 14px;
}

.th-ct-target.is-visible {
  display: flex;
}

.th-ct-target-label {
  font-size: 0.85rem;
  color: rgba(0, 83, 125, 0.78);
}

.th-ct-target-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;                  /* inset so the active thumb floats inside */
  border: 1px solid #ef589c;
  border-radius: 999px;
  background: #fff;
}

.th-ct-target-btn {
  border: none;
  background: transparent;
  color: #ef589c;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 999px;          /* rounded thumb when active */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.th-ct-target-btn.is-active {
  background: #ef589c;
  color: #fff;
}

/* "None" (clear-fill) segment — an action, present only on a filled outline
   shape (toggled by colour.js via .is-shown). Never gets the active thumb. */
.th-ct-target-none {
  display: none;
}
.th-ct-target-none.is-shown {
  display: inline-block;
}

/* The same segmented pill, reused in the shape panel as an always-visible
   "New shapes: Solid | Outline" placement toggle (sets window.thShapeOutline). */
.th-shape-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 14px;
}

/* =========================================================
   Font dropdown — shared component (font_dropdown.js).

   A compact replacement for a row of per-font buttons: one toggle
   button shows the active font in its own family, the popover list
   shows each font rendered in its own family for picking. Used by
   the album text picker and the shared font offcanvas panel.
   ========================================================= */

.th-font-dropdown {
  position: relative;
  display: inline-block;
}

.th-font-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 180px;
  padding: 6px 12px;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  background: #fff;
  color: #333;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.th-font-dropdown-toggle:hover,
.th-font-dropdown.is-open .th-font-dropdown-toggle {
  border-color: #ef589c;
  color: #ef589c;
}

.th-font-dropdown-toggle:focus {
  outline: 2px solid rgba(239, 88, 156, 0.45);
  outline-offset: 2px;
}

.th-font-dropdown-current {
  flex: 1 1 auto;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.th-font-dropdown-caret {
  flex: 0 0 auto;
  font-size: 0.8rem;
  line-height: 1;
}

.th-font-dropdown-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  max-width: min(280px, 90vw);
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  z-index: 100;
}

.th-font-dropdown-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 8px 16px;
  cursor: pointer;
  color: #333;
}

.th-font-dropdown-option-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.th-font-dropdown-option-sample {
  font-size: 1.2rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.th-font-dropdown-option:hover {
  background: rgba(239, 88, 156, 0.08);
}

.th-font-dropdown-option:hover .th-font-dropdown-option-label,
.th-font-dropdown-option:hover .th-font-dropdown-option-sample {
  color: #ef589c;
}

.th-font-dropdown-option.is-active {
  background: rgba(239, 88, 156, 0.14);
}

.th-font-dropdown-option.is-active .th-font-dropdown-option-label,
.th-font-dropdown-option.is-active .th-font-dropdown-option-sample {
  color: #ef589c;
}

/* =========================================================
   ROLLER SECTION — Lino Print's Roller, at the top of the shared
   colour panel (creative_toolbar_colour_panel.html under
   toolbar.roller; wiring in roller.js). A mini lino block shows the
   band at the chosen width in the active colour; the slider reuses
   the pen panel's range styling.
   ========================================================= */

.th-roller{
  max-width: 440px;
  margin: 0 auto 16px;
}

.th-roller-main{
  display: flex;
  align-items: center;
  gap: 14px;
}

.th-roller-preview{
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid rgba(0, 83, 125, 0.18);
  background: var(--lino-block, #5a3a22);
}

.th-roller-preview-band{
  width: 100%;
  height: 25%;
  background: var(--th-current-colour, #ef589c);
}

.th-roller-width{
  flex: 1 1 auto;
  min-width: 0;
}

.th-roller-actions{
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

/* With the Roller's section on top the colour panel needs more room than
   its usual cap, or the palette loses a row and a half to it. */
@media (min-height: 800px){
  #thColourPanel.th-ct-panel:has(.th-roller){
    max-height: 600px;
  }
}
