:root {
  --ink: #0f172a;
  --muted: #5b6475;
  --card: #ffffff;
  --edge: #e6dfd4;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --soft: #f8f4ec;
  --shadow: 0 20px 50px rgba(17, 24, 39, 0.14);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% -10%, #fce7c7, transparent 60%),
    radial-gradient(1000px 500px at 90% 10%, #d9f4ff, transparent 55%), #f6f2ea;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
  z-index: 0;
}

.orb-1 {
  width: 280px;
  height: 280px;
  background: #f8caa7;
  top: -60px;
  left: -40px;
  animation: drift 12s ease-in-out infinite;
}

.orb-2 {
  width: 320px;
  height: 320px;
  background: #a7d7ff;
  bottom: -80px;
  right: -60px;
  animation: drift 14s ease-in-out infinite reverse;
}

.app {
  width: min(960px, 95vw);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
  animation: floatIn 0.6s ease;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 4px;
  width: fit-content;
}

.tab {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.2s ease,
    color 0.2s ease;
}

.tab.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.25);
}

.chat-section,
.image-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 2rem;
  letter-spacing: 0.5px;
}

.subtle {
  margin: 6px 0 0;
  color: var(--muted);
}

.api-key {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
}

.api-key label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.api-key input {
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  font-size: 0.95rem;
  background: #fffaf3;
}

.chat {
  background: #fbf9f4;
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 16px;
  min-height: 55vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 6px;
}

.message {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.5;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  white-space: pre-wrap;
  animation: messageIn 0.2s ease;
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.message.assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #efe6d7;
  color: #1f2937;
  border-bottom-left-radius: 6px;
}

.message.error {
  background: #fff1f1;
  border: 1px solid #f3b3b3;
  color: #7a1b1b;
  box-shadow: none;
}

.typing {
  align-self: flex-start;
  font-size: 0.9rem;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed #d7d0c4;
  padding: 6px 12px;
  border-radius: 999px;
}

.hidden {
  display: none;
}

.composer {
  background: #ffffff;
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.image-panel {
  background: #fbf9f4;
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 55vh;
}

.image-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.context-status {
  font-size: 0.9rem;
  color: var(--muted);
}

.image-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.image-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.image-actions {
  display: flex;
  justify-content: flex-end;
}

.image-error {
  background: #fff1f1;
  border: 1px solid #f3b3b3;
  color: #7a1b1b;
  padding: 10px 12px;
  border-radius: 12px;
}

.image-error.note {
  background: #fff7e6;
  border-color: #f2d49b;
  color: #7a4d0a;
}

.image-result {
  min-height: 240px;
  border: 1px dashed #d7d0c4;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.image-result img {
  width: 100%;
  max-width: 420px;
  border-radius: 16px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

textarea {
  width: 100%;
  border: 1px solid #d7d0c4;
  border-radius: 14px;
  padding: 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #fefbf6;
  resize: none;
  min-height: 64px;
  max-height: 160px;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.2s ease;
}

button.primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.25);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(15, 118, 110, 0.3);
}

button.ghost {
  background: transparent;
  border: 1px solid #d7d0c4;
  color: #3a4354;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

@media (max-width: 720px) {
  body {
    padding: 20px 12px;
  }

  .app {
    padding: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .api-key {
    width: 100%;
  }

  .actions {
    width: 100%;
  }

  .actions button {
    flex: 1;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    text-align: center;
  }

  .image-actions {
    width: 100%;
  }

  .image-actions button {
    flex: 1;
  }

  .image-context {
    width: 100%;
  }

  .image-context button {
    width: 100%;
  }

  .chat {
    min-height: 50vh;
  }

  .image-panel {
    min-height: 50vh;
  }
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  0% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(12px, -10px);
  }
  100% {
    transform: translate(0, 0);
  }
}
