/* KaryoMaker — CruxSci studio styling, mirrors the KaryoSnap look. */

:root,
[data-ui="light"] {
  --surface-bg: #f3f5fa;
  --panel: #ffffff;
  --edge: #e2e6ef;
  --ink: #212b38;
  --muted: #647082;
  --headline: #2c3d63;
  --accent: #5b7da3;
  --accent-hover: #4d6c92;
  --input-bg: #f7f8fc;
  --input-edge: #c9d2e4;
  --brand-b: #2563eb;
  --share: #7c4dcc;
  --share-hover: #6a3fb8;
}
[data-ui="colorful"] {
  --surface-bg: linear-gradient(135deg, #aab8f2 0%, #9fd9ef 100%);
  --panel: rgba(255, 255, 255, 0.93);
  --edge: #d9d4f2;
  --ink: #2a2f45;
  --muted: #5d6480;
  --headline: #3b3f66;
  --accent: #a75fa3;
  --accent-hover: #94518f;
  --input-bg: #ffffff;
  --input-edge: #cdc3ec;
  --brand-b: #7b4bd8;
  --share: #a75fa3;
  --share-hover: #94518f;
}
[data-ui="neon"] {
  --surface-bg: #0c0d18;
  --panel: #131527;
  --edge: #272b45;
  --ink: #e8ecff;
  --muted: #8b93b8;
  --headline: #36d8ff;
  --accent: #7c4dff;
  --accent-hover: #6a3fe8;
  --input-bg: #090a14;
  --input-edge: #36d8ff;
  --brand-b: #36d8ff;
  --share: #7c4dff;
  --share-hover: #6a3fe8;
}
[data-ui="dark"] {
  --surface-bg: #0b0e14;
  --panel: #151921;
  --edge: #2d343f;
  --ink: #e2e8f0;
  --muted: #94a3b8;
  --headline: #60a5fa;
  --accent: #3b82f6;
  --accent-hover: #2f6fd6;
  --input-bg: #05070c;
  --input-edge: #3b82f6;
  --brand-b: #60a5fa;
  --share: #7c4dff;
  --share-hover: #6a3fe8;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--surface-bg);
  color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
}
a { color: var(--headline); }

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--panel);
  border-bottom: 1px solid var(--edge);
  padding: 12px 20px 8px;
}
.wordmark {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: flex-start;
  gap: 1px;
}
.wm-a { color: var(--ink); }
.wm-b { color: var(--brand-b); }
.beta {
  margin-left: 5px;
  margin-top: -4px;
  display: inline-block;
  transform: rotate(-13deg);
  border: 1.5px solid rgba(180, 120, 20, 0.7);
  border-radius: 2px;
  padding: 0 4px;
  font-size: 8px;
  font-weight: 900;
  line-height: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(160, 105, 15, 0.85);
  -webkit-mask-image: radial-gradient(ellipse at 32% 68%, #000 45%, rgba(0,0,0,.55) 78%, rgba(0,0,0,.3) 100%);
  mask-image: radial-gradient(ellipse at 32% 68%, #000 45%, rgba(0,0,0,.55) 78%, rgba(0,0,0,.3) 100%);
}
.poweredby {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
}
.poweredby b { font-family: Syne, ui-sans-serif, sans-serif; color: var(--ink); font-weight: 700; }
.poweredby img { height: 14px; width: 14px; }
.divider { width: 1px; height: 30px; background: var(--edge); }
.tagline {
  font-family: Syne, ui-sans-serif, sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--headline);
}
.topright { margin-left: auto; display: flex; align-items: center; gap: 8px; align-self: flex-end; }
.header-links { display: flex; align-items: center; gap: 14px; margin-left: 8px; }
.header-links a { font-size: 13px; font-weight: 700; text-decoration: none; color: var(--headline); }
.header-links a:hover { text-decoration: underline; color: var(--brand-b); }
.minilabel { font-size: 11px; font-weight: 600; color: var(--muted); }
.subhead { margin: 8px 20px 0; font-size: 13px; color: var(--muted); max-width: 70ch; }

/* ---------- layout ---------- */
.layout { display: flex; gap: 20px; padding: 16px 20px 40px; align-items: flex-start; }
.panel {
  width: 310px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(15, 20, 40, 0.05);
}
.panel.hidden { display: none; }
.panelhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.paneltitle { font-family: Syne, ui-sans-serif, sans-serif; font-weight: 700; font-size: 14px; color: var(--headline); }
.stage { flex: 1 1 auto; min-width: 0; }
.stagehead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stagehead h2 { font-family: Syne, ui-sans-serif, sans-serif; font-size: 19px; font-weight: 700; color: var(--headline); margin: 0; }
.stageinfo { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.zoomrow { display: flex; align-items: center; gap: 6px; margin-left: 10px; }
.zoomrow span { font-size: 12px; font-weight: 600; color: var(--muted); width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.canvaswrap {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 6px 24px rgba(15, 20, 40, 0.12);
  overflow: auto;
  max-height: 78vh;
}
canvas { display: block; width: 100%; height: auto; }

/* ---------- controls ---------- */
h2.group {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 700;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--edge);
}
.field { margin-bottom: 10px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
select, input[type="text"] {
  width: 100%;
  border: 2px solid var(--input-edge);
  background: var(--input-bg);
  color: var(--ink);
  border-radius: 7px;
  padding: 7px 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}
select.mini { width: auto; padding: 4px 6px; font-size: 12px; border-width: 1px; }
.ctl { margin-bottom: 9px; }
.ctl .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.ctl .top b { color: var(--headline); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0 0; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.share { background: var(--share); color: #fff; }
.btn.share:hover { background: var(--share-hover); }
.btn.ghost { background: var(--input-bg); color: var(--ink); border-color: var(--input-edge); }
.btn.sm { flex: 0 0 auto; padding: 6px 10px; font-size: 12px; }
.btnrow { display: flex; gap: 8px; margin-top: 10px; }
.iconbtn {
  border: 1px solid var(--input-edge);
  background: var(--input-bg);
  color: var(--muted);
  border-radius: 999px;
  width: 26px; height: 26px;
  font-weight: 700; cursor: pointer; line-height: 1;
}
.iconbtn.sm { border-radius: 7px; width: auto; height: auto; padding: 3px 8px; }
.iconbtn:hover { color: var(--ink); }
.hidden { display: none; }

/* ---------- share ---------- */
.sharebox { margin-top: 16px; border-top: 1px solid var(--edge); padding-top: 12px; }
.sharetitle { font-size: 12px; font-weight: 700; color: var(--headline); margin-bottom: 2px; }
.pasterow { display: flex; gap: 6px; margin-top: 4px; }
.pasterow input { font-size: 12px; font-weight: 400; }
.sharemsg { font-size: 11.5px; color: var(--muted); min-height: 16px; margin-top: 6px; }
.sharemsg.ok { color: #1f8a4c; font-weight: 600; }

/* ---------- pro card + about ---------- */
.procard { margin-top: 16px; border: 1px solid var(--edge); background: var(--input-bg); border-radius: 9px; padding: 10px; }
.protitle { font-size: 13px; font-weight: 700; color: var(--headline); }
.protitle span { font-size: 11px; font-weight: 600; color: var(--muted); }
.procard p { margin: 4px 0 6px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.procard a { font-size: 11.5px; font-weight: 700; text-decoration: none; }
.procard a:hover { text-decoration: underline; }
.about { max-width: 74ch; margin: 26px auto 0; font-size: 14px; }
.about h3 { font-family: Syne, ui-sans-serif, sans-serif; font-size: 17px; color: var(--headline); margin-bottom: 6px; }
.about .muted { color: var(--muted); font-size: 13px; }
.err { color: #d33; font: 11px ui-monospace, Consolas, monospace; white-space: pre-wrap; margin-top: 8px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(12, 16, 28, 0.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal.hidden { display: none; }
.modalcard { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 18px; max-width: 520px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.modalcard h3 { font-family: Syne, ui-sans-serif, sans-serif; margin: 0 0 8px; color: var(--headline); }
.modalcard ol { margin: 0 0 12px; padding-left: 20px; font-size: 13.5px; line-height: 1.55; }
.modalcard li { margin-bottom: 5px; }

.checkrow { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); margin: 2px 0 4px; }

/* ---------- print: one landscape letter page, branded ---------- */
.printfoot { display: none; }
@media print {
  @page { size: letter landscape; margin: 10mm; }
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .layout { display: block; padding: 0; }
  .stage { width: 100%; }
  .canvaswrap {
    box-shadow: none;
    padding: 0;
    max-height: none;
    overflow: visible;
    text-align: center;
  }
  canvas {
    width: auto !important;
    max-width: 100%;
    max-height: 6.4in;
    height: auto;
    margin: 0 auto;
  }
  .printfoot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    border-top: 1px solid #d5d9e2;
    margin-top: 8px;
    padding-top: 6px;
    font-size: 11px;
    color: #4a5568;
  }
  .pf-brand { font-weight: 800; font-size: 14px; color: #1f2733; }
  .pf-brand span { color: #2563eb; }
  .pf-brand em { font-style: normal; font-weight: 600; font-size: 11px; color: #6b7785; }
}

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 65%, transparent); }
::-webkit-scrollbar-button { display: none; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .panel { width: 100%; }
}
