:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  --background: #101117;
  --panel: #171921;
  --stage: #12141c;
  --text: #f5f6fa;
  --muted: #a1a5b5;
  --line: #353949;
  --accent: #a1a5ff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); }
button { font: inherit; }
a { color: inherit; }
svg { display: block; width: 1.2em; height: 1.2em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.page-width { width: min(87.5%, 1304px); margin-inline: auto; }
.page-header { min-height: 84px; padding-inline: 14px 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 16px; text-decoration: none; font-size: 2.08rem; font-weight: 750; letter-spacing: -.035em; }
.privacy { display: flex; gap: 10px; align-items: center; color: var(--muted); margin: 0; font-size: clamp(.875rem, 1.4vw, 1.25rem); }
.privacy svg { width: 1.42em; height: 1.42em; }

main { padding-block: clamp(32px, 3.5vw, 53px) 40px; }
h1 { margin: 0; font-size: clamp(2.5rem, 5vw, 4.55rem); line-height: 1.04; font-weight: 750; letter-spacing: -.048em; }
.intro { margin: 8px 0 clamp(26px, 3vw, 44px); font-size: clamp(1.0625rem, 2vw, 1.8rem); color: var(--muted); line-height: 1.35; letter-spacing: -.018em; }
.editor { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: clamp(11px, 1.2vw, 18px); border-bottom: 1px solid var(--line); }
.tools, .actions, .empty-actions { display: flex; gap: clamp(6px, 1.35vw, 20px); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  border: 1px solid transparent;
  padding: .52em .95em;
  min-height: 44px;
  border-radius: 9px;
  white-space: nowrap;
  font-size: clamp(.9rem, 1.4vw, 1.25rem);
  line-height: 1.2;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}
.button:disabled { opacity: .43; cursor: default; }
.button:focus-visible, .brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.quiet:not(:disabled):hover { background: #272b39; }
.draw { color: #edefec; background: #323555; border-color: #8e93e8; }
.draw:not(:disabled):hover { background: #3d426a; }
.secondary { border-color: #565c70; font-weight: 580; }
.secondary:hover { background: #252835; }
.primary { background: var(--accent); color: #13142a; font-weight: 690; }
.primary:not(:disabled):hover { background: #b8bbff; }

.stage {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(310px, 36vw, 532px);
  height: clamp(310px, min(36vw, 100svh - 425px), 532px);
  padding: 24px;
  container-type: size;
  background-color: var(--stage);
  background-image: linear-gradient(#262a38 1px, transparent 1px), linear-gradient(90deg, #262a38 1px, transparent 1px);
  background-size: 23px 23px;
}
.stage.dragging::after { content: ""; position: absolute; inset: 6px; border: 2px dashed var(--accent); pointer-events: none; border-radius: 5px; }
.empty { display: grid; justify-items: center; text-align: center; }
.file-icon { display: grid; place-items: center; width: 66px; height: 66px; margin-bottom: 20px; border: 1px solid #444967; border-radius: 14px; background: #1f2233; color: var(--accent); font-size: 1.75rem; }
.empty h2 { margin: 0; font-size: clamp(1.4rem, 2vw, 1.875rem); line-height: 1.15; letter-spacing: -.025em; }
.empty p { margin: 8px 0 22px; color: var(--muted); }
.empty-actions { justify-content: center; flex-wrap: wrap; gap: 9px; }
.empty-actions .button { font-size: .95rem; }
canvas { display: block; max-width: 100%; cursor: crosshair; touch-action: none; outline: none; user-select: none; -webkit-user-select: none; }
canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.metadata { display: flex; gap: .5em; align-items: baseline; padding: .65em 1.5em; border-top: 1px solid var(--line); font-size: clamp(.8rem, 1.4vw, 1.25rem); }
#filename { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#dimensions, #count { white-space: nowrap; }
#count { margin-left: auto; padding-left: .5em; }
.tip, .feedback { margin: 18px 0 0; color: var(--muted); font-size: clamp(.875rem, 1.35vw, 1.2rem); }
.feedback { margin-top: 8px; }
.feedback[data-error] { color: #ffadae; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 730px) {
  .page-width { width: calc(100% - 32px); }
  .page-header { min-height: 66px; padding-inline: 0; }
  .brand { font-size: 1.48rem; gap: 9px; }
  .brand img { width: 23px; height: 23px; }
  .privacy { gap: 5px; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .stage { padding: 16px; height: clamp(300px, 65vw, 450px); background-size: 18px 18px; }
  .metadata { padding: .8em 1em; }
}

@media (max-width: 420px) {
  .actions { flex-basis: 100%; }
  .actions > button { flex: 1; }
  .privacy { font-size: .75rem; }
}
