:root{
    --bg:#ffffff;
    --ink:#0b0b0b;
    --muted:#6b6b6b;
    --line:#1a1a1a;
    --soft:#f4f4f4;
  }
  
  html,body{
    margin:0;
    padding:0;
    background:var(--bg);
    color:var(--ink);
    font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  }
  
  canvas{ display:block; }
  
  .ui{
    position:fixed;
    inset:0;
    pointer-events:none;
    padding:22px 26px;
  }
  
  .head{
    display:flex;
    justify-content:space-between;
    gap:18px;
    align-items:flex-start;
  }
  
  .left{ max-width:780px; }
  .kicker{ font-size:12px; color:var(--muted); letter-spacing:0.02em; margin-bottom:6px; }
  h1{ font-size:30px; line-height:1.05; margin:0 0 8px 0; }
  .sub{ font-size:14px; line-height:1.4; color:var(--muted); margin:0; }
  
  .row{
    margin-top:10px;
    display:flex;
    gap:10px;
    align-items:center;
    flex-wrap:wrap;
    pointer-events:auto;
  }
  
  .seg{
    display:flex;
    border:1px solid var(--line);
    border-radius:999px;
    overflow:hidden;
  }
  .seg button{
    border:0;
    background:#fff;
    padding:8px 12px;
    font-weight:700;
    font-size:12px;
    cursor:pointer;
  }
  .seg button.active{ background:var(--ink); color:#fff; }
  
  .pill{
    border:1px solid var(--line);
    border-radius:999px;
    padding:9px 12px;
    font-size:13px;
    font-weight:650;
    background:var(--soft);
  }
  
  .note{ font-size:12px; color:var(--muted); }
  
  .right{ pointer-events:auto; }
  .controls{ display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; margin-bottom:10px; }
  
  .btn{
    appearance:none;
    border:1px solid var(--line);
    background:#fff;
    border-radius:999px;
    padding:10px 14px;
    font-weight:650;
    font-size:13px;
    cursor:pointer;
    text-decoration:none;
    color:inherit;
  }
  .btn:active{ transform:translateY(1px); }
  .btn.link{ display:inline-flex; align-items:center; }
  
  .toast{
    position:fixed;
    left:18px;
    bottom:18px;
    background:#111;
    color:#fff;
    padding:10px 12px;
    border-radius:12px;
    font-size:13px;
    opacity:0;
    transform:translateY(6px);
    transition:opacity 0.2s ease, transform 0.2s ease;
    pointer-events:none;
  }
  .toast.show{ opacity:1; transform:translateY(0); }
  
  /* Archive page */
  .archiveBody{ padding:24px; }
  .archiveHeader{ display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:18px; }
  .archiveHeader h1{ margin:0; font-size:28px; }
  .archiveActions{ display:flex; gap:10px; flex-wrap:wrap; }
  
  .archiveMain{ display:grid; grid-template-columns: 1fr; gap:16px; }
  
  .card{
    border:2px solid var(--line);
    border-radius:18px;
    padding:16px;
  }
  .cardHead h2{ margin:0 0 6px 0; font-size:18px; }
  .muted{ margin:0; color:var(--muted); font-size:13px; }
  
  .grid{
    margin-top:14px;
    display:grid;
    grid-template-columns: repeat(13, minmax(0, 1fr));
    gap:10px;
  }
  
  .tile{
    border:1px solid #b9b9b9;
    border-radius:12px;
    padding:10px;
    background:#fff;
  }
  .tileHead{ display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
  .tileLabel{ font-weight:800; font-size:13px; }
  .tileButtons{ display:flex; gap:6px; }
  .tileButtons button{
    border:1px solid var(--line);
    background:#fff;
    border-radius:999px;
    padding:6px 10px;
    font-size:11px;
    font-weight:750;
    cursor:pointer;
  }
  
  .thumb{
    width:100%;
    aspect-ratio: 1/1;
    background:#fff;
    border-radius:10px;
    border:1px solid #eee;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
  }
  .thumb img{ width:100%; height:100%; object-fit:contain; }
  
  .sentenceLine{
    margin-top:14px;
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    align-items:flex-end;
  }
  .wordChip{
    border:1px solid #b9b9b9;
    border-radius:999px;
    padding:8px 12px;
    font-weight:750;
    font-size:13px;
  }
  .sentenceControls{ margin-top:12px; display:flex; gap:10px; flex-wrap:wrap; }
  
  .previewWrap{
    margin-top:12px;
    border:1px solid #b9b9b9;
    border-radius:16px;
    overflow:hidden;
  }
  #previewCanvas{ width:100%; height:auto; display:block; background:#fff; }


  .archiveBar{
    margin-top:12px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
  }
  .selected{
    font-weight:750;
    font-size:13px;
    color:#111;
  }
  .barBtns{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
  }
  .tile.selectedTile{
    outline: 3px solid #111;
  }





  .archiveControls{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    margin:12px 0 10px;
    flex-wrap:wrap;
  }
  
  .selectedLabel{
    font-weight:700;
    font-size:13px;
  }
  
  .btnRow{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
  }
  
  /* make sure tiles are clickable */
  .tile{ cursor:pointer; }
  .tile.selectedTile{ outline:3px solid #111; }







  .wordChip{
    display:flex;
    flex-direction:column;
    gap:6px;
    padding:10px 12px;
    border:1px solid #bbb;
    border-radius:999px;
    background:#fff;
    cursor:pointer;
    align-items:center;
  }
  
  .wordLabel{
    font-weight:700;
    font-size:13px;
  }
  
  .wordThumb{
    width:70px;
    height:44px;
    border:1px solid #e5e5e5;
    border-radius:12px;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    background:#fff;
  }
  
  .wordThumb img{
    width:100%;
    height:100%;
    object-fit:contain;
  }






  /* 2-column archive layout */
.archiveGrid2{
  display:grid;
  grid-template-columns: 1fr 1.15fr;
  gap:16px;
  align-items:stretch;
}

.archiveLeftCol{
  display:grid;
  grid-template-rows: 1fr 1fr;
  gap:16px;
  min-height: 0;
}

.archivePreviewCard #previewCanvas{

  width:100%;
  height:auto;   /* keep aspect ratio */
  display:block;

}
.archivePreviewCard .previewWrap{
  flex:1;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#fff;
}

/* keep a stable preview ratio */
.archivePreviewCard .previewWrap{
  aspect-ratio: 11 / 6; /* matches 1100x600 */
}

/* canvas scales to wrapper without distortion */
.archivePreviewCard #previewCanvas{
  width:100%;
  height:100%;
  display:block;
}

.archivePreviewCard #previewCanvas{
  width:100%;
  height:100%;
  display:block;
}

.archiveLeftCol .card{
  min-height:0;
  overflow:auto;
}






.previewControls{
  margin-top:12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}





/* sentence archive uses same control bar spacing as a–z */
#sentenceSelected{
  font-weight:700;
  font-size:13px;
}



/* Primary button (used for Open Archive) */
.btnPrimary{
  background:#111;
  color:#fff;
  font-weight:800;
  border:1px solid #111;
}

.btnPrimary:hover{
  background:#000;
}