/* Foundation styles (split from legacy monolithic app stylesheet) */

:root {
  /* Document / print-preview accent (overridden from Settings → Theme) */
  --stepbinder-doc-accent: #C4956A;
  --stepbinder-doc-accent-dark: #A07548;
  --stepbinder-doc-note-bg: #FDF5EC;
  --stepbinder-doc-note-strong: #A07548;
  /* Editor arrow & box markup color (Settings → Mark Up) */
  --stepbinder-editor-markup: #C4956A;

  --teal: #2C2420;
  --teal-dark: #1A100C;
  --teal-light: #F0E8DF;
  --orange: #C4956A;
  --orange-dark: #A07548;
  --orange-light: #FDF5EC;
  --ink: #1A1A1A;
  --ink-soft: #4A4A4A;
  --gray-900: #2D2D2D;
  --gray-700: #5A5A5A;
  --gray-600: #6B6B6B;
  --gray-500: #8A8A8A;
  --gray-400: #A8A8A8;
  --gray-300: #D4D4D4;
  --gray-200: #E8E8E8;
  --gray-100: #F4F4F4;
  --gray-50: #FAFAFA;
  --paper: #FCFBF8;
  --red: #C8342C;
  --green: #2D7A4F;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;
  --font-display: 'Lora', Georgia, serif;
  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --t-page-title-size: 30px;
  --t-display-size: 38px;
  --t-display-line: 1.05;
  --t-h1-size: 28px;
  --t-h1-line: 1.1;
  --t-h2-size: 24px;
  --t-h2-line: 1.2;
  --t-h3-size: 18px;
  --t-h3-line: 1.3;
  --t-body-size: 14px;
  --t-body-line: 1.55;
  --t-body-sm-size: 13px;
  --t-body-sm-line: 1.5;
  --t-caption-size: 12px;
  --t-caption-line: 1.4;
  --t-eyebrow-size: 11px;
  --t-eyebrow-tracking: 0.08em;
  --t-eyebrow-weight: 600;
  --t-microlabel-size: 10px;
  --t-microlabel-tracking: 0.06em;
  --t-mono-size: 12px;
  --t-mono-tracking: 0.02em;

  --sp-1: 4px;
  --sp-2: 6px;
  --sp-3: 8px;
  --sp-4: 10px;
  --sp-5: 12px;
  --sp-6: 14px;
  --sp-7: 16px;
  --sp-8: 18px;
  --sp-9: 20px;
  --sp-10: 24px;
  --sp-12: 28px;
  --sp-14: 32px;
  --sp-16: 40px;
  --sp-20: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-ui);
  font-size: var(--t-body-size);
  line-height: var(--t-body-line);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* === APP SHELL === */
#app { height: 100vh; display: flex; flex-direction: column; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  user-select: none;
  cursor: pointer;
  min-width: 0;
  flex: 0 1 auto;
}

@media (max-width: 1100px) {
  .brand-sub { display: none; }
}

/* Local-only chip + privacy popover (design kit) */
.privacy-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  background: transparent;
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.privacy-chip:hover {
  background: var(--gray-100);
  color: var(--teal);
  border-color: var(--gray-200);
}
.privacy-chip-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.privacy-chip-wrap.open .privacy-chip {
  background: var(--gray-100);
  color: var(--teal);
  border-color: var(--gray-200);
}

.privacy-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  padding: 14px 16px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--gray-200);
  box-shadow: 0 12px 32px rgba(20, 15, 10, 0.14), 0 2px 6px rgba(20, 15, 10, 0.06);
  z-index: 120;
  color: var(--gray-700);
  animation: privacyPop 0.14s ease-out;
}
@keyframes privacyPop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.privacy-pop-arrow {
  position: absolute;
  top: -6px;
  right: 18px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  border-top: 1px solid var(--gray-200);
  transform: rotate(45deg);
}
.privacy-pop-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.privacy-pop-body { font-size: 12px; line-height: 1.5; color: var(--gray-600); margin: 0 0 12px; }
.privacy-pop-diagram {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
  background: #FAF7F2;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--gray-700);
}
.pp-node { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; background: #fff; border: 1px solid var(--gray-200); border-radius: 6px; }
.pp-arrow { color: var(--teal); font-weight: 700; }
.pp-cloud-strike { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; margin-left: auto; color: var(--gray-400); font-size: 10px; }
.privacy-pop-checks { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--gray-700); }
.pp-check { display: inline-block; width: 14px; color: var(--teal); font-weight: 700; }

.privacy-pop-footnote {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--gray-200);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--gray-600);
}
.privacy-pop-footnote strong { color: var(--ink); }

.privacy-pop-offline {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
}
.privacy-pop-offline .settings-offline-row { margin-bottom: 6px; }
.privacy-pop-offline .settings-offline-title { font-size: 12px; }
.privacy-pop-offline-hint {
  font-size: 11px;
  line-height: 1.45;
  color: var(--gray-500);
  margin: 0;
}
.privacy-popover[hidden] { display: none !important; }
.brand-mark-svg {
  flex-shrink: 0;
  display: block;
  width: 62px;
  height: 62px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 4.5px;
  min-width: 0;
}
.brand-name {
  font-family: 'Lora', Georgia, serif;
  font-size: 33px;
  font-style: italic;
  color: #2C2420;
  letter-spacing: -0.015em;
  line-height: 1;
}
.brand-sub {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 13.75px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #8B6B4A;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

.top-bar-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* F-02: consistent icon-action buttons for Help and Settings */
.icon-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: 1.5px solid transparent;
}
.icon-action-btn:hover {
  background: var(--gray-100);
  color: var(--teal);
  border-color: var(--gray-200);
}
.icon-action-icon {
  font-size: 16px;
  line-height: 1;
}
.icon-action-label {
  font-size: 12px;
  font-weight: 500;
}
/* keep old .help-btn for any legacy references */
.help-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: transparent;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
}
.help-btn:hover { background: var(--gray-100); color: var(--teal); }

.tour-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--orange-light);
  color: var(--orange-dark);
  border: 1.5px solid var(--orange);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tour-btn:hover { background: var(--orange); color: #fff; }

.quickstart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 8000;
}
.quickstart-overlay.visible { display: flex; }
.quickstart-card {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 90%;
  box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.quickstart-header {
  background: linear-gradient(165deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  padding: 32px;
  text-align: center;
}
.quickstart-header h2 {
  font-family: var(--font-display);
  font-size: 38px;
  margin-bottom: 8px;
  font-weight: 400;
}
.quickstart-header p {
  font-size: 14px;
  opacity: 0.9;
}
.quickstart-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 32px;
}
/* Stack steps in one grid cell so pane height = tallest step (no card jump between steps). */
.qs-step-panes {
  display: grid;
  align-items: start;
}
.qs-step {
  grid-area: 1 / 1;
  margin-bottom: 0;
  visibility: hidden;
  pointer-events: none;
}
.qs-step.active {
  visibility: visible;
  pointer-events: auto;
}
.qs-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 14px;
}
.qs-step h3 {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ink);
  margin-bottom: 10px;
  font-weight: 400;
}
.qs-step p, .qs-step ul {
  color: var(--gray-700);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 14px;
}
.qs-step ul { margin-left: 20px; }
.qs-step li { margin-bottom: 6px; }
.qs-highlight {
  background: var(--orange-light);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--orange-dark);
  font-weight: 600;
}
.quickstart-footer {
  padding: 20px 32px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.qs-progress {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
}
.qs-controls { display: flex; gap: 8px; }
.qs-btn-prev, .qs-btn-next, .qs-btn-skip {
  padding: 8px 16px;
  font-size: 12px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s;
}
.qs-btn-prev { background: var(--gray-200); color: var(--ink); }
.qs-btn-prev:hover { background: var(--gray-300); }
.qs-btn-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.qs-btn-next { background: var(--teal); color: #fff; }
.qs-btn-next:hover { background: var(--teal-dark); }
.qs-btn-skip { background: transparent; color: var(--gray-500); text-decoration: underline; }
.qs-btn-skip:hover { color: var(--ink); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-700);
}
.status-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gray-500);
}
.status-pill.active { background: var(--teal-light); color: var(--teal-dark); }
.status-pill.active .dot { background: var(--teal); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.status-pill.capturing {
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1.5px solid var(--teal);
  font-weight: 600;
  animation: capturing-glow 2s ease-in-out infinite;
}
.status-pill.capturing .dot {
  background: var(--teal);
  animation: pulse 1.5s infinite;
}
@keyframes capturing-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,139,139,0); }
  50%       { box-shadow: 0 0 0 4px rgba(0,139,139,0.2), 0 0 14px rgba(0,139,139,0.12); }
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn[hidden] {
  display: none !important;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--teal); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--teal-dark); box-shadow: var(--shadow); }

/* Size tokens — pair with .btn-cta, .btn-secondary, .btn-ghost, .btn-danger */
.btn-lg {
  min-height: 44px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  box-sizing: border-box;
}
.btn-md {
  min-height: 36px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  box-sizing: border-box;
}
.btn-sm {
  min-height: 32px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  box-sizing: border-box;
}

.btn-cta { background: var(--orange); color: #fff; box-shadow: var(--shadow-sm); font-weight: 600; }
.btn.btn-cta.btn-lg {
  min-height: 44px;
  padding: 12px 24px;
  font-size: 14px;
}
.btn.btn-cta.btn-md,
.btn.btn-cta:not(.btn-lg):not(.btn-sm) {
  min-height: 36px;
  padding: 10px 16px;
  font-size: 13px;
}
.btn-cta:hover { background: var(--orange-dark); box-shadow: var(--shadow); }
.btn-cta:disabled,
.btn-cta[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-cta:disabled:hover,
.btn-cta[aria-disabled="true"]:hover {
  background: var(--orange);
  transform: none;
}

.btn-secondary { background: #fff; color: var(--ink); border-color: var(--gray-300); }
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); color: var(--ink); transform: none; }

.btn-danger { background: #fff; color: var(--red); border-color: var(--gray-300); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-icon { padding: 8px; }

/* Sticky footers — back links stay flat on hover */
.sop-footer-bar .btn-ghost:hover,
.export-footer-bar .btn-ghost:hover {
  transform: none;
}

/* === MAIN VIEWS === */
/* flex-basis 0 + min-height 0 lets this region shrink inside #app so overflow-y can scroll (welcome, etc.). */
.view {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  display: none;
  flex-direction: column;
}
.view.active { display: flex; }

/* === WELCOME VIEW === */
#view-welcome {
  align-items: center;
  justify-content: flex-start;
  padding: clamp(12px, 2.5vh, 24px) 16px 12px;
  min-height: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse at top left, rgba(0,139,139,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(232,119,34,0.04) 0%, transparent 50%),
    var(--paper);
}

.welcome-card {
  max-width: 1100px;
  width: 100%;
  flex: 0 0 auto;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  align-items: stretch;
}

.welcome-left {
  background: #FDF8F3;
  color: #2C2420;
  padding: 28px 32px 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  position: relative;
  z-index: 2;
  overflow: visible;
  min-width: 0;
}
.welcome-left::before {
  display: none;
}
.welcome-left-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 0 1 auto;
  min-height: 0;
  --welcome-preview-caption-font-size: 13px;
  --welcome-preview-caption-lines: 6;
  --welcome-preview-caption-gap: 22px;
}
.welcome-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8B6B4A;
  margin-bottom: 18px;
}
.welcome-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-weight: 400;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.06em;
  max-width: 100%;
}
.welcome-title-line1,
.welcome-title-line2 {
  display: block;
  max-width: 100%;
}
.welcome-title-line1 {
  color: #2C2420;
}
.welcome-title-line2 {
  margin-top: 0;
}
.welcome-title-line2 em {
  color: #C4956A;
  font-style: italic;
  font-weight: 500;
}

.welcome-sub {
  font-size: 13px;
  line-height: 1.45;
  color: #8B6B4A;
  max-width: 340px;
  margin-bottom: 4px;
}
.welcome-footer {
  font-size: 11px;
  color: #C4956A;
  opacity: 0.7;
  letter-spacing: 0.05em;
  position: relative; z-index: 1;
}

.welcome-right {
  padding: 20px 22px 16px;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: visible;
  /* Let clicks reach the sample preview when columns overlap (short viewports). */
  pointer-events: none;
}
.welcome-right :is(
  button,
  input,
  textarea,
  select,
  a,
  label,
  summary,
  [role="button"],
  [role="tab"],
  [tabindex]:not([tabindex="-1"])
) {
  pointer-events: auto;
}
.welcome-right h2 {
  font-size: var(--t-page-title-size);
  font-family: var(--font-display);
  font-weight: 400;
  margin-bottom: 6px;
}
.welcome-right .subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.template-card {
  padding: 11px 12px;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  text-align: left;
  transition: all 0.15s;
  cursor: pointer;
}
.template-card:hover { border-color: var(--orange); background: #fff; }
.template-card.is-previewing {
  border-color: var(--orange);
  background: #fff;
  box-shadow: 0 0 0 1px rgba(232, 93, 38, 0.2);
}
.template-card.selected {
  border-color: var(--orange);
  background: var(--orange-light);
  box-shadow: none;
}

.welcome-features { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; margin-top: 0; }
.welcome-feature { display: flex; gap: 12px; align-items: center; color: #2C2420; }
.welcome-feature-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--orange-light);
  color: var(--orange-dark);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.welcome-feature-num.done { background: var(--green); color: #fff; font-size: 12px; }
.welcome-feature-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; color: var(--ink); }

.welcome-cta-trust {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--gray-700);
  font-weight: 500;
}

.welcome-actions-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.welcome-left-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
}
/* F-05: template icons — color + symbol per type, not abbreviation */
.template-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  flex-shrink: 0;
  transition: filter 0.15s;
}
.template-icon svg { display: block; }
/* per-template background colors — warm brand palette */
.template-card[data-template="change"] .template-icon { background: #F0E8DF; }
.template-card[data-template="sop"]    .template-icon { background: #F0E8DF; }
.template-card[data-template="kb"]     .template-icon { background: #F0E8DF; }
.template-card[data-template="tipsheet"] .template-icon { background: #F0E8DF; }
.template-card[data-template="blank"]  .template-icon { background: #F0E8DF; }
/* selected state */
.template-card.selected[data-template="change"] .template-icon { background: #E8DDD0; }
.template-card.selected[data-template="sop"]    .template-icon { background: #E8DDD0; }
.template-card.selected[data-template="kb"]     .template-icon { background: #E8DDD0; }
.template-card.selected[data-template="tipsheet"] .template-icon { background: #E8DDD0; }
.template-card.selected[data-template="blank"]  .template-icon { background: #E8DDD0; }
.template-name { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 2px; }
.template-desc { font-size: 11px; color: var(--gray-500); line-height: 1.4; }

.welcome-left .welcome-template-preview {
  position: relative;
  z-index: 3;
  cursor: pointer;
  pointer-events: auto;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  --welcome-preview-scale: 0.32;
  --welcome-preview-w: calc(816px * var(--welcome-preview-scale));
  --welcome-preview-h: calc(1056px * var(--welcome-preview-scale));
  --welcome-preview-tilt-pad: 14px;
  margin: 8px 0 10px;
  flex-shrink: 0;
  max-width: 100%;
  overflow: visible;
}
.welcome-left .welcome-template-preview > * {
  pointer-events: none;
}
.welcome-left .welcome-template-preview-header {
  margin-bottom: 6px;
  pointer-events: none;
}
.welcome-left .welcome-template-preview-label {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.25;
  color: rgba(252, 251, 248, 0.72);
  margin-bottom: 0;
}
.welcome-left .welcome-template-preview-frame-wrap {
  width: var(--welcome-preview-w);
  height: var(--welcome-preview-h);
  min-width: var(--welcome-preview-w);
  min-height: var(--welcome-preview-h);
  flex-shrink: 0;
  overflow: hidden;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  box-shadow: none;
  position: relative;
  margin: 4px auto 0;
  transform: rotate(-2.75deg);
  transform-origin: center center;
  isolation: isolate;
}
.welcome-left .welcome-template-preview-visual {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  border-radius: inherit;
}
.welcome-left .welcome-template-preview:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.welcome-left .welcome-template-preview:focus-visible .welcome-template-preview-frame-wrap {
  background: rgba(44, 36, 32, 0.06);
}
.welcome-left .welcome-template-preview-tap-hint {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #2c2420;
  background: rgba(252, 251, 248, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.welcome-left .welcome-template-preview:hover .welcome-template-preview-tap-hint,
.welcome-left .welcome-template-preview:focus-visible .welcome-template-preview-tap-hint {
  opacity: 1;
}
.welcome-left .welcome-template-preview:hover .welcome-template-preview-frame-wrap {
  background: rgba(44, 36, 32, 0.06);
}
.welcome-left .welcome-template-preview.is-hover-preview {
  cursor: default;
}
.welcome-left .welcome-template-preview.is-hover-preview .welcome-template-preview-tap-hint {
  opacity: 1;
  background: rgba(252, 251, 248, 0.88);
  color: var(--gray-600);
}
@keyframes welcome-preview-shake {
  0%, 100% { transform: rotate(-2.75deg) translateX(0); }
  50% { transform: rotate(-2.78deg) translateX(0.5px); }
}
.welcome-left .welcome-template-preview-frame-wrap.welcome-template-preview-shake {
  animation: welcome-preview-shake 0.2s ease-out;
}
.welcome-left .welcome-template-preview-doc {
  position: absolute;
  top: 0;
  left: 0;
  width: 816px;
  min-height: 1056px;
  transform: scale(var(--welcome-preview-scale));
  transform-origin: top left;
  /* Sample covers use default export palette — not Settings → Theme doc accent on :root */
  --stepbinder-doc-accent: #C4956A;
  --stepbinder-doc-accent-dark: #A07548;
  --stepbinder-doc-note-bg: #FDF5EC;
  --stepbinder-doc-note-strong: #A07548;
  color: #1a1a1a;
}
.welcome-left .welcome-template-preview-doc .pp-page {
  box-shadow: none;
  margin: 0;
  color: #1a1a1a;
  background: #fff;
}
.welcome-left .welcome-template-preview-doc .pp-page-header,
.welcome-left .welcome-template-preview-doc .pp-page-footer {
  color: #888;
}
.welcome-left .welcome-template-preview-doc .pp-meta-table td {
  color: #1a1a1a;
}
.welcome-left .welcome-template-preview-doc .pp-cover-title {
  color: #1a1a1a;
}
.welcome-left .welcome-template-preview-doc .pp-cover-desc {
  color: #5a5a5a;
}
.welcome-left .welcome-template-preview-doc.is-loading {
  background: rgba(252, 251, 248, 0.92);
}
.welcome-left .welcome-template-preview-doc .welcome-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 816px;
  height: 1056px;
  font-size: 12px;
  color: #8a8a8a;
  background: #fff;
}
.welcome-left .welcome-template-preview-caption {
  margin: var(--welcome-preview-caption-gap) auto 0;
  flex-shrink: 0;
  height: calc(var(--welcome-preview-caption-font-size) * 1.45 * var(--welcome-preview-caption-lines));
  min-height: calc(var(--welcome-preview-caption-font-size) * 1.45 * var(--welcome-preview-caption-lines));
  max-width: var(--welcome-preview-w);
  font-size: var(--welcome-preview-caption-font-size);
  color: rgba(252, 251, 248, 0.62);
  line-height: 1.45;
  pointer-events: none;
  overflow: hidden;
}

.field-group { margin-bottom: 16px; }

/* Do not use margin-top: auto here — the grid row matches the taller column (often the left),
   which pushed the primary CTA to the bottom of a very tall row and off-screen without a scroll hint. */
.welcome-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 28px;
  padding-top: 4px;
}
.welcome-actions-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
}
#btn-start-capture { margin-left: 0; }

/* Welcome v3 */
.welcome-left {
  background: var(--teal);
  color: #FCFBF8;
}
.welcome-eyebrow { color: var(--orange); }
.welcome-title-line1 { color: #FCFBF8; }
.welcome-title-line2 { color: #FCFBF8; }
.welcome-sub { color: rgba(252,251,248,.72); }
.welcome-feature { color: rgba(252,251,248,.92); }
.welcome-feature-num {
  background: rgba(196,149,106,.15);
  border: 1px solid rgba(196,149,106,.4);
  color: var(--orange);
}
.welcome-feature-num.done {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--teal);
}
.welcome-feature-title { color: rgba(252,251,248,.92); }

.tour-cta {
  margin-top: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 12px 14px;
  background: rgba(252,251,248,.06);
  border: 1px solid rgba(196,149,106,.35);
  border-radius: 10px;
  color: #FCFBF8;
  text-align: left;
  transition: background .15s ease;
}
.tour-cta:hover { background: rgba(252,251,248,.1); }
.tour-cta:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.tour-cta-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tour-cta-play {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--orange); color: var(--teal);
  display: grid; place-items: center; flex-shrink: 0;
}
.tour-cta-textwrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tour-cta-text { font-size: 13px; font-weight: 600; line-height: 1.3; }
.tour-cta-sub { font-size: 11px; color: rgba(252,251,248,.6); line-height: 1.3; }
.tour-cta-chip {
  background: rgba(196,149,106,.18);
  color: var(--orange);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.welcome-tabs {
  display: flex;
  width: 100%;
  background: var(--gray-100);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 10px;
  flex-shrink: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.welcome-tab {
  font-family: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 1 1 0;
  min-width: 0;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease;
}
.welcome-tab:hover { color: var(--ink); }
.welcome-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.welcome-tab-count {
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  box-sizing: border-box;
}
.welcome-tab[data-empty="true"] .welcome-tab-count {
  visibility: hidden;
}
.welcome-tab-count--placeholder {
  visibility: hidden;
  pointer-events: none;
}

.welcome-panels {
  position: relative;
  flex: 0 1 auto;
  display: grid;
  grid-template-columns: 1fr;
}

.welcome-panel {
  display: flex;
  flex-direction: column;
  grid-area: 1 / 1 / 2 / 2;
  overflow: visible;
}
.welcome-panels > .welcome-panel[hidden] {
  display: flex;
  visibility: hidden;
  pointer-events: none;
  z-index: 0;
}
.welcome-panels > .welcome-panel:not([hidden]) {
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}
.welcome-panel > :first-child { margin-top: 0; }
#view-welcome .field-group { margin-bottom: 10px; }
#view-welcome .sop-field-hint {
  margin-top: 4px;
  margin-bottom: 0;
}
#view-welcome textarea.sop-input--grow {
  resize: none;
  overflow-y: hidden;
  line-height: 1.45;
}
#view-welcome #doc-title.sop-input--grow { min-height: 42px; }
#view-welcome #doc-desc {
  min-height: 52px;
  height: 52px;
  resize: vertical;
  overflow-y: auto;
  line-height: 1.45;
  box-sizing: border-box;
}
.welcome-panel h2 {
  font-size: var(--t-page-title-size);
  font-family: var(--font-display);
  font-weight: 400;
  margin-top: 0;
  margin-bottom: 6px;
}
.welcome-panel .subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 14px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recent-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
  font-family: inherit;
}
.recent-card:hover {
  border-color: var(--orange);
  background: var(--orange-light);
  transform: translateX(2px);
}
.recent-card:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.recent-thumb {
  width: 56px;
  height: 40px;
  border-radius: 5px;
  overflow: hidden;
  background: var(--gray-100);
}
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-meta { min-width: 0; }
.recent-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-sub {
  font-size: 11.5px;
  color: var(--gray-500);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.recent-sub .badge {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 10.5px;
}
.recent-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--gray-400); }
.recent-action { font-size: 11.5px; color: var(--gray-500); white-space: nowrap; transition: color .15s ease; }
.recent-card:hover .recent-action { color: var(--orange-dark); font-weight: 600; }
.recent-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--gray-500);
  font-size: 12.5px;
  border: 1px dashed var(--gray-200);
  border-radius: 10px;
  background: var(--gray-50);
}

.drop-zone {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px;
  border: 2px dashed var(--gray-300);
  border-radius: 10px;
  background: var(--gray-50);
  color: var(--gray-600);
  text-align: center;
  transition: all .2s ease;
}
.drop-zone.active {
  border-color: var(--orange);
  background: var(--orange-light);
  color: var(--orange-dark);
  transform: scale(1.01);
}
.drop-strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.drop-strong code { font-family: var(--font-mono); font-size: 11px; }
.drop-or { font-size: 11px; color: var(--gray-500); }
.drop-link {
  color: var(--orange-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
}
.drop-link:hover { color: var(--orange); }

.welcome-cta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}
.welcome-cta-row--single {
  justify-content: flex-end;
}
.welcome-alt-link {
  font-size: 12px;
  color: var(--gray-600);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
  font-family: inherit;
}
.welcome-alt-link:hover { color: var(--ink); text-decoration: underline; }

.welcome-drag-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(44,36,32,.85);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.welcome-drag-overlay.show { opacity: 1; }
.welcome-drag-overlay-card {
  background: var(--paper);
  border: 2px dashed var(--orange);
  border-radius: var(--radius-lg);
  padding: 36px 48px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.welcome-drag-overlay-card .arrow { font-size: 56px; color: var(--orange); margin-bottom: 6px; line-height: 1; }
.welcome-drag-overlay-card h3 { font-family: var(--font-display); font-size: 24px; font-weight: 500; color: var(--teal); }
.welcome-drag-overlay-card p { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

@media (max-height: 760px) {
  #view-welcome { padding: 8px 12px 10px; }
  .welcome-left { padding: 20px 22px 16px; }
  .welcome-right { padding: 16px 18px 12px; }
  .welcome-right .subtitle { margin-bottom: 12px; }
  .template-grid { margin-bottom: 10px; }
  #view-welcome .field-group { margin-bottom: 8px; }
  .welcome-left-content {
    --welcome-preview-caption-font-size: 12px;
    --welcome-preview-caption-lines: 5;
  }
  .welcome-left .welcome-template-preview {
    margin: 6px 0 8px;
    --welcome-preview-scale: 0.24;
  }
}

@media (max-width: 880px) {
  .welcome-card {
    grid-template-columns: 1fr;
  }
  .welcome-left {
    padding: 28px 24px 20px;
    position: relative;
    z-index: 2;
  }
  .welcome-right {
    position: relative;
    z-index: 1;
  }
}

.mode-indicator {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gray-300);
}
.mode-indicator.extension-on .dot { background: var(--green); }

/* === CAPTURE OVERLAY === */
#capture-overlay {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: none;
  align-items: center;
  gap: 14px;
  z-index: 10000;
  min-width: 320px;
}
#capture-overlay.visible { display: flex; }
.overlay-status {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.overlay-step-count {
  font-family: var(--font-display);
  font-size: 22px;
  font-style: italic;
  line-height: 1;
}
.overlay-step-count span { color: var(--orange); }
.overlay-hint {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.overlay-controls { display: flex; gap: 6px; }
.overlay-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  font-size: 14px;
  position: relative;
}
.overlay-btn:hover { background: rgba(255,255,255,0.24); }
.overlay-btn.stop { background: var(--red); }
.overlay-btn.stop:hover { background: #E04840; }
.overlay-btn.capture-now { background: var(--orange); }
.overlay-btn.capture-now:hover { background: var(--orange-dark); }
/* Switch source button — wider pill shape so it reads as distinct */
#btn-switch-source {
  width: auto;
  border-radius: 20px;
  padding: 0 10px;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,0.18);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
/* F-19: Switch label is now a real <span> child — no ::after needed */
#btn-switch-source:hover { background: rgba(255,255,255,0.32); }
#btn-capture-pip.pip-active { background: rgba(196,149,106,0.35); box-shadow: 0 0 0 1px rgba(196,149,106,0.5); }

/* flash on capture */
.capture-flash {
  position: fixed; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 99999;
  transition: opacity 0.15s;
}
.capture-flash.flash { opacity: 0.6; }

/* Review: hide workflow chrome on welcome */
.top-bar-progress.hidden { display: none !important; }

.template-card:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

