:root {
  color-scheme: dark;
  --bg: #151817;
  --panel: #1b1f1d;
  --raised: #212623;
  --input: #171b19;
  --line: #323934;
  --ink: #f0f3ee;
  --sub: #b2bdb5;
  --muted: #96a49a;
  --accent: #aaf2cb;
  --accent-ink: #122219;
  --danger: #ffb1a4;
  --radius: 8px;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(26px, 3vw, 38px); line-height: 1.14; letter-spacing: -.042em; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  cursor: pointer;
  font-weight: 550;
  font-size: 13px;
  transition: background-color 140ms ease, border-color 140ms ease;
}
button:hover:not(:disabled) { background: #2a322c; border-color: #57645a; }
button:disabled { cursor: default; opacity: .48; }
button.primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }
button.primary:hover:not(:disabled) { color: var(--accent-ink); background: #c2f8da; }
button.quiet { border-color: transparent; background: transparent; color: var(--sub); }
button.text-button { color: var(--accent); background: transparent; border-color: transparent; padding: 0 4px; }
button.danger-text { color: var(--danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, select, textarea {
  display: block; width: 100%; min-width: 0; min-height: 44px; color: var(--ink);
  background: var(--input); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px;
}
input[type=color] { padding: 6px 8px; cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }
label { display: block; color: var(--sub); font-size: 13px; font-weight: 550; min-width: 0; }
label input, label select, label textarea { margin-top: 4px; font-size: 14px; }
.topbar {
  min-height: 64px; border-bottom: 1px solid var(--line); padding: 8px clamp(16px, 4vw, 56px);
  display: flex; align-items: center; gap: 16px;
}
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 21px; letter-spacing: -.035em; }
.mark {
  display: inline-block; width: 27px; height: 27px; border-radius: 50%; border: 1px solid #668c77;
  position: relative; background: radial-gradient(circle at center, var(--accent) 0 3px, transparent 3.5px 6px, #668c77 6.5px 7px, transparent 7.5px);
}
.mark::after { content: ''; width: 5px; height: 5px; position: absolute; border-radius: 50%; background: var(--accent); right: -1px; top: 3px; }
.header-divider { height: 24px; width: 1px; background: var(--line); }
.workspace-name { color: var(--sub); font-size: 14px; }
.top-actions { display: flex; gap: 4px; margin-left: auto; }
#device-open { display: flex; gap: 8px; align-items: center; }
.status-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: #829187; }
.status-dot.ready { background: var(--accent); }
.workspace-body { max-width: 1552px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 56px) 40px; }
.workspace-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.workspace-heading p { font-size: 13px; color: var(--muted); margin-top: 6px; }
.toolbar, .history-group, .command-actions, .button-pair { display: flex; gap: 8px; }
.history-group { gap: 0; }
.history-group button { width: 44px; padding: 0; font-size: 20px; }
.history-group button:first-child { border-radius: 8px 0 0 8px; }
.history-group button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.notice { margin: -4px 0 16px; padding: 10px 12px; background: var(--raised); border-left: 2px solid var(--accent); border-radius: 4px; }
.notice.error, .message.error { border-color: var(--danger); color: var(--danger); }
.studio { display: grid; grid-template-columns: 228px minmax(0, 1fr) 272px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--panel); min-height: 628px; }
.left-panel, .right-panel { display: flex; flex-direction: column; min-width: 0; }
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); }
.panel-section { padding: 14px 16px 16px; }
.panel-section + .panel-section { border-top: 1px solid var(--line); }
.panel-section > h2 { margin-bottom: 12px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.panel-heading:has(button[hidden]) { min-height: 44px; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-grid button { display: flex; align-items: center; gap: 8px; padding: 0 8px; }
.add-grid .wide { grid-column: 1 / -1; }
.tool-symbol { display: inline-grid; place-items: center; width: 16px; height: 16px; color: var(--sub); font-style: normal; flex: 0 0 16px; }
.text-tool { font-family: Georgia, serif; font-size: 16px; font-weight: 700; }
.shape-tool::after { content: ''; width: 11px; height: 11px; border: 1.5px solid; border-radius: 2px; }
.image-tool { position: relative; border: 1.5px solid; border-radius: 2px; height: 13px; }
.image-tool::after { content: ''; width: 6px; height: 6px; border-left: 1.5px solid; border-top: 1.5px solid; transform: rotate(45deg); align-self: end; }
.clock-tool { border: 1.5px solid; border-radius: 50%; }
.clock-tool::after { content: ''; width: 4px; height: 5px; border-left: 1px solid; border-bottom: 1px solid; transform: translate(1px,-1px); }
.layers { display: grid; gap: 4px; max-height: 324px; overflow-y: auto; padding: 3px; margin: 0 -3px; }
.layer-button { display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; padding: 0 8px; border-color: transparent; background: transparent; }
.layer-button b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.layer-button[aria-pressed=true] { background: #27382f; border-color: #527962; color: var(--accent); }
.layer-kind { color: var(--muted); font-family: ui-monospace, monospace; width: 18px; flex: 0 0 18px; text-align: center; font-size: 12px; }
.presets { margin-top: auto; }
.button-pair > button { flex: 1 1 0; padding: 0 8px; min-width: 0; }
.stage { display: flex; flex-direction: column; min-width: 0; background: #131715; }
.stage-header, .stage-footer { padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.stage-header { min-height: 48px; border-bottom: 1px solid #29312c; }
.stage-header > span:first-child { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 550; font-size: 13px; }
.canvas-size, .pair-code { font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.phone-space {
  flex: 1; display: grid; place-items: center; padding: 16px; min-height: 0;
  background-image: radial-gradient(circle, #36443a 1px, transparent 1px);
  background-size: 20px 20px; background-position: center;
}
.phone {
  width: min(100%, clamp(220px, 30vw, 256px)); aspect-ratio: 360 / 780; position: relative; border-radius: 31px;
  box-shadow: 0 0 0 1px #6d7e72, 0 0 0 5px #101411, 0 0 0 6px #445249, 0 18px 32px #0008;
  isolation: isolate; background: #101b1c;
}
.artboard { position: relative; width: 100%; aspect-ratio: 360 / 780; overflow: hidden; background: #101b1c; background-size: cover; background-position: center; --unit: 1px; }
.phone .artboard { border-radius: inherit; }
.camera-hole { position: absolute; z-index: 2; pointer-events: none; top: 7px; left: calc(50% - 4px); width: 8px; height: 8px; border-radius: 50%; background: #040707; border: 1px solid #24302a; }
.preview-footer { pointer-events: none; position: absolute; bottom: 9px; left: 12px; right: 12px; z-index: 2; display: grid; justify-items: center; gap: 9px; }
.preview-footer span { padding: 7px 14px; border: 1px solid #537365; border-radius: 8px; color: #dcf4e8; background: #172924; font-size: 10px; }
.preview-footer i { width: 30%; height: 3px; border-radius: 4px; background: #b1c7bf; }
.stage-footer { border-top: 1px solid #29312c; min-height: 56px; }
.stage-footer button { background: transparent; }
.art-layer { position: absolute; transform-origin: center; }
.art-content { width: 100%; height: 100%; display: flex; align-items: center; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.14; }
.art-content span { min-width: 0; }
img.art-content { display: block; object-fit: contain; }
.art-content.countdown-complete { font-size: calc(var(--unit) * 20) !important; }
.art-shape { background: var(--shape-color); border-radius: calc(var(--unit) * 12); }
.art-shape.circle, .art-shape.ring { border-radius: 50%; }
.art-shape.ring { background: transparent; border: 1px solid var(--shape-color); }
.editable .art-layer { touch-action: none; cursor: move; }
.editable .art-layer .art-content { pointer-events: none; user-select: none; }
.editable .selection-outline { outline: 1px dashed var(--accent); pointer-events: none; }
.grip { position: absolute; display: grid; place-items: center; width: 34px; height: 34px; z-index: 1; touch-action: none; pointer-events: auto; }
.grip::after { content: ''; width: 10px; height: 10px; background: var(--accent); border: 1px solid var(--accent-ink); }
.grip.resize { bottom: -5px; right: -5px; cursor: nwse-resize; }
.grip.rotate { left: calc(50% - 17px); top: -28px; cursor: grab; }
.grip.rotate::after { border-radius: 50%; }
#properties { display: grid; gap: 12px; }
.field-grid { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layer-order { padding-top: 4px; }
.file-name { color: var(--sub); font-size: 13px; overflow-wrap: anywhere; margin: 12px 0 8px; }
.control { border: 1px solid var(--line); border-radius: 14px; margin-top: 16px; background: var(--panel); }
.control-top { padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.control-top p { margin-top: 4px; color: var(--muted); font-size: 13px; }
button.quick-logout { color: var(--danger); border-color: var(--danger); white-space: nowrap; }
button.quick-logout:hover { border-color: var(--danger); }
#command-history { padding: 16px; border-top: 1px solid var(--line); }
#commands { display: grid; gap: 0; padding: 0; margin: 8px 0 0; list-style: none; }
#commands li { display: grid; grid-template-columns: minmax(78px, 1fr) minmax(100px, 2fr) minmax(0, 2fr); gap: 8px; padding: 10px 0; font-size: 13px; }
#commands li + li { border-top: 1px solid var(--line); }
#commands li span:last-child { color: var(--muted); }
dialog { width: min(428px, calc(100% - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; color: var(--ink); padding: 20px; }
dialog::backdrop { background: #050806b5; }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dialog-top h2 { font-size: 19px; }
dialog p { color: var(--sub); overflow-wrap: anywhere; margin-bottom: 12px; }
dialog input { margin: 4px 0 12px; }
.site-address { padding: 8px 10px; background: var(--input); border-radius: var(--radius); }
.pair-code { font-size: 22px; letter-spacing: .04em; color: var(--accent); }
.message { color: var(--muted); font-size: 13px; }
.message:empty { display: none; }
dialog button + .message { margin-top: 12px; }
.signin { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 368px); padding: 24px; display: grid; gap: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; }
.login-card h1 { font-size: 29px; margin: 8px 0; }
.login-card label { margin-bottom: -8px; }
.recovery-body { background: #101b1c; min-height: 100dvh; display: grid; place-items: center; }
.recovery-body .artboard { width: min(100vw, calc(100dvh * 360 / 780)); max-height: 100dvh; }
.native .web-only { display: none; }
.native .workspace-body { padding-top: 16px; }
.native .topbar { min-height: 48px; }
@media (max-width: 1020px) {
  .studio { grid-template-columns: 192px minmax(0, 1fr) 220px; }
  .panel-section { padding-inline: 12px; }
}
@media (max-width: 760px) {
  .workspace-body { padding: 16px 12px 24px; }
  .topbar { padding-inline: 12px; gap: 8px; }
  .workspace-heading { flex-wrap: wrap; align-items: center; }
  .studio { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stage { grid-row: 1; grid-column: 1 / -1; }
  .phone-space { padding: 24px 16px; }
  .phone { width: min(256px, 74%, max(156px, 34dvh)); }
  .left-panel { grid-row: 2; }
  .right-panel { grid-row: 2; border-left: 0; }
  .layers { max-height: 278px; }
}
@media (max-width: 480px) {
  .workspace-name, .header-divider { display: none; }
  .workspace-heading { gap: 8px; }
  .workspace-heading h1 { font-size: 24px; }
  .panel-heading { flex-wrap: wrap; row-gap: 0; }
  .panel-section { padding: 10px 8px; }
  .add-grid { gap: 4px; }
  .add-grid button { padding: 0 4px; gap: 4px; }
  .stage-footer span { display: none; }
  .control-top { flex-wrap: wrap; }
  .command-actions { width: 100%; }
  .command-actions button { flex: 1; }
  #commands li { grid-template-columns: minmax(78px, 1fr) minmax(0, 2fr); }
  #commands li span:last-child { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

.native button, .native input, .native select { min-height: 48px; }
.quick-control { margin: 0 0 16px; }
