/* QuickWerx.Convert — Project Phoenix "Translate Editor".
   Vanilla-CSS implementation of Figma node 604:3, driven by phoenix-editor.js
   (pdf.js renders the page thumbnails + document surface). Scoped under .ph-*
   so it never collides with the editor bundle or the .tv-* viewer styles. */

:root {
  --ph-line: #ddd7ca;          /* color/line        */
  --ph-paper: #f8f4ec;         /* color/paper       */
  --ph-accent: #ff7b3d;        /* color/accent      */
  --ph-text-2: #6e7490;        /* color/text-2      */
  --ph-ink-600: #3a4566;       /* color/ink-600     */
  --ph-page-border: #eaebed;   /* wss_global secondary cta/copy t-600 */
  --ph-badge: rgba(0, 0, 0, 0.6);

  --ph-page-w: 820px;          /* rendered page sheet width */

  --ph-font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --ph-font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ph-paper);
  font-family: var(--ph-font-ui);
  color: var(--ph-ink-600);
}

.ph-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===================== Nav / Light (604:4) ===================== */
.ph-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  padding: 18px 40px;
  background: #fff;
  border-bottom: 1px solid var(--ph-line);
  overflow: hidden;
  flex-shrink: 0;
}

.ph-nav-left {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-shrink: 0;
  min-width: 0;
}

.ph-logo {
  display: block;
  width: 137px;
  height: 31px;
  flex-shrink: 0;
}
.ph-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }

.ph-breadcrumb { min-width: 0; overflow: hidden; }
.ph-breadcrumb p {
  margin: 0;
  font-weight: 400;
  font-size: 11px;
  line-height: normal;
  letter-spacing: 1.1px;
  color: var(--ph-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ph-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* Preview / Full mode toggle */
.ph-mode {
  display: inline-flex;
  padding: 3px;
  background: var(--ph-paper);
  border: 1px solid var(--ph-line);
  border-radius: 999px;
}
.ph-mode button {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 999px;
  font-family: var(--ph-font-ui);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: var(--ph-text-2);
}
.ph-mode button.is-active {
  background: #fff;
  color: var(--ph-ink-600);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* CTA (604:24) */
.ph-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 15px 75px;
  background: var(--ph-accent);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
}
.ph-cta span {
  font-weight: 700;
  font-size: 16px;
  line-height: normal;
  letter-spacing: 1.92px;
  color: #fff;
  white-space: nowrap;
}
.ph-cta:hover { background: #f56a28; }

/* ===================== Workspace (604:42) ===================== */
.ph-main {
  flex: 1 0 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
  background: var(--ph-paper);
  width: 100%;
}

/* Thumbnail Rail (604:43) */
.ph-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 248px;
  flex-shrink: 0;
  padding: 24px 20px;
  background: #fff;
  border-right: 1px solid var(--ph-line);
  overflow-y: auto;
}

.ph-rail-title {
  margin: 0;
  font-weight: 400;
  font-size: 11px;
  line-height: normal;
  letter-spacing: 1.32px;
  color: var(--ph-text-2);
  white-space: nowrap;
}

/* Thumb Grid (604:45) */
.ph-thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  align-items: start;
  justify-items: center;
  width: 100%;
}

/* Each thumbnail: 97 x 130 box holding a rendered page canvas + number badge. */
.ph-thumb {
  position: relative;
  width: 97px;
  height: 130px;
  padding: 0;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--ph-ink-600);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  color: inherit;
}
.ph-thumb--active { border: 2px solid var(--ph-accent); }
.ph-thumb--clickable { cursor: pointer; transition: transform 0.08s ease, box-shadow 0.08s ease; }
.ph-thumb--clickable:hover { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16); }
.ph-thumb--clickable:hover:not(.ph-thumb--active) { border-color: var(--ph-accent); }

.ph-media { display: block; max-width: 100%; }

/* Locked thumbnails (preview mode, pages 2..N) */
.ph-thumb--locked { cursor: default; }
.ph-thumb--locked .ph-media { filter: blur(3px) grayscale(0.45); opacity: 0.4; }
.ph-thumb-lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ph-ink-600);
  background: rgba(248, 244, 236, 0.35);
}

/* Page-number badge (604:57) */
.ph-thumb-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 22px;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ph-badge);
  border-radius: 3px;
  font-family: var(--ph-font-mono);
  font-size: 9px;
  line-height: normal;
  color: #fff;
  z-index: 2;
}

/* ===================== Document surface (604:178) ===================== */
.ph-doc {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px 24px 56px;
  overflow: auto;
}

/* A rendered page sheet (604:179 look): white, soft border, drop shadow. */
.ph-page {
  position: relative;
  width: var(--ph-page-w);
  max-width: 100%;
  flex-shrink: 0;
  background: #fff;
  border: 2px solid var(--ph-page-border);
  border-radius: 10.728px;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.ph-page .ph-media { width: 100%; height: auto; }

/* DOCX preview: soft blur + fade at the height-slice cutoff so the previewed
   page trails off intentionally instead of showing a hard mid-content chop.
   The mask ramps the blur/fade in from ~0 at the top of the strip to full at
   the bottom edge; the gradient dissolves the last lines into the page. */
.ph-page-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 190px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.85) 65%, #fff 100%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 55%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 55%);
}

/* A docx "page" — a fixed-size window onto the height-paginated rendered content. */
.ph-doc-window,
.ph-doc-flow { position: relative; overflow: hidden; background: #fff; }
.ph-doc-slice { transform-origin: top left; }
/* Neutralize docx-preview's own page chrome; our .ph-page provides the sheet. */
.ph-doc-window .docx,
.ph-doc-flow .docx { box-shadow: none !important; margin: 0 !important; }

/* Continuous (full) view: each page is its own sheet with a gap between them,
   so a multi-page document reads as separate pages — not one tall block. The
   wrapper is chrome-less; the per-page sheet look moves onto each PDF canvas. */
.ph-page--continuous {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.ph-flow { display: block; }
.ph-flow .ph-media { display: block; width: 100%; height: auto; }
/* Only PDF page canvases become separated sheets; docx height-slices
   (div.ph-media) keep flowing seamlessly with no chrome or gap. */
.ph-flow > canvas.ph-media {
  box-sizing: border-box;
  background: #fff;
  border: 2px solid var(--ph-page-border);
  border-radius: 10.728px;
  box-shadow: 0 4px 4px 0 rgba(0, 0, 0, 0.25);
}
.ph-flow > canvas.ph-media:not(:last-child) { margin-bottom: 28px; }

/* TXT — plain text rendered into a letter-proportioned page (then height-sliced). */
.ph-txt {
  background: #fff;
  box-sizing: border-box;
  padding: 72px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.75;
  color: #1c2333;
}

/* PPTX renders as a converted PDF (server-side), so slides flow through the PDF
   path above — no bespoke slide-card styling needed. */

/* Locked panel shown after page 1 in preview mode. */
.ph-locked {
  width: var(--ph-page-w);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.6);
  border: 2px dashed var(--ph-line);
  border-radius: 10.728px;
}
.ph-locked-icon { color: var(--ph-accent); line-height: 0; }
.ph-locked-title { margin: 4px 0 0; font-size: 18px; font-weight: 700; color: var(--ph-ink-600); }
.ph-locked-sub { margin: 0; font-size: 14px; color: var(--ph-text-2); }
.ph-unlock-btn { margin-top: 12px; }
.ph-unlock-btn span { letter-spacing: 1.2px; font-size: 14px; }

/* ===================== rail-less views (spreadsheet, plain text) ===================== */
.ph-app--norail .ph-rail { display: none; }

/* After translation the rail is removed, but the doc surface keeps its normal
   centered/scrollable layout (unlike the sheet/text norail treatment). */
.ph-app--converted .ph-rail { display: none; }
.ph-app--norail .ph-doc { padding: 0; align-items: stretch; overflow: hidden; }

/* Plain text — one scrollable document, clamped + blur-beyond in preview. */
.ph-text-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 32px 24px;
}
.ph-text-scroll.is-clamped { overflow: hidden; }
.ph-text-scroll .ph-txt {
  width: 100%;
  max-width: 820px;
  align-self: flex-start;
  border-radius: 10px;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
}

/* ===================== spreadsheet view (xlsx / csv) ===================== */

.ph-sheet {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.ph-sheet-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}
.ph-sheet-scroll.is-clamped { overflow: hidden; }

/* Grid (SheetJS sheet_to_html output) */
.ph-grid table {
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.08);
}
.ph-grid td,
.ph-grid th {
  border: 1px solid #e4e0d6;
  padding: 5px 12px;
  white-space: nowrap;
  color: var(--ph-ink-600);
}
.ph-grid tr:first-child td {
  background: #f3efe6;
  font-weight: 700;
}

/* Blur everything beyond the visible viewport in preview mode. */
.ph-sheet-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 55%;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(248, 244, 236, 0) 0%, rgba(248, 244, 236, 0.55) 55%, var(--ph-paper) 100%);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 42%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 42%);
}
.ph-sheet-unlock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 28px;
}
.ph-sheet-unlock .ph-cta { pointer-events: auto; }
.ph-sheet-unlock .ph-unlock-btn span { letter-spacing: 1.2px; font-size: 14px; }

/* Sheet tabs, pinned at the bottom like a spreadsheet app. */
.ph-sheet-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 0;
  background: #fff;
  border-top: 1px solid var(--ph-line);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none; /* Firefox — hide the scrollbar but keep scrollability */
  -ms-overflow-style: none;
}
.ph-sheet-tabs::-webkit-scrollbar { display: none; } /* WebKit/Blink */
.ph-sheet-tab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: 0;
  background: var(--ph-paper);
  color: var(--ph-text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 7px 7px 0 0;
  cursor: pointer;
  white-space: nowrap;
}
.ph-sheet-tab:hover:not(.is-active):not(.is-locked) { color: var(--ph-ink-600); }
.ph-sheet-tab.is-locked { opacity: 0.55; cursor: default; }
.ph-tab-lock {
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  color: var(--ph-text-2);
  vertical-align: middle;
}
.ph-sheet-tab.is-active {
  background: #fff;
  color: var(--ph-accent);
  border-color: var(--ph-line);
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.05);
  position: relative;
  top: 1px;
}

/* ---------------- loading / error ---------------- */
.ph-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 12vh;
  color: var(--ph-text-2);
}
.ph-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid #e6e1d5;
  border-top-color: var(--ph-accent);
  border-radius: 50%;
  animation: ph-spin 0.9s linear infinite;
}
@keyframes ph-spin { to { transform: rotate(360deg); } }

.ph-fallback { margin-top: 12vh; max-width: 460px; text-align: center; }
/* Keeps .ph-doc centred, unlike .ph-app--norail. */
.ph-app--error .ph-rail { display: none; }
.ph-fallback-title { font-size: 20px; font-weight: 700; margin: 0 0 8px; color: var(--ph-ink-600); }
.ph-fallback-sub { font-size: 14px; color: var(--ph-text-2); margin: 0; }

/* ===================== convert mode: modals ===================== */

/* The dev Preview/Full toggle is hidden in the convert product. */
.ph-app--convert .ph-mode { display: none; }

.ph-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 35, 51, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.ph-modal-overlay[hidden] { display: none; }

.ph-modal {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #fff;
  border: 1px solid var(--ph-line);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  padding: 32px 32px 28px;
}
.ph-modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--ph-text-2);
  cursor: pointer;
}
.ph-modal-close:hover { color: var(--ph-ink-600); }
/* ---------- format picker: Translate picker chrome (2080:3146) + DocEditor
   download rows (21:267 collapsed / 21:696 expanded) ---------- */
.ph-modal--picker {
  max-width: 599px;
  max-height: 650px;
  background: var(--ph-paper);
  border: 0;
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.ph-picker-body { display: flex; flex-direction: column; min-height: 0; }
.ph-picker-head { display: flex; flex-direction: column; }
/* 21:269 — Inter Black 36, accent on the emphasised run. */
.ph-picker-title { margin: 0; font-size: 36px; font-weight: 900; line-height: normal; color: #1c2038; text-align: start; }
.ph-picker-title span { color: var(--ph-accent); }
/* 21:271 */
.ph-picker-sub { margin: 4px 0 0; font-size: 20px; font-weight: 400; line-height: 1.5; color: var(--ph-text-2); text-align: start; }

.ph-picker-controls { display: flex; flex-direction: column; min-height: 0; }

/* 21:605 — rows 10px apart, 20px under the heading. */
.ph-fmt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0 0;
  padding: 0 4px 0 0;
  list-style: none;
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #687585 transparent;
}
.ph-fmt-list::-webkit-scrollbar { width: 5px; }
.ph-fmt-list::-webkit-scrollbar-track { background: transparent; }
.ph-fmt-list::-webkit-scrollbar-thumb { background: #687585; border-radius: 100px; }

.ph-fmt-opt.is-extra { display: none; }
.is-expanded .ph-fmt-opt.is-extra { display: block; }
.ph-fmt-more { display: flex; }
.is-expanded .ph-fmt-more { display: none; }
.ph-fmt-less { display: none; }

/* 21:688 / 21:613 — the selected ring is an inset shadow, so 1px→2px can't shift content. */
.ph-fmt-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 20px 10px;
  border: 0;
  border-radius: 15px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #a8afc4;
  cursor: pointer;
  text-align: start;
  font: inherit;
  overflow: hidden;
}
.ph-fmt-row:hover { box-shadow: inset 0 0 0 1px var(--ph-accent); }
.ph-fmt-row:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ph-accent); }
.ph-fmt-row input { position: absolute; opacity: 0; pointer-events: none; }

/* 21:690 — 75px chip, Inter Bold 20 white. PNG/JPEG (21:749/21:765) size to content. */
.ph-fmt-chip {
  flex: none;
  box-sizing: border-box;
  width: 75px;
  padding: 5px;
  border-radius: 15px;
  font-size: 20px;
  font-weight: 700;
  line-height: normal;
  letter-spacing: -0.5px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
}
.ph-fmt-chip.is-auto { width: auto; padding: 5px 10px; }
.ph-fmt-chip.is-pdf { background: #ff6b6b; }
.ph-fmt-chip.is-docx { background: #5f9fe8; }
.ph-fmt-chip.is-txt { background: #6b7389; }
.ph-fmt-chip.is-png,
.ph-fmt-chip.is-jpeg { background: #ffc06e; }
.ph-fmt-chip.is-xlsx { background: #4eb87c; }
.ph-fmt-chip.is-pptx { background: #ff9e6e; }

/* 21:693 / 21:694 */
.ph-fmt-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ph-fmt-name { font-size: 16px; font-weight: 700; line-height: 1; color: #1c2038; }
.ph-fmt-desc { font-size: 12px; font-weight: 400; line-height: normal; color: var(--ph-text-2); }

/* 21:677 — the same card, with a 24px glyph where the chip would be. */
.ph-fmt-more { margin-top: 10px; padding-left: 20px; flex: none; }
.ph-fmt-glyph { flex: none; display: inline-flex; width: 24px; height: 24px; color: #1c2038; }
.ph-fmt-glyph svg { width: 24px; height: 24px; }

/* 23:789 — replaces the card once expanded. */
.is-expanded .ph-fmt-less {
  display: flex;
  flex: none;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: none;
  color: #5f9fe8;
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.36px;
  cursor: pointer;
}
.is-expanded .ph-fmt-less svg { width: 24px; height: 24px; }

/* 21:349 — full-width accent pill, 30px below the block. */
.ph-fmt-submit {
  width: 100%;
  margin-top: 30px;
  padding: 20px 40px;
  border: 0;
  border-radius: 100px;
  background: var(--ph-accent);
  color: #fff;
  cursor: pointer;
  display: block;
  text-align: center;
  white-space: nowrap;
}
.ph-fmt-submit:hover { background: #f2691f; }
.ph-fmt-submit span { font-size: 18px; font-weight: 700; line-height: 1.2; letter-spacing: 0.36px; text-transform: uppercase; }

.ph-modal--progress {
  max-width: 440px;
  border: 1px solid var(--ph-accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 40px 32px 34px;
}

/* loading / completed states — mirror the DocEditor.QuickWerx convert modal */
.ph-convert-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}
.ph-convert-state[hidden] { display: none; }
.ph-convert-text { display: flex; flex-direction: column; }
.ph-convert-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--ph-accent); white-space: nowrap; }
.ph-convert-sub { margin: 0; font-size: 13px; line-height: 1.5; color: #6e7490; }
.ph-success-title { margin: 0; font-size: 22px; font-weight: 700; color: #4eb87c; white-space: nowrap; }
.ph-check-anim { width: 120px; height: 120px; }
#ph-complete-download { margin-top: 6px; }

/* Branded qwSpinner (same as DocEditor.QuickWerx) */
.qw-spinner-svg { width: 124px; height: 124px; display: block; }
.qw-spinner-rotator {
  transform-box: view-box;
  transform-origin: 44px 44px;
  animation: qwSpinnerSpin 1.2s linear infinite;
}
@keyframes qwSpinnerSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* mobile strip breadcrumb — hidden on desktop (nav shows it there) */
.ph-rail-crumb { display: none; }

@media (max-width: 720px) {
  .ph-nav { padding: 12px 16px; }
  .ph-nav-left { gap: 16px; }
  .ph-mode { display: none; }
}

/* ===================== mobile (Figma node 2084:3494) =====================
   Nav = logo + CTA only; the left rail becomes a horizontal top strip
   (breadcrumb + scrollable thumbnails); the document goes full-width. */
@media (max-width: 640px) {
  .ph-nav { padding: 12px 16px; height: auto; min-height: 60px; }
  .ph-breadcrumb { display: none; }
  .ph-cta { padding: 10px 20px; }
  .ph-cta span { font-size: 14px; letter-spacing: 1.2px; }

  .ph-main { flex-direction: column; }
  .ph-rail {
    width: 100%;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--ph-line);
    overflow-y: visible;
    flex-shrink: 0;
  }
  .ph-rail-title { display: none; }
  .ph-rail-crumb {
    display: block;
    margin: 0;
    font-size: 11px;
    letter-spacing: 1.1px;
    color: var(--ph-text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ph-thumb-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    justify-items: initial;
    align-items: initial;
    scrollbar-width: thin;
  }
  .ph-thumb { width: 52px; height: 62px; border-radius: 3px; }
  .ph-thumb canvas,
  .ph-thumb .ph-media { width: 100% !important; height: auto !important; }
  .ph-thumb-badge { display: none; }

  .ph-doc { padding: 20px 12px 40px; gap: 20px; }
  .ph-page { border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
  /* Continuous view: tighter gap + lighter sheet on small screens. */
  .ph-flow > canvas.ph-media { border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); }
  .ph-flow > canvas.ph-media:not(:last-child) { margin-bottom: 16px; }
  /* The rendered page canvas carries an inline width:820px; scale it to the
     viewport (override the inline style) so the document isn't stretched/clipped. */
  .ph-doc .ph-media { width: 100% !important; height: auto !important; }

  /* modals: centered, fit the viewport, scroll only if taller than the screen */
  .ph-modal-overlay { padding: 12px; align-items: center; overflow-y: auto; }
  .ph-modal { padding: 24px 18px 22px; }
  .ph-modal--picker { max-width: 100%; max-height: none; padding: 20px; }
  .ph-modal--progress { max-width: 100%; }
  .ph-picker-title { font-size: 26px; }
  .ph-picker-sub { font-size: 15px; }
  .ph-fmt-list { max-height: 46vh; gap: 8px; margin-top: 14px; }
  /* Desktop's 20px padding plus a two-line description made ~90px rows, so only
     four fit. Trim the padding and chip instead of clipping the description. */
  .ph-fmt-row { padding: 12px 10px; gap: 8px; border-radius: 12px; }
  .ph-fmt-chip { width: 58px; padding: 4px; border-radius: 12px; font-size: 16px; }
  .ph-fmt-chip.is-auto { padding: 4px 8px; }
  .ph-fmt-name { font-size: 15px; }
  .ph-fmt-desc { font-size: 11.5px; line-height: 1.3; }
  .ph-fmt-more { margin-top: 8px; padding-left: 14px; }
  .ph-fmt-glyph, .ph-fmt-glyph svg { width: 20px; height: 20px; }
  .ph-fmt-submit { margin-top: 18px; padding: 16px 20px; }
  .ph-fmt-submit span { font-size: 16px; }
  .is-expanded .ph-fmt-less { margin-top: 8px; font-size: 16px; }
  .is-expanded .ph-fmt-less svg { width: 20px; height: 20px; }
  /* titles are nowrap on desktop; let them wrap on mobile so they don't clip */
  .ph-convert-title,
  .ph-success-title { white-space: normal; }
}
