* {
  box-sizing: border-box;
}
:root {
  --ink: #213f43;
  --teal: #245c62;
  --muted: #5d6a64; /* 4.5:1+ on paper and panels (was #7a8680, 3.4:1) */
  --paper: #f5f2e9;
  --line: #e3e5da;
  --panel: #fffef9;
}
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font:
    14px/1.5 system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 7px;
  padding: 9px 13px;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover {
  background: #e8ede3;
}
button:active {
  transform: translateY(1px);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
svg:focus-visible {
  outline: 3px solid #d69a49;
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.35;
  cursor: default;
}
.primary {
  background: var(--teal);
  color: white;
  border-color: var(--teal);
}
.primary:hover {
  background: #19494e;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 36px;
  background: #fffdf6;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.identity {
  display: flex;
  align-items: center;
  gap: 13px;
}
.brand-mark {
  font-size: 43px;
  color: var(--teal);
  line-height: 1;
}
.identity h1 {
  font:
    26px Georgia,
    serif;
  margin: 0;
}
.identity div > span {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--muted);
}
.version {
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 8px;
  color: var(--muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-actions > span {
  font-size: 11px;
  color: var(--muted);
  margin-right: 12px;
}
.intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1510px;
  margin: auto;
  padding: 29px 36px 24px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 2.2px;
  color: #9c7949;
  font-weight: 700;
}
h2 {
  font:
    27px/1.2 Georgia,
    serif;
  margin: 9px 0 0;
}
.text-button {
  border: 0;
  font-size: 12px;
}
main {
  display: grid;
  grid-template-columns: 218px minmax(360px, 1fr) 258px;
  gap: 22px;
  max-width: 1510px;
  margin: 0 auto;
  padding: 0 36px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.library,
.settings {
  padding: 20px 17px;
  align-self: start;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
h3 {
  font:
    19px Georgia,
    serif;
  margin: 0;
}
.panel-heading > span {
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
}
.muted {
  color: var(--muted);
  font-size: 11px;
}
.library > .muted {
  margin: 6px 0 20px;
}
.motifs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.motif {
  padding: 8px 3px 6px;
  background: #f8f8f0;
  border-color: #ebede3;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  gap: 3px;
}
.motif svg {
  width: 63px;
  height: 63px;
  pointer-events: none;
}
.library-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: #899087;
}
.library-note span {
  font-size: 23px;
  color: #af945e;
}
.library-note p {
  font-size: 10px;
  margin: 2px 0;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 13px;
  gap: 10px;
}
.segmented {
  background: #e9ede4;
  border-radius: 8px;
  padding: 3px;
  display: flex;
}
.segmented button {
  font-size: 11px;
  padding: 7px 12px;
  border: 0;
}
.segmented .active {
  background: #fffef8;
  box-shadow: 0 1px 4px #00000009;
}
.tool-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tool-actions button {
  padding: 3px 9px;
  font-size: 22px;
  border: 0;
}
.divider {
  height: 20px;
  border-left: 1px solid #d5dcd1;
  margin: 0 5px;
}
.stage {
  background: #e5e9df;
  border: 1px solid #dce1d5;
  border-radius: 12px;
  padding: 32px 34px 17px;
  position: relative;
  min-height: 420px;
  background-image: radial-gradient(#96a08b35 0.7px, transparent 0.7px);
  background-size: 12px 12px;
}
.tile-wrap {
  width: min(100%, 490px);
  margin: auto;
  aspect-ratio: 1;
  box-shadow:
    0 13px 25px #233e4020,
    0 2px 4px #20373715;
  position: relative;
}
#editor {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}
#editor [data-id] {
  cursor: grab;
}
#editor.dragging [data-id] {
  cursor: grabbing;
}
.tile-wrap.glazed:after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(128deg, #ffffff20 0%, #ffffff00 37%, #ffffff18 52%, #fff0 68%);
  box-shadow:
    inset 0 0 0 2px #fff5,
    inset 0 0 16px #8c99821c;
}
.stage-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 490px;
  margin: 19px auto 0;
  font-size: 8px;
  letter-spacing: 1.5px;
  color: #7d8a7c;
}
.stage-caption > span + span {
  font-size: 17px;
  color: #9aab8f;
}
.presets {
  display: flex;
  gap: 5px;
}
.presets button {
  font-size: 10px;
  padding: 7px 9px;
  background: #fffdf6;
}
.presets .active {
  border-color: #77958a;
  color: var(--teal);
}
.preview {
  padding: 18px 20px;
  margin-top: 22px;
}
.preview .panel-heading h3 {
  font-size: 17px;
}
.preview-surface {
  margin-top: 14px;
  background: #c8cabb;
  overflow: hidden;
  border-radius: 5px;
  max-height: 260px;
}
.preview-surface svg {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
}
#fullRepeat {
  width: min(100%, 490px);
  margin: auto;
  aspect-ratio: 1;
  box-shadow: 0 8px 25px #233e4020;
}
#fullRepeat svg {
  width: 100%;
  height: 100%;
  display: block;
}
.settings .panel-heading {
  margin-bottom: 22px;
}
.selected-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}
.selected-label strong {
  font-size: 12px;
}
.icon-danger {
  border: 0;
  padding: 3px;
  color: #99654d;
  font-size: 11px;
}
label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  margin: 14px 0 6px;
}
output {
  color: var(--muted);
  font-size: 10px;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
  height: 16px;
  cursor: pointer;
}
select {
  width: 100%;
  border: 1px solid var(--line);
  padding: 8px;
  color: var(--ink);
  background: #fffef8;
  border-radius: 6px;
  font-size: 11px;
}
.color-row {
  display: flex;
  gap: 12px;
}
.color-row label {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 5px;
  font-size: 10px;
}
.color-row input {
  width: 29px;
  height: 29px;
  padding: 1px;
  border: 1px solid #dfe3d7;
  background: transparent;
  cursor: pointer;
}
.pair {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}
.pair button {
  flex: 1;
  font-size: 10px;
  padding: 7px 2px;
}
hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 21px 0;
}
.small-note {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.5;
}
.toggle {
  justify-content: flex-start;
  gap: 8px;
}
.toggle input {
  accent-color: var(--teal);
}
.wide {
  width: 100%;
  margin-top: 17px;
  font-size: 11px;
}
.empty-selection {
  font-size: 13px;
  padding: 16px 0;
  color: var(--teal);
}
.empty-selection span {
  font-size: 10px;
  color: var(--muted);
}
footer {
  max-width: 1510px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 28px auto 0;
  padding: 20px 36px;
  color: #8c9285;
  font-size: 10px;
}
footer span + span {
  font-size: 8px;
  letter-spacing: 1.5px;
}
#toast {
  position: fixed;
  bottom: 25px;
  left: 50%;
  transform: translate(-50%, 15px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: #fffdf5;
  border-radius: 8px;
  padding: 12px 20px;
  transition: all 0.2s;
  z-index: 20;
  font-size: 12px;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
dialog {
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 35px;
  max-width: 530px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 25px 90px #0003;
}
dialog::backdrop {
  background: #163e4155;
  backdrop-filter: blur(3px);
}
dialog .close {
  display: block;
  margin: 0 0 24px auto;
  border: 0;
}
dialog li {
  padding: 7px 0;
}
dialog p {
  font-size: 12px;
  line-height: 1.8;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1500px) {
  .stage {
    padding-top: 40px;
    padding-bottom: 22px;
  }
}
@media (max-width: 1100px) {
  main {
    grid-template-columns: 178px minmax(300px, 1fr) 223px;
    gap: 14px;
    padding: 0 20px;
  }
  .intro,
  header {
    padding-left: 20px;
    padding-right: 20px;
  }
  .header-actions > span {
    display: none;
  }
  .stage {
    padding: 22px;
  }
  .library,
  .settings {
    padding: 16px 12px;
  }
  .motif svg {
    width: 54px;
    height: 54px;
  }
}
@media (max-width: 820px) {
  header {
    flex-wrap: wrap;
  }
  .header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .intro {
    padding-top: 22px;
  }
  h2 {
    font-size: 23px;
  }
  main {
    grid-template-columns: 150px minmax(0, 1fr);
  }
  .settings {
    grid-column: 1/-1;
    display: block;
  }
  .settings #selectionControls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
  }
  .selected-label {
    grid-column: 1/-1;
  }
  .settings #selectionControls > label {
    grid-column: 1/-1;
  }
  .settings #selectionControls > input,
  .settings #selectionControls > select {
    grid-column: 1/-1;
  }
  .stage {
    min-height: 0;
    padding: 20px 15px;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .segmented button {
    padding: 6px 8px;
  }
  .stage-caption {
    font-size: 7px;
    letter-spacing: 0.6px;
  }
  .intro .text-button {
    display: none;
  }
  .preview .panel-heading {
    flex-wrap: wrap;
  }
  .preview-surface svg {
    height: 180px;
  }
  .motifs {
    gap: 5px;
  }
  .motif svg {
    width: 49px;
    height: 49px;
  }
  .library-note {
    display: none;
  }
  .panel-heading h3 {
    font-size: 16px;
  }
}
@media (max-width: 500px) {
  main {
    padding: 0 12px;
    gap: 10px;
    grid-template-columns: 98px minmax(0, 1fr);
  }
  .intro {
    padding: 20px 13px;
  }
  h2 {
    font-size: 20px;
  }
  .eyebrow {
    font-size: 8px;
  }
  .library {
    padding: 12px 6px;
  }
  .library .panel-heading {
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
  }
  .library h3 {
    font-size: 14px;
  }
  .motifs {
    grid-template-columns: 1fr;
  }
  .motif {
    flex-direction: row;
    padding: 2px;
    font-size: 8px;
  }
  .motif svg {
    width: 37px;
    height: 37px;
  }
  .library > .muted {
    font-size: 9px;
    margin: 7px 0 12px;
  }
  .tool-actions button {
    font-size: 20px;
  }
  .stage {
    padding: 12px 9px;
  }
  .stage-caption {
    margin-top: 11px;
    font-size: 6px;
  }
  .presets {
    flex-wrap: wrap;
  }
  .presets button {
    font-size: 9px;
  }
  .preview {
    padding: 12px;
  }
  .preview-surface svg {
    height: 160px;
  }
  .preview .panel-heading > span {
    font-size: 7px;
  }
  .preview .muted {
    font-size: 9px;
  }
  .header-actions {
    gap: 5px;
  }
  .header-actions button {
    font-size: 10px;
    padding: 8px;
  }
  .brand-mark {
    font-size: 34px;
  }
  .identity h1 {
    font-size: 23px;
  }
  footer {
    padding: 15px;
    flex-direction: column;
    gap: 6px;
  }
}
