:host {
  display: block;
  min-height: 100vh;
  padding: 32px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #f7f8fc 0%, #eef2f7 100%);
  color: #1f2937;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 30%) 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.pane {
  background: #ffffff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 25px 45px -30px rgba(15, 23, 42, 0.4), 0 1px 3px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.pane__header {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  color: #6b7280;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat__history {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat__message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 100%;
}

.chat__identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 56px;
}

.chat__message[data-role='user'] .chat__identity {
  align-items: center;
}

.chat__avatar-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4b5563;
  text-align: center;
}
.chat__message[data-role='assistant'] {
  align-self: flex-start;
}

.chat__message[data-role='user'] {
  flex-direction: row-reverse;
  align-self: flex-end;
}

.chat__bubble {
  padding: 16px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  max-width: min(100%, 520px);
  display: flex;
  flex-direction: column;
  gap: 0;
  word-break: break-word;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.chat__message[data-role='user'] .chat__bubble {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.16), rgba(59, 130, 246, 0.08));
  border-color: rgba(37, 99, 235, 0.24);
}

.chat__message[data-role='assistant'] .chat__bubble {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(16, 185, 129, 0.08));
  border-color: rgba(5, 150, 105, 0.22);
}

.chat__message:hover .chat__bubble {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px -14px rgba(15, 23, 42, 0.6);
}

.chat__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  color: #0f172a;
  background: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, 0.4);
  box-shadow: 0 8px 16px -12px rgba(15, 23, 42, 0.45);
}

.chat__avatar[data-role='user'] {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  color: #dbeafe;
  border-color: rgba(37, 99, 235, 0.3);
}

.chat__avatar[data-role='assistant'] {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  color: #ecfdf5;
  border-color: rgba(5, 150, 105, 0.3);
}

.chat__avatar-icon {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.chat__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  white-space: pre-wrap;
}

.chat__composer {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6b7280;
}

.chat__input {
  min-height: 140px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #f9fafb;
  resize: vertical;
  font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #111827;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.chat__input:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.6);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.chat__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.model-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 3px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.26);
  margin-left: auto;
}

.model-toggle__button {
  min-width: 0;
  border: none;
  border-radius: 999px;
  padding: 4px 12px;
  background: transparent;
  color: #1f2937;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1.2;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.model-toggle__button:hover {
  transform: translateY(-1px);
  background: rgba(37, 99, 235, 0.08);
}

.model-toggle__button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.model-toggle__button--active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  box-shadow: 0 16px 32px -24px rgba(79, 70, 229, 0.6);
}

.model-toggle__label {
  display: inline-block;
}




.chat__send {
  height: 42px;
  min-width: 120px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.chat__send:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 12px 25px -18px rgba(37, 99, 235, 0.8);
}

.chat__send:active:not([disabled]) {
  transform: translateY(0);
}

.chat__send[disabled] {
  cursor: not-allowed;
  opacity: 0.4;
}

.pane--preview {
  min-height: 0;
}

.preview__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.preview__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pane__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.pane__subtitle {
  margin: 6px 0 0;
  font-size: 13px;
  color: #6b7280;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  padding: 4px;
  background: #f9fafb;
}

.preview__refresh {
  height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #1f2937;
  background: #ffffff;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.preview__refresh:hover:not([disabled]) {
  background: rgba(148, 163, 184, 0.15);
  color: #111827;
  box-shadow: 0 16px 34px -24px rgba(148, 163, 184, 0.8);
}

.preview__refresh:active:not([disabled]) {
  background: rgba(148, 163, 184, 0.22);
}

.preview__refresh[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}
.preview__export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  width: 40px;
  padding: 0;
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 12px;
  color: #1f2937;
  background: #ffffff;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.preview__export:hover:not([disabled]) {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.preview__export:active:not([disabled]) {
  background: rgba(37, 99, 235, 0.12);
}

.preview__export:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}

.preview__export[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.preview__export-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.preview__deploy {
  height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #ffffff;
  background: linear-gradient(135deg, #10b981, #14b8a6);
  cursor: pointer;
  box-shadow: 0 14px 28px -20px rgba(14, 116, 144, 0.9);
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.preview__deploy:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 20px 38px -26px rgba(13, 148, 136, 0.85);
}

.preview__deploy:active:not([disabled]) {
  transform: translateY(0);
}

.preview__deploy[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.view-toggle__button {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.view-toggle__button:hover {
  background: rgba(148, 163, 184, 0.15);
}

.view-toggle__button--active {
  background: #ffffff;
  color: #1f2937;
  box-shadow: 0 6px 16px -12px rgba(15, 23, 42, 0.6);
}

.preview__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.preview__progress {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(59, 130, 246, 0.05));
  border: 1px solid rgba(59, 130, 246, 0.25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.preview__progress-bar {
  position: relative;
  flex: 1;
  height: 6px;
  min-width: 140px;
  max-width: 220px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  overflow: hidden;
}

.preview__progress-fill {
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
  border-radius: inherit;
  animation: preview-progress-slide 1.25s ease-in-out infinite;
}

.preview__progress-text {
  font-size: 13px;
  font-weight: 600;
  color: #1d4ed8;
}

@keyframes preview-progress-slide {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(35%);
  }
  100% {
    transform: translateX(110%);
  }
}

.preview__placeholder {
  padding: 24px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  color: #6b7280;
  font-size: 14px;
  text-align: center;
}

.code-view {
  display: grid;
  gap: 16px;
}

.code-view__title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #475569;
}

.code-view__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.code-view__copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.code-view__copy:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: #1d4ed8;
  transform: translateY(-1px);
}

.code-view__copy:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.55);
  outline-offset: 2px;
}

.code-view__copy--copied {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.4);
  color: #047857;
}

.code-view__copy-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.code-view__editor {
  width: 100%;
  min-height: 240px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #0f172a;
  color: #f9fafb;
  font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
  white-space: pre;
  tab-size: 2;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.code-view__editor:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.55), 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.code-view__editor::selection {
  background: rgba(96, 165, 250, 0.35);
}



.deploy-modal {
  position: fixed;
  inset: 0;
  z-index: 1010;
  display: grid;
  place-items: center;
  padding: 24px;
}

.deploy-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.deploy-modal__panel {
  position: relative;
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 32px 64px -40px rgba(15, 23, 42, 0.62), 0 18px 36px -28px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1;
}

.deploy-modal__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.deploy-modal__subtitle {
  margin: 0;
  font-size: 14px;
  color: #475569;
  line-height: 1.5;
}

.deploy-modal__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.deploy-modal__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deploy-modal__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.deploy-modal__input {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  background: #f8fafc;
  font-size: 14px;
  color: #0f172a;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.deploy-modal__input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.65);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.deploy-modal__hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

.deploy-modal__targets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.deploy-target {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #f8fafc;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.deploy-target__input {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: #2563eb;
}

.deploy-target__details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deploy-target__label {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.deploy-target__description {
  font-size: 12px;
  color: #64748b;
}

.deploy-target:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 10px 24px -20px rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.08);
}

.deploy-target input:checked + .deploy-target__details .deploy-target__label {
  color: #2563eb;
}

.deploy-target input:checked + .deploy-target__details .deploy-target__description {
  color: #1d4ed8;
}

.deploy-modal__error {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
}

.deploy-modal__actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.deploy-modal__cancel {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.16);
  color: #334155;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, opacity 140ms ease;
}

.deploy-modal__cancel:hover:not([disabled]) {
  background: rgba(148, 163, 184, 0.24);
}

.deploy-modal__cancel[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.deploy-modal__submit {
  flex: 1;
  height: 42px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.deploy-modal__submit:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px -24px rgba(79, 70, 229, 0.75);
}

.deploy-modal__submit:active:not([disabled]) {
  transform: translateY(0);
}

.deploy-modal__submit[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

@media (max-width: 1080px) {
  :host {
    padding: 24px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .pane--preview {
    order: 1;
  }

  .pane--chat {
    order: 2;
  }
}

@media (max-width: 640px) {

  .preview__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .preview__deploy {
    width: 100%;
  }

  .preview__refresh {
    width: 100%;
  }

  .preview__export {
    width: 100%;
  }

  .code-view__editor {
    min-height: 200px;
  }

  .deploy-modal {
    padding: 16px;
  }

  .deploy-modal__panel {
    width: 100%;
    padding: 24px;
  }

  .deploy-target {
    padding: 10px;
  }
  :host {
    padding: 20px;
  }

  .pane {
    padding: 20px;
  }

  .pane__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .model-toggle {
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
  }

  .model-toggle__button {
    flex: 1 1 0;
    text-align: center;
  }

  .chat__actions {
    justify-content: center;
  }

  .chat__input {
    min-height: 120px;
  }

  .view-toggle__button {
    padding: 8px 14px;
  }
}

