/* Prompt 15 layout layer: presentation only. Prompt 12 renderer and data stay untouched. */
:root {
  --p15-left-width: 292px;
  --p15-gap: 8px;
  --p15-toolbar-height: 46px;
}

body[data-prompt15-layout] {
  min-height: 100dvh;
  overflow: hidden;
}

body[data-prompt15-layout] > .topbar,
body[data-prompt15-layout] > footer {
  display: none;
}

body[data-prompt15-layout] .app-shell {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: var(--p15-left-width) minmax(0, 1fr);
  grid-template-rows: var(--p15-toolbar-height) auto minmax(0, 1fr);
  grid-template-areas:
    "parts toolbar"
    "parts finishes"
    "parts replica";
  gap: var(--p15-gap);
  height: 100dvh;
  max-width: none;
  padding: 8px;
  margin: 0;
}

body[data-prompt15-layout] .left-panel {
  grid-area: parts;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body[data-prompt15-layout] .left-panel > .selected-card {
  display: none;
}

body[data-prompt15-layout] .left-panel > .panel {
  padding: 10px;
}

body[data-prompt15-layout] .left-panel .panel-heading {
  align-items: center;
}

body[data-prompt15-layout] .left-panel .panel-heading h2 {
  margin: 0;
  font-size: 1rem;
}

body[data-prompt15-layout] .left-panel .panel-kicker {
  margin-bottom: 2px;
}

body[data-prompt15-layout] .parts-list {
  display: grid;
  gap: 4px;
  max-height: none;
  overflow: visible;
  padding: 2px;
}

body[data-prompt15-layout] .part-button {
  min-height: 34px;
  padding: 5px 7px;
}

body[data-prompt15-layout] .workspace {
  display: contents;
}

body[data-prompt15-layout] .workspace-toolbar {
  grid-area: toolbar;
  min-width: 0;
  min-height: 0;
  padding: 5px 8px;
  border-radius: 10px;
}

body[data-prompt15-layout] .workspace-toolbar .segmented {
  min-width: 0;
}

body[data-prompt15-layout] .workspace-toolbar .segmented button,
body[data-prompt15-layout] .p15-file-button {
  min-height: 34px;
}

body[data-prompt15-layout] .p15-file-button {
  margin-left: auto;
  min-width: 48px;
  padding-inline: 14px;
  border-color: #5f665c;
  background: #202922;
}

body[data-prompt15-layout] .finish-rail-panel {
  grid-area: finishes;
  min-width: 0;
  min-height: 0;
  padding: 8px 10px;
}

body[data-prompt15-layout] .finish-rail-heading {
  align-items: end;
  gap: 10px;
  margin-bottom: 5px;
}

body[data-prompt15-layout] .finish-rail-heading h2 {
  margin: 0;
  font-size: 1rem;
}

body[data-prompt15-layout] .finish-search-label {
  min-width: min(310px, 42vw);
}

body[data-prompt15-layout] .finish-search-label span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body[data-prompt15-layout] .finish-search-label input {
  min-height: 34px;
}

body[data-prompt15-layout] .finish-rail {
  min-height: 66px;
  padding-block: 4px;
}

body[data-prompt15-layout] .finish-chip {
  min-width: 100px;
  min-height: 56px;
}

body[data-prompt15-layout] .finish-chip[hidden] {
  display: none !important;
}

body[data-prompt15-layout] .finish-rail-footer {
  margin-top: 4px;
}

body[data-prompt15-layout] .finish-rail-footer p {
  overflow: hidden;
  max-width: calc(100% - 170px);
  white-space: nowrap;
  text-overflow: ellipsis;
}

body[data-prompt15-layout] .canvas-viewport {
  grid-area: replica;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border-radius: 12px;
}

body[data-prompt15-layout] .right-panel,
body[data-prompt15-layout] .workspace-selection,
body[data-prompt15-layout] .workspace-status,
body[data-prompt15-layout] .summary-panel {
  display: none;
}

.p15-family-panel {
  flex: 0 0 auto;
}

.p15-family-panel h2 {
  margin: 0;
  font-size: 1rem;
}

.p15-family-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 7px;
}

.p15-family-button {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 34px;
  padding: 4px 6px;
  text-align: left;
}

.p15-family-button[aria-pressed="true"] {
  border-color: #dad6a0;
  box-shadow: inset 0 0 0 1px #dad6a0;
  background: #313a30;
}

.p15-family-dot {
  width: 9px;
  height: 9px;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 50%;
  background: var(--family-indicator, #889188);
}

.p15-family-label {
  overflow: hidden;
  font-size: .72rem;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.p15-family-count {
  color: #bfc6bc;
  font: 600 .68rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.p15-drawer-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  justify-items: end;
  background: rgba(2, 5, 4, .68);
  backdrop-filter: blur(3px);
}

.p15-drawer-overlay[hidden] {
  display: none;
}

.p15-drawer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(500px, 94vw);
  height: 100dvh;
  background: #0e1310;
  border-left: 1px solid #566057;
  box-shadow: -18px 0 48px rgba(0,0,0,.55);
}

.p15-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid #3f4941;
}

.p15-drawer-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.p15-drawer-close {
  min-width: 42px;
  min-height: 42px;
  font-size: 1.4rem;
}

.p15-drawer-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
}

.p15-drawer-body > section,
.p15-drawer-body > header,
.p15-drawer-body > div {
  margin-bottom: 8px;
}

.p15-drawer-body .topbar {
  display: block;
  padding: 12px;
}

.p15-drawer-body .topbar h1 {
  margin-block: 3px;
  font-size: 1.15rem;
}

.p15-drawer-body .topbar .subtitle {
  font-size: .8rem;
}

body[data-prompt15-layout] .p15-drawer-body .workspace-selection,
body[data-prompt15-layout] .p15-drawer-body .workspace-status,
body[data-prompt15-layout] .p15-drawer-body .summary-panel {
  display: flex;
}

.p15-drawer-body .workspace-selection,
.p15-drawer-body .workspace-status {
  border: 1px solid #343d36;
  border-radius: 10px;
}

.p15-drawer-body .workspace-status {
  flex-direction: column;
}

.p15-drawer-body .summary-panel {
  display: block;
}

.p15-drawer-body .view-tools {
  display: grid;
  grid-template-columns: auto 42px auto 42px auto;
  align-items: center;
  gap: 5px;
  padding: 9px;
  border: 1px solid #343d36;
  border-radius: 10px;
}

body[data-prompt15-layout] .p15-drawer-body .right-panel {
  display: grid;
  gap: 8px;
}

.p15-drawer-body .right-panel .panel {
  margin: 0;
}

body.p15-drawer-open {
  overflow: hidden;
}

@media (max-width: 760px) {
  body[data-prompt15-layout] {
    overflow: auto;
  }

  body[data-prompt15-layout] .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(260px, 52vh);
    grid-template-areas:
      "toolbar"
      "parts"
      "finishes"
      "replica";
    height: auto;
    min-height: 100dvh;
    padding: 6px;
  }

  body[data-prompt15-layout] .workspace-toolbar {
    position: sticky;
    z-index: 20;
    top: 0;
    flex-direction: row;
    align-items: center;
  }

  body[data-prompt15-layout] .workspace-toolbar .segmented {
    display: flex;
    flex: 1 1 auto;
  }

  body[data-prompt15-layout] .workspace-toolbar .segmented button {
    flex: 1 1 50%;
    min-width: 0;
  }

  body[data-prompt15-layout] .workspace-toolbar .segmented button,
  body[data-prompt15-layout] .p15-file-button,
  .p15-family-button {
    min-height: 44px;
  }

  body[data-prompt15-layout] .left-panel {
    overflow: visible;
  }

  body[data-prompt15-layout] .parts-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
  }

  body[data-prompt15-layout] .part-button {
    flex: 0 0 156px;
    min-height: 44px;
    scroll-snap-align: start;
  }

  .p15-family-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .p15-family-button {
    grid-template-columns: 9px minmax(0, 1fr);
    grid-template-rows: auto auto;
    padding: 5px;
  }

  .p15-family-count {
    grid-column: 2;
  }

  body[data-prompt15-layout] .finish-rail-heading {
    align-items: stretch;
    flex-direction: column;
  }

  body[data-prompt15-layout] .finish-search-label {
    min-width: 0;
    width: 100%;
  }

  body[data-prompt15-layout] .finish-search-label input {
    min-height: 44px;
  }

  body[data-prompt15-layout] .finish-rail-footer p {
    max-width: 65%;
  }

  body[data-prompt15-layout] .canvas-viewport {
    min-height: 260px;
    height: 52vh;
  }
}

@media (max-width: 430px) {
  body[data-prompt15-layout] .workspace-toolbar {
    gap: 5px;
  }

  body[data-prompt15-layout] .workspace-toolbar .segmented button,
  body[data-prompt15-layout] .p15-file-button {
    padding-inline: 8px;
    font-size: .75rem;
  }

  .p15-family-label {
    font-size: .64rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .p15-drawer-overlay,
  .p15-drawer {
    scroll-behavior: auto;
  }
}
