.epicmats-designer{
    --ink:#141414;
    --ink-soft:#6B6B6B;
    --paper:#FFFFFF;
    --paper-dim:#F2F2F2;
    --line:#DEDEDE;
    --accent:#FCED1D;
    --accent-ink:#141414;
    --accent-soft:#FFF9C2;
    --success:#1F8A4C;
    --success-soft:#E3F3E9;
    --canvas-bg:#F2F2F2;
    --card-bg:#FFFFFF;
    --focus:#1B6FE0;
    --font-display:'Kanit', sans-serif;
    --font-body:'Kanit', sans-serif;
    --font-mono:'Kanit', sans-serif;
  }
  @media (prefers-color-scheme: dark){
    .epicmats-designer:not([data-theme="light"]){
      --ink:#F5F5F5;
      --ink-soft:#A3A3A3;
      --paper:#141414;
      --paper-dim:#1E1E1E;
      --line:#383838;
      --accent:#FCED1D;
      --accent-ink:#141414;
      --accent-soft:#3A3410;
      --success:#3FC480;
      --success-soft:#133722;
      --card-bg:#1C1C1C;
      --canvas-bg:#0F0F0F;
      --focus:#6AA8FF;
    }
  }
  .epicmats-designer[data-theme="dark"]{
    --ink:#F5F5F5;
    --ink-soft:#A3A3A3;
    --paper:#141414;
    --paper-dim:#1E1E1E;
    --line:#383838;
    --accent:#FCED1D;
    --accent-ink:#141414;
    --accent-soft:#3A3410;
    --success:#3FC480;
    --success-soft:#133722;
    --card-bg:#1C1C1C;
    --canvas-bg:#0F0F0F;
    --focus:#6AA8FF;
  }

  .epicmats-designer, .epicmats-designer *{box-sizing:border-box;}
  .epicmats-designer{
    margin:0;
    background:var(--paper);
    color:var(--ink);
    font-family:var(--font-body);
    font-variant-numeric:tabular-nums;
    padding-inline:clamp(16px, 4vw, 40px);
    padding-block:clamp(16px, 3vw, 32px);
  }
  .epicmats-designer h1, .epicmats-designer h2, .epicmats-designer h3{
    font-family:var(--font-display); font-weight:800; text-transform:uppercase;
    letter-spacing:0.01em; text-wrap:balance; margin:0;
  }
  .epicmats-designer ::selection{background:var(--accent); color:var(--accent-ink);}
  .epicmats-designer button{font-family:inherit;}
  .epicmats-designer :focus-visible{outline:2.5px solid var(--focus); outline-offset:2px;}

  .epicmats-designer .wrap{max-width:1500px; margin-inline:auto;}

  /* ---------- site header ----------
     A plain brand header for the standalone page — not shown in the
     WordPress-embedded version, which keeps the shop's own header instead
     (see class-em-designer.php's embed(), untouched by this). Two rows: a
     scrolling promo ticker, then the logo and a way back to the shop. No
     nav/account/cart — this page only ever does one job. */
  .epicmats-designer .site-header{
    margin:calc(-1 * clamp(16px, 3vw, 32px)) calc(-1 * clamp(16px, 4vw, 40px)) clamp(16px, 3vw, 32px);
  }
  .epicmats-designer .promo-ticker{
    background:var(--accent); color:var(--accent-ink);
    overflow:hidden; white-space:nowrap;
  }
  .epicmats-designer .promo-track{
    display:inline-flex; width:max-content;
    animation:promo-scroll 26s linear infinite;
  }
  @keyframes promo-scroll{
    from{ transform:translateX(0); }
    to{ transform:translateX(-50%); }
  }
  @media (prefers-reduced-motion:reduce){
    .epicmats-designer .promo-track{ animation:none; }
    .epicmats-designer .promo-ticker{ overflow-x:auto; }
  }
  .epicmats-designer .promo-item{
    display:inline-flex; align-items:center; gap:7px;
    padding:9px clamp(14px, 2.4vw, 28px);
    font-size:12.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.04em;
    white-space:nowrap;
  }
  .epicmats-designer .promo-icon{flex:none;}
  .epicmats-designer .site-header-row{
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    padding:14px clamp(16px, 4vw, 40px);
    border-bottom:1px solid var(--line);
    background:var(--paper);
  }
  .epicmats-designer .site-logo{
    display:inline-flex; align-items:center;
    line-height:0; /* so the row's height comes from the image, not font metrics */
  }
  .epicmats-designer .site-logo-img{
    display:block; height:34px; width:auto;
  }
  .epicmats-designer .btn-home{
    display:inline-flex; align-items:center; gap:8px; flex:none;
    font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:0.03em;
    border-radius:0; padding:11px 18px;
    background:var(--ink); color:var(--accent); text-decoration:none;
    border:1.5px solid var(--ink);
  }
  .epicmats-designer .btn-home:hover{opacity:0.88;}

  .epicmats-designer main.layout{
    display:grid;
    grid-template-columns: minmax(0,1.15fr) minmax(320px, 440px);
    gap:28px;
    align-items:start;
  }
  @media (max-width:900px){
    .epicmats-designer main.layout{ grid-template-columns: 1fr; }
  }

  .epicmats-designer .stage{ position:sticky; top:16px; }
  .epicmats-designer .stage-inner{ display:flex; flex-direction:column; gap:14px; }

  /* Inside the plugin's frame, position:sticky cannot work at all: the page
     that scrolls is the shop's, not the frame's, so a sticky element has
     nothing to be sticky against and scrolls away with everything else. When
     the page tells the frame where the visitor's window is, the frame switches
     to this and moves the preview itself. */


  .epicmats-designer .layout.pinned .stage{ position:relative; top:auto; align-self:stretch; }
  .epicmats-designer .layout.pinned .stage-inner{ will-change:transform; }

  .epicmats-designer .stage-frame{
    background:var(--canvas-bg);
    border:1px solid var(--line);
    border-radius:0;
    padding:clamp(18px, 4vw, 40px);
    display:flex; align-items:center; justify-content:center;
    /* Fixed regardless of view or mat orientation, so switching tabs or
       flipping a mat to portrait never resizes this window — only what's
       drawn inside it changes. The minimum is set by the 3D view, which
       needs the most headroom (see layout3D()'s maxH). */
    height:clamp(480px, 34vw, 580px);
    /* The 3D view's zoom/tilt presets (Close-up, Edge profile) scale and
       rotate the rig with a CSS transform, which paints outside its layout
       box without growing it — clip at the window's own edge so a preset
       can never spill past the border, the same way a photo viewport crops
       a zoomed-in image rather than resizing the frame around it. */
    overflow:hidden;
  }
  .epicmats-designer #em-matCanvas{
    display:block;
    width:auto;
    height:auto;
    /* Contain within the fixed stage-frame box rather than stretching to
       its width — a portrait mat shrinks to fit instead of growing the box. */
    max-width:100%;
    max-height:100%;
    touch-action:none;
    cursor:grab;
    border-radius:0;
  }
  .epicmats-designer #em-matCanvas.dragging{cursor:grabbing;}

  .epicmats-designer .stage-caption{
    display:flex; justify-content:space-between; gap:10px; flex-wrap:wrap;
    font-size:13px; color:var(--ink-soft);
  }
  .epicmats-designer .stage-caption b{color:var(--ink); font-weight:600;}
  .epicmats-designer .stage-caption .dims{font-family:var(--font-mono);}

  .epicmats-designer .callout{
    display:flex; gap:10px; align-items:flex-start;
    background:var(--paper-dim);
    border:1px solid var(--line);
    border-radius:0;
    padding:12px 14px;
    font-size:13.5px;
    color:var(--ink-soft);
    line-height:1.5;
  }
  .epicmats-designer .callout b{color:var(--ink);}

  /* view toggle + 3D stage */


  .epicmats-designer .stage-topbar{
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    margin-bottom:2px;
  }
  .epicmats-designer .view-toggle{display:flex; gap:6px; flex-wrap:wrap;}
  .epicmats-designer .view-tab{
    padding:8px 16px; border-radius:0; border:1.5px solid var(--line);
    background:transparent; font-size:12.5px; font-weight:700; text-transform:uppercase;
    letter-spacing:0.04em; color:var(--ink-soft); cursor:pointer;
  }
  .epicmats-designer .view-tab.active{background:var(--ink); color:var(--paper); border-color:var(--ink);}

  /* Share/email, as a small icon toolbar next to the view tabs rather than a
     pair of full-width buttons buried at the bottom of the order form — the
     longer explanation of what each one does lives in its title tooltip. */
  .epicmats-designer .stage-actions{display:flex; gap:6px; flex:none;}
  .epicmats-designer .icon-btn-lg{
    width:36px; height:36px; display:flex; align-items:center; justify-content:center;
    border:1.5px solid var(--line); border-radius:0; background:transparent;
    color:var(--ink-soft); cursor:pointer; flex:none;
  }
  .epicmats-designer .icon-btn-lg:hover, .epicmats-designer .icon-btn-lg:focus-visible{
    border-color:var(--ink); color:var(--ink);
  }
  .epicmats-designer .share-panel{display:flex; flex-direction:column;}
  .epicmats-designer .share-panel .share-note:empty{display:none;}
  .epicmats-designer .stage-3d{display:none; flex-direction:column; gap:14px;}
  .epicmats-designer .stage-3d.active{display:flex;}

  /* in a doorway: the mat laid on the floor of a real photograph */


  .epicmats-designer .stage-situ{display:none; flex-direction:column; gap:12px; padding:0; overflow:hidden;}
  .epicmats-designer .stage-situ.active{display:flex;}
  .epicmats-designer .situ-viewport{
    position:relative; width:100%; aspect-ratio:1843/853; overflow:hidden;
    min-height:0; border-radius:0; background:#1a1b1d;
  }
  .epicmats-designer .situ-scene{position:absolute; inset:0;}
  .epicmats-designer .situ-art{position:absolute; inset:0; width:100%; height:100%; display:block; object-fit:cover;}
  .epicmats-designer .situ-stage{position:absolute; inset:0; touch-action:none; cursor:grab;}
  .epicmats-designer .situ-stage.dragging{cursor:grabbing;}
  /* Both the mat and its shadow are warped onto the floor by a matrix3d worked
     out from the photograph, so they are pinned to the top-left of the stage
     and the matrix does the rest. */

  .epicmats-designer .situ-mat, .epicmats-designer .situ-shadow{position:absolute; left:0; top:0; transform-origin:0 0;}
  .epicmats-designer .situ-shadow{
    background:rgba(28,24,20,0.55); filter:blur(7px); pointer-events:none;
  }
  .epicmats-designer .situ-mat canvas{width:100%; height:100%; display:block;}
  .epicmats-designer .situ-note{
    margin:0 0 4px; padding:0 14px 12px; font-size:12px; line-height:1.5; color:var(--ink-soft);
  }
  .epicmats-designer .stage-situ .view-presets{padding:12px 14px 0;}
  .epicmats-designer .scene-3d-wrap{position:relative; width:100%; min-height:380px; display:flex; align-items:center; justify-content:center;}
  .epicmats-designer .mat-3d-scene{
    perspective:1300px; width:100%; height:100%;
    display:flex; align-items:center; justify-content:center;
    touch-action:none; cursor:grab; position:relative; z-index:1;
  }
  .epicmats-designer .mat-3d-scene.dragging{cursor:grabbing;}
  .epicmats-designer .mat-3d-rig{position:relative; transform-style:preserve-3d; transition:transform 0.55s cubic-bezier(.2,.8,.2,1);}
  /* A logo mat is a sheet about 11mm thick, not a block, so the rig is built
     from a chain of hinged slices: each slice hangs off the bottom edge of the
     one above it and is turned a fraction of a degree, which adds up to the
     gentle curl a real mat takes when you pick it up. */

  .epicmats-designer .mat-seg{position:absolute; transform-style:preserve-3d; transform-origin:50% 0;}
  .epicmats-designer .mat-seg .sf{position:absolute; backface-visibility:hidden; background-repeat:no-repeat;}
  .epicmats-designer .mat-seg .sf.front{background-color:#0A0A0A;}
  .epicmats-designer .mat-seg .sf.back{background-color:#090909;}
  /* the 3mm backing is the moulded high-grip one, and it reads as a dot field */

  .epicmats-designer .mat-3d-rig.highgrip .mat-seg .sf.back{
    background-image:radial-gradient(circle, #2e2e2e 1px, transparent 1.6px);
    background-size:7px 7px; background-repeat:repeat;
  }
  /* The cut edges of the backing. Brightness filters do nothing useful on
     near-black, so each gets an explicit tone — still black, but separated
     enough to read as a solid edge. */

  .epicmats-designer .mat-seg .sf.rim{background:#1C1C1C;}
  .epicmats-designer .mat-seg .sf.cap.top{background:#2B2B2B;}
  .epicmats-designer .mat-seg .sf.cap.bottom{background:#0C0C0C;}
  /* parked out of sight while the 3D view is showing */

  .epicmats-designer #em-canvasPark{position:absolute; left:0; top:0; width:0; height:0; overflow:hidden; opacity:0; pointer-events:none;}
  .epicmats-designer .ground-shadow{
    position:absolute; bottom:14%; left:50%; transform:translateX(-50%);
    border-radius:50%; background:radial-gradient(closest-side, rgba(0,0,0,0.35), rgba(0,0,0,0));
    filter:blur(7px); pointer-events:none; z-index:0;
  }
  .epicmats-designer .view-presets{display:flex; gap:8px; flex-wrap:wrap; justify-content:center;}
  .epicmats-designer .view-presets button{
    font-size:12px; font-weight:600; padding:6px 13px; border-radius:0;
    border:1.5px solid var(--line); background:transparent; color:var(--ink-soft); cursor:pointer;
  }
  .epicmats-designer .view-presets button.active{border-color:var(--accent); color:var(--accent-ink); background:var(--accent-soft);}

  /* design-style chooser */


  .epicmats-designer .style-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
  .epicmats-designer .style-opt{
    display:flex; flex-direction:column; gap:3px; text-align:left;
    border:1.5px solid var(--line); background:transparent; color:var(--ink);
    border-radius:0; padding:10px; cursor:pointer; font-family:inherit;
  }
  .epicmats-designer .style-opt:hover{border-color:var(--ink-soft);}
  .epicmats-designer .style-opt.active{border-color:var(--accent); background:var(--accent-soft); color:var(--accent-ink);}
  .epicmats-designer .style-opt .name{font-weight:600; font-size:13px; margin-top:4px;}
  .epicmats-designer .style-opt .desc{font-size:11.5px; opacity:0.8; line-height:1.35;}
  .epicmats-designer .style-art{
    display:block; height:44px; border-radius:0; border:1.5px solid var(--ink);
    position:relative; overflow:hidden;
  }
  .epicmats-designer .style-art.logo-art{background:#A19C91;}
  .epicmats-designer .style-art.logo-art .badge{
    position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
    width:20px; height:20px; border-radius:0; background:#fff; border:2px solid var(--ink);
  }
  .epicmats-designer .style-art.photo-art{
    background:
      linear-gradient(135deg, #C1683B 0 25%, #4E6E5D 25% 50%, #7B4B52 50% 75%, #3F5B78 75% 100%);
  }
  .epicmats-designer .muted-note{font-style:italic; opacity:0.85;}

  /* proof sheet */


  /* Standalone this is a fixed, centred dialog and the browser puts it in the
     middle of the window. Inside the plugin's frame it cannot be: the frame is
     as tall as its whole content, so "fixed" pins to the frame's box rather
     than to the window, and the dialog is centred hundreds of pixels off the
     bottom of the screen. All you see is the page go dark. So in the frame it
     becomes an absolute overlay the height of the document, and the sheet is
     placed level with whatever the customer was looking at when they pressed
     the button. */


  .epicmats-designer .proof-overlay{
    position:fixed; inset:0; z-index:60; display:none;
    align-items:center; justify-content:center; padding:20px;
    background:rgba(12,12,14,0.55);
  }
  .epicmats-designer .proof-overlay.anchored{
    position:absolute; inset:auto; left:0; top:0; width:100%;
    align-items:flex-start;
  }
  .epicmats-designer .proof-overlay.show{display:flex;}
  .epicmats-designer .proof-sheet{
    background:var(--card-bg); border-radius:0; border:1px solid var(--line);
    max-width:640px; width:100%; max-height:92vh; overflow:auto;
    padding:22px; box-shadow:0 22px 60px rgba(0,0,0,0.3);
  }
  .epicmats-designer .proof-sheet h3{
    font-family:var(--font-display); font-weight:800; font-size:20px; margin:0 0 2px;
  }
  .epicmats-designer .proof-sheet .proof-sub{font-size:12.5px; color:var(--ink-soft); margin:0 0 16px;}
  .epicmats-designer .proof-sheet img.proof-img{
    width:100%; height:auto; display:block; border-radius:0;
    background:var(--canvas-bg); padding:14px; margin-bottom:16px;
  }
  .epicmats-designer .proof-spec{border-top:1px solid var(--line);}
  .epicmats-designer .proof-spec div{
    display:flex; justify-content:space-between; gap:16px;
    padding:6px 0; font-size:13px; border-bottom:1px solid var(--line);
  }
  .epicmats-designer .proof-spec div span:first-child{color:var(--ink-soft);}
  .epicmats-designer .proof-spec div span:last-child{font-weight:600; text-align:right;}
  .epicmats-designer .proof-actions{display:flex; gap:8px; justify-content:flex-end; margin-top:16px;}

  /* segmented controls (orientation / surface) */


  .epicmats-designer .seg-control{display:flex; border:1.5px solid var(--line); border-radius:0; overflow:hidden;}
  .epicmats-designer .seg-btn{
    flex:1; border:none; background:transparent; padding:8px 6px; font-size:12.5px;
    font-weight:600; cursor:pointer; color:var(--ink-soft); font-family:inherit;
  }
  .epicmats-designer .seg-btn.active{background:var(--ink); color:var(--paper);}
  .epicmats-designer .field-block{margin-top:12px;}
  .epicmats-designer .checkbox-row{
    display:flex; align-items:center; gap:8px; font-size:13px; margin-top:10px; color:var(--ink);
  }
  .epicmats-designer .checkbox-row .mono{font-family:var(--font-mono); color:var(--ink-soft); font-size:11.5px;}
  .epicmats-designer .checkbox-row input{width:16px; height:16px; accent-color:var(--accent);}

  .epicmats-designer .panel{display:flex; flex-direction:column; gap:18px;}

  /* Step navigation — hidden on desktop. Styled at the end of this file,
     after every rule it needs to override (same reasoning as the stage's
     own mobile block above: equal specificity, so source order decides). */
  .epicmats-designer .step-nav{display:none;}

  .epicmats-designer .card{
    background:var(--card-bg);
    border:1px solid var(--line);
    border-radius:0;
    padding:18px 18px 20px;
  }
  .epicmats-designer .card-head{
    display:flex; align-items:center; gap:10px;
    margin-bottom:14px;
  }
  .epicmats-designer .step-no{
    font-family:var(--font-display); font-weight:800; font-size:14px;
    width:24px; height:24px; border-radius:0;
    display:flex; align-items:center; justify-content:center;
    background:var(--ink); color:var(--paper);
    flex:none;
  }
  .epicmats-designer .card-head h2{font-size:16.5px; font-weight:800; letter-spacing:0.01em;}
  .epicmats-designer .card-sub{font-size:12.5px; color:var(--ink-soft); margin:2px 0 0 34px;}

  /* The longer explanation a section used to carry as a paragraph now lives
     in this button's title tooltip instead, so the card shows only the
     essential line and the rest is one hover/tap away. */
  .epicmats-designer .info-btn{
    width:17px; height:17px; border-radius:0; border:1.5px solid var(--ink-soft);
    background:transparent; color:var(--ink-soft); font-size:10.5px; font-weight:700;
    font-family:var(--font-mono); line-height:1; cursor:help; flex:none; padding:0;
    display:inline-flex; align-items:center; justify-content:center; vertical-align:middle;
  }
  .epicmats-designer .card-head .info-btn{margin-left:-2px;}
  .epicmats-designer .info-btn:hover, .epicmats-designer .info-btn:focus-visible{
    border-color:var(--ink); color:var(--ink);
  }
  .epicmats-designer .info-btn[aria-expanded="true"]{background:var(--ink); color:var(--paper); border-color:var(--ink);}
  /* Positioned in JS (fixed, next to whichever button opened it) and
     appended to <body> — which is itself .epicmats-designer, so it still
     inherits the right theme colours and font. */
  .epicmats-designer .info-pop{
    position:fixed; z-index:80; max-width:280px;
    background:var(--ink); color:var(--paper);
    font-family:var(--font-body); font-size:12.5px; font-weight:400;
    text-transform:none; letter-spacing:normal; line-height:1.5;
    padding:10px 12px; border-radius:0;
    box-shadow:0 10px 28px rgba(0,0,0,0.28);
  }

  /* Size cards */


  .epicmats-designer .size-grid{display:grid; grid-template-columns:1fr 1fr; gap:8px;}
  @media (max-width:520px){ .epicmats-designer .size-grid{grid-template-columns:1fr;} }
  .epicmats-designer .size-opt{
    text-align:left;
    border:1.5px solid var(--line);
    background:transparent;
    border-radius:0;
    padding:9px 11px;
    cursor:pointer;
    color:var(--ink);
    display:flex; flex-direction:column; gap:2px;
  }
  .epicmats-designer .size-opt:hover{border-color:var(--ink-soft);}
  .epicmats-designer .size-opt.active{border-color:var(--accent); background:var(--accent-soft); color:var(--accent-ink);}
  .epicmats-designer .size-opt .name{font-weight:600; font-size:13.5px;}
  .epicmats-designer .size-opt .dims{font-family:var(--font-mono); font-size:11.5px; color:inherit; opacity:0.85;}
  .epicmats-designer .size-opt .price{font-family:var(--font-mono); font-size:11.5px; margin-top:2px; opacity:0.85;}

  /* Colour swatches */


  .epicmats-designer .colour-group{margin-bottom:12px;}
  .epicmats-designer .colour-group:last-child{margin-bottom:0;}
  .epicmats-designer .colour-group-label{
    font-family:var(--font-mono); font-weight:600; font-size:10.5px; letter-spacing:0.07em;
    text-transform:uppercase; color:var(--ink-soft); margin-bottom:7px;
  }
  .epicmats-designer .swatch-grid{
    display:grid;
    grid-template-columns:repeat(10, 1fr);
    gap:5px;
  }
  @media (max-width:420px){ .epicmats-designer .swatch-grid{grid-template-columns:repeat(8,1fr);} }
  .epicmats-designer .swatch{
    aspect-ratio:1; border-radius:0; border:1.5px solid rgba(0,0,0,0.12);
    cursor:pointer; padding:0; position:relative;
  }
  .epicmats-designer .swatch.active{box-shadow:0 0 0 2px var(--card-bg), 0 0 0 4px var(--ink);}
  .epicmats-designer .colour-readout{
    display:flex; align-items:center; gap:10px; margin-top:12px;
    padding-top:12px; border-top:1px solid var(--line);
  }
  .epicmats-designer .colour-readout .chip{width:26px; height:26px; border-radius:0; border:1px solid rgba(0,0,0,0.15); flex:none;}
  .epicmats-designer .colour-readout .name{font-weight:600; font-size:13.5px;}
  .epicmats-designer .colour-readout .hex{font-family:var(--font-mono); font-size:11.5px; color:var(--ink-soft);}

  /* Logo + text controls */


  .epicmats-designer .dropzone{
    border:1.5px dashed var(--line);
    border-radius:0;
    padding:20px 16px;
    text-align:center;
    font-size:13px;
    color:var(--ink-soft);
    transition:border-color 0.15s, background 0.15s;
  }
  .epicmats-designer #em-logoCard.drop-active .dropzone, .epicmats-designer #em-logoCard.drop-active #em-artworkList .element-block{
    border-color:var(--accent);
    background:var(--accent-soft);
  }
  .epicmats-designer .drop-veil{
    position:fixed; inset:0; z-index:50;
    display:none; align-items:center; justify-content:center;
    background:color-mix(in srgb, var(--paper) 82%, transparent);
    pointer-events:none;
  }
  /* same reason as the proof sheet above */

  .epicmats-designer .drop-veil.anchored{
    position:absolute; inset:auto; left:0; top:0; width:100%;
    align-items:flex-start;
  }
  .epicmats-designer .drop-veil.show{display:flex;}
  .epicmats-designer .drop-veil .inner{
    border:2.5px dashed var(--accent);
    border-radius:0;
    padding:28px 40px;
    background:var(--card-bg);
    text-align:center;
    box-shadow:0 18px 40px rgba(0,0,0,0.14);
  }
  .epicmats-designer .drop-veil .inner strong{
    display:block; font-family:var(--font-display); font-weight:800;
    font-size:22px; letter-spacing:0.01em; color:var(--ink); margin-bottom:4px;
  }
  .epicmats-designer .drop-veil .inner span{font-size:13px; color:var(--ink-soft);}

  .epicmats-designer .dpi-warning{
    margin:8px 0 0; font-size:12px; line-height:1.45;
    color:#8A5A12; background:#FBF0DC; border:1px solid #E6CF9E;
    border-radius:0; padding:8px 10px;
  }
  @media (prefers-color-scheme: dark){
    .epicmats-designer:not([data-theme="light"]) .dpi-warning{ background:#33270F; border-color:#5E4A1E; color:#F0CE86; }
  }
  .epicmats-designer[data-theme="dark"] .dpi-warning{ background:#33270F; border-color:#5E4A1E; color:#F0CE86; }

  .epicmats-designer .print-file{
    margin-top:14px; padding:13px; border:1.5px solid var(--line);
    border-radius:0; background:var(--card-bg);
  }
  .epicmats-designer .print-file strong{
    display:block; font-size:11px; text-transform:uppercase; letter-spacing:0.06em;
    color:var(--ink); margin-bottom:6px;
  }
  .epicmats-designer .print-file p{margin:0 0 10px; font-size:12.5px; line-height:1.5; color:var(--ink-soft);}
  .epicmats-designer .print-file p b{color:var(--ink);}
  .epicmats-designer .print-file-status{
    margin:10px 0 0 !important; font-size:12.5px; font-weight:600;
  }
  .epicmats-designer .print-file-status.supplied{color:var(--success);}
  .epicmats-designer .print-file-status.later{color:var(--accent-ink);}

  .epicmats-designer .format-guide{
    margin-top:12px; padding:11px 13px; border:1px solid var(--line);
    border-radius:0; background:var(--paper-dim);
    display:flex; flex-direction:column; gap:5px;
    font-size:12.5px; line-height:1.45; color:var(--ink-soft);
  }
  .epicmats-designer .format-guide strong{
    color:var(--ink); font-size:11px; text-transform:uppercase; letter-spacing:0.06em;
  }
  .epicmats-designer .format-guide b{color:var(--ink);}

  .epicmats-designer .upload-error{
    margin:10px 0 0;
    font-size:12.5px;
    color:#B3432E;
    background:#FBE7E1;
    border:1px solid #E3B3A5;
    border-radius:0;
    padding:8px 10px;
  }
  @media (prefers-color-scheme: dark){
    .epicmats-designer:not([data-theme="light"]) .upload-error{ background:#3A2016; border-color:#6B3626; color:#FFB4A0; }
  }
  .epicmats-designer[data-theme="dark"] .upload-error{ background:#3A2016; border-color:#6B3626; color:#FFB4A0; }
  .epicmats-designer .btn{
    font-size:13px; font-weight:600; border-radius:0; padding:8px 13px;
    border:1.5px solid var(--ink); background:var(--ink); color:var(--paper);
    cursor:pointer;
  }
  .epicmats-designer .btn:hover{opacity:0.88;}
  .epicmats-designer .btn.secondary{background:transparent; color:var(--ink); border-color:var(--line);}
  .epicmats-designer .btn.secondary:hover{border-color:var(--ink-soft);}
  .epicmats-designer .btn.danger{background:transparent; color:#B3432E; border-color:#E3B3A5;}
  .epicmats-designer .btn-row{display:flex; gap:8px; flex-wrap:wrap; margin-top:10px;}

  .epicmats-designer .element-block{
    border:1px solid var(--line); border-radius:0; padding:12px;
    margin-top:12px; display:flex; flex-direction:column; gap:10px;
  }
  .epicmats-designer .element-block.selected{border-color:var(--accent);}
  .epicmats-designer .element-row{display:flex; align-items:center; gap:10px;}
  .epicmats-designer .element-thumb{
    width:38px; height:38px; border-radius:0; border:1px solid var(--line);
    object-fit:contain; background:var(--paper-dim); flex:none;
  }
  .epicmats-designer .file-thumb{
    display:flex; align-items:center; justify-content:center;
    font-family:var(--font-mono); font-size:10px; font-weight:600;
    color:var(--ink-soft); text-transform:uppercase;
  }
  .epicmats-designer .field-label{
    font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:0.06em;
    color:var(--ink-soft); display:block; margin-bottom:4px;
  }
  .epicmats-designer .text-input{
    width:100%; font-family:var(--font-body); font-size:14px;
    padding:7px 9px; border-radius:0; border:1.5px solid var(--line);
    background:transparent; color:var(--ink);
  }
  .epicmats-designer .slider-row{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
  .epicmats-designer input[type="range"]{width:100%; accent-color:var(--accent);}
  .epicmats-designer select.text-input{cursor:pointer;}
  .epicmats-designer .colour-pick-btn{
    display:flex; align-items:center; gap:8px; width:100%;
    border:1.5px solid var(--line); background:transparent; color:var(--ink);
    border-radius:0; padding:6px 9px; cursor:pointer; font-size:12.5px; font-family:inherit;
    text-align:left;
  }
  .epicmats-designer .colour-pick-btn:hover{border-color:var(--ink-soft);}
  .epicmats-designer .colour-pick-btn .chip{
    width:18px; height:18px; border-radius:0; flex:none;
    border:1px solid rgba(0,0,0,0.25);
  }
  .epicmats-designer .text-colour-picker{
    margin-top:10px; padding:10px; border:1px solid var(--line);
    border-radius:0; background:var(--paper-dim);
  }
  .epicmats-designer .text-colour-picker .colour-group-label{margin:8px 0 5px;}
  .epicmats-designer .text-colour-picker .colour-group-label:first-child{margin-top:0;}

  .epicmats-designer .mini-swatches{display:flex; gap:6px; flex-wrap:wrap;}
  .epicmats-designer .mini-swatch{
    width:20px; height:20px; border-radius:0; border:1.5px solid rgba(0,0,0,0.15); cursor:pointer;
  }
  .epicmats-designer .mini-swatch.active{box-shadow:0 0 0 2px var(--card-bg), 0 0 0 3.5px var(--ink);}
  .epicmats-designer .icon-btn{
    border:none; background:transparent; color:var(--ink-soft); cursor:pointer;
    font-size:15px; padding:2px 6px; border-radius:0; margin-left:auto;
  }
  .epicmats-designer .icon-btn:hover{background:var(--paper-dim); color:var(--ink);}
  .epicmats-designer .add-text-btn{
    width:100%; margin-top:12px; border:1.5px dashed var(--line); background:transparent;
    color:var(--ink-soft); border-radius:0; padding:9px; cursor:pointer; font-size:13px; font-weight:600;
  }
  .epicmats-designer .add-text-btn:hover{border-color:var(--accent); color:var(--accent-ink); background:var(--accent-soft);}

  /* Order card */


  .epicmats-designer .summary-line{display:flex; justify-content:space-between; font-size:13.5px; padding:5px 0; color:var(--ink-soft);}
  .epicmats-designer .summary-line b{color:var(--ink); font-weight:600;}
  .epicmats-designer .summary-total{
    display:flex; justify-content:space-between; align-items:baseline;
    border-top:1px solid var(--line); margin-top:8px; padding-top:10px;
  }
  .epicmats-designer .summary-total .label{font-size:13px; color:var(--ink-soft);}
  .epicmats-designer .summary-total .value{font-family:var(--font-mono); font-size:22px; font-weight:600;}
  .epicmats-designer .add-basket-btn{
    width:100%; margin-top:14px; background:var(--accent); border:2px solid var(--ink);
    color:var(--ink); font-size:14.5px; font-weight:700; text-transform:uppercase;
    letter-spacing:0.04em; padding:13px; border-radius:0;
  }
  .epicmats-designer .add-basket-btn:hover{opacity:0.92;}
  .epicmats-designer .add-basket-btn:disabled{
    opacity:0.45; cursor:not-allowed; background:var(--ink-soft); border-color:var(--ink-soft);
  }
  .epicmats-designer .order-lines{margin-top:14px; display:flex; flex-direction:column; gap:8px;}
  .epicmats-designer .order-line{
    border:1.5px solid var(--line); border-radius:0; padding:10px;
    display:flex; flex-direction:column; gap:8px; background:var(--card-bg);
  }
  .epicmats-designer .order-line.primary{border-color:var(--ink-soft); background:var(--paper-dim);}
  .epicmats-designer .order-line .line-head{display:flex; align-items:center; gap:8px;}
  .epicmats-designer .order-line .line-title{font-weight:600; font-size:12.5px;}
  .epicmats-designer .order-line .line-total{margin-left:auto; font-family:var(--font-mono); font-size:13px; font-weight:600;}
  .epicmats-designer .order-line select, .epicmats-designer .order-line input[type="number"]{
    font-family:inherit; font-size:12.5px; padding:5px 7px; border-radius:0;
    border:1.5px solid var(--line); background:transparent; color:var(--ink);
    min-width:0; max-width:100%;
  }
  .epicmats-designer .order-line .line-controls{
    display:grid; grid-template-columns:minmax(0,1.15fr) minmax(0,1fr) minmax(0,1fr) 52px;
    gap:6px; align-items:center;
  }
  @media (max-width:620px){ .epicmats-designer .order-line .line-controls{grid-template-columns:minmax(0,1fr) minmax(0,1fr);} }
  .epicmats-designer .order-line .warn{font-size:11.5px; color:#8A5A12;}
  .epicmats-designer .hidden-field{display:none;}
  .epicmats-designer .btn.small{font-size:12.5px; padding:8px 10px;}
  .epicmats-designer .share-url{
    display:none; width:100%; margin-top:8px; font-family:var(--font-mono); font-size:11.5px;
    padding:8px; border-radius:0; border:1.5px solid var(--line);
    background:var(--paper-dim); color:var(--ink);
  }
  .epicmats-designer .share-url.show{display:block;}
  .epicmats-designer .email-row{display:none; gap:8px; margin-top:8px;}
  .epicmats-designer .email-row.show{display:flex;}
  .epicmats-designer .email-row input{
    flex:1; font-family:inherit; font-size:13px; padding:8px 10px; border-radius:0;
    border:1.5px solid var(--line); background:transparent; color:var(--ink);
  }
  .epicmats-designer .share-note{margin:8px 0 0 0;}
  .epicmats-designer .shared-note{
    margin-top:10px; padding:10px; border-radius:0; font-size:12.5px;
    background:#FDF3E3; border:1.5px solid #E8C89A; color:#6B4A12;
  }

  .epicmats-designer .order-blockers{
    margin:12px 0 0; font-size:12.5px; font-weight:600; line-height:1.45;
    color:#8A5A12; background:#FBF0DC; border:1px solid #E6CF9E;
    border-radius:0; padding:9px 11px;
  }
  @media (prefers-color-scheme: dark){
    .epicmats-designer:not([data-theme="light"]) .order-blockers{ background:#33270F; border-color:#5E4A1E; color:#F0CE86; }
  }
  .epicmats-designer[data-theme="dark"] .order-blockers{ background:#33270F; border-color:#5E4A1E; color:#F0CE86; }

  .epicmats-designer .rights-box{
    margin-top:14px; padding:12px; border:1.5px solid var(--line);
    border-radius:0; background:var(--paper-dim); font-size:13px; line-height:1.45;
  }
  .epicmats-designer .rights-box.needed{border-color:var(--accent); background:var(--accent-soft);}
  .epicmats-designer .rights-box.done{border-color:var(--success);}
  .epicmats-designer .success-banner{
    margin-top:10px; background:var(--success-soft); color:var(--success);
    border:1px solid var(--success); border-radius:0; padding:9px 11px;
    font-size:13px; font-weight:600; display:none; align-items:center; gap:8px;
  }
  .epicmats-designer .success-banner.show{display:flex;}

  .epicmats-designer details.devnote{margin-top:6px; font-size:12.5px; color:var(--ink-soft);}
  .epicmats-designer details.devnote summary{cursor:pointer; font-weight:600; color:var(--ink);}
  .epicmats-designer details.devnote p{line-height:1.55;}
  .epicmats-designer details.devnote code{
    font-family:var(--font-mono); background:var(--paper-dim); padding:1px 5px; border-radius:0; font-size:11.5px;
  }

  .epicmats-designer footer.page-foot{
    margin-top:34px; padding-top:16px; border-top:1px solid var(--line);
    font-size:12px; color:var(--ink-soft); text-align:center;
  }

  .epicmats-designer input[type="file"]{display:none;}
  .epicmats-designer input[type="color"]{
    width:30px; height:30px; padding:0; border:1.5px solid var(--line); border-radius:0; cursor:pointer; background:none;
  }

  /* ---------- mobile step mode (<=900px) ----------
     Deliberately last in the file: every rule here overrides something
     defined earlier (.stage, .card, .seg-btn, .swatch-grid and so on), all
     at equal specificity, so the only way to reliably win the cascade is
     to come after all of it — not by hunting down each individual rule
     and increasing specificity. Desktop is untouched; nothing here has any
     effect above the breakpoint. */
  @media (max-width:900px){
    .epicmats-designer .step-nav{
      display:flex; align-items:center; justify-content:space-between; gap:10px;
      margin-bottom:14px;
    }
    .epicmats-designer .step-nav-btn{
      display:inline-flex; align-items:center; gap:6px; flex:none;
      height:40px; padding:0 14px; border:1.5px solid var(--ink);
      background:var(--ink); color:var(--paper); cursor:pointer;
      font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:0.05em;
    }
    .epicmats-designer .step-nav-btn span{font-size:15px; line-height:1;}
    .epicmats-designer .step-nav-btn:disabled{
      background:transparent; color:var(--line); border-color:var(--line); cursor:default;
    }
    .epicmats-designer .step-nav-label{
      font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:0.06em;
      color:var(--ink-soft);
    }

    /* One card showing at a time. */
    .epicmats-designer .panel{gap:0; touch-action:pan-y;} /* horizontal flicks are ours; vertical scroll still works */
    .epicmats-designer .panel .card{display:none;}
    .epicmats-designer .panel .card.step-active{display:block;}

    /* The site header pins above the fixed preview instead of scrolling
       away — if it scrolled normally, the preview (position:fixed, which
       ignores document flow entirely) would sit at the true viewport top
       and permanently cover it. Full-bleed via negative margins (see the
       base rule) only makes sense in normal flow; fixed positioning already
       escapes the parent's padding on its own, so that margin has to be
       cancelled here or left/right:0 would overshoot the viewport. */
    .epicmats-designer .site-header{
      position:fixed; top:0; left:0; right:0; z-index:50; margin:0;
    }

    /* The fixed preview, shorter and without the callout. Sits below the
       fixed header rather than at the very top of the screen — the offset
       is measured in JS (syncHeaderHeight()) via --header-h-mobile, the
       same way the preview's own height is measured below. */
    .epicmats-designer .stage{
      position:fixed; top:var(--header-h-mobile, 90px); left:0; right:0; z-index:40;
      background:var(--paper);
      border-bottom:1px solid var(--line);
      padding:10px 16px 8px;
      margin:0;
    }
    .epicmats-designer .stage-inner{ gap:6px; }
    .epicmats-designer .stage-frame{
      /* Tall enough for the 3D/doorway views' own preset buttons to fit
         inside without being clipped — they share this box's height with
         Edit's canvas (same "every view is the same size" rule as desktop),
         so this can't shrink purely to what Edit alone would need. */
      height:clamp(230px, 54vw, 300px);
      padding:clamp(10px, 3vw, 18px);
    }
    .epicmats-designer .callout{ display:none; } /* the fixed header has no room to spare */
    .epicmats-designer .view-toggle{ gap:4px; }
    .epicmats-designer .view-tab{ padding:6px 10px; font-size:10.5px; }
    .epicmats-designer .icon-btn-lg{ width:30px; height:30px; }
    .epicmats-designer .stage-caption{ font-size:11.5px; }
    .epicmats-designer .view-presets{ gap:5px; }
    .epicmats-designer .view-presets button{ padding:4px 8px; font-size:10.5px; }
    .epicmats-designer .situ-note{ display:none; } /* supplementary text; the box is tight on mobile */
    .epicmats-designer .stage-situ .view-presets{ padding:8px 10px 0; }
    /* Desktop's 380px min-height (room for the rig at its largest) would
       force this taller than the whole mobile frame on its own — the rig
       scales itself down from wrap.clientWidth (see layout3D()) and fits
       the shrunk frame fine without a tall floor to enforce here too. */
    .epicmats-designer .scene-3d-wrap{ min-height:0; flex:1; }

    /* Pushes the step-nav + panel below the fixed site header and fixed
       preview above — both measured in JS, since both vary with viewport
       width and font loading. */
    .epicmats-designer main.layout{ padding-top:calc(var(--header-h-mobile, 90px) + var(--stage-h-mobile, 260px)); }

    /* A step now fills most of the screen on its own, so it can afford to
       be slightly denser than when seven of these were stacked and scrolled
       past at once. */
    .epicmats-designer .card{padding:14px 14px 16px;}
    .epicmats-designer .card-head{gap:8px; margin-bottom:11px;}
    .epicmats-designer .card-head h2{font-size:14.5px;}
    .epicmats-designer .step-no{width:21px; height:21px; font-size:12.5px;}
    .epicmats-designer .card-sub{font-size:11.5px; margin-left:29px;}
    .epicmats-designer .seg-btn{padding:7px 5px; font-size:11.5px;}
    .epicmats-designer .text-input{padding:6px 8px; font-size:13px;}
    .epicmats-designer .field-label{font-size:10px;}
    .epicmats-designer .swatch-grid{gap:4px;}
    .epicmats-designer .colour-group{margin-bottom:9px;}
    .epicmats-designer .style-grid{gap:7px;}
    .epicmats-designer .style-opt{padding:8px;}
    .epicmats-designer .style-art{height:36px;}

    .epicmats-designer .promo-item{ padding:7px 12px; font-size:11px; gap:5px; }
    .epicmats-designer .site-header-row{ padding:10px 16px; gap:10px; }
    .epicmats-designer .site-logo-img{ height:24px; }
    .epicmats-designer .btn-home{ padding:9px 12px; font-size:11px; gap:6px; }
  }
