  .panel { display: none; }
  .panel.active { display: block; }
  .drop { border: 2px dashed #39414d; border-radius: 12px; padding: 34px 20px; text-align: center;
          transition: border-color .15s, background .15s; }
  .drop.over { border-color: #3b82f6; background: #16203a; }
  .pick { background: #2563eb; color: #fff; border: 0; border-radius: 9px; padding: 11px 18px;
          font-size: .98rem; cursor: pointer; }
  .pick:hover { background: #1d4ed8; }
  .pick:disabled { background: #33415a; cursor: default; }
  .hint { color: #79828f; font-size: .85rem; margin-top: 10px; }
  .opts { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; }
  .opts label { font-size: .9rem; color: #c4ccd8; }
  .status { margin: 18px 0; padding: 12px 14px; border-radius: 9px; background: #131a26; font-size: .92rem; }
  .big { font-size: 2rem; font-weight: 700; margin: 8px 0; }
  .err { background: #4a1f22; color: #ffb4ac; }
  .ok { background: #16341f; color: #9be6ac; }
  .warnbox { background: #3a2f16; color: #e8cf8a; }
  canvas.result { max-width: 100%; border-radius: 10px; margin-top: 12px; display: none; }
  .spin { display:none; margin-top:14px; color:#9aa4b2; }
  .progress { height:6px; background:#1c2531; border-radius:6px; overflow:hidden; margin-top:10px; }
  .progress-fill { height:100%; width:40%; background:#3b82f6; border-radius:6px;
                   animation: slide 1.1s ease-in-out infinite; }
  @keyframes slide { 0% { margin-left:-42%; } 100% { margin-left:102%; } }
  .rtab { border-collapse: collapse; width: 100%; font-size: .92rem; }
  .rtab th, .rtab td { padding: 5px 8px; border-bottom: 1px solid #23402c; text-align: right; }
  .rtab th:first-child, .rtab td:first-child { text-align: left; }
  .rtab th { color: #c9f0d3; font-weight: 600; }
  .note { margin-top: 8px; color: #9aa4b2; font-size: .84rem; }
  .layers { background: #131a26; border-radius: 9px; padding: 10px 14px; margin: 0 0 6px; }
  .lg { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 4px 0; }
  .lt { color: #8a94a3; font-size: .82rem; min-width: 62px; text-transform: uppercase; letter-spacing: .04em; }
  .lg label { font-size: .9rem; color: #d6dde8; cursor: pointer; }
  .lg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
  .ver { color: #6b7480; font-size: .8rem; margin: 2px 2px 0; }
  .report { background: #131a26; border-radius: 9px; padding: 10px 14px 12px; margin: 0 0 6px; }
  .rbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 8px; }
  .rlabel { color: #8a94a3; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
  .seg { display: inline-flex; border: 1px solid #2c3647; border-radius: 8px; overflow: hidden; }
  .seg button { background: none; border: 0; color: #9aa4b2; padding: 5px 12px; font-size: .88rem; cursor: pointer; }
  .seg button + button { border-left: 1px solid #2c3647; }
  .seg button.active { background: #2563eb; color: #fff; }
  .rcopy { margin-left: auto; background: #1f2a3b; color: #dbe4f0; border: 1px solid #2c3647; border-radius: 8px;
           padding: 5px 12px; font-size: .88rem; cursor: pointer; }
  .rcopy:hover { background: #27354b; }
  .rcopy.done { background: #16341f; color: #9be6ac; border-color: #23402c; }
  .rtext { display: block; width: 100%; resize: vertical; background: #0b0f16; color: #e8ecf3; border: 1px solid #222a36;
           border-radius: 7px; padding: 9px 10px; font-family: inherit; font-size: .9rem; line-height: 1.45; }

  /* ---------- workspace: image viewer (left) + results / report (right) ---------- */
  .ws { display: none; }
  .panel.has-result .intro, .panel.has-result .drop { display: none; }
  .panel.has-result .ws { display: grid; grid-template-columns: minmax(0, 1fr) clamp(330px, 30vw, 450px);
                          gap: 18px; align-items: start; }
  .ws-main { display: flex; flex-direction: column; gap: 10px; height: calc(100vh - 78px); min-height: 460px; }
  .ws.over .viewer { outline: 2px dashed #3b82f6; outline-offset: -2px; }
  .viewer { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; background: #05080d;
            border: 1px solid #1c2431; border-radius: 12px; }
  .viewer canvas.result { margin: 0; border-radius: 0; }
  .viewer.fit canvas.result { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; }
  .viewer.fitw canvas.result { width: 100%; height: auto; max-width: none; }
  .ws-side { position: sticky; top: 12px; max-height: calc(100vh - 78px); overflow: auto; display: flex;
             flex-direction: column; gap: 12px; padding-right: 2px; }
  .ws-side .status, .ws-side .report, .ws-side .layers { margin: 0; }

  /* toolbar above the image */
  .toolbar { flex-direction: column; gap: 6px; padding: 8px 10px; background: #111824; border: 1px solid #1c2431;
             border-radius: 12px; }
  .tb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .tb-spacer { flex: 1 1 auto; }
  .ehint { color: #aeb8c6; font-size: .84rem; line-height: 1.35; min-height: 2.7em; padding: 0 2px; }
  .tbtn { display: inline-flex; align-items: center; gap: 6px; background: #1a2332; color: #dbe4f0; border: 1px solid #2c3647;
          border-radius: 9px; padding: 7px 12px; font-size: .88rem; line-height: 1.2; cursor: pointer; text-decoration: none; }
  .tbtn:hover:not(:disabled) { background: #232f43; }
  .tbtn:disabled { opacity: .45; cursor: default; }
  .tbtn svg { width: 15px; height: 15px; }
  .tbtn.amber { border-color: #b7791f; color: #f6d38a; background: #2a2112; }
  .tbtn.amber:hover { background: #352a15; }
  .btn-adjust { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(180deg, #3b82f6, #2563eb);
                color: #fff; border: 1px solid #60a5fa; border-radius: 10px; padding: 8px 15px; font-size: .93rem;
                font-weight: 600; line-height: 1.2; cursor: pointer; box-shadow: 0 2px 10px rgba(37,99,235,.35); }
  .btn-adjust svg { width: 17px; height: 17px; }
  .btn-adjust:hover:not(:disabled) { filter: brightness(1.08); }
  .btn-adjust:disabled { opacity: .5; cursor: default; }
  .btn-adjust[aria-pressed="true"] { background: linear-gradient(180deg, #22c55e, #16a34a); border-color: #4ade80;
                                     box-shadow: 0 2px 10px rgba(22,163,74,.35); }
  .btn-adjust.attn { animation: attn 1.6s ease-out 0s 3; }
  @keyframes attn {
    0%   { box-shadow: 0 0 0 0 rgba(96,165,250,.75), 0 2px 10px rgba(37,99,235,.35); }
    100% { box-shadow: 0 0 0 14px rgba(96,165,250,0), 0 2px 10px rgba(37,99,235,.35); }
  }
  @media (prefers-reduced-motion: reduce) { .btn-adjust.attn { animation: none; } }

  canvas.result { -webkit-user-select: none; user-select: none; }
  canvas.result.editing { touch-action: none; }
  canvas.result.placing { cursor: crosshair; }
  .loupe { position: fixed; z-index: 50; width: 160px; height: 160px; border-radius: 50%; border: 2px solid #3b82f6;
           box-shadow: 0 6px 24px rgba(0,0,0,.6); pointer-events: none; display: none; background: #000; }
  .ltip { position: fixed; z-index: 51; pointer-events: none; display: none; white-space: nowrap; background: rgba(11,15,22,.92);
          color: #e8ecf3; font-size: .8rem; padding: 3px 8px; border-radius: 6px; border: 1px solid #2c3647; }

  @media (max-width: 900px) {
    /* one column: the viewer takes the image's own height (no empty bands), at most 78 % of the screen */
    .panel.has-result .ws { grid-template-columns: minmax(0, 1fr); }
    .ws-main { height: auto; min-height: 0; }
    .viewer { flex: none; max-height: 78vh; }
    .viewer.fit canvas.result { position: static; display: block; width: auto; height: auto; max-width: 100%;
                                max-height: calc(78vh - 2px); margin: 0 auto; }
    .ws-side { position: static; max-height: none; overflow: visible; }
    .toolbar { padding: 7px 8px; }
    .tb-spacer { display: none; }
  }
