:root {
  color-scheme: dark;
  --bg: #101211;
  --panel: #181c19;
  --panel-2: #212622;
  --line: #313931;
  --text: #edf0e8;
  --muted: #a3ada2;
  --accent: #c9f377;
  --danger: #ffb5ab;
  --radius: 9px;
  font: 14px/1.4 system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); }
h1,h2,p { margin: 0; }
h1 { font-size: clamp(26px,4vw,43px); letter-spacing: -.045em; line-height: 1.07; }
h2 { font-size: 13px; font-weight: 650; }
a { color: inherit; }
button, .button, input, select, textarea { font: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border .12s;
}
button:not(:disabled):hover, .button:hover { border-color: #59644f; background: #2a3228; }
button:disabled { opacity: .42; cursor: default; }
button.primary, .button.primary { color: #1b2510; background: var(--accent); border-color: transparent; font-weight: 740; }
button.primary:not(:disabled):hover, .button.primary:hover { background: #dcffa2; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select, textarea { color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #121612; min-width: 0; }
input[type=range] { accent-color: var(--accent); padding: 0; width: 100%; min-width: 36px; }
input[type=color] { height: 28px; padding: 2px; width: 34px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.application { min-height: 100svh; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.topbar { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; gap: 17px; padding: 11px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; font-size: 15px; letter-spacing: -.025em; }
.brand img { object-fit: contain; }
.file-actions,.history,.account { display: flex; gap: 5px; align-items: center; }
.history { border-left: 1px solid var(--line); padding-left: 12px; }
.history button { font-size: 18px; min-width: 36px; }
.account { margin-left: auto; }
#viewer { color: var(--muted); font-size: 11px; max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 6px; }
.workspace { display: grid; grid-template-columns: minmax(0,1fr) 304px; min-height: 0; height: calc(100svh - 92px); }
.workarea { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.document-bar,.bottom-bar,.status { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); background: var(--panel); padding: 7px 14px; }
.document-bar { border-bottom: 1px solid var(--line); }
.document-bar input { border-color: transparent; background: transparent; font-size: 13px; max-width: min(58%, 310px); color: var(--text); }
.document-bar input:hover { border-color: var(--line); }
#geometry,.zoom output { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viewport { display: flex; padding: 24px; overflow: auto; min-height: 0; position: relative; background: #0f1110 radial-gradient(#ffffff13 1px, transparent 1px) 0 0/18px 18px; }
.viewport.is-drop { outline: 2px dashed var(--accent); outline-offset: -7px; }
.board { margin: auto; position: relative; flex: 0 0 auto; background: conic-gradient(#ffffff0c 25%, #ffffff04 0 50%, #ffffff0c 0 75%, #ffffff04 0) 0 0 / 20px 20px, #2a302a; box-shadow: 0 18px 40px #0009; outline: 1px solid #dddddd36; }
#canvas { display: block; width: 100%; height: auto; touch-action: none; }
#canvas[data-tool=move] { cursor: grab; }
#canvas[data-tool=text] { cursor: text; }
#canvas[data-tool=brush], #canvas[data-tool=crop], #canvas[data-tool=eraser] { cursor: crosshair; }
#crop-box { position: absolute; border: 1px dashed #f5ffd8; box-shadow: 0 0 0 1px #203013; pointer-events: none; }
.welcome { margin: auto; text-align: center; max-width: 400px; padding: 34px min(6vw,42px); background: #171c18; border: 1px solid #394238; border-radius: 16px; box-shadow: 0 20px 60px #0714084d; }
.welcome-mark { color: var(--accent); font-size: 27px; margin: 0 auto 18px; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: #243322; border: 1px solid #46583a; }
.welcome p { color: var(--muted); margin: 12px 0 24px; }
.welcome button { min-height: 38px; }
.bottom-bar { border-top: 1px solid var(--line); padding: 9px 13px; justify-content: center; position: relative; flex-wrap: wrap; }
.tool-bar,.zoom { display: flex; align-items: center; justify-content: center; gap: 5px; }
.tool-bar span { font-size: 16px; }
.tool-bar [aria-pressed=true] { color: var(--accent); border-color: #5c734c; background: #273322; }
.zoom { margin-left: auto; }
.zoom output { min-width: 42px; text-align: center; }
.zoom button { padding-inline: 8px; }
.inspector { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; }
.pane { padding: 15px 14px; border-bottom: 1px solid var(--line); }
.pane-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pane-title button { min-height: 28px; font-size: 12px; }
.layers { display: grid; gap: 4px; padding: 0; margin: 10px 0; list-style: none; }
.layers:empty { margin: 0; }
.layer { display: grid; grid-template-columns: minmax(0,1fr) 34px; align-items: stretch; gap: 4px; }
.layer button { text-align: left; justify-content: start; overflow: hidden; }
.layer button:last-child { padding: 0; justify-content: center; }
.layer button[aria-pressed=true] { background: #293521; border-color: #596c48; }
.layer .preview { width: 29px; height: 29px; flex: 0 0 29px; background: #131814; border: 1px solid #fff2; border-radius: 4px; }
.layer .layer-label { overflow: hidden; text-overflow: ellipsis; }
.layer-actions,.transform-buttons { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.layer-actions { margin-top: 9px; }
.layer-actions button { min-height: 29px; padding: 3px 8px; }
.settings { margin: 10px 0 0; display: grid; gap: 10px; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 11px; color: var(--muted); font-size: 12px; }
.settings label > :is(input:not([type=color]),.range,select) { flex: 0 1 60%; min-width: 0; }
.settings p { color: var(--muted); font-size: 12px; }
.range { display: flex; align-items: center; gap: 6px; }
.range output { flex: 0 0 36px; text-align: right; font-variant-numeric: tabular-nums; }
fieldset { border: 0; padding: 0; min-width: 0; }
fieldset:disabled { opacity: .45; }
fieldset:disabled button { cursor: default; }
.status { min-height: 30px; font-size: 11px; padding-block: 4px; border-top: 1px solid var(--line); }
.error, .status [data-error=true] { color: var(--danger); }
dialog { padding: 0; width: min(420px,90vw); color: var(--text); background: var(--panel); border: 1px solid #465445; border-radius: 14px; box-shadow: 0 24px 80px #000a; }
dialog::backdrop { background: #050805b8; }
dialog form { display: grid; gap: 13px; padding: 25px; }
dialog h2 { font-size: 20px; }
dialog label { display: grid; gap: 4px; color: var(--muted); }
.dialog-actions { display: flex; gap: 6px; justify-content: end; }
.sign-in { min-height: 100svh; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at 65% 15%,#293a26,var(--bg) 65%); }
.sign-box { width: min(440px,100%); padding: clamp(24px,6vw,42px); border: 1px solid #424d3d; border-radius: 14px; background: var(--panel); box-shadow: 0 24px 90px #0006; }
.sign-box img { object-fit: contain; margin-bottom: 25px; }
.sign-box p { margin: 13px 0 21px; color: var(--muted); }
.sign-box p.error { color: var(--danger); }
.sign-box .button { min-height: 43px; width: 100%; }
@media (max-width: 860px) {
  #viewer { display: none; }
  .topbar { gap: 9px; padding-inline: 10px; }
  .workspace { grid-template-columns: minmax(0,1fr) 255px; }
  .bottom-bar { justify-content: space-between; }
}
@media (max-width: 640px) {
  .topbar { position: relative; flex-wrap: wrap; }
  .brand { margin-right: auto; }
  .file-actions { order: 2; }
  .history { order: 3; padding-left: 5px; }
  .account { margin-left: 0; }
  .workspace { display: block; min-height: 0; height: auto; }
  .workarea { height: max(430px,63svh); }
  .viewport { padding: 14px; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .tool-bar button { font-size: 12px; padding: 4px 6px; }
  .zoom { margin-left: 0; }
  .bottom-bar { justify-content: center; }
}
