/*!
 * 123PhotoTool tool-page layout: one look for every tool.
 *
 * Every photo tool is the same five parts, in the same places:
 *
 *   .pt-tool               the tool card (title + grid)
 *   .pt-tool-panel         controls: upload zone, settings, then save
 *     .pt-tool-upload        the "Upload Photo / drop / paste" zone
 *     .pt-tool-save          format, quality and the Save button, last
 *   .pt-tool-stage         the editor column
 *     .pt-tool-viewport      the photo's box: empty state, then the canvas
 *     .pt-tool-empty         empty state: one Upload button and the samples
 *     .pt-tool-status        the one-line message under the photo
 *
 * Desktop: the photo on the left in a workspace of a fixed height, so the
 * editor is the same size from tool to tool, and the controls on the right
 * (mirrored in RTL). The photo column comes second in the markup and is
 * moved first with order-1 at every width. Phone:
 * the photo first, with its one Upload button; once a photo loads the
 * full-screen editor (pt-app.css) takes over.
 *
 * The pages carry years of inline styles (borders, fixed 450px boxes), so
 * the rules that set the shared look are !important by design.
 */
:root {
  --pt-radius: 16px;
  --pt-radius-sm: 12px;
  --pt-line: #e3e7ee;
  --pt-surface: #f6f8fb;
  --pt-ink: #343f52;
  --pt-muted: #6c757d;
  --pt-accent: var(--bs-primary, var(--pt-accent, #0f70e6));
  --pt-accent-soft: rgba(15, 112, 230, 0.06);
  --pt-ws-h: clamp(440px, 66vh, 720px);
  --pt-ws-h-phone: min(60vh, 520px);
}

/* Nothing on a phone page may push the layout wider than the screen: one
   stray element (a long FAQ question that would not wrap) widens the layout
   viewport, the page scrolls sideways and every tap lands off target. */
html { overflow-x: clip; }
/* Scrolling something into view (focus, #links, find, scrollIntoView) stops
   below the sticky header; --pt-head is its height (pt-app.js measures it). */
html { scroll-padding-top: calc(var(--pt-head, 78px) + 12px); }
/* The theme's body { overflow-x: hidden !important } stops reaching the
   viewport once <html> clips, and makes <body> a scroll container of its
   own: the window never scrolls, so the sticky header and back-to-top never
   show and phones keep their address bar open. clip makes no scroller. */
body { overflow-x: clip !important; }
.card-header .btn-link { white-space: normal; text-align: start; }
.card-header .btn-link > .uil { flex: none; margin-inline-start: 8px; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.pt-tool > h1,
.pt-tool > .pt-tool-title {
  font-size: clamp(1.45rem, 1.05rem + 1.3vw, 2.05rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1.5rem !important;
}

/* ── Controls panel ──────────────────────────────────────────────────────── */
.pt-tool-panel { gap: 0; }
.pt-tool-panel > * { width: 100%; }
.pt-tool-upload {
  border: 1.5px dashed #c5d3ea !important;
  border-radius: var(--pt-radius-sm) !important;
  background: var(--pt-accent-soft) !important;
  padding: 14px 12px !important;
  margin-bottom: 1.25rem !important;
  transition: border-color 0.15s, background-color 0.15s;
}
.pt-tool-upload:hover { border-color: var(--pt-accent) !important; }
.pt-tool-upload .btn { min-height: 46px; font-weight: 600; }
.pt-tool-upload p { margin-bottom: 0 !important; }
/* Each setting: name on the left, live value on the right, control below. */
.pt-tool-panel .form-label { color: var(--pt-ink); font-weight: 600; }
/* The value keeps its own order: "20 px" in an Arabic page otherwise reads
   "px 20" (the phone editor's readout does the same). */
.pt-tool-panel .form-label > span[id$="-value"],
.pt-tool-panel [id$="-value"].fw-bold { font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
.pt-tool-panel .form-range { height: 1.75rem; }

/* ── Sliders: one line each ──────────────────────────────────────────────
   Name, track and live value on a single line, as the phone editor's own
   slider is, instead of a name row, a track row and often a row of min/max
   or tick labels (62-101 px a slider). The pages write their sliders in a
   few dozen ways; the two shapes nearly all of them share are laid out here,
   with the rows that only group things stepping aside (display: contents),
   so no page's markup changes. The phone sheet too: it lifts the controls
   out of the panel. Grid columns follow the page direction (RTL).
   Shape 1: <div><label class="form-label"><span>Name</span><span>50%</span></label>
            <input class="form-range"> [<div>0% 50% 100%</div>]</div>
            (several such pairs under one heading work too: each fills a line)
   Shape 2: <div><div><label class="form-label">Name</label><span>50</span>[<button>]</div>
            <div><span>min</span><input class="form-range"><span>max</span></div>
            [<div><small>Gray</small><small>Vivid</small></div>]</div>
            (or the range straight after the first row) */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) {
  display: grid;
  /* The sizes come from pt-theme.css on a desktop (compact rows); the
     fallbacks are the phone sheet's. */
  grid-template-columns: var(--pt-sl-cols, minmax(5.5rem, 32%) minmax(0, 1fr) minmax(2.75rem, max-content));
  grid-auto-flow: row dense;
  align-items: center;
  column-gap: var(--pt-sl-cgap, 0.75rem);
  row-gap: 0.25rem;
  min-height: var(--pt-sl-h, 0);
  margin-bottom: var(--pt-sl-gap, 0.625rem) !important;
}
/* A page that shows a slider again with style.display = 'block'. */
:is(.pt-tool-panel, .pt-app-sheet) div[style*="display: block"]:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))),
:is(.pt-tool-panel, .pt-app-sheet) div[style*="display: block"]:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) {
  display: grid !important;
}
/* The rows that only group things step aside. */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > label.form-label:has(> span + span:last-child):not(:has(> :nth-child(3))),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > :first-child,
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > div:nth-child(2) {
  display: contents !important;
}
/* The name. */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > label.form-label:has(> span + span:last-child):not(:has(> :nth-child(3))) > span:first-child,
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > label.form-label:not(:has(> span + span:last-child):not(:has(> :nth-child(3)))),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > :first-child > label.form-label {
  grid-column: 1;
  margin: 0 !important;
  min-width: 0;
  width: auto !important;
  text-align: start !important;
  line-height: 1.25;
  overflow-wrap: anywhere;
  hyphens: auto;
}
/* The track. */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > input.form-range,
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > input.form-range,
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > div:nth-child(2) > input.form-range {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  margin: 0 !important;
}
/* A label with no value beside it: the track takes the value's place too, so
   every line is full and the next slider cannot back-fill a gap. */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > label.form-label:not(:has(> span + span:last-child):not(:has(> :nth-child(3)))) + input.form-range {
  grid-column: 2 / -1;
}
/* The value, at the end of the line (the absolute centring some pages use
   for it under the name is undone). */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > label.form-label:has(> span + span:last-child):not(:has(> :nth-child(3))) > span:last-child,
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > :first-child > :not(label):not(button) {
  grid-column: 3;
  justify-self: end;
  text-align: end;
  white-space: nowrap;
  position: static !important;
  transform: none !important;
  width: auto !important;
  margin: 0 !important;
}
/* A button beside the value (the editor's on/off eye). */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > :first-child > button {
  grid-column: 4;
}
/* Min/max ends, tick rows and end words: the value already says where the
   slider is (the colour pages' tracks are painted with their range). */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > input.form-range ~ div:not(:has(> :not(span))),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > div:nth-child(2) > :is(span, small),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > div:nth-child(3):has(> :nth-child(2)) {
  display: none !important;
}
/* Anything else in a group (a heading, a hint, a note): a line of its own. */
:is(.pt-tool-panel, .pt-app-sheet) div:has(> label.form-label + input.form-range):is(:not(:has(> input.form-range ~ input.form-range)), :not(:has(> :not(label.form-label, input.form-range, .form-label)))) > :not(label.form-label):not(input.form-range),
:is(.pt-tool-panel, .pt-app-sheet) div:has(> :first-child > label.form-label):is(:has(> input.form-range:nth-child(2)), :has(> :nth-child(2) > input.form-range)):not(:has(> :nth-child(4))):not(:has(> :first-child input.form-range)):not(:has(> :nth-child(n+2) label)):not(:has(> :nth-child(3) > :not(span, small))) > :nth-child(3) {
  grid-column: 1 / -1;
}
/* ── /sliders ── */

.pt-tool-save {
  border-top: 1px solid var(--pt-line);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  margin-bottom: 0 !important;
}
.pt-tool-savebar { margin-top: 0.25rem; margin-bottom: 0 !important; display: flex; flex-wrap: wrap; gap: 8px; }
.pt-tool-savebar > .btn:not(.btn-success) { min-height: 50px; flex: 1 0 auto; }
.pt-tool-save .btn-success,
.pt-tool-savebar .btn-success {
  width: 100%;
  min-height: 50px;
  font-weight: 600;
  font-size: 1rem;
  /* Bootstrap's own: smudge and blur-editor set every phone button to 1.4,
     which made their Save 6px shorter than everyone else's. */
  line-height: var(--bs-btn-line-height);
}
/* A second button sits beside Save at its own size while the two fit; when
   they do not ("Copy Color Information", "Farbinformationen kopieren") each
   takes a full row. Labels wrap rather than run out of the bar (.btn is
   nowrap). The grow weights keep the spare room on Save's side. */
.pt-tool-savebar > .btn { min-width: 0; max-width: 100%; white-space: normal; }
.pt-tool-savebar > .btn-success { width: auto; flex: 1000 1 auto; }

/* Save in progress (pt-app.js): the button holds a spinner until the file is
   ready, and a second click is ignored. */
.btn.pt-saving { position: relative; color: transparent !important; pointer-events: none; }
.btn.pt-saving::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 3px solid rgba(30, 34, 40, 0.25);
  border-top-color: #1e2228;
  animation: pt-ui-spin 0.8s linear infinite;
}
@keyframes pt-ui-spin { to { transform: rotate(360deg); } }

/* ── Editor ──────────────────────────────────────────────────────────────── */
.pt-tool-viewport {
  position: relative;
  width: 100%;
  min-height: 420px !important;
  max-height: none !important;
  max-width: none !important;
  border: 1px solid var(--pt-line) !important;
  border-radius: var(--pt-radius) !important;
  background: var(--pt-surface) !important;
  box-shadow: none !important;
}
/* A workspace of one size on every tool, empty or loaded (so nothing jumps
   when the photo arrives); the photo is fitted in it. */
@media (min-width: 768px) {
  .pt-tool-viewport { height: var(--pt-ws-h) !important; }
  /* Where the settings run longer than the photo box, the photo stays in
     view while the lower settings are used (below the fixed header). */
  .pt-tool-stage { position: sticky; top: calc(var(--pt-head, 78px) + 10px); align-self: flex-start; }
  /* A tool's own toolbars (Undo / Redo, zoom) sit in one row under the
     photo, so the photo box starts level with the upload box as on every
     other tool. */
  .pt-tool-stage:has(> .pt-tool-deskbar) {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center !important;
    column-gap: 12px;
  }
  .pt-tool-stage:has(> .pt-tool-deskbar) > * { flex: 0 0 100%; order: 2; }
  .pt-tool-stage:has(> .pt-tool-deskbar) > .pt-tool-viewport { order: 0; }
  /* One button height, icon font or SVG, so toolbars side by side line up;
     an icon and its label sit 6px apart. */
  .pt-tool-deskbar .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding-top: 0; padding-bottom: 0; }
  .pt-tool-deskbar .btn > .uil { line-height: 1; }
  .pt-tool-stage > .pt-tool-deskbar {
    order: 1 !important;
    flex: 0 1 auto !important;
    width: auto !important;
    margin: 12px 0 0 !important;
    /* Never wider than the photo box: long labels (de, fr, ru) wrap to a
       second row instead of running past the card at tablet widths. */
    max-width: 100%;
    flex-wrap: wrap;
    row-gap: 8px;
  }
}
/* Tablet portrait (iPad, 768-991px wide): side by side, the photo box was
   ~360px wide and 720 tall, so a landscape photo was a 334x250 strip in the
   middle of it. The photo goes on top at the full width, the settings under
   it, and the box takes about half the screen so the first settings are in
   view under it. Landscape tablets and small laptop windows keep the
   columns. */
@media (min-width: 768px) and (max-width: 991.98px) and (orientation: portrait) {
  :root { --pt-ws-h: clamp(420px, 50vh, 620px); }
  .pt-tool .pt-tool-stage,
  .pt-tool .pt-tool-panel { flex: 0 0 100% !important; width: 100% !important; max-width: 100% !important; }
  .pt-tool .pt-tool-stage { order: 1 !important; position: static; }
  .pt-tool .pt-tool-panel { order: 2 !important; margin-top: 1.25rem; }
}
.pt-fit-page .pt-app-fit {
  width: var(--pt-fit-w) !important;
  height: var(--pt-fit-h) !important;
  max-width: none !important;
  max-height: none !important;
}
.pt-tool-empty-upload { min-height: 48px; font-weight: 600; padding-left: 1.5rem; padding-right: 1.5rem; }
.pt-tool-status {
  min-height: 1.5em;
  font-size: 0.875rem;
  color: var(--pt-muted);
  text-align: center;
}

/* Desktop extras the shell adds to the photo box (pt-app.js). */
.pt-vbar {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  z-index: 6;
  display: none;
  gap: 6px;
}
.pt-app-loaded > .pt-vbar { display: flex; }
html.pt-phone .pt-vbar { display: none !important; }
.pt-vbar-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--pt-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
  padding: 0;
}
.pt-vbar-btn svg { width: 20px; height: 20px; }
.pt-vbar-btn:hover { background: #fff; color: var(--pt-accent); }
.pt-vbar-btn.pressed { background: var(--pt-accent); color: #fff; }
.pt-compare-label {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 6;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  display: none;
}
.pt-comparing > .pt-compare-label { display: block; }

/* Drop a photo anywhere on a tool page (desktop). */
.pt-drop {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 112, 230, 0.14);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.pt-drop.show { display: flex; }
.pt-drop-card {
  padding: 28px 40px;
  border: 2px dashed var(--pt-accent);
  border-radius: 20px;
  background: #fff;
  color: var(--pt-ink);
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

/* ── Phone page ──────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .pt-tool { padding: 1rem !important; }
  .pt-tool > h1, .pt-tool > .pt-tool-title { margin-bottom: 1rem !important; }
  .pt-tool-viewport { min-height: 320px !important; }
  /* Between editing sessions the photo is a picture on the page: the box
     hugs it (pt-app.js fits it to the width and a share of the height). */
  /* Scoped to the page column: in the editor the box sits in the stage. */
  .pt-tool-stage > .pt-tool-viewport.pt-app-loaded.pt-fit-page { height: auto !important; min-height: 0 !important; }
  .pt-tool-stage > .pt-tool-viewport.pt-app-loaded:not(.pt-fit-page) { height: var(--pt-ws-h-phone) !important; }
  /* One way in: the Upload button in the photo box, not a second one above. */
  .pt-tool .pt-tool-mobile-upload { display: none !important; }
  .pt-tool .pt-tool-empty-upload { display: flex !important; }
  .pt-tool-panel { margin-top: 1rem !important; }
  /* iOS zooms the page into any field under 16px when it is tapped, and
     the theme's are 15px. */
  .pt-tool .form-select, .pt-tool .form-control { font-size: 16px; }
  /* With the phone editor, every control lives in it: the page is the
     title, the photo box and the content. (In the editor's sheet the panel
     is no longer inside .pt-tool, so this does not reach it there.) */
  /* .pt-tool-app is in the markup, not set by script, so nothing shifts. */
  .pt-tool.pt-tool-app .pt-tool-panel { display: none !important; }
  /* Toolbars over the photo (Undo / Redo, zoom) live in the editor's top
     bar on a phone. */
  .pt-tool.pt-tool-app .pt-tool-deskbar { display: none !important; }
  /* "drag & drop" means nothing on a phone; the box says what to do. An
     error stays (a file that would not open, a photo too big for the tool):
     with no photo in, the editor never opens to say it. */
  .pt-tool.pt-tool-app .pt-tool-stage:has(.pt-tool-viewport:not(.pt-app-loaded)) .pt-tool-status:not(.text-danger) { display: none; }
}

/* "Continue editing with" buttons: the theme's 20px side padding and nowrap
   left a 107px button 63px for its name, so de "Weichzeichen-Pinsel" or tr
   "Bulanıklaştırma Fırçası" ran past the border. Long names wrap now, and
   every button in a row keeps the row's height. */
.continue-to-btn {
  --bs-btn-padding-x: .35rem;
  white-space: normal;
  line-height: 1.2;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.continue-to-btn > span { white-space: normal; overflow-wrap: break-word; }
