:root {
  color-scheme: light;
  --ink: #14273e;
  --muted: #52657d;
  --line: #d8e3ef;
  --accent: #174ec2;
  --surface: #fff;
  --page: #f0f5fa;
  font-family: system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color: var(--ink);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

h1,h2,p {
  margin: 0;
}

a {
  color: inherit;
}

button,input,textarea {
  font: inherit;
}

.top {
  min-height: 64px;
  padding: 12px max(24px,calc((100vw - 1480px)/2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(110deg, #11233d, #183858);
  border-bottom: 1px solid #2c4a6b;
  color: #fff;
}

.brand,.back {
  text-decoration: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.brand span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 32px;
  border-radius: 9px;
  background: #2558aa;
  box-shadow: inset 0 0 0 1px #ffffff24;
  font-size: 13px;
}

.back {
  font-size: 14px;
  color: #e1eeff;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #ffffff33;
}

.back:hover {
  text-decoration: underline;
}

.shell {
  max-width: 1528px;
  margin: auto;
  padding: 30px 24px;
}

.intro,.actions,.panel-bar,.layer-header,.dialog-heading,.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.intro {
  margin-bottom: 20px;
  padding: 24px 22px;
  background: linear-gradient(112deg, #ffffff, #eaf2ff);
  border: 1px solid var(--line);
  border-radius: 18px;
  flex-wrap: wrap;
}

.intro h1 {
  font-size: clamp(25px,3.3vw,39px);
  letter-spacing: -.045em;
  line-height: 1.15;
}

.intro p {
  margin-top: 8px;
  color: var(--muted);
}

.actions,.dialog-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
}

button:hover:not(:disabled) {
  background: #edf3ff;
  border-color: #afc5ec;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: #1945aa;
}

button:disabled {
  opacity: .45;
  cursor: default;
}

:focus-visible {
  outline: 3px solid #3375f5;
  outline-offset: 3px;
}

.save-status,#copy-status {
  color: #365777;
  font-size: 13px;
  max-width: 280px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(210px,240px) minmax(0,1fr) minmax(240px,280px);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 24px #1a37570c;
  min-width: 0;
}

.library,.settings {
  padding: 18px;
}

.panel h2,dialog h2 {
  font-size: 16px;
  letter-spacing: -.015em;
}

.hint {
  line-height: 1.5;
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
}

.palette {
  display: grid;
  gap: 7px;
  margin-top: 15px;
}

.palette button {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 6px 9px;
  background: #f8fbff;
}

.palette button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #edf3ff;
  color: #194bb0;
}

.palette b {
  margin-left: auto;
  font-weight: 600;
  color: #405c83;
}

.layer-header {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.layer-header span {
  font-size: 12px;
  color: var(--muted);
}

.layers {
  margin: 9px 0 15px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  max-height: 350px;
  overflow: auto;
}

.layers button {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 7px 9px 7px 12px;
  border-left: 3px solid #d2deee;
  font-weight: 650;
}

.layers [aria-pressed=true] {
  border-color: #b5ccf8;
  border-left-color: var(--accent);
  background: #eaf2ff;
  color: #1c48a1;
}

.subtle {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.preview .panel-bar {
  padding: 14px 17px;
  flex-wrap: wrap;
}

.preview h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-indicator {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #217954;
  box-shadow: 0 0 0 4px #e0f4ea;
}

.layer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layers small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.layers [data-kind="banner"]:not([aria-pressed="true"]) {
  border-left-color: #b297e5;
}

.layers [data-kind="button"]:not([aria-pressed="true"]) {
  border-left-color: #6ab9a1;
}

.color-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #edf2f8;
}

.switch button {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  background: transparent;
  font-size: 12px;
}

.switch [aria-pressed=true] {
  background: #fff;
  color: #204faa;
  box-shadow: 0 1px 4px #22365920;
}

.stage {
  padding: clamp(17px, 3vw, 42px);
  min-height: 505px;
  border-radius: 0 0 15px 15px;
  background: radial-gradient(#b0d1f45c 1px, transparent 1px) 0 0 / 18px 18px, linear-gradient(145deg, #17324f, #0f2138);
}

.stage.dragging {
  outline: 2px dashed var(--accent);
  outline-offset: -5px;
}

.canvas {
  max-width: 740px;
  margin: 0 auto;
  min-width: 0;
  filter: drop-shadow(0 13px 24px #06142860);
  transition: max-width .2s ease;
}

.canvas.mobile {
  max-width: 375px;
}

.canvas [data-item] {
  cursor: pointer;
  border-radius: 5px;
  outline-offset: 4px;
  min-height: 1.2em;
}

.canvas [data-item][aria-pressed=true] {
  outline: 2px solid #2460dc;
  box-shadow: 0 0 0 3px #dbe8ff;
}

.canvas .empty {
  border: 1px dashed #8ea5c2;
  border-radius: 12px;
  text-align: center;
  padding: 48px 16px;
  color: #465b77;
  background: #fff;
}

.badge {
  color: #254e9e;
  background: #edf3ff;
  padding: 4px 7px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}

.badge:empty {
  display: none;
}

.fields {
  display: grid;
  gap: 15px;
  margin-top: 18px;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 650;
}

.field input:not([type=color]),.field textarea,dialog textarea {
  width: 100%;
  border: 1px solid #becce0;
  border-radius: 8px;
  padding: 8px 9px;
  color: var(--ink);
  background: #f9fbfe;
  min-height: 41px;
}

.field textarea,dialog textarea {
  resize: vertical;
}

.field input[type=color] {
  border: 1px solid #becce0;
  border-radius: 7px;
  padding: 3px;
  width: 100%;
  height: 37px;
  background: #fff;
  cursor: pointer;
}

.field input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}

.field .field-label {
  display: flex;
  justify-content: space-between;
  gap: 5px;
}

.field output {
  color: var(--muted);
  font-weight: 500;
}

.edit-actions {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
  margin-top: 19px;
}

.edit-actions .danger {
  grid-column: 1/-1;
  color: #a22631;
}

dialog {
  width: min(680px,calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  color: var(--ink);
  box-shadow: 0 18px 80px #17264050;
}

dialog::backdrop {
  background: #0d1d3a80;
}

.dialog-heading button {
  min-height: 30px;
  padding: 2px 10px;
  font-size: 20px;
}

dialog textarea {
  margin: 14px 0;
  background: #f6f8fc;
  font: 13px/1.5 ui-monospace,monospace;
}

.dialog-actions {
  margin-top: 13px;
}

@media(max-width:1080px) {
  .workspace {
    grid-template-columns: 180px minmax(0,1fr) 216px;
    gap: 10px;
  }
  .shell {
    padding: 24px 15px;
  }
  .library,.settings {
    padding: 13px;
  }
}

@media(max-width:820px) {
  .workspace {
    grid-template-columns: minmax(156px, 2fr) minmax(0, 3fr);
  }
  .preview {
    grid-column: 2;
  }
  .settings {
    grid-column: 2;
  }
  .library {
    grid-row: 1 / span 2;
  }
  .stage {
    min-height: 250px;
  }
}

@media(max-width:590px) {
  .workspace {
    grid-template-columns: minmax(0,1fr);
  }
  .library,.preview,.settings {
    grid-column: 1;
    grid-row: auto;
  }
  .palette {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .palette button {
    gap: 6px;
    font-size: 13px;
  }
  .palette button span {
    width: 23px;
    flex-shrink: 0;
  }
  .layers {
    max-height: 140px;
  }
  .top {
    padding: 10px 12px;
    gap: 8px;
  }
  .brand {
    gap: 7px;
    font-size: 14px;
  }
  .brand span {
    width: 31px;
    font-size: 11px;
  }
  .back {
    padding-inline: 7px;
    font-size: 13px;
  }
  .shell {
    padding: 14px 10px;
  }
  .actions {
    justify-content: flex-start;
  }
  .intro {
    padding: 17px 13px;
  }
  .intro p {
    font-size: 14px;
  }
}

@media(prefers-reduced-motion:reduce) {
  .canvas {
    transition: none;
  }
}

.top-actions, .language-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.language-switch {
  gap: 2px;
  padding: 2px;
  border: 1px solid #ffffff33;
  border-radius: 8px;
}

.language-switch button {
  min-height: 26px;
  padding: 3px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #dce8ff;
  font-size: 12px;
}

.language-switch button:hover:not(:disabled),
.language-switch button[aria-pressed="true"] {
  background: #3b6098;
  color: white;
}

.palette .element-label {
  display: inline;
  width: auto;
  height: auto;
  color: inherit;
  background: transparent;
}

@media (max-width: 590px) {
  .top-actions {
    gap: 5px;
  }

  .brand span {
    display: none;
  }
}

@media (max-width: 360px) {
  .top {
    flex-wrap: wrap;
  }
}
