.workspace {
  display: block;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  padding: 0;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  box-shadow: none;
  background: #f5f7fb;
}

.workspace-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1.55fr) minmax(360px, 430px);
  gap: 20px;
  align-items: start;
  width: min(1880px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 12px 34px;
}

.workspace-main,
.workspace-side,
.workspace-history-rail,
.workspace-visual-rail {
  display: grid;
  gap: 18px;
}

.workspace-history-rail,
.workspace-visual-rail {
  min-width: 0;
}

.workspace-conversation-panel {
  min-width: 0;
  align-self: start;
}

.workspace-history-rail {
  position: sticky;
  top: 84px;
  gap: 12px;
  align-self: start;
}

.workspace-history-rail-toggle {
  width: fit-content;
  min-height: 40px;
  padding: 0 16px;
}

.panel {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(17, 24, 39, 0.07);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.panel-head {
  margin-bottom: 18px;
}

.workspace-stage-panel,
.workspace-products-panel,
.workspace-conversation-panel {
  padding: 20px;
}

.workspace-stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.workspace-stage-head h2 {
  margin: 6px 0 6px;
  max-width: 920px;
  font-size: 34px;
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.workspace-stage-head p,
.workspace-products-panel .panel-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace-credit-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: #ffffff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.stage-grid:not(.has-result) .stage.before {
  grid-column: 1 / -1;
}

.stage {
  min-width: 0;
}

.stage-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(78, 100, 129, 0.88);
}

.image-placeholder {
  margin-top: 10px;
  min-height: 0;
  aspect-ratio: 4 / 5;
  max-height: clamp(320px, 52vh, 540px);
  border-radius: 20px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  display: block;
  background: #f3eee8;
  font-size: 24px;
  font-weight: 700;
  color: rgba(112, 83, 52, 0.78);
}

.image-placeholder.accent {
  background: #ecf2f8;
}

.workspace-conversation-panel {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 108px);
  overflow: auto;
}

.workspace-form {
  display: grid;
  gap: 16px;
}

.workspace-config-shell {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.88);
  overflow: hidden;
}

.workspace-config-shell[open] {
  background: rgba(255, 255, 255, 0.96);
}

.workspace-config-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
}

.workspace-config-summary::-webkit-details-marker {
  display: none;
}

.workspace-config-summary-copy {
  display: grid;
  gap: 4px;
}

.workspace-config-summary-copy strong {
  font-size: 14px;
  line-height: 1.2;
}

.workspace-config-summary-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.workspace-config-summary-action {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-config-shell .workspace-form {
  padding: 18px;
}

.workspace-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 16px;
}

.workspace-form-grid-single {
  grid-template-columns: 1fr;
}

.workspace-field {
  display: grid;
  gap: 10px;
  margin: 0;
}

.workspace-field > span,
.workspace-field legend {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.workspace-field legend {
  margin-bottom: 10px;
  padding: 0;
}

.workspace-field fieldset,
.workspace-field legend {
  border: 0;
}

.workspace-field input[type="text"],
.workspace-field input[type="number"],
.workspace-field select,
.workspace-field textarea,
.workspace-file-input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  padding: 11px 13px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
  resize: vertical;
}

.workspace-field textarea {
  min-height: 96px;
  line-height: 1.7;
}

.workspace-file-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  overflow: hidden;
}

.workspace-file-input-native {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.workspace-file-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace-file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-field-wide {
  grid-column: 1 / -1;
}

.choice-grid,
.choice-check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.direction-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card,
.check-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: #ffffff;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.choice-card:hover,
.check-card:hover {
  transform: translateY(-1px);
  border-color: rgba(17, 24, 39, 0.14);
}

.choice-card input,
.check-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card strong,
.check-card span {
  color: var(--text);
}

.choice-card span {
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.choice-card:has(input:checked),
.check-card:has(input:checked) {
  border-color: rgba(37, 99, 235, 0.28);
  background: #f8fbff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.direction-card strong {
  font-size: 18px;
  line-height: 1.18;
}

.direction-card-wide {
  grid-column: 1 / -1;
}

.workspace-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.workspace-form-actions.compact {
  margin-top: -6px;
}

.workspace-feedback {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: #ffffff;
  color: var(--text);
  line-height: 1.55;
}

.workspace-feedback.is-error {
  border-color: rgba(173, 64, 47, 0.22);
  background: rgba(255, 244, 241, 0.95);
  color: #8f3328;
}

.workspace-feedback.is-success {
  border-color: rgba(83, 126, 67, 0.22);
  background: rgba(245, 251, 242, 0.95);
  color: #345f28;
}

.workspace-chat-shell {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(180deg, rgba(246, 249, 255, 0.98), rgba(237, 243, 252, 0.96));
  box-shadow: 0 18px 42px rgba(148, 163, 184, 0.16);
}

.workspace-chat-head .eyebrow {
  color: rgba(71, 85, 105, 0.82);
}

.workspace-chat-head h2 {
  margin: 6px 0 6px;
  font-size: 24px;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: #122033;
}

.workspace-chat-head p {
  margin: 0;
  color: #526377;
  line-height: 1.5;
}

.workspace-chat-thread {
  display: grid;
  gap: 12px;
  max-height: 44vh;
  padding-right: 4px;
  overflow: auto;
}

.conversation-message {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(6px);
}

.conversation-message-assistant {
  background: rgba(255, 255, 255, 0.92);
}

.conversation-message-user {
  background: rgba(37, 99, 235, 0.08);
}

.conversation-message-pending {
  border-style: dashed;
}

.conversation-role {
  color: rgba(59, 130, 246, 0.92);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.conversation-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.65;
  color: #1e293b;
}

.conversation-pending-status {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: rgba(191, 219, 254, 0.88);
  font-size: 12px;
  font-weight: 700;
}

.conversation-visual {
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(226, 232, 240, 0.55);
}

.conversation-visual img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: cover;
}

.conversation-meta {
  margin: 0;
  display: grid;
  gap: 8px;
}

.conversation-meta div {
  display: grid;
  gap: 2px;
}

.conversation-meta dt {
  color: rgba(100, 116, 139, 0.9);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.conversation-meta dd {
  margin: 0;
  color: #334155;
  line-height: 1.55;
}

.workspace-chat-compose {
  display: grid;
  gap: 12px;
  padding-top: 6px;
}

.workspace-chat-compose-field {
  display: grid;
  gap: 10px;
}

.workspace-chat-compose-field > span {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.workspace-chat-compose textarea {
  width: 100%;
  min-height: 110px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 14px;
  font: inherit;
  color: #122033;
  background: rgba(255, 255, 255, 0.92);
  line-height: 1.65;
  resize: vertical;
  border-color: rgba(148, 163, 184, 0.28);
}

.workspace-chat-compose textarea::placeholder {
  color: rgba(100, 116, 139, 0.82);
}

.workspace-history-shell {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  background: rgba(255, 255, 255, 0.98);
  max-height: calc(100vh - 136px);
  overflow: auto;
}

.workspace-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.workspace-history-head .eyebrow {
  margin-bottom: 10px;
}

.workspace-history-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.workspace-history-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.workspace-history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.workspace-history-new {
  min-height: 40px;
  padding: 0 16px;
}

.workspace-history-list {
  display: grid;
  gap: 12px;
}

.workspace-history-card {
  width: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.workspace-history-card.is-active {
  border-color: rgba(37, 99, 235, 0.3);
  background: #f8fbff;
}

.workspace-history-thumb {
  overflow: hidden;
  border-radius: 14px;
  background: #eef2f7;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.workspace-history-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.workspace-history-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.workspace-history-title {
  color: #111827;
  font-size: 14px;
  line-height: 1.35;
}

.workspace-history-meta,
.workspace-history-time {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.workspace-history-empty {
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed rgba(17, 24, 39, 0.12);
  background: #f8fafc;
  color: var(--muted);
  line-height: 1.55;
}

.image-stage,
.result-stage {
  position: relative;
  overflow: hidden;
}

.image-stage img,
.result-stage img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: inherit;
}

.image-stage img {
  object-fit: contain;
}

.result-stage img {
  object-fit: cover;
}

.image-placeholder-copy {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 8px;
  place-content: center;
  padding: 24px;
  text-align: center;
}

.image-placeholder-copy strong {
  font-size: 22px;
}

.image-placeholder-copy span {
  font-size: 15px;
  color: rgba(125, 77, 43, 0.78);
}

.workspace-products-panel .product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.workspace-products-panel .product-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  align-content: start;
}

.product-card-visual {
  overflow: hidden;
  border-radius: 18px;
  background: rgba(244, 246, 250, 0.92);
  aspect-ratio: 1 / 1;
}

.product-card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.product-price {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.workspace-products-panel .product-card h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.28;
}

.workspace-products-panel .product-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.product-details {
  margin: 0;
  display: grid;
  gap: 10px;
}

.product-details div {
  display: grid;
  gap: 4px;
}

.product-details dt {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.product-details dd {
  margin: 0;
  color: #2f3846;
  line-height: 1.55;
}

.product-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(17, 24, 39, 0.1);
  background: #111827;
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 1480px) {
  .workspace-shell {
    grid-template-columns: minmax(240px, 280px) minmax(0, 1.35fr) minmax(320px, 380px);
    width: min(1680px, calc(100% - 18px));
  }

  .workspace-products-panel .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .workspace-shell {
    grid-template-columns: minmax(200px, 240px) minmax(0, 1.2fr) minmax(280px, 340px);
    gap: 16px;
    width: min(100%, calc(100% - 16px));
    padding: 16px 8px 28px;
  }

  .workspace-stage-panel,
  .workspace-products-panel,
  .workspace-conversation-panel,
  .workspace-history-shell {
    padding: 16px;
  }

  .workspace-stage-head h2 {
    font-size: 30px;
  }

  .workspace-chat-head h2,
  .workspace-history-head h2 {
    font-size: 20px;
  }
}

@media (max-width: 900px) {
  .workspace-shell {
    grid-template-columns: 1fr;
  }

  .workspace-history-rail,
  .workspace-conversation-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
  }

  .workspace-stage-head {
    display: grid;
  }

  .stage-grid,
  .workspace-products-panel .product-grid {
    grid-template-columns: 1fr;
  }

  .workspace-chat-thread {
    max-height: none;
  }

  .workspace-history-head {
    display: grid;
  }
}

@media (max-width: 760px) {
  .workspace {
    width: auto;
    margin-left: 0;
    padding: 18px;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
  }

  .workspace-shell {
    width: 100%;
    padding: 0;
    gap: 18px;
  }

  .workspace-conversation-panel,
  .workspace-stage-panel,
  .workspace-products-panel,
  .workspace-history-shell {
    padding: 18px;
  }

  .workspace-stage-head h2 {
    font-size: 24px;
  }

  .image-placeholder,
  .image-stage img,
  .result-stage img {
    min-height: 240px;
  }
}
