﻿:root {
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Sora", "Segoe UI", sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-body);
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 4%, rgba(34, 211, 238, 0.18) 0%, transparent 38%),
    radial-gradient(circle at 90% 8%, rgba(168, 85, 247, 0.2) 0%, transparent 40%),
    radial-gradient(circle at 88% 86%, rgba(34, 197, 94, 0.14) 0%, transparent 34%),
    linear-gradient(150deg, #020617 0%, #0b1120 46%, #111827 100%);
  color: #e2e8f0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
}

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
}

.ambient {
  position: absolute;
  z-index: -1;
  filter: blur(18px);
  opacity: 0.72;
  pointer-events: none;
}

.ambient-left {
  width: min(42vw, 480px);
  height: min(42vw, 480px);
  left: -140px;
  top: -130px;
  background: radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.5) 0%, rgba(34, 211, 238, 0) 72%);
  animation: drift 14s ease-in-out infinite;
}

.ambient-right {
  width: min(46vw, 560px);
  height: min(46vw, 560px);
  right: -180px;
  bottom: -150px;
  background: radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.45) 0%, rgba(168, 85, 247, 0) 74%);
  animation: drift 16s ease-in-out infinite reverse;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(18px, -16px, 0) scale(1.06);
  }
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  box-shadow: 0 24px 48px -36px rgba(0, 0, 0, 0.8);
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #67e8f9;
}

.workspace-header h1 {
  margin: 6px 0 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 8px 22px rgba(56, 189, 248, 0.24);
}

.header-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 60%;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(120deg, rgba(14, 116, 144, 0.34), rgba(88, 28, 135, 0.32));
  border: 1px solid rgba(125, 211, 252, 0.34);
  color: #e0f2fe;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(420px, 1fr);
  gap: 16px;
  min-height: calc(100vh - 132px);
}

.chat-column,
.result-column {
  display: grid;
  background: rgba(15, 23, 42, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 22px;
  box-shadow: 0 30px 54px -40px rgba(2, 6, 23, 0.95);
  backdrop-filter: blur(16px);
  min-height: 0;
  overflow: hidden;
}

.chat-column {
  grid-template-rows: 1fr auto;
}

.result-column {
  grid-template-rows: auto 1fr;
}

.chat-log {
  overflow-y: auto;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-content: start;
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.32), rgba(15, 23, 42, 0.58));
}

.message {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  animation: reveal 220ms ease-out;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  margin-left: 14%;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(56, 189, 248, 0.12));
  border-color: rgba(125, 211, 252, 0.32);
}

.message.assistant {
  margin-right: 12%;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(74, 222, 128, 0.1));
  border-color: rgba(134, 239, 172, 0.28);
}

.message.status {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.16), rgba(51, 65, 85, 0.2));
  border-color: rgba(148, 163, 184, 0.24);
}

.message-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.message-role {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(15, 23, 42, 0.62);
  color: #cbd5e1;
}

.message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #e2e8f0;
}

.loading-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  width: fit-content;
  border-radius: 999px;
  background: rgba(6, 78, 59, 0.36);
  border: 1px solid rgba(134, 239, 172, 0.3);
  font-size: 13px;
  color: #bbf7d0;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #22d3ee;
  animation: pulse 1.2s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: 0.16s;
}

.dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.4), rgba(2, 6, 23, 0.62));
}

.composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 100px;
  max-height: 210px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  background: rgba(15, 23, 42, 0.72);
  font: inherit;
  color: #f8fafc;
}

.composer textarea::placeholder {
  color: #94a3b8;
}

.composer textarea:focus {
  outline: 2px solid rgba(34, 211, 238, 0.8);
  outline-offset: 1px;
  border-color: rgba(34, 211, 238, 0.9);
}

.preset-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.preset-chip {
  flex: 0 0 auto;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #dbeafe;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  cursor: pointer;
  transition: 160ms ease;
}

.preset-chip:hover:not(:disabled) {
  background: rgba(30, 58, 138, 0.5);
  border-color: rgba(147, 197, 253, 0.42);
}

.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.error-text {
  margin: 0;
  font-size: 13px;
  color: #fca5a5;
  opacity: 0;
  transition: opacity 150ms ease;
}

.error-text.show {
  opacity: 1;
}

#generate-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  color: #f8fafc;
  background: linear-gradient(120deg, #0891b2, #7c3aed);
  box-shadow: 0 14px 26px -16px rgba(124, 58, 237, 0.9);
  cursor: pointer;
  transition: 180ms ease;
}

#generate-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 20px 34px -18px rgba(124, 58, 237, 0.95);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.result-header h2 {
  margin: 6px 0 0;
  font-size: 24px;
  line-height: 1.1;
  color: #f8fafc;
}

.result-meta {
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: #e0f2fe;
  background: rgba(12, 74, 110, 0.5);
  border: 1px solid rgba(125, 211, 252, 0.3);
  white-space: nowrap;
}

.result-panel {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}

.result-output {
  margin: 0;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 6, 23, 0.66);
  color: #e2e8f0;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  min-height: 300px;
}

.result-output.empty {
  color: #94a3b8;
  font-family: var(--font-body);
}

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

.usage-grid div {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.54);
}

.usage-grid p {
  margin: 0 0 6px;
  font-size: 12px;
  color: #93c5fd;
}

.usage-grid strong {
  font-size: 16px;
  color: #f8fafc;
}

.result-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.result-button {
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font: inherit;
  font-weight: 700;
  color: #f8fafc;
  background: linear-gradient(120deg, #0ea5e9, #6366f1);
  cursor: pointer;
}

.result-button.ghost {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
}

.chat-log,
.preset-row,
.result-output {
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.55) rgba(15, 23, 42, 0.2);
}

.chat-log::-webkit-scrollbar,
.preset-row::-webkit-scrollbar,
.result-output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.chat-log::-webkit-scrollbar-track,
.preset-row::-webkit-scrollbar-track,
.result-output::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.35);
  border-radius: 999px;
}

.chat-log::-webkit-scrollbar-thumb,
.preset-row::-webkit-scrollbar-thumb,
.result-output::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.78), rgba(96, 165, 250, 0.65));
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.45);
}

.chat-log::-webkit-scrollbar-thumb:hover,
.preset-row::-webkit-scrollbar-thumb:hover,
.result-output::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.92), rgba(167, 139, 250, 0.8));
}

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(560px, 58vh) minmax(540px, 1fr);
  }

  .workspace-header {
    flex-direction: column;
  }

  .header-badges {
    max-width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .workspace-grid {
    grid-template-rows: minmax(560px, 60vh) minmax(520px, 1fr);
  }

  .message.user,
  .message.assistant {
    margin-left: 0;
    margin-right: 0;
  }

  .result-header h2 {
    font-size: 20px;
  }

  .usage-grid {
    grid-template-columns: 1fr;
  }
}
