:root {
  /* Sage garden */
  --bg: #f5f7f2; --panel: #ffffff; --text: #25302a; --muted: #64706a; --line: #dde5da;
  --accent: #4a7a57; --accent-ink: #ffffff; --accent-soft: #e4eee5; --soft: #ebf1e8;
  --radius: 12px; --shadow: 0 1px 2px rgba(30, 50, 35, .06), 0 4px 16px rgba(30, 50, 35, .05);
  color-scheme: light;
}
/* Light is the default; dark only when the visitor picks it with the theme switcher. */
:root[data-theme="dark"] {
  --bg: #161a17; --panel: #1f2420; --text: #e8ede8; --muted: #a3ada5; --line: #323a34;
  --accent: #8cc49b; --accent-ink: #0f2416; --accent-soft: #24332a; --soft: #262c27;
  color-scheme: dark;
}
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; padding: 0; flex: none; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
.header-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
@media (max-width: 640px) {
  /* Phone: logo and theme button share the top row, menu goes underneath. */
  .header-right { display: contents; }
  .theme-toggle { order: 2; margin-left: auto; }
  .site-header nav { order: 3; width: 100%; padding-bottom: 10px; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
a { color: var(--accent); }
img, canvas { max-width: 100%; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--line); background: var(--panel); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.brand svg { flex: none; }
.site-header nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14.5px; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--text); }
.site-footer { border-top: 1px solid var(--line); margin-top: 56px; padding: 28px 0 40px; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* hero */
.hero { padding: 32px 0 12px; }
.hero h1 { font-size: clamp(28px, 4.5vw, 40px); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.01em; }
.hero p { margin: 0; color: var(--muted); max-width: 720px; font-size: 17px; }

/* tool */
.tool { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; margin: 20px 0 8px; align-items: start; }
@media (max-width: 860px) { .tool { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.controls { position: sticky; top: 12px; }
@media (max-width: 860px) { .controls { position: static; order: 2; } }
/* Big photo drop area above the preview */
.drop { position: relative; display: flex; align-items: center; gap: 18px; min-height: 118px; padding: 20px 22px;
  border: 2px dashed color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: 12px; cursor: pointer;
  background: var(--accent-soft); transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 85%, var(--accent)); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { flex: none; width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; background: var(--panel); color: var(--accent); }
.drop-icon svg { width: 28px; height: 28px; }
.drop-thumb { flex: none; width: 76px; height: 76px; border-radius: 10px; object-fit: cover; background: var(--panel); border: 1px solid var(--line); }
.drop-text { min-width: 0; }
.drop-text strong { display: block; font-size: 18px; line-height: 1.3; }
.drop-text span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.drop-btn { margin-left: auto; flex: none; pointer-events: none; padding: 10px 18px; font-size: 15px; }
.drop-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; margin: 8px 2px 16px; font-size: 13.5px; color: var(--muted); }
@media (max-width: 560px) {
  .drop { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .drop-btn { margin-left: 0; width: 100%; text-align: center; }
  .drop-thumb { width: 60px; height: 60px; }
}
/* Picture library */
.library { margin: 0 0 18px; }
.lib-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 0 2px 8px; }
.lib-head h2 { font-size: 15px; margin: 0; }
.lib-count { color: var(--muted); font-size: 13px; }
.lib-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 2px 10px; }
@media (max-width: 560px) { .lib-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; } }
.lib-tabs button { flex: none; font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
.lib-tabs button:hover { border-color: var(--accent); }
.lib-tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lib-blurb { color: var(--muted); font-size: 13px; margin: 0 2px 8px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.lib-item { font: inherit; display: flex; flex-direction: column; gap: 5px; align-items: stretch; padding: 5px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); cursor: pointer; text-align: center; }
.lib-item:hover { border-color: var(--accent); }
.lib-item[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.lib-item img { width: 100%; aspect-ratio: 1; border-radius: 6px; display: block; }
.lib-item span { font-size: 12px; line-height: 1.25; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; padding: 0; cursor: pointer; text-decoration: underline; }
.field { margin-top: 16px; }
.controls .field:first-child { margin-top: 0; }
.field > .lbl { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg label { text-align: center; font-size: 13px; padding: 7px 2px; cursor: pointer; border-right: 1px solid var(--line); line-height: 1.25; }
.seg label:last-child { border-right: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -3px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=number], select { font: inherit; font-size: 14px; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; }
input[type=number] { width: 72px; text-align: right; }
select { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 12px; font-size: 14px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); font-size: 12.5px; }
.privacy-note { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; }
.error { background: #fde8e8; color: #8a1c1c; border-radius: 8px; padding: 8px 10px; font-size: 14px; margin-top: 12px; }

.output { min-width: 0; }
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty svg { opacity: .5; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.summary { font-size: 14px; color: var(--muted); }
.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn { font: inherit; font-size: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chart-box { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; }
#chart { display: block; cursor: crosshair; touch-action: none; margin: 0 auto; }
.edit-hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

/* Chart with the color key: key below the chart by default (phones, narrow windows),
   in a column to the right of the chart on desktop. */
.chart-col { min-width: 0; }
.palette-title { display: none; }
@media (min-width: 1000px) {
  .chart-area { display: grid; grid-template-columns: minmax(0, 1fr) 196px; gap: 16px; align-items: start; }
  .palette-col { position: sticky; top: 12px; }
  .palette-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: 14px; margin: 2px 2px 8px; }
  .palette-title span { font-weight: 400; font-size: 12.5px; color: var(--muted); }
  .palette-col .palette { grid-template-columns: 1fr; margin-top: 0; }
}

.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 14px; }
.swatch { position: relative; display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 7px 28px 7px 8px; cursor: pointer; background: var(--panel); }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chip { width: 30px; height: 30px; border-radius: 7px; border: 1px solid rgba(0,0,0,.15); flex: none; position: relative; cursor: pointer; }
.chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.sw-text { font-size: 13px; line-height: 1.3; min-width: 0; }
.sw-text span { color: var(--text); }
.sw-text small { display: block; color: var(--muted); }
.merge { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }
.merge:hover { background: var(--soft); color: var(--text); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 12px; overflow-x: auto; }
.tabs button { font: inherit; font-size: 14.5px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.written { white-space: pre-wrap; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--soft); border-radius: 8px; padding: 12px; max-height: 520px; overflow: auto; margin: 0; }
.mat { width: 100%; border-collapse: collapse; font-size: 14px; }
.mat th, .mat td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.mat .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mat tfoot td { font-weight: 600; border-bottom: 0; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); vertical-align: -1px; }
.size { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; }

/* ad slots (empty until AdSense is approved) */
.ad-slot:empty { display: none; }
.ad-slot { margin: 24px auto; text-align: center; min-height: 90px; }

/* content */
.content { max-width: 760px; }
.content h2 { font-size: 26px; line-height: 1.25; margin: 44px 0 12px; }
.content h3 { font-size: 19px; margin: 26px 0 8px; }
.content p, .content li { color: var(--text); }
.content ol, .content ul { padding-left: 22px; }
.content li { margin: 6px 0; }
.styles-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.styles-grid .panel h3 { margin-top: 0; font-size: 17px; }
.styles-grid .panel p { margin: 0; font-size: 15px; color: var(--muted); }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
details summary { font-weight: 600; cursor: pointer; }
details p { margin: 8px 0 0; }
.page { max-width: 760px; padding: 32px 0; }
.page h1 { font-size: 32px; margin: 0 0 12px; }

@media print {
  .site-header, .site-footer, .controls, .content, .ad-slot, .hero p, .toolbar .btns, .tabs, .edit-hint, .merge, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  .tool { display: block; margin: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .tabpane { display: block !important; break-inside: auto; }
  .written { max-height: none; overflow: visible; background: none; padding: 0; font-size: 10.5px; }
  .chart-box { border: 0; overflow: visible; }
  #chart { max-width: 100% !important; height: auto !important; }
  .palette { grid-template-columns: repeat(4, 1fr); }
}
