:root {
  color-scheme: light;
  --text: #292b2a; --muted: #646961; --background: #e9e9e4;
  --panel: #f7f6f1; --header: #263d36; --header-text: #faf8f0;
  --header-muted: #cfdbd4; --border: #d5d7cf; --input-border: #b9c1b6;
  --input: #ffffff; --hover: #e2eadd; --focus: #87ad92;
  --accent: #426d58; --export: #efdcab; --export-text: #292b2a;
  --canvas: #d9dbd4; --link: #245f9b;
  --error-text: #a12e21; --error-bg: #fff0e8; --error-border: #d6a495;
  font-family: system-ui, sans-serif; color: var(--text); background: var(--background);
}
:root[data-theme="catppuccin-mocha"] {
  color-scheme: dark;
  --text: #cdd6f4; --muted: #bac2de; --background: #1e1e2e;
  --panel: #181825; --header: #11111b; --header-text: #cdd6f4;
  --header-muted: #a6adc8; --border: #45475a; --input-border: #585b70;
  --input: #313244; --hover: #45475a; --focus: #cba6f7;
  --accent: #a6e3a1; --export: #cba6f7; --export-text: #11111b;
  --canvas: #313244; --link: #89b4fa;
  --error-text: #f38ba8; --error-bg: #313244; --error-border: #f38ba8;
}
:root[data-theme="nord"] {
  color-scheme: dark;
  --text: #eceff4; --muted: #d8dee9; --background: #2e3440;
  --panel: #3b4252; --header: #2e3440; --header-text: #eceff4;
  --header-muted: #d8dee9; --border: #4c566a; --input-border: #616e88;
  --input: #434c5e; --hover: #4c566a; --focus: #88c0d0;
  --accent: #88c0d0; --export: #a3be8c; --export-text: #2e3440;
  --canvas: #242933; --link: #88c0d0;
  --error-text: #edb9bf; --error-bg: #3b4252; --error-border: #bf616a;
}
:root[data-theme="solarized-light"] {
  color-scheme: light;
  --text: #073642; --muted: #586e75; --background: #eee8d5;
  --panel: #fdf6e3; --header: #073642; --header-text: #fdf6e3;
  --header-muted: #eee8d5; --border: #c9c4b3; --input-border: #839496;
  --input: #fdf6e3; --hover: #eee8d5; --focus: #268bd2;
  --accent: #2aa198; --export: #b58900; --export-text: #ffffff;
  --canvas: #ded8c5; --link: #006cad;
  --error-text: #a92d29; --error-bg: #fdf6e3; --error-border: #dc322f;
}
:root[data-theme="graphite"] {
  color-scheme: dark;
  --text: #eeeeee; --muted: #c0c0c0; --background: #202020;
  --panel: #292929; --header: #151515; --header-text: #ffffff;
  --header-muted: #bbbbbb; --border: #494949; --input-border: #676767;
  --input: #353535; --hover: #494949; --focus: #b8d8ff;
  --accent: #b8d8ff; --export: #dedede; --export-text: #151515;
  --canvas: #151515; --link: #b8d8ff;
  --error-text: #ffb4ab; --error-bg: #353535; --error-border: #ffb4ab;
}
* { box-sizing: border-box; }
body { margin: 0; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 28px; background: var(--header); color: var(--header-text); }
h1 { margin: 0; font-size: 24px; letter-spacing: -.5px; }
header p { margin: 4px 0 0; color: var(--header-muted); }
h1 { overflow-wrap: anywhere; }
a { color: var(--link); }
main { display: grid; grid-template-columns: 350px minmax(0, 1fr); height: calc(100vh - 100px); }
aside { overflow-y: auto; background: var(--panel); padding: 22px; border-right: 1px solid var(--border); }
section { margin-bottom: 24px; }
h2 { font-size: 15px; margin: 0 0 12px; }
section > label { display: block; font-weight: 650; margin-bottom: 8px; }
p { font-size: 12px; line-height: 1.5; color: var(--muted); }
button, select, input[type=number] { font: inherit; color: var(--text); border: 1px solid var(--input-border); border-radius: 6px; background: var(--input); padding: 8px 10px; }
button { cursor: pointer; }
button:hover:enabled { background: var(--hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#export { background: var(--export); color: var(--export-text); border: none; font-weight: 650; }
.export-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.export-controls label { font-size: 12px; }
.export-controls select { width: auto; max-width: 100%; }
select { width: 100%; }
.buttons { display: flex; gap: 8px; }
#source { max-height: 100px; max-width: 100%; margin-top: 6px; object-fit: contain; }
#filename { overflow-wrap: anywhere; }
#attribution { font-size: 9px; line-height: 1.4; }
.control { margin-bottom: 21px; }
.control-group { border-top: 1px solid var(--border); }
.control-group summary { padding: 14px 0; font-size: 14px; font-weight: 650; cursor: pointer; }
.control-group summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.group-content { padding: 4px 0 0; }
.control-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.control label { font-size: 13px; font-weight: 600; }
.control input[type=number] { width: 88px; padding: 5px 7px; font-size: 13px; }
.control input[type=range] { width: 100%; margin: 10px 0 0; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }
.control p { margin: 4px 0 0; font-size: 11px; }
article { display: flex; flex-direction: column; padding: 18px 24px; min-height: 0; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; font-size: 12px; }
.toolbar input { accent-color: var(--accent); }
#status { color: var(--muted); }
#canvas { flex: 1; min-height: 200px; margin-top: 16px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--canvas); border-radius: 8px; padding: 20px; }
#preview { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 3px 6px #0002); }
#error { color: var(--error-text); background: var(--error-bg); border: 1px solid var(--error-border); padding: 10px; margin: 12px 0 0; border-radius: 6px; }
.note { margin-bottom: 0; }
footer { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 12px 24px; font-size: 12px; }
footer select { width: auto; }
@media (max-width: 780px) {
  main { grid-template-columns: 1fr; height: auto; }
  aside { overflow: visible; }
  article { grid-row: 1; height: 72vh; min-height: 450px; padding: 14px; }
  header { padding: 16px; }
}
