/* pythonware tools - base stylesheet
   greys are cool-tinted (blue channel highest) so the slate accent sits in family
   last touched: see CHANGELOG */

:root {
  --paper: #e6e7e9;
  --paper-2: #dcdee1;
  --surface: #f4f5f5;
  --surface-2: #eaebec;
  --rule: #ccd1d4;
  --rule-soft: #dfe2e4;
  --ink: #1b1e21;
  --ink-soft: #5a646d;
  --ink-faint: #8b949b;
  --slate: #2f5d6b;
  --slate-deep: #234853;
  --pass: #40704b;
  --over: #95463a;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gap: 22px;
  --radius: 6px;
  --max: 1060px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 0.975rem/1.65 var(--sans);
  /* faint horizontal banding, reads like ruled paper without being loud */
  background-image: linear-gradient(var(--paper-2) 1px, transparent 1px);
  background-size: 100% 96px;
}

a { color: var(--slate); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--slate-deep); }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0;
}

h1 { font-size: clamp(1.5rem, 1.15rem + 1.5vw, 2.15rem); }
h2 { font-size: 1.16rem; }
h3 { font-size: 1rem; }

p, ul, ol { margin: 0; }

code, kbd, samp { font-family: var(--mono); font-size: 0.9em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 18px; }

.stack > * + * { margin-top: var(--gap); }
.stack-s > * + * { margin-top: 10px; }
.stack-l > * + * { margin-top: 40px; }

/* ---- header ---- */

.top {
  border-bottom: 1px solid var(--rule);
  background: rgba(244, 245, 245, 0.86);
  backdrop-filter: saturate(140%) blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-in {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 56px;
}

.brand {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.brand span { color: var(--ink-faint); font-weight: 400; }

.nav { display: flex; gap: 16px; margin-left: auto; }

.nav a {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--slate); }

.nav-btn { display: none; }

/* ---- page furniture ---- */

main { padding: 34px 0 60px; }

.crumb {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-faint);
  margin-bottom: 14px;
}

.crumb a { color: var(--ink-soft); text-decoration: none; }
.crumb a:hover { text-decoration: underline; }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.lede { font-size: 1.03rem; color: var(--ink-soft); max-width: 62ch; }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

/* ---- the workbench: tool on the left, readout on the right ---- */

.bench { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 26px; align-items: start; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
}

.panel-tight { padding: 14px 16px; }

.side { position: sticky; top: 74px; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* ---- drop zone ---- */

.drop {
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.drop:hover { border-color: var(--slate); }
.drop.hot { border-color: var(--slate); background: #e4ebed; }
.drop:focus-visible { outline: 2px solid var(--slate); outline-offset: 2px; }

.drop b { font-family: var(--mono); font-weight: 600; display: block; margin-bottom: 4px; }
.drop small { color: var(--ink-faint); }

.drop input[type="file"] { display: none; }

/* ---- controls ---- */

.field { display: block; }

.field > span {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; min-width: 0; }

input[type="text"], input[type="number"], select {
  width: 100%;
  font: 400 0.92rem var(--mono);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 8px 10px;
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: 2px solid var(--slate);
  outline-offset: -1px;
  border-color: var(--slate);
}

input[type="range"] { width: 100%; accent-color: var(--slate); }

.check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--ink-soft); }
.check input { accent-color: var(--slate); }

.btn {
  font: 600 0.88rem var(--mono);
  letter-spacing: -0.01em;
  color: #f2f5f6;
  background: var(--slate);
  border: 1px solid var(--slate-deep);
  border-radius: 4px;
  padding: 9px 18px;
  cursor: pointer;
}

.btn:hover { background: var(--slate-deep); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn-ghost { color: var(--ink-soft); background: transparent; border-color: var(--rule); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ---- byte budget gauge: the one flourish on this site ---- */

.gauge { font-family: var(--mono); }

.gauge-nums {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.gauge-nums strong { font-size: 1.35rem; font-weight: 600; color: var(--ink); letter-spacing: -0.03em; }

.gauge-track {
  position: relative;
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
}

.gauge-fill { height: 100%; width: 0; background: var(--pass); transition: width 0.14s linear; }
.gauge-track.over .gauge-fill { background: var(--over); }

.gauge-notch {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink);
  left: 100%;
}

.gauge-legend { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--ink-faint); margin-top: 5px; }

/* ---- results ---- */

.out { display: none; }
.out.on { display: block; }

.thumb {
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff repeating-conic-gradient(var(--surface-2) 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
  padding: 6px;
}

.thumb img { margin: 0 auto; max-height: 260px; width: auto; }

.kv { font-family: var(--mono); font-size: 0.8rem; border-collapse: collapse; width: 100%; }
.kv th { text-align: left; font-weight: 400; color: var(--ink-faint); padding: 3px 10px 3px 0; white-space: nowrap; vertical-align: top; }
.kv td { padding: 3px 0; color: var(--ink); word-break: break-word; }

.files { list-style: none; padding: 0; font-family: var(--mono); font-size: 0.82rem; }
.files li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--rule-soft); }
.files li:first-child { border-top: 0; }
.files .nm { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .sz { color: var(--ink-faint); }

.msg {
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 9px 12px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--surface-2);
  color: var(--ink-soft);
}

.msg-bad { border-color: #d8b6b0; background: #f5e7e4; color: var(--over); }
.msg-ok { border-color: #b9cdbd; background: #e6efe8; color: var(--pass); }

.spin { color: var(--ink-faint); font-family: var(--mono); font-size: 0.82rem; }

/* ---- long-form copy under the tool ---- */

.prose { max-width: 68ch; }
.prose h2 { margin-top: 34px; }
.prose h3 { margin-top: 22px; }
.prose p, .prose ul, .prose ol { margin-top: 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 6px; }
.prose code { background: var(--surface-2); border: 1px solid var(--rule-soft); border-radius: 3px; padding: 1px 4px; }

.steps { list-style: none; padding: 0; counter-reset: s; }
.steps li { position: relative; padding-left: 34px; margin-top: 12px; counter-increment: s; }
.steps li::before {
  content: counter(s, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--slate);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0 4px;
  background: var(--surface);
}

.faq { border-top: 1px solid var(--rule); }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary {
  cursor: pointer;
  padding: 13px 0;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.faq summary:hover { color: var(--slate); }
.faq details > div { padding: 0 0 14px; color: var(--ink-soft); max-width: 66ch; }
.faq details > div > * + * { margin-top: 10px; }

/* ---- indexes and cross links ---- */

.idx { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.idx caption { text-align: left; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-faint); padding-bottom: 8px; }
.idx th { text-align: left; font-family: var(--mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); font-weight: 400; border-bottom: 1px solid var(--rule); padding: 0 12px 7px 0; }
.idx td { border-bottom: 1px solid var(--rule-soft); padding: 11px 12px 11px 0; vertical-align: top; }
.idx tr:hover td { background: var(--surface); }
.idx td:first-child { font-family: var(--mono); font-size: 0.88rem; letter-spacing: -0.015em; white-space: nowrap; }
.idx .what { color: var(--ink-soft); }
.idx .fmt { font-family: var(--mono); font-size: 0.76rem; color: var(--ink-faint); white-space: nowrap; }

.rel { list-style: none; padding: 0; font-family: var(--mono); font-size: 0.84rem; }
.rel li { padding: 8px 0; border-top: 1px solid var(--rule-soft); }
.rel li:first-child { border-top: 0; }
.rel a { text-decoration: none; }
.rel a:hover { text-decoration: underline; }
.rel small { display: block; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-faint); margin-top: 2px; }

.tags { display: flex; flex-wrap: wrap; gap: 7px; list-style: none; padding: 0; }
.tags a {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 4px 9px;
  background: var(--surface);
}
.tags a:hover { color: var(--ink); border-color: var(--slate); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 26px; }

.card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
}

.card h3 { margin-bottom: 6px; }
.card p { color: var(--ink-soft); font-size: 0.9rem; }

/* ---- footer ---- */

.foot { border-top: 1px solid var(--rule); background: var(--surface); padding: 34px 0 44px; font-size: 0.88rem; }
.foot h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint); font-weight: 400; margin-bottom: 9px; }
.foot ul { list-style: none; padding: 0; }
.foot li { padding: 3px 0; }
.foot a { color: var(--ink-soft); text-decoration: none; }
.foot a:hover { color: var(--ink); text-decoration: underline; }
.foot-note { border-top: 1px solid var(--rule); margin-top: 28px; padding-top: 16px; color: var(--ink-faint); font-size: 0.82rem; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 8px; z-index: 40; background: #fff; padding: 8px 12px; border: 1px solid var(--slate); }

/* ---- narrow screens ---- */

@media (max-width: 900px) {
  .bench { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}

@media (max-width: 640px) {
  body { background-size: 100% 80px; }
  main { padding: 24px 0 44px; }
  .nav { display: none; gap: 12px; }
  .nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    right: 12px;
    top: 54px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 10px 16px;
    box-shadow: 0 10px 24px -14px rgba(27, 30, 33, 0.4);
  }
  .nav-btn {
    display: block;
    margin-left: auto;
    font: 600 0.8rem var(--mono);
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
  }
  .panel { padding: 15px; }
  .idx td:first-child { white-space: normal; }
  .idx .fmt { display: none; }
  .idx thead th:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@media print {
  .top, .foot, .side, .drop { display: none; }
  body { background: #fff; }
}

/* ---- interactive canvases -------------------------------------------------
   Shared by crop, blur and the signature pad. These were page-scoped before
   three tools needed them. */

.stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background:
    linear-gradient(45deg, var(--paper-2) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, var(--paper-2) 25%, transparent 25%) 0 8px/16px 16px,
    linear-gradient(45deg, transparent 75%, var(--paper-2) 75%) 8px -8px/16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--paper-2) 75%) -8px 0/16px 16px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  touch-action: none;
  cursor: crosshair;
}

.stage canvas,
.stage img { display: block; max-width: 100%; height: auto; }

.sel {
  position: absolute;
  border: 1px dashed var(--ink);
  background: rgba(47, 93, 107, 0.16);
  pointer-events: none;
}

.pad {
  width: 100%;
  height: auto;
  max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-bottom: 2px solid var(--ink-faint);
  border-radius: 4px;
  touch-action: none;
  cursor: crosshair;
}

/* ---- index table, a little more readable at length ---------------------- */

.idx tbody tr:nth-child(odd) td { background: var(--surface-2); }
.idx tbody tr:hover td { background: var(--surface); }
.idx tbody tr:hover td:first-child a { text-decoration-thickness: 2px; }

/* ---- home hero ---------------------------------------------------------- */

.hero {
  padding: 34px 0 26px;
  border-bottom: 1px solid var(--rule);
  background:
    repeating-linear-gradient(90deg, var(--rule-soft) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(0deg, var(--rule-soft) 0 1px, transparent 1px 40px);
  background-position: center;
}

.hero .lede { max-width: 60ch; }

/* ---- dark mode ----------------------------------------------------------
   Same palette rotated, rather than a separate design. */

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181a;
    --paper-2: #1d2023;
    --surface: #1f2225;
    --surface-2: #24282b;
    --rule: #343a3e;
    --rule-soft: #2a2f33;
    --ink: #e4e7e9;
    --ink-soft: #a2acb3;
    --ink-faint: #737d84;
    --slate: #7fb3c2;
    --slate-deep: #a8ced9;
    --pass: #6fb280;
    --over: #d08574;
  }

  .hero { background-image: none; }
  .drop { background: var(--surface-2); }
  img, canvas { opacity: 0.94; }
}
