/* =========================================================================
   Guide Builder (guide-editor.html). Builds on marker.css and the image
   editor shell (image-editor.css): top bar, steps list on the left, the
   guide pages in the middle, step properties on the right. Phones (760 px
   and below): top bar, pages, a bottom sheet for properties, and the steps
   as a scrolling strip.
   ========================================================================= */

.is-guide .ed-name { max-width: 420px; }
.gd-export .icon { margin-left: 6px; margin-right: -4px; }
.ed-actions { position: relative; }
.gd-menu { top: calc(100% + 6px); right: 0; min-width: 300px; }
.gd-menu button { flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 10px; }
.gd-menu b { font-weight: 600; }
.gd-menu-sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.gd-menu-copy { display: none !important; }
.gd-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ---- Steps list ---------------------------------------------------------- */
.gd-steps {
  flex: 0 1 264px;
  min-width: 220px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}
.gd-steps-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px 6px; }
.gd-steps-head h2 { font-size: 16px; line-height: 22px; }
.gd-steps-hint { font-size: 12px; color: var(--muted); }
.gd-list { display: flex; flex-direction: column; gap: 4px; position: relative; }
.gd-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.gd-step:hover { background: var(--raised); }
.gd-step[aria-current="true"] { border-color: var(--selection); background: color-mix(in srgb, var(--selection) 7%, var(--surface)); }
.gd-step.is-dragging { opacity: .35; }
.gd-step { -webkit-touch-callout: none; }
.gd-type-heading .gd-thumb, .gd-type-tip .gd-thumb, .gd-type-warning .gd-thumb { background: var(--surface); }
.gd-type-warning .gd-thumb { color: var(--warning); }
.gd-thumb {
  position: relative;
  width: 72px; height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.gd-thumb canvas { width: 100%; height: 100%; display: block; }
.gd-num {
  position: absolute;
  right: 4px; top: 4px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--marker);
  color: #FFFFFF;
  font: 700 10px/16px var(--font-body);
  text-align: center;
}
[data-theme="dark"] .gd-num { color: #141414; }
.gd-step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gd-step-title { font-size: 13px; line-height: 17px; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gd-step-title.is-empty { color: var(--muted); font-weight: 500; }
.gd-step-sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.gd-head-thumb { flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; padding: 0 8px; background: var(--surface); }
.gd-head-thumb i { display: block; height: 4px; border-radius: 2px; background: var(--control-border); }
.gd-head-thumb i + i { height: 3px; background: var(--line); }
.gd-drop-line { position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 2px; background: var(--selection); pointer-events: none; }

.gd-adds { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.gd-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1.5px dashed var(--muted);
  background: var(--surface);
  color: var(--ink);
  font: 600 13px/18px var(--font-body);
  cursor: pointer;
}
.gd-add:hover { border-color: var(--ink); }
.gd-add-rec { min-height: 44px; font-size: 13px; font-weight: 500; background: var(--raised); justify-content: center; gap: 8px; }
.gd-steps.is-drop { box-shadow: inset 0 0 0 2px var(--selection); }

/* ---- Pages ----------------------------------------------------------------- */
.gd-main { position: relative; }
.gd-scroll { flex: 1; overflow: auto; outline: none; }
.gd-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 32px 24px 48px; min-height: 100%; box-sizing: border-box; }
.gd-scroll.is-drop .gd-pages { box-shadow: inset 0 0 0 2px var(--selection); }
.gd-page {
  position: relative;
  background: #FFFFFF;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 12px 32px rgba(0, 0, 0, .08);
  flex-shrink: 0;
  cursor: pointer;
}
.gd-page canvas { display: block; width: 100%; height: 100%; border-radius: 4px; }
/* A tall page draws as a stack of tiles. */
.gd-page.is-tiled canvas { height: auto; border-radius: 0; }
.gd-page.is-tiled canvas:first-child { border-radius: 4px 4px 0 0; }
.gd-page.is-tiled canvas:last-of-type { border-radius: 0 0 4px 4px; }
.gd-sel {
  position: absolute;
  border: 2px solid var(--selection);
  border-radius: 4px;
  pointer-events: none;
}
.gd-hover {
  position: absolute;
  border: 1px dashed color-mix(in srgb, var(--selection) 60%, transparent);
  border-radius: 4px;
  pointer-events: none;
}
.is-guide .ed-float-history { display: none; }

/* ---- Properties -------------------------------------------------------------- */
.gd-props-head-buttons { display: flex; gap: 2px; }
.gd-props-head-buttons .btn { width: 36px; height: 36px; padding: 0; color: var(--muted); }
.gd-props-head-buttons .btn:hover { color: var(--ink); }
.gd-section { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 14px; }
.gd-section .ed-label { margin-bottom: 2px; }
.gd-section .ed-toggle { min-height: 40px; }
.gd-section .helper { margin-top: -6px; }
.gd-section .ed-group + .gd-pic-row, .gd-section .helper + .ed-group { margin-top: 6px; }
.gd-pic-row { display: flex; gap: 8px; }
.gd-pic-row .btn { flex: 1; }
.gd-info { font-size: 13px; line-height: 18px; color: var(--muted); }
.gd-warn-note { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--danger-border); border-radius: 8px; }
.gd-warn-note[hidden] { display: none; }
.gd-section-head { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.gd-section-head .btn { margin-right: -8px; }
.gd-style { gap: 14px; }
.gd-style .ed-group { gap: 6px; }
.gd-style .helper { margin-top: 0; }
.gd-fonts { font-size: 14px; line-height: 20px; color: var(--ink); }
.gd-logo-add { align-self: flex-start; }
.gd-font .msfp, .gd-font .select { width: 100%; }
.gd-font-add { align-self: flex-start; margin-left: -8px; }
.gd-font-file { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.gd-suggest { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.gd-suggest .ed-row-buttons { flex-wrap: wrap; }
.gd-suggest .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-suggest-btn { align-self: flex-start; margin: 2px 0 0 -8px; }
.gd-outlines { flex-wrap: wrap; gap: 8px; }
.gd-multi-help { margin: -4px 0 4px; }
.gd-rich-hint { margin-top: -2px; }

/* ---- Find Private Text ------------------------------------------------------- */
.gd-find { gap: 12px; }
.gd-find .helper { margin: 0; }
.gd-find progress {
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 99px;
  background: var(--raised);
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}
.gd-find progress::-webkit-progress-bar { background: var(--raised); border-radius: 99px; }
.gd-find progress::-webkit-progress-value { background: var(--ink); border-radius: 99px; }
.gd-find progress::-moz-progress-bar { background: var(--ink); border-radius: 99px; }
.gd-find-sum { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--ink); }
.gd-find-step { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--line); padding-top: 10px; }
.gd-find-step-head { display: flex; align-items: center; gap: 8px; }
.gd-find-goto {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 6px;
  margin-left: -6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 600 14px/20px var(--font-body);
  text-align: left;
  cursor: pointer;
}
.gd-find-goto:hover { background: var(--raised); }
.gd-find-num { flex-shrink: 0; }
.gd-find-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; color: var(--muted); }
.gd-find-step-head .btn { flex-shrink: 0; }
.gd-find-list { max-height: none; overflow: visible; }
.gd-find-row { padding-left: 6px; }
.gd-find-row .ed-smart-what { cursor: default; }
.gd-find-thumb { width: 96px; height: 48px; margin-top: 4px; border-radius: 4px; border: 1px solid var(--line); background: #FFFFFF; }
.gd-find-sum:focus { outline: none; }
/* Accept All stays in reach at the bottom of a long list. */
.gd-find-foot { position: sticky; bottom: 0; z-index: 1; border-top: 1px solid var(--line); padding: 12px 0; background: var(--surface); }
.gd-find .ed-kinds { margin-top: 0; }

/* ---- Work dialog ------------------------------------------------------------- */
dialog.gd-dialog { width: min(440px, calc(100vw - 32px)); }
dialog.gd-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.gd-work-text { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.gd-bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; }
.gd-bar span { background: var(--ink); width: 0; transition: width .15s linear; }
#gdWorkCancel { align-self: flex-start; }

/* ---- Phones -------------------------------------------------------------------- */
@media (max-width: 760px), (max-width: 900px) and (orientation: portrait) and (pointer: coarse) {
  .gd-copy { display: none; }
  .gd-menu-copy { display: flex !important; }
  .gd-menu { min-width: 0; width: min(320px, calc(100vw - 24px)); }
  .gd-export { padding: 0 14px; }

  .gd-pages { padding: 16px 12px 88px; gap: 16px; }
  .is-guide .ed-float-history { display: flex; }

  .gd-steps {
    order: 3;
    flex: 0 0 auto;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 8px 10px 10px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    position: relative;
    z-index: 7;
  }
  .gd-steps-head { display: none; }
  .gd-list { flex-direction: row; gap: 6px; }
  .gd-step { flex-direction: column; padding: 4px; gap: 0; touch-action: pan-x; }
  /* Hidden from view but still read out, so each step keeps its name. */
  .gd-step-text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gd-thumb { width: 64px; height: 44px; }
  .gd-adds { flex-direction: row; margin: 0; gap: 6px; }
  .gd-add, .gd-add-rec { width: 56px; min-height: 54px; padding: 0; flex-shrink: 0; }
  .gd-add span, .gd-add-rec span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .gd-drop-line { top: 6px !important; bottom: 6px; left: auto; right: auto; width: 3px; height: auto; }
  /* Toasts sit above the step strip, so taps on it always land (b7). */
  .is-guide .toast-region { bottom: calc(var(--gd-strip, 76px) + 12px); }
}

/* ---- Longer languages (A-17) ------------------------------------------
   guide-editor.js puts ms-i18n on the root only when the page is in
   another language (or ?pseudo), so English keeps every rule above as it
   is. image-editor.css carries the shared panel rules; these cover the
   guide's own rows, where longer words wrap onto a second line. */
:root.ms-i18n .gd-section-head,
:root.ms-i18n .gd-font-file,
:root.ms-i18n .gd-pic-row,
:root.ms-i18n .gd-find-step-head { flex-wrap: wrap; row-gap: 4px; }
:root.ms-i18n .gd-step-sub,
:root.ms-i18n .gd-menu button { overflow-wrap: break-word; }
:root.ms-i18n .gd-find-step-head .btn { flex-shrink: 1; }
:root.ms-i18n .gd-add, :root.ms-i18n .gd-add-rec { height: auto; text-align: center; }
