[hidden]{display:none !important;}
:root{
  --bg:#0b0e13;
  --bg-2:#10151d;
  --panel:#121922;
  --panel-2:#161e28;
  --panel-3:#1b2430;
  --line:rgba(255,255,255,.08);
  --line-strong:rgba(255,255,255,.14);
  --text:#ecf1f8;
  --text-soft:#95a2b5;
  --text-dim:#748195;
  --accent:#6db3ff;
  --accent-soft:rgba(109,179,255,.16);
  --accent-line:rgba(109,179,255,.35);
  --shadow:0 18px 40px rgba(0,0,0,.34);
  --radius:16px;
  --toolbar-h:58px;
  --topbar-h:68px;
  --btn-h:40px;
  --footer-h:52px;
}

*{box-sizing:border-box}
html,body{height:100%;margin:0}
.home-link{color:inherit;text-decoration:none;cursor:pointer}
.home-link:hover,.home-link:visited{color:inherit;text-decoration:none}
body{
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(circle at top, rgba(109,179,255,.08), transparent 26%),
    linear-gradient(180deg, #0b0e13 0%, #090c11 100%);
  color:var(--text);
  overflow:hidden;
  display:grid;
  grid-template-rows:minmax(0,1fr) auto;
}
button,input{font:inherit}

.site-footer{
  position:relative;
  z-index:20;
  height:var(--footer-h);
  padding:8px 12px calc(8px + env(safe-area-inset-bottom));
  background:linear-gradient(180deg, rgba(8,11,16,.38), rgba(8,11,16,.94));
  border-top:1px solid rgba(255,255,255,.08);
  backdrop-filter:blur(12px);
}

.site-footer__inner{
  width:min(100%, 1400px);
  height:100%;
  margin:0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  color:var(--text-dim);
  font-size:12px;
}

.site-footer__copy{
  white-space:nowrap;
}

.site-footer__link{
  color:var(--text);
  text-decoration:none;
  border-bottom:1px solid rgba(109,179,255,.42);
  padding-bottom:1px;
}

.site-footer__link:hover{
  color:#fff;
  border-bottom-color:rgba(109,179,255,.82);
}

button,input{font:inherit}

.app-shell{
  height:100%;
  display:grid;
  grid-template-rows: var(--topbar-h) var(--toolbar-h) 1fr;
  padding:12px;
  gap:10px;
}

.topbar,
.toolbar,
.canvas-frame,
.sidebar-card{
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.025), rgba(255,255,255,.01));
  box-shadow:var(--shadow);
}

.topbar{
  min-height:0;
  border-radius:18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;
  gap:14px;
  background:linear-gradient(180deg, rgba(18,25,34,.96), rgba(12,18,26,.96));
}

.brand-lockup{display:flex;align-items:center;gap:12px;min-width:0}
.brand-mark{
  width:32px;height:32px;border-radius:10px;
  background:linear-gradient(135deg, rgba(109,179,255,.95), rgba(109,179,255,.2));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 8px 22px rgba(109,179,255,.26);
}
.brand-copy{display:flex;flex-direction:column;min-width:0}
.eyebrow{font-size:11px;letter-spacing:.16em;color:var(--text-dim)}
.brand-copy strong{font-size:15px;font-weight:650}

.grading-tabs{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.tab-btn,
.tool-btn{
  height:var(--btn-h);
  border-radius:12px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  color:var(--text);
  padding:0 14px;
}
.tab-btn{
  min-width:64px;
  font-weight:600;
  color:var(--text);
}
.tab-btn.is-active{
  color:var(--text);
  border-color:var(--accent-line);
  background:linear-gradient(180deg, rgba(109,179,255,.18), rgba(109,179,255,.08));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.tab-btn:hover,
.tool-btn:hover,
.zoom-option:hover{
  color:var(--text);
  border-color:var(--accent-line);
  background:linear-gradient(180deg, rgba(109,179,255,.14), rgba(109,179,255,.06));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
}

.toolbar{
  min-height:0;border-radius:16px;display:flex;align-items:center;gap:10px;
  padding:8px 10px;overflow:visible;
}
.tool-group{
  min-width:0;display:flex;align-items:center;gap:8px;
  padding:8px;border:1px solid var(--line);
  border-radius:14px;background:rgba(255,255,255,.02);
}
.tool-btn{min-width:82px;font-size:14px;color:var(--text-soft)}
.tool-btn-strong{
  color:var(--text);border-color:var(--accent-line);
  background:linear-gradient(180deg, rgba(109,179,255,.18), rgba(109,179,255,.08));
}
.tool-btn-icon{min-width:40px;width:40px;padding:0;font-size:16px;color:var(--text)}
.tool-group-slider{flex:1 1 320px;gap:12px}
.tool-group-zoom{margin-left:auto}
.zoom-menu-wrap{position:relative;display:flex;align-items:center;z-index:70}
.zoom-dropdown{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  left:auto;
  z-index:60;
  min-width:92px;
  max-height:min(55svh, 320px);
  overflow:auto;
  padding:6px;
  border:1px solid var(--line-strong);
  border-radius:12px;
  background:linear-gradient(180deg, rgba(18,25,34,.98), rgba(10,15,22,.98));
  box-shadow:0 18px 36px rgba(0,0,0,.32);
  display:grid;
  gap:4px;
}
.zoom-option{
  height:34px;
  border-radius:10px;
  border:1px solid transparent;
  background:rgba(255,255,255,.03);
  color:var(--text-soft);
}
.zoom-option.is-active{
  color:var(--text);
  border-color:var(--accent-line);
  background:rgba(109,179,255,.14);
}
.slider-label,.slider-value{font-size:13px;color:var(--text-soft);white-space:nowrap}
input[type="range"]{flex:1;min-width:120px;accent-color: var(--accent)}

.workspace{min-height:0;display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:10px}
.canvas-panel{min-height:0}
.canvas-frame{
  height:100%;min-height:0;border-radius:20px;padding:12px;
  background:linear-gradient(180deg, rgba(17,23,31,.98), rgba(11,15,21,.98));
}
.canvas-inner{
  height:100%;min-height:0;border-radius:16px;border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.015), rgba(255,255,255,.005));
  padding:10px;
}
.placeholder-card{
  height:100%;min-height:0;display:grid;grid-template-rows:auto 1fr auto;gap:10px;
}
.placeholder-header,.placeholder-footer{
  display:flex;align-items:center;justify-content:space-between;
  color:var(--text-dim);font-size:12px;letter-spacing:.04em;padding:2px 4px;
  gap:12px;
}
.placeholder-footer span:last-child{text-align:right}
.placeholder-dot{
  width:8px;height:8px;border-radius:999px;background:var(--accent);display:inline-block;
  margin-right:8px;box-shadow:0 0 12px rgba(109,179,255,.65);
}
.placeholder-stage{min-height:0;display:flex}
.image-stage{
  position:relative;
  width:100%;
  height:100%;
  min-height:320px;
  overflow:hidden;
  border-radius:16px;
  background:linear-gradient(180deg, rgba(109,179,255,.05), rgba(109,179,255,.015));
  border:1px dashed var(--accent-line);
}
.dropzone{
  position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:18px;text-align:center;z-index:3;cursor:pointer;
}
.image-stage.has-image .dropzone{display:none}
.dropzone h1{margin:0;font-size:clamp(22px,2.3vw,34px);line-height:1.05}
.dropzone p{margin:10px 0 0;font-size:14px;max-width:420px;color:var(--text-soft)}
.upload-btn{margin-top:16px;cursor:pointer}

#stageImage,
#analysisImage{
  position:absolute;display:none;z-index:1;pointer-events:none;user-select:none;
  -webkit-user-drag:none;
  box-shadow:0 8px 28px rgba(0,0,0,.28);
  transform:translateZ(0);
  transition:opacity .16s ease, filter .16s ease;
}
#analysisImage{
  z-index:1;
  opacity:0;
}
.image-stage.has-image #stageImage,
.image-stage.has-image #analysisImage{display:block}

#overlaySvg{
  position:absolute;inset:0;width:100%;height:100%;display:none;z-index:2;pointer-events:auto;
}
.image-stage.has-image #overlaySvg{display:block}
#maskPath{
  fill:transparent !important;
}
#overlayArrowHead path{
  fill:rgba(205,232,255,.82);
}
#cropPolygon{
  fill:transparent;
  stroke:rgba(205,232,255,.82);
  stroke-width:1.6;
  stroke-dasharray:14 10;
  stroke-linecap:butt;
  vector-effect:non-scaling-stroke;
}
#edgeTop,#edgeRight,#edgeBottom,#edgeLeft{
  display:none !important;
  stroke:none !important;
}
#overlaySvg line{
  stroke:rgba(205,232,255,.96);
  stroke-width:2;
  vector-effect:non-scaling-stroke;
  stroke-linecap:round;
  pointer-events:none;
}
.measure-line{
  stroke:rgba(255,255,255,.92);
  stroke-width:1.5;
  stroke-dasharray:8 8;
}
.measure-hit{
  stroke:rgba(255,255,255,0.001) !important;
  stroke-width:28;
  pointer-events:stroke;
}
#arrowTl,#arrowTr,#arrowBr,#arrowBl{
  stroke:rgba(205,232,255,.78);
  stroke-width:1.8;
  stroke-dasharray:8 7;
  marker-end:url(#overlayArrowHead);
}
.crop-handle{
  --handle-size:36px;
  position:absolute;
  z-index:4;
  display:none;
  width:var(--handle-size);
  height:var(--handle-size);
  margin:calc(var(--handle-size) * -.5) 0 0 calc(var(--handle-size) * -.5);
  border-radius:999px;
  border:2px solid rgba(228,243,255,.96);
  background:radial-gradient(circle, rgba(205,232,255,.18) 0 34%, rgba(10,14,19,.58) 35% 100%);
  box-shadow:0 0 0 1px rgba(255,255,255,.08),0 0 24px rgba(109,179,255,.22);
  cursor:grab;
  touch-action:none;
  backdrop-filter:blur(1px);
}
.crop-handle::before,.crop-handle::after{
  content:"";
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  background:rgba(255,255,255,.96);
  border-radius:999px;
  pointer-events:none;
}
.crop-handle::before{width:2px;height:18px}
.crop-handle::after{width:18px;height:2px}
.image-stage.has-image .crop-handle{display:block}
.crop-handle:active{cursor:grabbing}
.image-stage::after{
  content:"";
  position:absolute;
  inset:10px;
  border-radius:20px;
  border:1px solid rgba(255,255,255,.05);
  pointer-events:none;
  z-index:0;
}
.view-indicator{
  position:absolute;
  top:12px;
  right:12px;
  z-index:5;
  display:none;
  align-items:center;
  padding:7px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(8,12,18,.82);
  color:var(--text-soft);
  font-size:12px;
  letter-spacing:.06em;
  text-transform:uppercase;
  backdrop-filter:blur(4px);
}
.image-stage.has-image .view-indicator{display:inline-flex}

.corner-magnifier{
  position:absolute;
  z-index:7;
  width:260px;
  height:260px;
  border-radius:18px;
  overflow:hidden;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(10,14,19,.88);
  box-shadow:0 14px 30px rgba(0,0,0,.32);
  pointer-events:none;
  backdrop-filter:blur(6px);
}
.corner-magnifier canvas{
  display:block;
  width:100%;
  height:100%;
}
.corner-magnifier-crosshair::before,
.corner-magnifier-crosshair::after{
  content:"";
  position:absolute;
  left:50%;
  top:50%;
  background:rgba(255,255,255,.88);
  transform:translate(-50%,-50%);
}
.corner-magnifier-crosshair::before{width:1px;height:100%;}
.corner-magnifier-crosshair::after{width:100%;height:1px;}
.corner-magnifier-badge{
  position:absolute;
  top:10px;
  right:10px;
  z-index:2;
  padding:4px 8px;
  border-radius:999px;
  background:rgba(8,12,18,.82);
  color:var(--text);
  font-size:12px;
  font-weight:700;
  letter-spacing:.04em;
}
@media (max-width: 900px){
  .corner-magnifier{
    width:160px;
    height:160px;
    border-radius:14px;
  }
  .corner-magnifier-badge{font-size:11px; padding:3px 7px;}
}
.corner-view-btn.is-active{
  border-color:rgba(205,232,255,.5);
  background:rgba(205,232,255,.12);
  color:var(--text);
  box-shadow:0 0 0 1px rgba(205,232,255,.08) inset;
}

.sidebar{min-height:0;display:grid;grid-template-rows:1fr 1fr;gap:10px}
.sidebar-card{
  min-height:0;border-radius:18px;padding:14px;display:flex;flex-direction:column;gap:14px;
  background:linear-gradient(180deg, rgba(18,25,34,.97), rgba(13,18,25,.97));
}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}
.card-kicker{font-size:12px;letter-spacing:.12em;text-transform:uppercase;color:var(--text-dim)}
.card-status{
  height:28px;display:inline-flex;align-items:center;padding:0 10px;border-radius:999px;
  border:1px solid var(--line);background:rgba(255,255,255,.03);color:var(--text-soft);font-size:12px;
}
.grade-block{flex:1;min-height:0;display:flex;align-items:center;gap:14px;padding:8px 0}
.grade-ring{
  width:min(132px,42%);aspect-ratio:1/1;border-radius:999px;border:2px solid var(--accent-line);
  background:
    radial-gradient(circle at 35% 28%, rgba(109,179,255,.2), rgba(109,179,255,.02) 60%),
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
  display:flex;align-items:center;justify-content:center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.grade-number{font-size:clamp(28px,4vw,52px);font-weight:750}
.grade-meta{display:flex;flex-direction:column;gap:6px}
.grade-meta strong{font-size:22px}
.grade-meta span{font-size:13px;color:var(--text-soft)}
body[data-grade-tone="pristine"] .grade-ring,
body[data-grade-tone="pristine"] .mobile-grade-ring{
  border-color:rgba(244,211,94,.78);
  box-shadow:0 0 22px rgba(244,211,94,.28), inset 0 0 0 1px rgba(255,255,255,.05);
  background:radial-gradient(circle at 35% 28%, rgba(244,211,94,.28), rgba(244,211,94,.04) 60%), linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
}
body[data-grade-tone="gem"] .grade-ring,
body[data-grade-tone="gem"] .mobile-grade-ring{
  border-color:rgba(204,255,245,.72);
  box-shadow:0 0 18px rgba(149,255,228,.22), inset 0 0 0 1px rgba(255,255,255,.04);
}
body[data-grade-tone="mint9"] .grade-ring,
body[data-grade-tone="mint9"] .mobile-grade-ring{
  border-color:rgba(255,120,120,.76);
  box-shadow:0 0 20px rgba(255,98,98,.22), inset 0 0 0 1px rgba(255,255,255,.04);
}
.metric-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.metric-item{
  border:1px solid var(--line);background:rgba(255,255,255,.02);border-radius:14px;padding:12px;
}
.metric-label{
  display:block;font-size:12px;text-transform:uppercase;letter-spacing:.09em;
  color:var(--text-dim);margin-bottom:8px;
}
.metric-item strong{font-size:20px}

@media (max-width: 1180px){
  .workspace{grid-template-columns:minmax(0,1fr) 290px}
}
@media (max-width: 980px){
  body{overflow:auto}
  .app-shell{height:auto;min-height:calc(100vh - var(--footer-h));grid-template-rows:auto auto 1fr}
  .topbar{flex-direction:column;align-items:flex-start;padding:12px;min-height:unset}
  .grading-tabs{width:100%;justify-content:flex-start}
  .toolbar{flex-wrap:wrap;overflow:visible}
  .tool-group-slider{flex:1 1 100%;order:2}
  .workspace{grid-template-columns:1fr}
  .sidebar{grid-template-rows:none;grid-template-columns:1fr 1fr}
}
@media (max-width: 720px){
  .app-shell{padding:10px;gap:8px}
  .topbar,.toolbar,.canvas-frame,.sidebar-card{border-radius:16px}
  .toolbar{padding:8px}
  .tool-group{width:100%;flex-wrap:wrap}
  .tool-btn{flex:1 1 calc(50% - 4px);min-width:0}
  .tool-btn-icon{flex:1 1 calc(25% - 6px);width:auto}
  .sidebar{grid-template-columns:1fr}
  .grade-block{flex-direction:column;align-items:flex-start}
  .grade-ring{width:108px}
  .metric-grid{grid-template-columns:1fr}
  .dropzone h1{font-size:26px}
  .crop-handle{--handle-size:38px;width:var(--handle-size);height:var(--handle-size);margin:calc(var(--handle-size) * -.5) 0 0 calc(var(--handle-size) * -.5)}
}
@media (max-width: 480px){
  .brand-copy strong{font-size:14px}
  .eyebrow{font-size:10px}
  .tab-btn{min-width:unset;flex:1 1 calc(33.333% - 6px)}
  .slider-label{width:100%}
  .tool-group-slider{align-items:flex-start}
}


/* Responsive stability fixes */
.canvas-panel,
.canvas-frame,
.canvas-inner,
.placeholder-card,
.placeholder-stage{
  min-height:0;
}

@media (max-width: 980px){
  .workspace{
    grid-template-columns:1fr;
    align-items:start;
  }

  .canvas-panel{
    min-height:56svh;
  }

  .canvas-frame,
  .canvas-inner,
  .placeholder-card,
  .placeholder-stage,
  .image-stage{
    min-height:56svh;
  }

  .sidebar{
    grid-template-columns:1fr 1fr;
  }
}

@media (max-width: 720px){
  .canvas-panel{
    min-height:52svh;
  }

  .canvas-frame,
  .canvas-inner,
  .placeholder-card,
  .placeholder-stage,
  .image-stage{
    min-height:52svh;
  }

  .dropzone{
    padding:16px;
  }

  .dropzone p{
    max-width:300px;
  }
}

@media (max-width: 480px){
  .canvas-panel{
    min-height:48svh;
  }

  .canvas-frame,
  .canvas-inner,
  .placeholder-card,
  .placeholder-stage,
  .image-stage{
    min-height:48svh;
  }

  .placeholder-header,
  .placeholder-footer{
    flex-direction:column;
    align-items:flex-start;
  }

  .upload-btn{
    width:100%;
    min-width:0;
  }
}


/* === MOBILE UX REWORK === */
@media (max-width: 980px){
  body{
    overflow:auto;
  }

  .app-shell{
    height:auto;
    min-height:calc(100svh - var(--footer-h));
    grid-template-rows:auto auto 1fr;
    padding:8px;
    gap:8px;
  }

  .topbar{
    min-height:56px;
    padding:8px 10px;
    gap:10px;
    flex-direction:row;
    align-items:center;
    justify-content:space-between;
  }

  .brand-lockup{
    gap:8px;
    flex:0 0 auto;
  }

  .brand-mark{
    width:24px;
    height:24px;
    border-radius:8px;
  }

  .eyebrow{
    display:none;
  }

  .brand-copy strong{
    font-size:12px;
    white-space:nowrap;
  }

  .grading-tabs{
    flex:1 1 auto;
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    justify-content:flex-start;
    scrollbar-width:none;
    -ms-overflow-style:none;
    padding-bottom:2px;
  }

  .grading-tabs::-webkit-scrollbar{
    display:none;
  }

  .tab-btn{
    flex:0 0 auto;
    min-width:58px;
    height:34px;
    padding:0 12px;
    font-size:12px;
  }

  .toolbar{
    flex-wrap:nowrap;
    overflow-x:auto;
    overflow-y:hidden;
    padding:6px 8px;
    gap:8px;
    scrollbar-width:none;
    -ms-overflow-style:none;
  }

  .toolbar::-webkit-scrollbar{
    display:none;
  }

  .tool-group{
    width:auto;
    flex:0 0 auto;
    flex-wrap:nowrap;
    gap:6px;
    padding:6px;
    border-radius:12px;
  }

  .tool-group-slider{
    flex:0 0 260px;
  }

  .tool-btn,
  .tool-btn-icon{
    height:34px;
  }

  .tool-btn{
    min-width:72px;
    padding:0 12px;
    font-size:12px;
  }

  .tool-btn-icon{
    min-width:34px;
    width:34px;
    font-size:15px;
  }

  .slider-label,
  .slider-value{
    font-size:12px;
  }

  .workspace{
    grid-template-columns:1fr;
    gap:8px;
    align-items:start;
  }

  .canvas-panel{
    min-height:62svh;
  }

  .canvas-frame{
    padding:8px;
    border-radius:16px;
  }

  .canvas-inner{
    padding:8px;
  }

  .placeholder-card{
    gap:8px;
  }

  .placeholder-header,
  .placeholder-footer{
    font-size:11px;
    padding:0 2px;
  }

  .placeholder-stage,
  .image-stage{
    min-height:58svh;
  }

  .dropzone{
    padding:14px;
  }

  .dropzone h1{
    font-size:24px;
  }

  .dropzone p{
    max-width:280px;
    font-size:12px;
  }

  .upload-btn{
    margin-top:12px;
    min-width:140px;
  }

  .sidebar{
    grid-template-columns:1fr 1fr;
    grid-template-rows:none;
    gap:8px;
  }

  .sidebar-card{
    padding:12px;
    gap:12px;
    border-radius:16px;
  }

  .grade-block{
    gap:12px;
  }

  .grade-ring{
    width:min(96px, 34%);
  }

  .grade-meta strong{
    font-size:18px;
  }

  .metric-item strong{
    font-size:17px;
  }
}

@media (max-width: 720px){
  .app-shell{
    padding:6px;
    gap:6px;
  }

  .topbar,
  .toolbar,
  .canvas-frame,
  .sidebar-card{
    border-radius:14px;
  }

  .topbar{
    min-height:52px;
    padding:6px 8px;
  }

  .brand-copy strong{
    font-size:12px;
  }

  .tab-btn{
    min-width:54px;
    height:32px;
    padding:0 10px;
    font-size:12px;
  }

  .toolbar{
    padding:5px 6px;
    gap:6px;
  }

  .tool-group{
    padding:5px;
    gap:5px;
  }

  .tool-btn,
  .tool-btn-icon{
    height:32px;
  }

  .tool-btn{
    min-width:66px;
    padding:0 10px;
    font-size:12px;
  }

  .tool-btn-icon{
    min-width:32px;
    width:32px;
  }

  .tool-group-slider{
    flex-basis:230px;
  }

  .canvas-panel{
    min-height:58svh;
  }

  .placeholder-stage,
  .image-stage{
    min-height:54svh;
  }

  .sidebar{
    grid-template-columns:1fr;
  }

  .grade-block{
    flex-direction:row;
    align-items:center;
  }

  .metric-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width: 480px){
  .topbar{
    gap:8px;
  }

  .brand-mark{
    width:20px;
    height:20px;
    border-radius:6px;
  }

  .brand-copy strong{
    display:none;
  }

  .grading-tabs{
    gap:6px;
  }

  .tab-btn{
    min-width:50px;
    padding:0 8px;
  }

  .tool-group-slider{
    flex-basis:210px;
  }

  .slider-label{
    display:none;
  }

  .canvas-panel{
    min-height:56svh;
  }

  .placeholder-stage,
  .image-stage{
    min-height:50svh;
  }

  .placeholder-header,
  .placeholder-footer{
    flex-direction:row;
    align-items:center;
  }

  .placeholder-footer{
    gap:8px;
    flex-wrap:wrap;
  }

  .grade-block{
    flex-direction:row;
    align-items:center;
  }
}


/* === MOBILE FIX ROUND 2 === */
@media (max-width: 900px){
  .workspace{
    grid-template-columns:1fr;
  }

  .sidebar{
    display:none !important;
  }

  .canvas-panel{
    min-height:calc(100svh - 132px);
  }

  .canvas-frame,
  .canvas-inner,
  .placeholder-card{
    height:100%;
    min-height:calc(100svh - 132px);
  }

  .placeholder-stage,
  .image-stage{
    min-height:calc(100svh - 210px);
  }
}

@media (max-width: 720px){
  .app-shell{
    padding:4px;
    gap:4px;
    grid-template-rows:auto auto 1fr;
  }

  .topbar{
    min-height:44px;
    padding:4px 6px;
    border-radius:12px;
    gap:6px;
  }

  .brand-lockup{
    gap:6px;
  }

  .brand-mark{
    width:16px;
    height:16px;
    border-radius:5px;
  }

  .grading-tabs{
    gap:4px;
    overflow-x:auto;
    padding-bottom:0;
  }

  .tab-btn{
    min-width:44px;
    height:28px;
    padding:0 7px;
    border-radius:9px;
    font-size:11px;
  }

  .toolbar{
    padding:4px 5px;
    gap:5px;
    border-radius:12px;
  }

  .tool-group{
    padding:4px;
    gap:4px;
    border-radius:10px;
  }

  .tool-btn,
  .tool-btn-icon{
    height:28px;
    border-radius:8px;
  }

  .tool-btn{
    min-width:54px;
    padding:0 8px;
    font-size:11px;
  }

  .tool-btn-icon{
    min-width:28px;
    width:28px;
    font-size:12px;
  }

  .tool-group-slider{
    flex-basis:170px;
    gap:6px;
  }

  .slider-label{
    display:none;
  }

  .slider-value{
    font-size:11px;
  }

  .canvas-panel{
    min-height:calc(100svh - 96px);
  }

  .canvas-frame{
    padding:4px;
    border-radius:12px;
  }

  .canvas-inner{
    padding:4px;
  }

  .placeholder-card{
    gap:4px;
  }

  .placeholder-header,
  .placeholder-footer{
    font-size:10px;
    padding:0;
  }

  .placeholder-stage,
  .image-stage{
    min-height:calc(100svh - 150px);
    border-radius:12px;
  }

  .dropzone{
    padding:10px;
  }

  .dropzone h1{
    font-size:18px;
  }

  .dropzone p{
    font-size:11px;
    max-width:260px;
  }

  .upload-btn{
    margin-top:8px;
    min-width:120px;
  }

  .crop-handle{
    --handle-size:32px;
    width:var(--handle-size);
    height:var(--handle-size);
    margin:calc(var(--handle-size) * -.5) 0 0 calc(var(--handle-size) * -.5);
  }
}

@media (max-width: 480px){
  .topbar{
    min-height:40px;
  }

  .brand-lockup{
    display:none;
  }

  .grading-tabs{
    width:100%;
    justify-content:flex-start;
  }

  .tab-btn{
    min-width:42px;
    font-size:10px;
  }

  .tool-group-slider{
    flex-basis:150px;
  }

  .placeholder-footer{
    flex-direction:column;
    align-items:flex-start;
    gap:2px;
  }

  .canvas-panel{
    min-height:calc(100svh - 88px);
  }

  .placeholder-stage,
  .image-stage{
    min-height:calc(100svh - 140px);
  }
}


/* === MOBILE MASK / GRADE / INFO === */
.mobile-mask-bar,
.mobile-info-panel,
.mobile-grade-badge{
  display:none;
}

@media (max-width: 900px){
  .mobile-mask-bar{
    display:block;
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(18,25,34,.96), rgba(12,18,26,.96));
    box-shadow:var(--shadow);
    border-radius:14px;
    padding:8px 10px;
  }

  .mobile-mask-label-row{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:6px;
    font-size:12px;
    color:var(--text-soft);
  }

  .mobile-mask-input{
    width:100%;
    accent-color: var(--accent);
  }

  .mobile-grade-badge{
    display:flex;
    align-items:center;
    gap:10px;
    position:absolute;
    top:10px;
    right:10px;
    z-index:5;
    padding:8px 10px;
    border-radius:14px;
    border:1px solid rgba(109,179,255,.24);
    background:rgba(11,14,19,.84);
    backdrop-filter: blur(10px);
    box-shadow:0 8px 20px rgba(0,0,0,.28);
  }

  .mobile-grade-ring{
    width:44px;
    height:44px;
    border-radius:999px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:2px solid rgba(109,179,255,.45);
    color:var(--text);
    font-weight:750;
    font-size:18px;
    background:radial-gradient(circle at 35% 28%, rgba(109,179,255,.18), rgba(109,179,255,.02) 60%);
  }

  .mobile-grade-text{
    display:flex;
    flex-direction:column;
    gap:2px;
  }

  .mobile-grade-text strong{
    font-size:12px;
    line-height:1;
  }

  .mobile-grade-text span{
    font-size:11px;
    color:var(--text-soft);
    line-height:1;
  }

  .mobile-info-panel{
    display:block;
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(18,25,34,.97), rgba(13,18,25,.97));
    box-shadow:var(--shadow);
    border-radius:14px;
    padding:10px;
  }

  .mobile-info-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    margin-bottom:10px;
    color:var(--text-dim);
    font-size:12px;
    letter-spacing:.08em;
    text-transform:uppercase;
  }

  .mobile-metric-section + .mobile-metric-section{
    margin-top:10px;
  }

  .mobile-metric-title{
    font-size:12px;
    color:var(--text-soft);
    margin-bottom:6px;
    text-transform:uppercase;
    letter-spacing:.08em;
  }

  .mobile-metric-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
  }

  .mobile-metric-card{
    border:1px solid var(--line);
    background:rgba(255,255,255,.02);
    border-radius:12px;
    padding:10px;
  }

  .mobile-metric-card span{
    display:block;
    font-size:11px;
    color:var(--text-dim);
    margin-bottom:6px;
    text-transform:uppercase;
    letter-spacing:.08em;
  }

  .mobile-metric-card strong{
    font-size:17px;
  }
}

@media (max-width: 480px){
  .mobile-grade-badge{
    top:8px;
    right:8px;
    padding:7px 8px;
    gap:8px;
    border-radius:12px;
  }

  .mobile-grade-ring{
    width:38px;
    height:38px;
    font-size:16px;
  }

  .mobile-grade-text strong{
    font-size:12px;
  }

  .mobile-grade-text span{
    font-size:10px;
  }

  .mobile-metric-grid{
    grid-template-columns:1fr;
  }
}


/* === CANVAS DEBUG OVERLAY === */
.canvas-debug-overlay{
  position:absolute;
  left:10px;
  right:10px;
  bottom:10px;
  z-index:5;
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(109,179,255,.18);
  background:rgba(11,14,19,.78);
  backdrop-filter: blur(10px);
  box-shadow:0 8px 20px rgba(0,0,0,.22);
  pointer-events:none;
}

.canvas-debug-overlay .debug-line{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:11px;
  line-height:1.25;
  color:var(--text-soft);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

@media (max-width: 900px){
  .canvas-debug-overlay{
    left:8px;
    right:8px;
    bottom:8px;
    padding:7px 8px;
    border-radius:10px;
  }

  .canvas-debug-overlay .debug-line{
    font-size:10px;
  }
}

@media (max-width: 480px){
  .canvas-debug-overlay{
    bottom:6px;
    left:6px;
    right:6px;
    gap:3px;
    padding:6px 7px;
  }

  .canvas-debug-overlay .debug-line{
    font-size:9px;
    white-space:normal;
    word-break:break-word;
  }
}


/* === STATUS BAR UNDER WORKSPACE === */
.canvas-status-bar{
  border:1px solid var(--line);
  background:rgba(255,255,255,.025);
  border-radius:12px;
  padding:6px 10px;
  display:flex;
  flex-direction:column;
  gap:3px;
}

.canvas-status-bar .status-line{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:11px;
  line-height:1.25;
  color:var(--text-soft);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

@media (max-width: 900px){
  .canvas-status-bar{
    padding:6px 8px;
    border-radius:10px;
  }

  .canvas-status-bar .status-line{
    font-size:10px;
  }
}

@media (max-width: 480px){
  .canvas-status-bar{
    padding:5px 7px;
    gap:2px;
  }

  .canvas-status-bar .status-line{
    font-size:9px;
    white-space:normal;
    word-break:break-word;
  }
}


/* === MOBILE TOP CARD (NON-FLOATING) === */
.mobile-top-card{
  display:none;
}

@media (max-width: 900px){
  .mobile-grade-badge{
    display:none !important;
  }

  .mobile-top-card{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(18,25,34,.97), rgba(13,18,25,.97));
    border-radius:14px;
    padding:10px 12px;
  }

  .mobile-top-card-header{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
    flex:0 0 auto;
  }

  .mobile-grade-ring{
    width:40px;
    height:34px;
    flex:0 0 40px;
    border-radius:999px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:2px solid rgba(109,179,255,.45);
    color:var(--text);
    font-weight:750;
    font-size:17px;
    background:radial-gradient(circle at 35% 28%, rgba(109,179,255,.18), rgba(109,179,255,.02) 60%);
  }

  .mobile-grade-text{
    display:flex;
    flex-direction:column;
    gap:2px;
    min-width:0;
  }

  .mobile-grade-text strong{
    font-size:12px;
    line-height:1.1;
  }

  .mobile-grade-text span{
    font-size:11px;
    color:var(--text-soft);
    line-height:1.1;
  }

  .mobile-centering-block{
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:4px;
    align-items:flex-end;
    text-align:right;
  }

  .mobile-centering-title{
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--text-dim);
  }

  .mobile-centering-line{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size:10px;
    line-height:1.2;
    color:var(--text-soft);
    white-space:nowrap;
  }

  .mobile-centering-line span{
    color:var(--text);
    font-weight:700;
  }

  .canvas-status-bar{
    display:none;
  }
}

@media (max-width: 480px){
  .mobile-top-card{
    padding:8px 10px;
    gap:10px;
    flex-direction:column;
    align-items:flex-start;
  }

  .mobile-top-card-header{
    gap:8px;
  }

  .mobile-grade-ring{
    width:36px;
    height:36px;
    flex-basis:36px;
    font-size:15px;
  }

  .mobile-grade-text strong{
    font-size:12px;
  }

  .mobile-grade-text span{
    font-size:10px;
  }

  .mobile-centering-block{
    align-items:flex-start;
    text-align:left;
  }

  .mobile-centering-title{
    font-size:9px;
  }

  .mobile-centering-line{
    font-size:9px;
    white-space:normal;
  }
}


/* === V11 centering layout refinement === */
.centering-stack{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.centering-group{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.centering-group-title{
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--text-dim);
}

@media (min-width: 901px){
  .sidebar{
    grid-template-rows: auto auto;
  }

  .sidebar-card .metric-grid{
    grid-template-columns:1fr 1fr;
  }

  .sidebar-card .metric-item{
    min-height:106px;
    display:flex;
    flex-direction:column;
    justify-content:space-between;
  }
}

/* Mobile top card */
.mobile-top-card{
  display:none;
}

@media (max-width: 900px){
  .mobile-top-card{
    display:block;
    margin-bottom:8px;
  }

  .mobile-top-card-inner{
    display:grid;
    grid-template-columns:minmax(0, 1fr) minmax(0, 1.2fr);
    gap:10px;
    align-items:stretch;
    padding:10px;
    border-radius:14px;
    border:1px solid rgba(109,179,255,.18);
    background:rgba(11,14,19,.58);
    box-shadow:0 8px 18px rgba(0,0,0,.18);
  }

  .mobile-grade-top{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
  }

  .mobile-centering-block{
    border-top:none;
    border-left:1px solid rgba(255,255,255,.08);
    padding-top:0;
    padding-left:10px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    gap:4px;
    min-width:0;
  }

  .mobile-centering-title{
    margin-bottom:2px;
  }

  .mobile-centering-line{
    white-space:normal;
    word-break:break-word;
  }
}

@media (max-width: 540px){
  .mobile-top-card-inner{
    grid-template-columns:1fr 1.15fr;
    gap:8px;
    padding:8px;
  }

  .mobile-grade-ring{
    width:38px;
    height:38px;
    flex:0 0 38px;
  }

  .mobile-grade-text strong{
    font-size:12px;
  }

  .mobile-grade-text span{
    font-size:10px;
  }

  .mobile-centering-block{
    padding-left:8px;
  }

  .mobile-centering-line{
    font-size:9px;
    line-height:1.25;
  }
}


/* === V12 layout corrections === */
.centering-summary-card{
  display:flex;
  flex-direction:column;
  gap:14px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:16px;
  padding:16px;
}

.centering-summary-row{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.centering-summary-row + .centering-summary-row{
  padding-top:14px;
  border-top:1px solid var(--line);
}

.centering-summary-label{
  font-size:12px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--text-dim);
}

.centering-summary-values{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.centering-summary-values span{
  display:flex;
  flex-direction:column;
  gap:6px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:14px;
  padding:12px;
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--text-dim);
}

.centering-summary-values strong{
  font-size:28px;
  line-height:1;
  color:var(--text);
  letter-spacing:normal;
  text-transform:none;
}

@media (max-width: 900px){
  .mobile-top-card{
    display:block;
    margin-bottom:8px;
  }

  .mobile-top-card-inner{
    display:grid;
    grid-template-columns:minmax(0, .95fr) minmax(0, 1.35fr);
    gap:10px;
    align-items:center;
    padding:10px;
    border-radius:14px;
    border:1px solid rgba(109,179,255,.18);
    background:rgba(11,14,19,.58);
    box-shadow:0 8px 18px rgba(0,0,0,.18);
  }

  .mobile-grade-side{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
  }

  .mobile-centering-side{
    min-width:0;
    border-left:1px solid rgba(255,255,255,.08);
    padding-left:10px;
    display:flex;
    flex-direction:column;
    justify-content:center;
    gap:4px;
  }

  .mobile-grade-ring{
    width:40px;
    height:34px;
    flex:0 0 40px;
  }

  .mobile-centering-title{
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--text-dim);
  }

  .mobile-centering-line{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size:10px;
    line-height:1.25;
    color:var(--text-soft);
    white-space:nowrap;
  }

  .mobile-centering-line span{
    color:var(--text);
    font-weight:700;
  }
}

@media (max-width: 540px){
  .mobile-top-card-inner{
    grid-template-columns:minmax(0, .9fr) minmax(0, 1.4fr);
    gap:8px;
    padding:8px;
  }

  .mobile-grade-side{
    gap:8px;
  }

  .mobile-grade-ring{
    width:36px;
    height:36px;
    flex-basis:36px;
    font-size:15px;
  }

  .mobile-grade-text strong{
    font-size:12px;
  }

  .mobile-grade-text span{
    font-size:10px;
  }

  .mobile-centering-side{
    padding-left:8px;
  }

  .mobile-centering-line{
    font-size:9px;
  }
}


/* === V13 hard overrides === */

/* Desktop: one centering block only, no nested cards */
.centering-plain-block{
  border:1px solid var(--line);
  background:rgba(255,255,255,.02);
  border-radius:16px;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
}

.centering-plain-row{
  display:grid;
  grid-template-columns:110px 1fr 1fr;
  gap:14px;
  align-items:start;
}

.centering-plain-row + .centering-plain-row{
  padding-top:14px;
  border-top:1px solid var(--line);
}

.centering-plain-side{
  font-size:12px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--text-dim);
  padding-top:4px;
}

.centering-plain-metric{
  display:flex;
  flex-direction:column;
  gap:8px;
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:var(--text-dim);
}

.centering-plain-metric strong{
  display:block;
  font-size:34px;
  line-height:1;
  color:var(--text);
  letter-spacing:normal;
  text-transform:none;
}

@media (max-width: 1200px){
  .centering-plain-row{
    grid-template-columns:90px 1fr 1fr;
    gap:12px;
  }

  .centering-plain-metric strong{
    font-size:30px;
  }
}

/* Mobile: force side-by-side, never stacked */
.mobile-top-card{
  display:none;
}

@media (max-width: 900px){
  .mobile-top-card{
    display:block;
    margin-bottom:8px;
  }

  .mobile-top-card-inner{
    display:grid !important;
    grid-template-columns:minmax(112px, 0.9fr) minmax(0, 1.35fr) !important;
    gap:10px !important;
    align-items:center !important;
    padding:10px;
    border-radius:14px;
    border:1px solid rgba(109,179,255,.18);
    background:rgba(11,14,19,.58);
    box-shadow:0 8px 18px rgba(0,0,0,.18);
  }

  .mobile-grade-side{
    display:flex !important;
    align-items:center !important;
    gap:10px !important;
    min-width:0;
  }

  .mobile-centering-side{
    display:flex !important;
    flex-direction:column !important;
    justify-content:center !important;
    gap:4px !important;
    min-width:0;
    border-left:1px solid rgba(255,255,255,.08);
    padding-left:10px;
  }

  .mobile-centering-title{
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--text-dim);
    margin:0;
  }

  .mobile-centering-line{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size:10px;
    line-height:1.25;
    color:var(--text-soft);
    white-space:nowrap;
    margin:0;
  }

  .mobile-centering-line span{
    color:var(--text);
    font-weight:700;
  }
}

@media (max-width: 540px){
  .mobile-top-card-inner{
    grid-template-columns:104px minmax(0, 1fr) !important;
    gap:8px !important;
    padding:8px;
  }

  .mobile-grade-side{
    gap:8px !important;
  }

  .mobile-grade-ring{
    width:36px;
    height:36px;
    flex:0 0 36px;
    font-size:15px;
  }

  .mobile-grade-text strong{
    font-size:12px;
  }

  .mobile-grade-text span{
    font-size:10px;
  }

  .mobile-centering-side{
    padding-left:8px;
  }

  .mobile-centering-line{
    font-size:9px;
  }
}


/* === V14 final layout corrections === */
/* Desktop centering: one clean block, no nested cards */
.centering-card-desktop .centering-simple{
  display:flex;
  flex-direction:column;
  gap:16px;
  padding-top:2px;
}
.centering-card-desktop .centering-simple-row{
  display:grid;
  grid-template-columns:84px 1fr auto 1fr;
  gap:12px;
  align-items:center;
  padding:2px 0;
}
.centering-card-desktop .centering-simple-row + .centering-simple-row{
  padding-top:14px;
  border-top:1px solid var(--line);
}
.centering-card-desktop .centering-simple-side{
  font-size:12px;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--text-dim);
}
.centering-card-desktop .centering-simple-text{
  font-size:13px;
  color:var(--text-soft);
  letter-spacing:.03em;
  white-space:nowrap;
}
.centering-card-desktop .centering-simple-text strong{
  color:var(--text);
  font-size:26px;
  letter-spacing:normal;
  font-weight:750;
  margin-left:8px;
}
.centering-card-desktop .centering-simple-sep{
  color:var(--text-dim);
  opacity:.75;
}
/* neutralize old nested styles if still present */
.centering-card-desktop .centering-plain-block,
.centering-card-desktop .centering-summary-card,
.centering-card-desktop .metric-grid,
.centering-card-desktop .metric-item,
.centering-card-desktop .centering-plain-row,
.centering-card-desktop .centering-plain-metric,
.centering-card-desktop .centering-summary-values span{
  border:none;
  background:none;
  box-shadow:none;
}
/* Mobile: grade and centering side by side */
@media (max-width: 900px){
  .mobile-grade-badge{display:none !important;}
  .mobile-top-card{display:block !important; margin-bottom:8px;}
  .mobile-top-card-inner{
    display:grid !important;
    grid-template-columns:minmax(118px, .92fr) minmax(0, 1.45fr) !important;
    gap:10px !important;
    align-items:center !important;
    padding:10px 12px;
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(18,25,34,.97), rgba(13,18,25,.97));
    border-radius:14px;
  }
  .mobile-grade-side{
    display:flex !important;
    align-items:center !important;
    gap:10px !important;
    min-width:0;
  }
  .mobile-centering-side{
    display:flex !important;
    flex-direction:column !important;
    justify-content:center !important;
    gap:5px !important;
    min-width:0;
    border-left:1px solid rgba(255,255,255,.08);
    padding-left:12px;
    text-align:left;
  }
  .mobile-centering-title{
    font-size:10px;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:var(--text-dim);
  }
  .mobile-centering-line{
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size:10px;
    line-height:1.3;
    color:var(--text-soft);
    white-space:nowrap;
  }
  .mobile-centering-line span{color:var(--text);font-weight:700; margin-right:4px;}
}
@media (max-width: 540px){
  .mobile-top-card-inner{
    grid-template-columns:110px minmax(0,1fr) !important;
    gap:8px !important;
    padding:8px 10px;
  }
  .mobile-grade-ring{width:36px;height:36px;flex:0 0 36px;font-size:15px;}
  .mobile-grade-text strong{font-size:12px;}
  .mobile-grade-text span{font-size:10px;}
  .mobile-centering-side{padding-left:10px;}
  .mobile-centering-line{font-size:9px;}
}
@media (max-width: 1200px){
  .centering-card-desktop .centering-simple-row{grid-template-columns:70px 1fr auto 1fr; gap:10px;}
  .centering-card-desktop .centering-simple-text strong{font-size:22px; margin-left:6px;}
}


/* === V15 desktop centering overflow fix === */
@media (min-width: 901px){
  .workspace{
    grid-template-columns:minmax(0, 1fr) 340px;
  }

  .sidebar{
    min-width:0;
    overflow:hidden;
  }

  .sidebar-card{
    min-width:0;
    overflow:hidden;
  }

  .centering-plain-block{
    min-width:0;
    padding:14px;
    gap:12px;
  }

  .centering-plain-row{
    grid-template-columns:72px minmax(0, 1fr);
    gap:10px 12px;
    align-items:center;
  }

  .centering-plain-side{
    padding-top:0;
    font-size:11px;
  }

  .centering-plain-metric{
    min-width:0;
    display:flex;
    flex-direction:row;
    align-items:baseline;
    gap:8px;
    font-size:11px;
    white-space:nowrap;
  }

  .centering-plain-metric strong{
    display:inline;
    font-size:24px;
    line-height:1;
  }

  .centering-plain-row .centering-plain-metric:first-of-type{
    grid-column:2 / 3;
  }

  .centering-plain-row .centering-plain-metric:last-of-type{
    grid-column:2 / 3;
  }
}

/* slightly tighter on medium desktop widths */
@media (min-width: 901px) and (max-width: 1280px){
  .workspace{
    grid-template-columns:minmax(0, 1fr) 320px;
  }

  .centering-plain-block{
    padding:12px;
  }

  .centering-plain-metric{
    font-size:10px;
    gap:6px;
  }

  .centering-plain-metric strong{
    font-size:22px;
  }
}


/* === V16 mobile spacing fix === */
@media (max-width: 900px){
  .workspace{
    gap:8px !important;
  }

  .mobile-top-card{
    margin-bottom:6px !important;
  }

  .drop-zone{
    margin-top:0 !important;
  }

  .workspace-main{
    margin-top:0 !important;
    padding-top:0 !important;
  }

  .card-preview-wrapper,
  .canvas-wrapper,
  .image-container{
    margin-top:0 !important;
  }
}


/* === V17 mobile image top align === */
@media (max-width: 900px){
  #stageImage{
    top: 0 !important;
  }

  .image-stage{
    align-content:start;
    justify-content:flex-start;
  }
}


/* === V18 mobile toolbar end cleanup === */
@media (max-width: 900px){
  .toolbar{
    padding-right: 10px !important;
  }

  .toolbar::after{
    content: "";
    display: block;
    flex: 0 0 10px;
  }

  .toolbar > .tool-group:last-child{
    margin-right: 2px;
  }
}

@media (max-width: 540px){
  .toolbar{
    padding-right: 12px !important;
  }

  .toolbar::after{
    flex-basis: 12px;
  }

  .toolbar > .tool-group:last-child{
    margin-right: 4px;
  }
}


/* === Stable desktop centering panel restore === */
.centering-card-desktop{
  min-height:0;
}

.centering-stable-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:10px;
  min-height:0;
}

.centering-stable-row{
  display:grid;
  grid-template-columns:64px 56px minmax(0,1fr);
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.02);
  min-width:0;
}

.centering-stable-surface,
.centering-stable-axis{
  font-size:12px;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.centering-stable-surface{
  color:var(--text-dim);
}

.centering-stable-axis{
  color:var(--text-soft);
}

.centering-stable-value{
  justify-self:end;
  text-align:right;
  font-size:24px;
  line-height:1;
  color:var(--text);
  white-space:nowrap;
}

@media (max-width: 1200px){
  .centering-stable-row{
    grid-template-columns:58px 50px minmax(0,1fr);
    gap:10px;
    padding:10px 12px;
  }

  .centering-stable-value{
    font-size:21px;
  }
}


.image-stage.is-pannable{cursor:grab}
.image-stage.is-panning{cursor:grabbing}
.image-stage.is-pannable #stageImage,
.image-stage.is-pannable #analysisImage{pointer-events:none}

.crop-result-modal{
  position:absolute;
  inset:0;
  z-index:6;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
  background:rgba(5,8,14,.66);
  backdrop-filter:blur(5px);
}
.crop-result-modal[hidden]{display:none}
.crop-result-panel{
  width:min(92%, 620px);
  max-height:92%;
  overflow:auto;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(18,25,34,.98), rgba(12,18,26,.98));
  box-shadow:0 18px 40px rgba(0,0,0,.4);
  padding:14px;
}
.crop-result-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px}
.crop-result-meta{font-size:12px;color:var(--text-soft);margin-bottom:12px}
#cropResultCanvas{
  width:100%;
  height:auto;
  display:block;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.08);
  background:#0a0f15;
}

/* === v1.3 measure mode upgrade === */
.image-stage{touch-action:none}
.image-stage.measure-mode .crop-handle,
.image-stage.measure-mode #arrowTl,
.image-stage.measure-mode #arrowTr,
.image-stage.measure-mode #arrowBr,
.image-stage.measure-mode #arrowBl{
  display:none !important;
  opacity:0 !important;
  visibility:hidden !important;
}
.image-stage.measure-mode .crop-handle{
  border-color:transparent !important;
  background:transparent !important;
  box-shadow:none !important;
  backdrop-filter:none !important;
}
.image-stage.measure-mode #cropPolygon{
  fill:rgba(109,179,255,.04);
  stroke:rgba(226,241,255,.9);
  stroke-dasharray:14 10;
  stroke-linecap:butt;
}
.measure-line,
.measure-hit{display:none}
.image-stage.measure-mode .measure-line,
.image-stage.measure-mode .measure-hit{display:block}
.measure-line{
  stroke:rgba(226,241,255,.92) !important;
  stroke-width:1.5 !important;
  stroke-dasharray:6 7;
}
.measure-hit{
  stroke:rgba(0,0,0,0);
  stroke-width:22;
  pointer-events:stroke;
  cursor:grab;
}
.image-stage.is-dragging-line .measure-hit{cursor:grabbing}
.image-stage.measure-mode #edgeTop,
.image-stage.measure-mode #edgeRight,
.image-stage.measure-mode #edgeBottom,
.image-stage.measure-mode #edgeLeft{
  display:none !important;
  stroke:none !important;
  stroke-width:0 !important;
}
#zoomStatusBtn{min-width:88px}
@media (max-width: 900px){
  .centering-stable-value{font-size:18px}
}


@media (max-width: 900px){
  .tool-group-zoom{
    flex:0 0 auto;
  }
  .tool-group-zoom .tool-btn{
    min-width:64px;
  }
}

@media (max-width: 720px){
  .tool-group-zoom{
    min-width:max-content;
  }
  .tool-group-zoom .tool-btn{
    min-width:58px;
    flex:0 0 auto;
  }
  .zoom-dropdown{
    min-width:84px;
    right:0;
  }
}

@media (max-width: 480px){
  .toolbar{
    justify-content:flex-start;
  }
  .tool-group-zoom .tool-btn{
    min-width:56px;
    padding:0 7px;
  }
  .zoom-dropdown{
    top:calc(100% + 6px);
  }
}


/* === v1.3.1 interaction + mobile toolbar fixes === */
.measure-hit{
  stroke:transparent !important;
  stroke-opacity:0 !important;
  opacity:0 !important;
  stroke-width:30 !important;
  pointer-events:stroke;
}
.image-stage.is-dragging-line,
.image-stage.is-dragging-line *{cursor:grabbing !important;}

@media (max-width: 900px){
  .tool-group-slider{display:none !important;}
  .mobile-mask-bar{display:block;}
}

@media (max-width: 540px){
  .toolbar{
    overflow:visible !important;
    flex-wrap:wrap !important;
    justify-content:flex-start !important;
    align-items:center;
    padding:4px !important;
    gap:4px !important;
  }
  .toolbar::after{display:none !important;}
  .tool-group{
    width:auto !important;
    flex:0 1 auto !important;
    padding:3px !important;
    gap:3px !important;
    min-width:0;
    max-width:100%;
  }
  .tool-group[aria-label="corner controls"]{order:1;}
  .tool-group[aria-label="history"]{order:2;}
  .tool-group-zoom{
    order:3;
    margin-left:0 !important;
    flex:0 0 auto !important;
  }
  .tool-group-zoom .zoom-menu-wrap{flex:0 0 auto;}
  .tool-btn{
    min-width:48px !important;
    height:30px !important;
    padding:0 7px !important;
    font-size:11px !important;
  }
  .tool-btn-icon{
    min-width:28px !important;
    width:28px !important;
    height:30px !important;
    font-size:13px !important;
    padding:0 !important;
  }
  #zoomStatusBtn{min-width:52px !important;}
  #resetBtn{min-width:50px !important;}
  .zoom-dropdown{
    top:calc(100% + 6px);
    right:0;
    left:auto;
    min-width:76px;
  }
}


.mobile-shell-static{display:none}

@media (max-width: 820px){
  html,body{height:100%;min-height:100%;overflow:hidden}
  body{
    overflow:hidden;
    display:grid;
    grid-template-rows:minmax(0,1fr) auto;
  }
  .app-shell{display:none !important}

  .mobile-shell-static{
    display:flex;
    flex-direction:column;
    justify-content:flex-start;
    box-sizing:border-box;
    width:min(100%, 420px);
    height:100%;
    min-height:0;
    max-height:none;
    margin:0 auto;
    padding:6px;
    gap:4px;
    overflow:hidden;
  }

  .mobile-shell-static > *{flex:0 0 auto; min-width:0;}

  .mobile-shell-top,
  .mobile-shell-card

  .mobile-shell-top,
  .mobile-shell-card{
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(18,25,34,.97), rgba(13,18,25,.97));
    border-radius:14px;
    box-shadow:var(--shadow);
  }

  .mobile-shell-top{padding:6px 8px;}
  .mobile-shell-brand{display:flex;align-items:center;gap:10px;min-width:0}
  .mobile-shell-logo{width:30px;height:30px;border-radius:9px;background:linear-gradient(135deg, rgba(109,179,255,.95), rgba(109,179,255,.22));box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 8px 22px rgba(109,179,255,.22);flex:none;}
  .mobile-shell-brand-copy{display:flex;flex-direction:column;min-width:0}
  .mobile-shell-eyebrow{font-size:9px;letter-spacing:.14em;color:var(--text-dim)}
  .mobile-shell-brand-copy strong{font-size:14px;font-weight:650;color:var(--text)}

  .mobile-shell-card{padding:4px;}
  .mobile-shell-tabs{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:4px;}
  .mobile-shell-corners{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;}
  .mobile-shell-actions{display:block;}
  .mobile-shell-action-row-quad{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:4px;}

  .mobile-chip,
  .mobile-shell-btn{
    appearance:none;
    border:1px solid var(--line);
    background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
    color:var(--text);
    border-radius:11px;
    height:30px;
    padding:0 6px;
    font:inherit;
    font-size:11px;
    font-weight:600;
    width:100%;
    min-width:0;
  }
  .mobile-chip.is-active,
  .mobile-shell-btn-strong{
    border-color:var(--accent-line);
    background:linear-gradient(180deg, rgba(109,179,255,.18), rgba(109,179,255,.08));
  }
  .mobile-shell-btn-icon{font-size:14px;}

  .mobile-corner-view-btn{
    transition:border-color 120ms ease, background 120ms ease, box-shadow 120ms ease, color 120ms ease;
  }
  .mobile-corner-view-btn.is-active{
    border-color:var(--accent-line);
    background:linear-gradient(180deg, rgba(109,179,255,.18), rgba(109,179,255,.08));
    box-shadow:0 0 0 1px rgba(109,179,255,.16) inset, 0 10px 24px rgba(109,179,255,.14);
  }

  .mobile-chip:disabled,
  .mobile-shell-btn:disabled{opacity:.48;cursor:not-allowed;}

  .mobile-shell-zoom-wrap{position:relative;min-width:0;display:flex;align-items:center;}
  .mobile-shell-zoom-dropdown{
    position:absolute;
    top:calc(100% + 6px);
    right:0;
    z-index:20;
    min-width:78px;
    max-height:42svh;
    overflow:auto;
    padding:4px;
    border:1px solid var(--line-strong);
    border-radius:12px;
    background:linear-gradient(180deg, rgba(18,25,34,.99), rgba(10,15,22,.99));
    box-shadow:0 18px 36px rgba(0,0,0,.36);
    display:grid;
    gap:4px;
  }
  .mobile-shell-zoom-option{
    appearance:none;
    border:1px solid transparent;
    background:rgba(255,255,255,.03);
    color:var(--text-soft);
    border-radius:10px;
    height:30px;
    font:inherit;
    font-size:11px;
    font-weight:600;
    padding:0 8px;
  }
  .mobile-shell-zoom-option.is-active{
    color:var(--text);
    border-color:var(--accent-line);
    background:rgba(109,179,255,.14);
  }

  .mobile-shell-range{
    width:100%;
    margin:0;
    accent-color:var(--accent);
  }

  .mobile-shell-upload{cursor:pointer;position:relative;}
  .mobile-shell-upload.measure-mode{touch-action:none;}
  .mobile-shell-upload:focus-visible{outline:2px solid rgba(109,179,255,.7);outline-offset:-2px;}
  .mobile-shell-upload.has-image .mobile-shell-upload-copy{opacity:0;pointer-events:none;}
  .mobile-shell-image{
    display:none;
    position:absolute;
    left:0;
    top:0;
    width:100%;
    height:100%;
    object-fit:fill;
    transform-origin:center center;
    transition:filter 120ms ease;
    user-select:none;
    -webkit-user-drag:none;
    pointer-events:none;
  }
  .mobile-shell-upload.has-image .mobile-shell-image{display:block;}
  .mobile-shell-analysis-image{opacity:0;filter:url(#analysisFilter);z-index:1;transition:opacity 120ms ease, filter 120ms ease;}
  .mobile-shell-image{z-index:0;}

  .mobile-shell-upload.has-image .mobile-shell-crop-overlay,
  .mobile-shell-upload.has-image .mobile-shell-crop-handle{display:block;}

  .mobile-corner-magnifier{
    width:160px;
    height:160px;
    border-radius:14px;
    z-index:8;
  }
  .mobile-shell-upload.measure-mode .mobile-corner-magnifier{display:block;}
  .mobile-shell-crop-overlay{
    display:none;
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    z-index:2;
    pointer-events:none;
    overflow:visible;
  }
  #mobilePhaseMaskPath{fill:transparent !important;}
  #mobilePhaseArrowHead path{fill:rgba(205,232,255,.82);}
  .mobile-shell-crop-shape{
    fill:transparent;
    stroke:rgba(205,232,255,.68);
    stroke-width:1.5;
    stroke-dasharray:12 10;
    vector-effect:non-scaling-stroke;
  }
  .mobile-shell-crop-overlay line{
    stroke:rgba(205,232,255,.96);
    stroke-width:2;
    vector-effect:non-scaling-stroke;
    stroke-linecap:round;
    pointer-events:none;
  }
  .mobile-shell-crop-arrow{
    stroke:rgba(205,232,255,.78);
    stroke-width:1.8;
    stroke-dasharray:8 7;
    marker-end:url(#mobilePhaseArrowHead);
  }
  .mobile-shell-crop-handle{
    --handle-size:36px !important;
    display:none;
    position:absolute;
    z-index:4;
    width:var(--handle-size);
    height:var(--handle-size);
    margin:calc(var(--handle-size) * -.5) 0 0 calc(var(--handle-size) * -.5);
    padding:0;
    border-radius:999px;
    border:2px solid rgba(228,243,255,.96);
    background:radial-gradient(circle, rgba(205,232,255,.18) 0 34%, rgba(10,14,19,.58) 35% 100%);
    box-shadow:0 0 0 1px rgba(255,255,255,.08),0 0 24px rgba(109,179,255,.22);
    touch-action:none;
    cursor:grab;
    backdrop-filter:blur(1px);
  }
  .mobile-shell-crop-handle::before,
  .mobile-shell-crop-handle::after{
    content:"";
    position:absolute;
    left:50%;
    top:50%;
    transform:translate(-50%,-50%);
    background:rgba(255,255,255,.96);
    border-radius:999px;
    pointer-events:none;
  }
  .mobile-shell-crop-handle::before{width:2px;height:18px;}
  .mobile-shell-crop-handle::after{width:18px;height:2px;}
  .mobile-shell-crop-handle.is-dragging{box-shadow:0 0 0 3px rgba(109,179,255,.18),0 0 24px rgba(109,179,255,.22);cursor:grabbing;}
  .mobile-shell-btn.is-muted{opacity:.72;}
  .mobile-shell-measure-line,
  .mobile-shell-measure-hit{display:none;}
  .mobile-shell-upload.measure-mode .mobile-shell-crop-handle,
  .mobile-shell-upload.measure-mode .mobile-shell-crop-arrow{display:none !important;}
  .mobile-shell-upload.measure-mode .mobile-shell-measure-line,
  .mobile-shell-upload.measure-mode .mobile-shell-measure-hit{display:block !important;}
  
  .mobile-shell-crop-overlay #cropPolygon{
    stroke-dasharray:14 10 !important;
    stroke-linecap:butt !important;
    vector-effect:non-scaling-stroke;
  }
.mobile-shell-crop-overlay .mobile-shell-measure-line{
    display:none;
    stroke:rgba(226,241,255,.92) !important;
    stroke-width:1.5 !important;
    stroke-dasharray:12 10 !important;
    stroke-linecap:butt !important;
    vector-effect:non-scaling-stroke;
    pointer-events:stroke;
    cursor:grab;
    touch-action:none;
    -webkit-touch-callout:none;
    -webkit-user-select:none;
    user-select:none;
    -webkit-user-drag:none;
  }
  .mobile-shell-crop-overlay .mobile-shell-measure-hit{
    display:none;
    stroke:rgba(0,0,0,0) !important;
    stroke-width:80 !important;
    pointer-events:stroke !important;
    cursor:grab;
    vector-effect:non-scaling-stroke;
    touch-action:none;
    -webkit-touch-callout:none;
    -webkit-user-select:none;
    user-select:none;
    -webkit-user-drag:none;
  }
  .mobile-shell-upload.is-dragging-line .mobile-shell-measure-line,
  .mobile-shell-upload.is-dragging-line .mobile-shell-measure-hit{cursor:grabbing;}
  .mobile-shell-upload,
  .mobile-shell-crop-overlay,
  .mobile-shell-image,
  .mobile-shell-analysis-image{
    -webkit-user-drag:none;
  }

  .mobile-shell-upload-copy{
    position:absolute;
    inset:0;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:12px;
    padding:16px 14px;
    text-align:center;
    transition:opacity 120ms ease;
  }

  .mobile-shell-analysis{display:grid;gap:4px;padding:5px 6px;}
  .mobile-shell-section-head{display:flex;align-items:center;justify-content:space-between;gap:8px;color:var(--text-soft);font-size:11px;}
  .mobile-shell-slider-track{height:5px;border-radius:999px;background:rgba(255,255,255,.18);overflow:hidden;}
  .mobile-shell-slider-fill{display:block;height:100%;width:0%;background:var(--accent);border-radius:999px;}

  .mobile-shell-grade-card{display:grid;grid-template-columns:42px minmax(0,1fr);gap:8px;align-items:start;padding:5px 6px;}
  .mobile-shell-grade-ring{width:38px;height:38px;border-radius:999px;border:2px solid var(--accent-line);display:flex;align-items:center;justify-content:center;font-size:16px;font-weight:700;color:var(--text);box-shadow:inset 0 0 0 1px rgba(255,255,255,.05);}
  .mobile-shell-grade-content{display:grid;gap:4px;min-width:0;}
  .mobile-shell-grade-title{font-size:14px;line-height:1.05;font-weight:700;color:var(--text);}

body[data-grade-tone="pristine"] .mobile-shell-grade-ring{
  border-color:rgba(244,211,94,.78);
  color:#fff3c2;
  box-shadow:0 0 22px rgba(244,211,94,.28), inset 0 0 0 1px rgba(255,255,255,.05);
  background:radial-gradient(circle at 35% 28%, rgba(244,211,94,.28), rgba(244,211,94,.04) 60%), linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
}
body[data-grade-tone="pristine"] .mobile-shell-grade-title{color:#fff3c2;}
body[data-grade-tone="gem"] .mobile-shell-grade-ring{
  border-color:rgba(204,255,245,.72);
  color:#e9fff8;
  box-shadow:0 0 18px rgba(149,255,228,.22), inset 0 0 0 1px rgba(255,255,255,.04);
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
}
body[data-grade-tone="gem"] .mobile-shell-grade-title{color:#e9fff8;}
body[data-grade-tone="mint9"] .mobile-shell-grade-ring{
  border-color:rgba(255,120,120,.76);
  color:#ffe8e8;
  box-shadow:0 0 20px rgba(255,98,98,.22), inset 0 0 0 1px rgba(255,255,255,.04);
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01));
}
body[data-grade-tone="mint9"] .mobile-shell-grade-title{color:#ffe8e8;}
  .mobile-shell-centering-block{display:grid;gap:3px;min-width:0;}
  .mobile-shell-centering-line{font-size:9px;line-height:1.2;color:var(--text-soft);white-space:normal;word-break:break-word;}
  .mobile-shell-centering-line span{display:inline-block;min-width:16px;color:var(--text);font-weight:700;}
  .mobile-shell-workspace{
    flex:1 1 auto;
    height:auto;
    min-height:220px;
    max-height:none;
    padding:0;
    overflow:hidden;
    position:relative;
  }
  .mobile-shell-upload{
    width:100%;
    height:100%;
    min-height:100%;
    max-height:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:12px;
    border-radius:inherit;
    background:linear-gradient(180deg, rgba(109,179,255,.05), rgba(109,179,255,.015));
    border:none;
    box-shadow: inset 0 0 0 1px rgba(109,179,255,.28);
    margin:0;
    text-align:center;
    padding:16px 14px;
    box-sizing:border-box;
    overflow:hidden;
  }
  .mobile-shell-upload-title{font-size:clamp(40px, 11vw, 62px);line-height:1;font-weight:400;color:var(--text);}
  .mobile-shell-upload-sub{font-size:13px;color:var(--text-soft);}
}

@media (max-width: 420px){
  .mobile-shell-static{padding:6px;gap:4px;}
  .mobile-shell-btn,.mobile-chip{height:29px;font-size:10px;}
  .mobile-shell-grade-title{font-size:13px;}
  .mobile-shell-centering-line{font-size:8.5px;}
}

@media (max-width: 900px){
  .crop-handle{ --handle-size:40px; }
}

.mobile-shell-upload.is-panning{cursor:grabbing;}
.mobile-shell-upload.is-pannable{touch-action:none;}

/* === SAFE TABLET / LAPTOP STABILITY OVERRIDE (non-destructive) === */
@media (min-width: 901px) and (max-width: 1199px){
  .app-shell{
    padding:10px;
    gap:10px;
  }

  .workspace{
    grid-template-columns:minmax(0,1fr) 292px;
    gap:10px;
    align-items:start;
  }

  .canvas-panel,
  .canvas-frame,
  .canvas-inner,
  .placeholder-card,
  .placeholder-stage{
    min-width:0;
  }

  .canvas-frame{
    padding:10px;
  }

  .canvas-inner{
    padding:8px;
  }

  .sidebar{
    grid-template-columns:1fr;
    grid-template-rows:auto auto;
    gap:10px;
    min-width:0;
  }

  .sidebar-card{
    min-width:0;
    padding:12px;
  }

  .toolbar{
    flex-wrap:wrap;
    align-items:center;
    overflow:visible;
  }

  .tool-group-slider{
    flex:1 1 100%;
    order:10;
  }

  .tool-group-zoom{
    margin-left:0;
  }
}


/* Analysis mode buttons (safe bridge on top of existing analysis engine) */
.analysis-range-hidden{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
  opacity:0 !important;
  pointer-events:none !important;
}
/* === CLEAN ANALYSIS BUTTONS === */
.tool-group[aria-label="analysis mode"] .slider-label,
.tool-group[aria-label="analysis mode"] .slider-value,
.mobile-shell-analysis .mobile-shell-section-head,
.mobile-mask-bar .mobile-mask-label-row{
  display:none !important;
}
.analysis-mode-buttons{
  display:flex;
  align-items:center;
  gap:8px;
  width:100%;
}
.analysis-mode-btn{
  height:var(--btn-h);
  border-radius:12px;
  border:1px solid var(--line);
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  color:var(--text);
  padding:0 14px;
  min-width:0;
  flex:1 1 0;
  font:inherit;
  font-size:14px;
  font-weight:600;
}
.analysis-mode-btn:hover{
  color:var(--text);
  border-color:var(--accent-line);
  background:linear-gradient(180deg, rgba(109,179,255,.14), rgba(109,179,255,.06));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
}
.analysis-mode-btn.is-active{
  color:var(--text);
  border-color:var(--accent-line);
  background:linear-gradient(180deg, rgba(109,179,255,.18), rgba(109,179,255,.08));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
@media (max-width: 720px){
  .analysis-mode-btn{height:32px;border-radius:8px;padding:0 10px;font-size:12px;}
}

/* === FINISH BARS IN CANVAS === */
.finish-bars-overlay{
  position:absolute;
  inset:0;
  z-index:6;
  pointer-events:none;
}
.finish-bar{
  --tone-rgb: 34,197,94;
  --breakpoint: 50%;
  position:absolute;
}
.finish-bar-fill{
  position:absolute;
  inset:0;
  overflow:hidden;
  border-radius:14px;
  border:1px solid rgba(173, 230, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(7,11,18,0.90), rgba(10,16,24,0.82));
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.03),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 10px 24px rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
}
.finish-bar-fill::before{
  content:"";
  position:absolute;
  inset:1px;
  border-radius:inherit;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  pointer-events:none;
}
.finish-bar-horizontal .finish-bar-fill::after,
.finish-bar-vertical .finish-bar-fill::after{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
}
.finish-bar-horizontal .finish-bar-fill::after{
  background:
    radial-gradient(circle at var(--breakpoint) 50%, rgba(var(--tone-rgb),0.40) 0%, rgba(var(--tone-rgb),0.24) 9%, rgba(var(--tone-rgb),0.12) 18%, rgba(var(--tone-rgb),0.00) 34%),
    linear-gradient(90deg, rgba(var(--tone-rgb),0.12) 0%, rgba(var(--tone-rgb),0.28) 50%, rgba(var(--tone-rgb),0.12) 100%),
    repeating-linear-gradient(90deg, rgba(214,244,255,0.14) 0 1px, transparent 1px 10px);
  mask: linear-gradient(180deg, transparent 6px, #000 6px calc(100% - 6px), transparent calc(100% - 6px));
}
.finish-bar-vertical .finish-bar-fill::after{
  background:
    radial-gradient(circle at 50% var(--breakpoint), rgba(var(--tone-rgb),0.40) 0%, rgba(var(--tone-rgb),0.24) 10%, rgba(var(--tone-rgb),0.12) 18%, rgba(var(--tone-rgb),0.00) 34%),
    linear-gradient(180deg, rgba(var(--tone-rgb),0.12) 0%, rgba(var(--tone-rgb),0.28) 50%, rgba(var(--tone-rgb),0.12) 100%),
    repeating-linear-gradient(180deg, rgba(214,244,255,0.14) 0 1px, transparent 1px 10px);
  mask: linear-gradient(90deg, transparent 6px, #000 6px calc(100% - 6px), transparent calc(100% - 6px));
}
.finish-bar-divider{
  position:absolute;
  background:rgba(243,251,255,0.96);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12),
    0 0 12px rgba(255,255,255,0.52),
    0 0 22px rgba(var(--tone-rgb),0.52);
}
.finish-bar-horizontal .finish-bar-divider{
  top:4px;
  bottom:4px;
  width:2px;
  transform:translateX(-1px);
}
.finish-bar-vertical .finish-bar-divider{
  left:4px;
  right:4px;
  height:2px;
  transform:translateY(-1px);
}
.finish-bar-text,
.finish-bar-axis-label{
  position:absolute;
  z-index:2;
  color:#f6fbff;
  font-weight:800;
  line-height:1;
  text-shadow:0 1px 2px rgba(0,0,0,.45);
}
.finish-bar-text{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:42px;
  min-height:28px;
  padding:0 10px;
  border-radius:11px;
  background:linear-gradient(180deg, rgba(28,39,55,0.92), rgba(11,17,25,0.88));
  border:1px solid rgba(208,236,255,0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 10px 18px rgba(0,0,0,0.22),
    0 0 0 1px rgba(255,255,255,0.02);
  font-size:12px;
  letter-spacing:0.01em;
}
.finish-bar-horizontal .finish-bar-text{
  top:-16px;
}
.finish-bar-horizontal .finish-bar-text-start{left:-2px;}
.finish-bar-horizontal .finish-bar-text-end{right:-2px;}
.finish-bar-vertical .finish-bar-text{
  min-width:36px;
  min-height:24px;
  padding:0 8px;
  font-size:12px;
  transform:rotate(-90deg);
  transform-origin:center center;
}
.finish-bar-vertical .finish-bar-text-start{left:-12px; top:-2px;}
.finish-bar-vertical .finish-bar-text-end{left:-12px; bottom:-2px;}
.finish-bar-axis-label{
  font-size:10px;
  font-weight:700;
  letter-spacing:.14em;
  color:rgba(234,245,255,0.82);
}
.finish-bar-axis-label-left{left:-2px;bottom:-18px;}
.finish-bar-axis-label-right{right:-2px;bottom:-18px;}
.finish-bar-axis-label-top{left:-18px;top:0;}
.finish-bar-axis-label-bottom{left:-18px;bottom:0;}
@media (max-width: 900px){
  .finish-bar-fill{border-radius:12px;}
  .finish-bar-text{min-width:38px;min-height:24px;padding:0 8px;font-size:11px;border-radius:10px;}
  .finish-bar-horizontal .finish-bar-text{top:-14px;}
  .finish-bar-vertical .finish-bar-text{min-width:32px;min-height:22px;font-size:11px;left:-10px;}
  .finish-bar-axis-label{font-size:9px;}
}



/* === THEME DOT SWITCHER === */
.mobile-shell-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.theme-switcher{
  display:flex;
  align-items:center;
  gap:10px;
  flex:0 0 auto;
}

.theme-switcher-desktop{
  margin-left:auto;
  margin-right:4px;
}

.theme-dot{
  appearance:none;
  width:14px;
  height:14px;
  padding:0;
  border-radius:999px;
  border:2px solid rgba(255,255,255,.22);
  cursor:pointer;
  outline:none;
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease, opacity .16s ease;
  box-shadow:0 0 0 1px rgba(0,0,0,.24) inset;
  opacity:.92;
}

.theme-dot:hover{
  transform:scale(1.12);
  opacity:1;
}

.theme-dot:focus-visible{
  border-color:rgba(255,255,255,.9);
  box-shadow:0 0 0 3px rgba(255,255,255,.12), 0 0 16px var(--theme-glow);
}

.theme-dot.is-active{
  border-color:rgba(255,255,255,.96);
  box-shadow:0 0 0 3px rgba(255,255,255,.10), 0 0 20px var(--theme-glow);
  transform:scale(1.08);
  opacity:1;
}

.theme-arctic{
  background:linear-gradient(135deg, #8bd0ff, #4d96ff);
}

.theme-nebula{
  background:linear-gradient(135deg, #c48cff, #7b52ff);
}

.theme-solar{
  background:linear-gradient(135deg, #ffd978, #f4b843);
}

@media (max-width: 900px){
  .theme-switcher{
    gap:8px;
  }
  .theme-dot{
    width:13px;
    height:13px;
  }
  .mobile-shell-top{
    padding:6px 8px;
  }
}

body[data-theme="arctic"]{
  --accent:#6db3ff;
  --accent-soft:rgba(109,179,255,.16);
  --accent-line:rgba(109,179,255,.35);
  --theme-glow:rgba(109,179,255,.22);
  --theme-panel:rgba(109,179,255,.08);
  --theme-panel-strong:rgba(109,179,255,.14);
  --theme-ring:rgba(109,179,255,.28);
}

body[data-theme="nebula"]{
  --accent:#b57cff;
  --accent-soft:rgba(181,124,255,.18);
  --accent-line:rgba(181,124,255,.38);
  --theme-glow:rgba(181,124,255,.22);
  --theme-panel:rgba(124,92,255,.10);
  --theme-panel-strong:rgba(181,124,255,.16);
  --theme-ring:rgba(181,124,255,.30);
}

body[data-theme="solar"]{
  --accent:#f4d35e;
  --accent-soft:rgba(244,211,94,.18);
  --accent-line:rgba(244,211,94,.38);
  --theme-glow:rgba(244,211,94,.20);
  --theme-panel:rgba(244,211,94,.10);
  --theme-panel-strong:rgba(244,211,94,.16);
  --theme-ring:rgba(244,211,94,.28);
}


/* === THEME VISUAL POLISH (NO LAYOUT CHANGES) === */
body{
  transition:background .26s ease, color .22s ease;
}

.topbar,
.toolbar,
.canvas-frame,
.sidebar-card,
.mobile-shell-card,
.mobile-shell-top,
.mobile-mask-bar{
  transition:border-color .22s ease, box-shadow .22s ease, background .22s ease;
}

.tool-btn,
.tab-btn,
.zoom-option,
.mobile-chip,
.mobile-shell-btn,
.analysis-mode-btn{
  transition:transform .14s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease, color .18s ease;
}

.tool-btn:active,
.tab-btn:active,
.zoom-option:active,
.mobile-chip:active,
.mobile-shell-btn:active,
.analysis-mode-btn:active{
  transform:translateY(1px);
}

.topbar{
  box-shadow:0 18px 40px rgba(0,0,0,.34), 0 0 0 1px rgba(255,255,255,.02) inset, 0 0 28px var(--theme-glow);
}

.toolbar,
.mobile-shell-card,
.mobile-mask-bar,
.sidebar-card,
.canvas-frame{
  box-shadow:var(--shadow), 0 0 0 1px rgba(255,255,255,.025) inset;
}

.canvas-frame{
  border-color:color-mix(in srgb, var(--accent-line) 70%, rgba(255,255,255,.08));
}

.canvas-inner{
  background:linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,.006));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.03);
}

.image-stage{
  background:
    radial-gradient(circle at 50% 0%, var(--theme-panel) 0%, transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.005)),
    linear-gradient(180deg, rgba(109,179,255,.05), rgba(109,179,255,.015));
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.02), 0 0 24px rgba(0,0,0,.16);
}

.brand-mark{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 8px 22px var(--theme-glow), 0 0 0 1px rgba(255,255,255,.03);
}

.tab-btn.is-active,
.tool-btn-strong,
.mobile-chip.is-active,
.mobile-shell-btn-strong,
.analysis-mode-btn.is-active,
.zoom-option.is-active{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 0 18px var(--theme-glow);
}

.tool-btn:hover,
.tab-btn:hover,
.mobile-chip:hover,
.mobile-shell-btn:hover,
.analysis-mode-btn:hover,
.zoom-option:hover{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), 0 0 14px color-mix(in srgb, var(--theme-glow) 80%, transparent);
}

.theme-dot{
  box-shadow:0 0 0 1px rgba(0,0,0,.24) inset, 0 0 10px transparent;
}

.theme-dot.is-active{
  box-shadow:0 0 0 3px rgba(255,255,255,.12), 0 0 18px var(--theme-glow), 0 0 30px color-mix(in srgb, var(--theme-glow) 70%, transparent);
}

.grade-ring,
.mobile-grade-ring,
.mobile-shell-grade-ring{
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.05), 0 0 22px var(--theme-ring);
}

.crop-handle{
  border-color:color-mix(in srgb, var(--accent) 72%, white);
  box-shadow:0 0 0 1px rgba(255,255,255,.08), 0 0 18px var(--theme-glow), 0 0 28px color-mix(in srgb, var(--theme-glow) 70%, transparent);
}

.corner-view-btn.is-active,
.mobile-corner-view-btn.is-active{
  border-color:var(--accent-line);
  background:linear-gradient(180deg, color-mix(in srgb, var(--theme-panel-strong) 90%, rgba(255,255,255,.04)), color-mix(in srgb, var(--theme-panel) 90%, rgba(255,255,255,.02)));
  box-shadow:0 0 0 1px rgba(255,255,255,.04) inset, 0 0 16px var(--theme-glow);
}

.finish-bar{
  border-color:color-mix(in srgb, rgba(var(--tone-rgb,250,204,21),.36) 75%, rgba(255,255,255,.10));
  box-shadow:0 8px 24px rgba(0,0,0,.26), 0 0 0 1px rgba(255,255,255,.03) inset;
  backdrop-filter:blur(8px);
}

.finish-bar-text,
.finish-bar-axis-label{
  box-shadow:0 8px 18px rgba(0,0,0,.24);
}

.view-indicator,
.zoom-dropdown,
.mobile-shell-zoom-dropdown,
.canvas-debug-overlay{
  box-shadow:0 12px 28px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.03) inset;
}

body[data-theme="arctic"]{
  background:
    radial-gradient(circle at top, rgba(109,179,255,.10), transparent 26%),
    radial-gradient(circle at 80% 16%, rgba(125,206,255,.06), transparent 18%),
    linear-gradient(180deg, #0b0e13 0%, #090c11 100%);
}
body[data-theme="arctic"] .topbar,
body[data-theme="arctic"] .toolbar,
body[data-theme="arctic"] .canvas-frame,
body[data-theme="arctic"] .sidebar-card,
body[data-theme="arctic"] .mobile-shell-card,
body[data-theme="arctic"] .mobile-shell-top,
body[data-theme="arctic"] .mobile-mask-bar{
  background:linear-gradient(180deg, rgba(18,25,34,.96), rgba(11,16,24,.96));
}

body[data-theme="nebula"]{
  background:
    radial-gradient(circle at top, rgba(181,124,255,.12), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(102,77,255,.08), transparent 18%),
    linear-gradient(180deg, #0b0913 0%, #090711 100%);
}
body[data-theme="nebula"] .topbar,
body[data-theme="nebula"] .toolbar,
body[data-theme="nebula"] .canvas-frame,
body[data-theme="nebula"] .sidebar-card,
body[data-theme="nebula"] .mobile-shell-card,
body[data-theme="nebula"] .mobile-shell-top,
body[data-theme="nebula"] .mobile-mask-bar{
  background:linear-gradient(180deg, rgba(25,20,39,.96), rgba(16,12,28,.96));
}
body[data-theme="nebula"] .brand-mark{
  background:linear-gradient(135deg, rgba(196,140,255,.95), rgba(123,82,255,.24));
}
body[data-theme="nebula"] #cropPolygon,
body[data-theme="nebula"] #overlaySvg line,
body[data-theme="nebula"] #overlayArrowHead path{
  stroke:rgba(224,208,255,.9);
  fill:rgba(224,208,255,.86);
}
body[data-theme="nebula"] .image-stage{
  background:
    radial-gradient(circle at 50% 0%, rgba(181,124,255,.11) 0%, transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,.006)),
    linear-gradient(180deg, rgba(123,82,255,.05), rgba(123,82,255,.015));
}

body[data-theme="solar"]{
  background:
    radial-gradient(circle at top, rgba(244,211,94,.11), transparent 24%),
    radial-gradient(circle at 78% 18%, rgba(255,184,77,.08), transparent 18%),
    linear-gradient(180deg, #110e09 0%, #0d0b08 100%);
}
body[data-theme="solar"] .topbar,
body[data-theme="solar"] .toolbar,
body[data-theme="solar"] .canvas-frame,
body[data-theme="solar"] .sidebar-card,
body[data-theme="solar"] .mobile-shell-card,
body[data-theme="solar"] .mobile-shell-top,
body[data-theme="solar"] .mobile-mask-bar{
  background:linear-gradient(180deg, rgba(30,24,15,.96), rgba(18,14,10,.96));
}
body[data-theme="solar"] .brand-mark{
  background:linear-gradient(135deg, rgba(255,226,138,.96), rgba(244,184,67,.24));
}
body[data-theme="solar"] .tab-btn.is-active,
body[data-theme="solar"] .tool-btn-strong,
body[data-theme="solar"] .mobile-chip.is-active,
body[data-theme="solar"] .mobile-shell-btn-strong,
body[data-theme="solar"] .analysis-mode-btn.is-active,
body[data-theme="solar"] .zoom-option.is-active{
  color:#fff6db;
}
body[data-theme="solar"] .image-stage{
  background:
    radial-gradient(circle at 50% 0%, rgba(244,211,94,.12) 0%, transparent 44%),
    linear-gradient(180deg, rgba(255,255,255,.022), rgba(255,255,255,.006)),
    linear-gradient(180deg, rgba(244,184,67,.05), rgba(244,184,67,.015));
}
body[data-theme="solar"] .placeholder-dot{
  box-shadow:0 0 14px rgba(244,211,94,.52);
}

@media (max-width: 900px){
  .topbar,
  .toolbar,
  .canvas-frame,
  .sidebar-card,
  .mobile-shell-card,
  .mobile-shell-top,
  .mobile-mask-bar{
    box-shadow:0 14px 28px rgba(0,0,0,.28), 0 0 0 1px rgba(255,255,255,.02) inset;
  }
  .theme-dot.is-active{
    box-shadow:0 0 0 2px rgba(255,255,255,.14), 0 0 14px var(--theme-glow);
  }
}


/* === Psyduck logo implementation (safe) === */
.brand-mark,
.mobile-shell-logo{
  background-image: url("logo-psyduck.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  box-shadow: none;
}

.brand-mark{
  overflow: hidden;
}

.mobile-shell-logo{
  overflow: hidden;
}


@media (max-width: 820px){
  .site-footer{
    padding:6px 10px calc(6px + env(safe-area-inset-bottom));
  }

  .site-footer__inner{
    width:min(100%, 420px);
    font-size:11px;
  }
}

@media (max-width: 480px){
  .site-footer__inner{
    font-size:10px;
    gap:8px;
  }

  .site-footer__copy{
    white-space:normal;
  }
}


/* === TARGETED MOBILE LANDSCAPE FOOTER FIX === */
@media (orientation: landscape) and (pointer: coarse) and (max-width: 1200px){
  html,
  body{
    height:auto;
    min-height:100dvh;
    overflow:auto;
  }

  body{
    display:grid;
    grid-template-rows:minmax(0,1fr) auto;
  }

  .app-shell{
    height:auto;
    min-height:calc(100dvh - var(--footer-h));
  }

  .site-footer{
    position:relative;
    inset:auto;
    margin-top:0;
  }
}

@media (orientation: landscape) and (pointer: coarse) and (max-width: 820px){
  html,
  body{
    height:auto;
    min-height:100dvh;
    overflow:auto;
  }

  body{
    display:grid;
    grid-template-rows:minmax(0,1fr) auto;
  }

  .mobile-shell-static{
    height:auto;
    min-height:calc(100dvh - var(--footer-h));
    overflow:visible;
  }

  .site-footer{
    position:relative;
    inset:auto;
  }
}
