:root {
  color-scheme: dark;
  --bg: #10141e;
  --panel: #1b2230;
  --bar: #161c28;
  --input: #101824;
  --button: #232d3d;
  --edge: #343e50;
  --text: #f4f6fb;
  --muted: #aab7cb;
  --accent: #7cafff;
  --primary-text: #0d1b31;
  --active: #29466c;
  --dot: #2b3548;
  background: var(--bg);
}
body.light {
  color-scheme: light;
  --bg: #f0f3f8;
  --panel: #fff;
  --bar: #f5f7fb;
  --input: #fff;
  --button: #f5f7fb;
  --edge: #c7d0dc;
  --text: #15243b;
  --muted: #53647a;
  --accent: #2863b4;
  --primary-text: #fff;
  --active: #dbe8fa;
  --dot: #b9c7d9;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: var(--bar);
  color: var(--text);
  font: 15px system-ui, sans-serif;
}
button, input, select { font: inherit }
button {
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--button);
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: .38; cursor: default }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px }
button.primary {
  background: var(--accent);
  color: var(--primary-text);
  border-color: transparent;
  font-weight: 700;
}
.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  flex: none;
  display: grid;
  place-items: center;
}
.icon-button svg { width: 22px; height: 22px; pointer-events: none }
header, footer { padding: 6px clamp(6px, 2vw, 16px); background: var(--bar); z-index: 2 }
header {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--edge);
}
.brand, .header-controls { display: flex; align-items: center }
.brand { margin-right: auto; gap: 6px; font-size: 17px; white-space: nowrap }
.brand img { display: block; border-radius: 6px }
.header-controls { gap: 4px; margin-left: auto }
.monitor {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 7px;
  font-size: 13px;
}
.track { display: block; position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--edge) }
.track::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--text);
}
.monitor[aria-checked=true] .track::before { transform: translateX(14px) }
@media (max-width: 460px) {
  .monitor-label { display: none }
  .monitor { min-width: 44px; justify-content: center; padding-inline: 4px }
  .header-controls { gap: 3px }
  .brand { gap: 4px; font-size: 14px }
  .brand img { width: 24px; height: 24px }
}
main { display: flex; flex-direction: column; min-height: 0 }
#sheetbar { padding: 5px 8px; background: var(--panel); overflow-x: auto }
#tabs { display: flex; gap: 4px }
#tabs button { font-size: 12px; white-space: nowrap }
#tabs button[aria-current=true] { border-color: var(--accent) }
.workspace {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
}
.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  background: radial-gradient(var(--dot) 1px, transparent 1px) 0 0 / 17px 17px;
}
.stage canvas { position: absolute; display: block; box-shadow: 0 8px 28px #0007; background: white }
#emptyOpen { min-height: 44px }
.side-tab {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  min-width: 44px;
  padding: 10px 8px;
  touch-action: none;
  z-index: 1;
  background: var(--panel);
}
.left { left: 0 }
.right { right: 0 }
.side-tab.left { border-radius: 0 9px 9px 0 }
.side-tab.right { border-radius: 9px 0 0 9px }
#drawerShade { position: absolute; inset: 0; z-index: 2; background: #0004 }
.drawer {
  position: absolute;
  inset-block: 0;
  z-index: 3;
  width: min(280px, 88%);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 10px 12px 16px;
  background: var(--panel);
  box-shadow: 0 0 24px #0006;
  animation: slide-in .17s ease-out;
}
.drawer.left { --slide-from: -100%; border-right: 1px solid var(--edge) }
.drawer.right { --slide-from: 100%; border-left: 1px solid var(--edge) }
.tools { width: min(210px, 82%); display: flex; flex-direction: column; gap: 5px }
@keyframes slide-in { from { transform: translateX(var(--slide-from)) } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none } }
.drawer-heading { display: flex; justify-content: space-between; align-items: center; gap: 4px }
.drawer-heading .icon-button { background: transparent; border-color: transparent }
.tools [data-tool] { text-align: left; min-height: 39px; padding: 7px 9px }
.tools [data-tool] span { margin-left: 4px }
.tools button.active { background: var(--active); border-color: var(--accent) }
#toolName { color: var(--accent); font-size: 12px; margin: 0 0 12px }
label, .sub { color: var(--muted); font-size: 12px }
label { display: block; margin: 0 0 13px }
label select, label input[type=text] {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 7px;
  font-size: 16px;
}
label input { accent-color: var(--accent) }
label input[type=range] { display: block; width: 100% }
label input[type=color] { float: right; width: 45px; height: 24px; border: 0; padding: 0; background: transparent }
label output { float: right; color: var(--text) }
#strokeOptions label:first-child, #textOptions label:last-child { min-height: 26px }
footer { position: relative; border-top: 1px solid var(--edge) }
.footer-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center }
.footer-actions { display: flex; gap: 6px; justify-self: end }
#exportMenu {
  display: grid;
  gap: 4px;
  position: absolute;
  bottom: calc(100% + 4px);
  right: 6px;
  border: 1px solid var(--edge);
  border-radius: 9px;
  padding: 5px;
  background: var(--panel);
}
#status {
  position: absolute;
  z-index: 4;
  bottom: calc(64px + env(safe-area-inset-bottom));
  left: 50%;
  width: max-content;
  max-width: min(90%, 420px);
  transform: translateX(-50%);
  padding: 7px 11px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  pointer-events: none;
}
#status:empty { display: none }
dialog {
  width: min(350px, calc(100% - 32px));
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 15px;
  padding: 12px 18px 18px;
  max-height: calc(100% - 24px);
}
dialog::backdrop { background: #0009 }
dialog h2 { font-size: 20px; margin: 0 }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end }
#closeImageMessage { color: var(--muted); margin: 12px 0 18px }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px }
.dialog-heading button { background: transparent; border-color: transparent }
.preference { display: flex; gap: 8px; align-items: center; min-height: 38px; margin: 0; font-size: 15px; color: var(--text) }

.monitor[aria-checked=true] .track { background: #1b9d59 }
.monitor[aria-checked=true] .track::before { background: #fff }
.tools [data-tool] { display: flex; align-items: center; gap: 8px }
.tools [data-tool] .tool-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  margin: 0;
}
.tool-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round }
#toolName { margin: 3px 0 5px; font-size: 15px }
#hint { margin: 0 0 16px; line-height: 1.45 }
#allOptions, .about-app a { color: var(--accent); text-underline-offset: 3px }
#allOptions { display: block; width: fit-content; margin-top: 14px; padding: 8px 0 }
.graphic-select { margin: 0 0 13px }
.field-label { color: var(--muted); font-size: 12px }
.graphic-value, .graphic-list button {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 4px 10px;
  background: var(--input);
}
.graphic-value { justify-content: space-between; margin-top: 5px }
.graphic-value::after {
  content: '';
  width: 7px;
  height: 7px;
  margin: 0 3px 4px 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
}
.graphic-list { display: grid; gap: 3px; margin-top: 3px }
.graphic-list button[aria-selected=true] { border-color: var(--accent); background: var(--active) }
.graphic-select svg { width: 96px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none }
.graphic-select .filled { fill: currentColor }
.about-app { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--edge) }
.about-app span, .about-app p { color: var(--muted); font-size: 13px }
.about-app span { margin-left: 5px }
.about-app p { margin: 5px 0 0; line-height: 1.45 }

#dragPreview {
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 5;
  pointer-events: none;
}
.trash {
  background: var(--button);
  border: 1px solid var(--edge);
  border-radius: 9px;
  color: var(--muted);
  opacity: .45;
}
.trash.drop-ready { opacity: 1 }
.trash.drop-target {
  background: #be303c;
  border-color: #ff6d77;
  color: #fff;
  outline: 2px solid #ff6d77;
  outline-offset: 2px;
}
