/* Shared app shell. Both materials must use this contract for common flows. */
:root {
  --atelier-dialog-width: 1440px;
  --atelier-gap: 24px;
}
.atelier-document-bar {
  max-width: 1560px;
  margin: 0 auto 18px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}
.atelier-document-bar > input {
  min-width: 140px;
  max-width: 390px;
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font:
    22px Georgia,
    serif;
  padding: 7px 0;
}
.atelier-document-bar > span {
  font-size: 10px;
  color: var(--muted);
  margin-right: auto;
}
.atelier-document-bar > button {
  font-size: 11px;
  padding: 9px 13px;
  white-space: nowrap;
}
.atelier-document-bar > button.primary {
  background: var(--teal);
  color: var(--paper);
}
.atelier-intro {
  max-width: 1560px;
  padding: 24px 28px 20px;
  margin: auto;
}
header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.atelier-new-dialog,
.atelier-review-dialog {
  box-sizing: border-box;
  width: min(var(--atelier-dialog-width), calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  height: min(980px, calc(100dvh - 40px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  overflow: hidden;
}
dialog.atelier-new-dialog[open],
dialog.atelier-review-dialog[open] {
  display: flex;
  flex-direction: column;
}
.atelier-new-dialog > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  margin: 0;
}
.atelier-dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 26px;
  margin: 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.atelier-dialog-heading h2 {
  font:
    30px Georgia,
    serif;
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.atelier-dialog-heading > button {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 12px;
}
.atelier-new-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: 0;
  min-height: 0;
  flex: 1;
  margin: 0;
  align-items: stretch;
  overflow: hidden;
}
.atelier-new-controls {
  min-width: 0;
  overflow: auto;
  padding: 22px 26px;
  scrollbar-gutter: stable;
}
.atelier-new-controls > label,
.atelier-new-controls > .visual-label {
  font-size: 11px;
  margin: 16px 0 7px;
  display: block;
}
.atelier-new-controls > input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.atelier-new-dialog .atelier-new-options {
  position: static;
  align-self: stretch;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 22px 24px;
  background: var(--paper);
  display: block;
  text-align: left;
}
.atelier-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.atelier-preview-heading > .eyebrow {
  font-size: 10px;
}
.atelier-preview-heading > button {
  font-size: 11px;
  padding: 6px 10px;
}
.atelier-new-preview {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: clamp(280px, 43dvh, 460px);
  min-height: 280px;
  aspect-ratio: auto;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 15px;
  overflow: hidden;
}
.atelier-new-preview svg {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  flex: 1;
  min-width: 0;
  min-height: 0;
}
.atelier-new-options > label,
.atelier-new-options > .visual-label {
  display: block;
  margin: 17px 0 8px;
  font-size: 11px;
}
.atelier-new-options .small-note {
  font-size: 10px;
  line-height: 1.6;
}
.atelier-new-options .vc-dropdown[open] > .vc-options {
  max-height: 230px;
}
.atelier-new-options .background-heading {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}
.atelier-new-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 15px 26px;
  background: var(--panel);
}
.atelier-new-footer > div {
  min-width: 0;
}
.atelier-new-footer > button {
  white-space: nowrap;
  min-width: 150px;
  font-size: 12px;
}
.atelier-new-footer .small-note {
  margin: 0 0 6px;
}
.atelier-new-footer label {
  margin: 0;
  font-size: 11px;
}
.atelier-new-footer input {
  accent-color: var(--teal);
}
.atelier-new-footer .new-tile-error,
.atelier-new-footer .kilim-error {
  margin: 5px 0 0;
  font-size: 11px;
}
.atelier-new-dialog .starter-grid,
.atelier-new-dialog #templateChoices > .vc-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.atelier-new-dialog #templateChoices .vc-preview {
  height: 128px;
}
.atelier-new-dialog #newCeramicFormChoices .vc-preview,
.atelier-new-dialog #newWeaveFormChoices .vc-preview {
  height: 64px;
}
.atelier-new-dialog #newCeramicFormChoices .vc-options,
.atelier-new-dialog #newWeaveFormChoices .vc-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.atelier-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 24px;
  padding: 22px 26px;
  min-height: 0;
  flex: 1;
  align-items: stretch;
  overflow: hidden;
}
.atelier-review-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 9px;
  background: #dcd2c0;
  box-shadow: 0 6px 25px #0001;
}
.atelier-review-view svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  min-width: 0;
  min-height: 0;
}
.atelier-review-settings {
  min-height: 0;
  overflow: auto;
  padding: 0;
  display: block;
}
.atelier-review-settings label {
  display: block;
  margin: 15px 0 8px;
  font-size: 12px;
}
.atelier-review-settings > label:first-child {
  margin-top: 0;
}
.atelier-review-settings select,
.atelier-review-settings input[type="range"] {
  width: 100%;
  box-sizing: border-box;
}
.atelier-review-settings .wide {
  width: 100%;
  margin: 12px 0 0;
  font-size: 11px;
}
.atelier-review-settings output {
  float: right;
  color: var(--muted);
  font-size: 11px;
}
.atelier-review-settings p {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
}
.atelier-flat-view {
  flex: 1;
  min-height: 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}
.atelier-flat-view svg {
  display: block;
  max-width: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.atelier-flat-note {
  padding: 0 26px;
  margin: 12px 0 18px;
}
@media (max-width: 1000px) {
  .atelier-new-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
  }
  .atelier-new-controls {
    padding: 18px;
  }
  .atelier-new-options {
    padding: 18px;
  }
  .atelier-new-dialog .starter-grid,
  .atelier-new-dialog #templateChoices > .vc-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .atelier-review-layout {
    grid-template-columns: minmax(0, 1fr) 200px;
    gap: 16px;
    padding: 18px;
  }
}
@media (max-width: 720px) {
  .atelier-new-dialog,
  .atelier-review-dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
  }
  .atelier-dialog-heading {
    padding: 16px;
  }
  .atelier-dialog-heading h2 {
    font-size: 24px;
  }
  .atelier-dialog-heading > button {
    font-size: 10px;
  }
  .atelier-new-layout {
    display: flex;
    flex-direction: column;
    overflow: auto;
  }
  .atelier-new-controls {
    overflow: visible;
    order: 1;
    padding: 16px;
  }
  .atelier-new-dialog .atelier-new-options {
    overflow: visible;
    order: 0;
    padding: 16px;
    position: static;
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .atelier-new-preview {
    height: 300px;
    min-height: 240px;
  }
  .atelier-new-footer {
    padding: 12px 16px;
    gap: 10px;
  }
  .atelier-new-footer > button {
    min-width: 110px;
    font-size: 11px;
  }
  .atelier-new-footer label {
    font-size: 10px;
  }
  .atelier-new-footer .small-note {
    font-size: 9px;
  }
  .atelier-review-layout {
    display: flex;
    flex-direction: column;
    overflow: auto;
    padding: 12px;
    gap: 16px;
  }
  .atelier-review-view {
    min-height: 52dvh;
    height: 52dvh;
    flex-shrink: 0;
  }
  .atelier-review-settings {
    overflow: visible;
    display: block;
  }
  .atelier-review-settings .wide {
    font-size: 12px;
  }
  .atelier-document-bar {
    padding: 0 16px;
  }
  .atelier-document-bar > input {
    flex-basis: 100%;
    max-width: none;
  }
  .atelier-document-bar > span {
    display: none;
  }
  .atelier-document-bar > button {
    flex: 1;
    font-size: 10px;
    padding: 8px;
  }
  .atelier-intro {
    padding: 20px 16px;
  }
  .atelier-flat-view {
    padding: 12px;
  }
}

body .atelier-header {
  max-width: 1560px;
  margin: auto;
  padding: 20px 28px;
}
.atelier-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin-left: auto;
}
.atelier-header .header-actions > button {
  white-space: nowrap;
}
.atelier-new-dialog [hidden] {
  display: none !important;
}
#starterCollectionPanel {
  margin: 16px 0;
}
.atelier-new-options .kilim-form-grid input {
  box-sizing: border-box;
  width: 100%;
}
@media (max-width: 820px) {
  body .atelier-header {
    padding: 16px;
    flex-wrap: wrap;
  }
  .atelier-header .header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .atelier-header .header-actions > span {
    display: none;
  }
}

#unitModeOptions {
  display: flex;
  align-items: center;
  gap: 10px;
}
#unitModeOptions[hidden],
#neighborsOptions[hidden],
#borderCornerOptions[hidden],
#sceneKindOptions[hidden] {
  display: none !important;
}

/* One glazed colour sample for individual tools in both material workbenches.
   Decoration sits over the solid colour, leaving stored/exported pigments exact.
   Continuous hue/saturation fields deliberately remain unobstructed. */
:is(
  .color-trigger i,
  .brush-color i,
  .pigment-sample i,
  .pigment-well i,
  .mini-well,
  .popover-swatch i,
  .vc-single > i,
  .generator-color i,
  .new-backgrounds i,
  .new-background-custom i,
  #designColors button,
  .shelf-colors button,
  .shelf-ground i,
  .shelf-record-colors > i,
  .guide-used-colors button,
  .guide-color-sample,
  #guideColorSample,
  #shelfChip,
  #colorChip,
  .yarn-swatches button,
  .yarn-current i,
  .kilim-usage i
) {
  position: relative;
  border-radius: 5px 6px 4px 7px;
  box-shadow: inset 0 0 0 1px #0001;
}
:is(
  .color-trigger i,
  .brush-color i,
  .pigment-sample i,
  .pigment-well i,
  .mini-well,
  .popover-swatch i,
  .vc-single > i,
  .generator-color i,
  .new-backgrounds i,
  .new-background-custom i,
  #designColors button,
  .shelf-colors button,
  .shelf-ground i,
  .shelf-record-colors > i,
  .guide-used-colors button,
  .guide-color-sample,
  #guideColorSample,
  #shelfChip,
  #colorChip,
  .yarn-swatches button,
  .yarn-current i,
  .kilim-usage i
)::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 4px;
  background: linear-gradient(135deg, #fff4, transparent 50%, #fff1);
  box-shadow: none;
  pointer-events: none;
}
/* A palette reads as one colour composition, rather than individual pigment wells.
   Interactive colour buttons retain their textured finish and selection affordances. */
.vc-palette,
.new-palette-colors:not(:has(.generator-color)) {
  position: relative;
  isolation: isolate;
  display: flex;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #00000014;
}
.vc-palette > i,
.new-palette-colors > i {
  display: block;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.vc-palette > i::after,
.new-palette-colors > i::after {
  content: none;
}
.vc-palette::after,
.new-palette-colors:not(:has(.generator-color))::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, #ffffff12, transparent 45%, #00000008);
  box-shadow: inset 0 0 0 1px #ffffff0a;
}
.vc-dropdown > summary .vc-mini:has(.vc-palette),
.vc-rows .vc-preview:has(.vc-palette) {
  height: 24px;
  border-radius: 6px;
  background: transparent;
}
.shelf-record-colors > .vc-palette {
  height: 28px;
}
.shelf-record-colors > i {
  height: 28px;
  width: 28px;
}
.inspector .color-trigger i,
.border-colors .color-trigger i {
  box-shadow: inset 0 0 0 1px #0001;
}
.brush-color i {
  width: 25px;
  height: 25px;
}

.atelier-component-slot {
  display: contents;
}
.atelier-error {
  color: #a24638;
  font-size: 11px;
  margin: 6px 0 0;
}
[data-theme="dark"] .atelier-error {
  color: #f2a395;
}

#objectPanel[hidden],
#objectControls[hidden] {
  display: none !important;
}
.placed-objects {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 180px;
  overflow: auto;
  margin: 10px 0;
}
.placed-objects button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  font-size: 11px;
  text-align: left;
}
.placed-objects small {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
.placed-objects button.active {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}
.object-inks {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.object-inks .color-trigger {
  flex: 0 0 auto;
  font-size: 10px;
  padding: 5px;
}
.object-inks i {
  display: block;
  width: 26px;
  height: 26px;
}
#objectControls > .pair {
  flex-wrap: wrap;
  margin: 8px 0;
}
#objectControls > .pair button {
  font-size: 10px;
  padding: 7px;
}

.placed-object-thumb {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border-radius: 4px;
}
.placed-object-thumb svg {
  width: 100%;
  height: 100%;
}
.placed-objects button > span {
  flex: 1;
}

#placementAccent[hidden],
#placementSymmetry[hidden] {
  display: none !important;
}

.atelier-selection-back {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0 0 14px;
  padding: 9px 10px;
  font-size: 11px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: left;
}
.atelier-selection-back kbd {
  font: 9px system-ui;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 4px;
}
.atelier-selection-back:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

#objectInkOptions[hidden] {
  display: none !important;
}
.kilim-settings .align-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 10px 0;
}
.kilim-settings .align-tools button {
  font-size: 10px;
  padding: 6px 3px;
}
.kilim-settings .inspector-disclosure > summary {
  font-size: 12px;
}
.kilim-app .kilim-viewbar {
  flex-wrap: wrap;
}

/* Shared functional copy and new-project method tabs. */
.atelier-intro {
  justify-content: flex-end;
  min-height: 0;
  padding-top: 10px;
  padding-bottom: 10px;
  gap: 18px;
}
.creation-modes {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 9px;
  margin: 20px 0 18px;
}
.creation-mode {
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
  padding: 15px 12px;
  background: #fffef8;
  border: 1px solid #d7dfce;
  min-width: 0;
}
.creation-mode strong {
  display: block;
  font-size: 12px;
}
.creation-mode small {
  display: block;
  font-size: 10px;
  line-height: 1.5;
  color: #788773;
  margin-top: 4px;
}
.creation-mode.active {
  background: #eaf1e2;
  border-color: #507c67;
  box-shadow: inset 0 0 0 1px #507c67;
}
.creation-mark {
  font-size: 27px;
  color: #547d66;
}
#weaveGeneratorPanel > button {
  margin-top: 16px;
}
#weaveGeneratorColors {
  margin: 14px 0;
}
#weaveInkChoices button {
  padding: 4px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
}
#weaveInkChoices button[aria-pressed="true"] {
  outline: 2px solid var(--teal, #236068);
  outline-offset: 1px;
}
#weaveInkChoices i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow:
    inset 0 1px 3px #ffffff70,
    inset 0 -2px 4px #0003;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.16' filter='url(%23n)'/%3E%3C/svg%3E");
}

#weaveStarterPanel > label,
#weaveStarterPanel > .visual-label,
#weaveGeneratorPanel > label {
  display: block;
  font-size: 11px;
  margin: 16px 0 7px;
}
#weaveGeneratorPanel > select,
#weaveGeneratorPanel > input {
  width: 100%;
  box-sizing: border-box;
}
#weaveGeneratorPanel output {
  float: right;
  color: var(--muted);
}
#weaveGeneratorPanel > select {
  padding: 9px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}

@media (max-width: 850px) {
  .creation-modes {
    grid-template-columns: 1fr;
  }
  .creation-mode {
    padding: 12px;
  }
  .creation-mode small {
    font-size: 9px;
  }
}
@media (max-width: 600px) {
  .creation-modes {
    grid-template-columns: 1.2fr 1fr;
    gap: 7px;
  }
  .creation-mode {
    padding: 10px 8px;
    gap: 6px;
  }
  .creation-mode strong {
    font-size: 11px;
  }
  .creation-mark {
    display: none;
  }
}

/* One approved motif mark shared by both material workbenches. */
.atelier-header .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  line-height: 1;
}
.atelier-header .brand-mark img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}
[data-theme="dark"] .atelier-header .brand-mark {
  background: #f5f2e9;
  border-radius: 10px;
}
@media (max-width: 820px) {
  .atelier-header .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }
  .atelier-header .brand-mark img {
    width: 38px;
    height: 38px;
  }
}

/* Shared language preference, outside the document and undo state. */
.language-choice {
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.language-choice select {
  width: 58px;
  padding: 8px 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
}
.language-choice select:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
[data-i18n-text] {
  white-space: inherit;
}
button > span[data-i18n-text] {
  pointer-events: none;
}

/* One material inspector for ceramic and woven surfaces. */
.material-review-controls {
  border-bottom: 1px solid var(--line);
  padding-bottom: 15px;
  margin-bottom: 15px;
}
.material-review-modes {
  display: flex;
  gap: 4px;
}
.material-review-modes button {
  flex: 1;
  padding: 8px 5px;
  font-size: 11px;
}
.material-review-modes button[aria-pressed="true"] {
  background: var(--teal);
  color: white;
}
.material-review-controls > button {
  width: 100%;
  margin-top: 9px;
  font-size: 11px;
}
.atelier-review-view {
  position: relative;
}
.material-canvas-host {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
}
.material-canvas-host canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.material-canvas-host canvas:active {
  cursor: grabbing;
}
.material-review-controls .small-note {
  min-height: 32px;
  margin-bottom: 0;
}

/* Autosave failed (storage full / unavailable): make the status impossible to miss. */
#saveStatus.save-failed {
  color: #b3412e;
  font-weight: 700;
}
[data-theme="dark"] #saveStatus.save-failed {
  color: #f08c74;
}
