/* ---------- tokens ---------- */
:root{
    --bg: #fcfefe;
    --ink: #1f2a2a;
    --muted: #5c6a69;
    --line: #e6eceb;
    --card: #ffffff;
    --accent: #4d7471;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .875rem;
    --space-4: 1.25rem;
    --radius: 12px;
    --shadow: 0 4px 16px rgba(0,0,0,.06);
  }
  
  * { box-sizing: border-box; }
  html, body { margin: 0; }
  body{
    min-height: 100dvh;
    overflow-x: hidden;     /* no sideways scroll */
    overflow-y: auto;       /* allow page scroll */
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
  }
  
  /* ---------- layout ---------- */
  /* Keep the big, readable image, but add breathing room via inner padding & cards */
  .editor-grid{
    display: grid;
    grid-template-columns: 30vw 70vw; /* keep your 80% image column */
    width: 100vw;
    gap: 0;                /* avoid extra width; panes have internal padding */
  }
  
  .left-pane,
  .right-pane{ padding: var(--space-4); }
  
  .left-pane{
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
  }
  
  /* RIGHT column */
  .right-pane{
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
  }
  
  /* ---------- cards & headings ---------- */
  .card{
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow);
  }
  
  .card-title{
    margin: 0 0 var(--space-2) 0;
    font-size: 1.05rem;
  }
  
  .card-subtitle{
    margin: 0 0 var(--space-2) 0;
    font-size: .98rem;
    color: var(--muted);
  }
  
  /* collapsible sections */
  details.card > summary.card-summary{
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    margin: 0;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: .5ch;
  }
  details.card > summary.card-summary::before{
    content: "▸";
    transition: transform .15s ease;
  }
  details[open].card > summary.card-summary::before{
    transform: rotate(90deg);
  }
  
  /* lists: more breathing room */
  .results ul, .results ol,
  .card ul, .card ol{
    margin: 0;
    padding-left: 1.1rem;
  }
  .results li, .card li{ margin-block: .25rem; }
  
  /* ---------- controls ---------- */
  .uploader{ display: grid; gap: var(--space-2); }
  
  .buttons{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .inline{ display: grid; gap: .375rem; }
  
  button, select, input[type="file"]{
    font: inherit;
    padding: .6rem .8rem;
    border-radius: 10px;
    border: 1px solid #cfd9d8;
    background: #fff;
  }
  button{ cursor: pointer; }
  button:disabled{ opacity: .6; cursor: not-allowed; }
  
  /* decision row */
  .decision .decision-row{
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: center;
  }
  #status{ margin-left: auto; font-size: .9rem; color: var(--muted); }
  
  /* caption */
  .image-caption{
    display: none; /* shown by JS */
    font-size: .95rem;
    color: #334;
    background: #f6fbfb;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: .6rem .75rem;
  }
  
  /* history grid: fewer, larger thumbs = calmer */
  .grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px,1fr));
    gap: 8px;
  }
  .grid img.thumb{
    width: 100%;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.05);
  }
  
  /* ---------- image + progress ---------- */
  .progress{
    width: 100%;
    height: 8px;
    background: #eef3f2;
    border-radius: 999px;
    overflow: hidden;
    display: none;
  }
  .progress.active{ display: block; }
  .progress-bar{
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width .25s linear;
  }
  .progress-bar.error{ background: #c0392b; }
  
  .preview{
    background: #f9fcfc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  
  /* prevent warping; keep aspect ratio; fill right column width comfortably */
  .canvas{
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;         /* preserves aspect ratio */
    image-rendering: auto;
  }
  
  
  /* ---------- responsive ---------- */
  @media (max-width: 1100px){
    /* give a bit more room to controls visually */
    .card{ padding: .9rem; }
  }
  
  @media (max-width: 900px){
    .editor-grid{ grid-template-columns: 1fr; }
    .right-pane{ order: -1; }        /* image first on small screens */
    .left-pane, .right-pane{ padding: var(--space-3); }
  }
  