:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --ink: #191817;
  --muted: #68625c;
  --line: #ded8cf;
  --panel: #fffefa;
  --panel-strong: #ffffff;
  --accent: #148a7a;
  --accent-dark: #0c665b;
  --accent-soft: #dff4ef;
  --danger: #b32929;
  --shadow: 0 24px 70px rgba(43, 37, 30, 0.13);
}

* {
  box-sizing: border-box;
}
h3{
  margin: 6px 0;
}

[hidden] {
  display: none !important;
}

body {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 138, 122, 0.13), transparent 36rem),
    linear-gradient(135deg, #f7f1e9 0%, #eef5f1 48%, #f7f7f4 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

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

.shell {
  width: min(1180px, calc(100% - 32px));
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.mode-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px;
  width: fit-content;
  background: rgba(255, 254, 250, 0.82);
  border: 1px solid rgba(222, 216, 207, 0.9);
  border-radius: 8px;
  box-shadow: 0 14px 38px rgba(43, 37, 30, 0.09);
  backdrop-filter: blur(18px);
}

.mode-tab {
  min-height: 40px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
}

.mode-tab:hover {
  color: var(--ink);
  background: rgba(20, 138, 122, 0.08);
}

.mode-tab.is-active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: rgba(20, 138, 122, 0.18);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: rgba(255, 254, 250, 0.8);
  border: 1px solid rgba(222, 216, 207, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
h1,
p {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin-top: 3px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

.status-pill {
  min-width: 94px;
  padding: 8px 12px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid rgba(20, 138, 122, 0.16);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.status-pill.is-error {
  color: var(--danger);
  background: #fde8e6;
  border-color: #f3bbb5;
}

.stage {
  position: relative;
  min-height: 0;
  padding: 24px;
  display: grid;
  overflow: auto;
}

.chat-stage {
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: auto;
}

.empty-state {
  min-height: 0;
  display: grid;
  place-items: center;
  gap: 14px;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.chat-empty {
  flex: 1;
}

.empty-mark {
  position: relative;
  overflow: hidden;
  width: min(280px, 64vw);
  aspect-ratio: 1;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 138, 122, 0.18), transparent 46%),
    linear-gradient(45deg, rgba(227, 87, 64, 0.16), transparent 60%),
    repeating-linear-gradient(135deg, #ffffff 0 12px, #f0ebe3 12px 24px);
  border: 1px solid var(--line);
}

.stage.is-generating .empty-state {
  min-height: 0;
}

.stage.is-generating .empty-mark {
  border-color: rgba(20, 138, 122, 0.28);
  background:
    radial-gradient(circle at 50% 50%, rgba(20, 138, 122, 0.18), transparent 42%),
    conic-gradient(from 0deg, rgba(20, 138, 122, 0.14), rgba(227, 87, 64, 0.2), rgba(20, 138, 122, 0.14)),
    repeating-linear-gradient(135deg, #ffffff 0 12px, #f0ebe3 12px 24px);
  animation: image-pulse 1600ms ease-in-out infinite;
}

.stage.is-generating .empty-mark::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 36%,
    rgba(255, 255, 255, 0.82) 48%,
    transparent 60%
  );
  animation: image-sheen 1800ms ease-in-out infinite;
}

.stage.is-generating .empty-state p::after {
  content: "";
  display: inline-block;
  width: 1.2em;
  text-align: left;
  animation: loading-dots 1200ms steps(4, end) infinite;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, min(100%, 720px)));
  justify-content: center;
  align-content: center;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.image-card {
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: fit-content;
  max-width: 100%;
  max-height: 100%;
  justify-self: center;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.image-preview-button {
  display: grid;
  place-items: center;
  width: auto;
  max-width: 100%;
  height: min(62vh, 560px);
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 0;
  background: #ece7df;
  border: 0;
  cursor: zoom-in;
}

.image-card img {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.image-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.image-card .meta {
  min-width: 0;
}

.edit-source,
.download {
  color: var(--accent-dark);
  background: transparent;
  border: 0;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.edit-source {
  padding: 0;
  font-size: 12px;
}

.edit-source:hover,
.download:hover {
  color: var(--accent);
}

.edit-source-bar {
  min-height: 52px;
  padding: 8px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid rgba(20, 138, 122, 0.18);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}

.edit-source-bar img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  background: #ffffff;
  border: 1px solid rgba(20, 138, 122, 0.18);
  border-radius: 6px;
}

.edit-source-bar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-source-bar button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(20, 138, 122, 0.18);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-preview-backdrop {
  position: absolute;
  inset: 0;
  padding: 0;
  background: rgba(25, 24, 23, 0.72);
  border: 0;
  cursor: zoom-out;
}

.image-preview-frame {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  max-width: min(96vw, 1280px);
  max-height: 92vh;
}

.image-preview-frame img {
  display: block;
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.image-preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #ffffff;
  background: rgba(25, 24, 23, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  font-weight: 900;
  cursor: pointer;
}

.composer {
  padding: 18px;
  display: grid;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  border-top: 1px solid var(--line);
}

.chat-composer {
  padding: 14px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(86px, 112px);
  gap: 8px;
  align-items: end;
  background: rgba(255, 255, 255, 0.76);
  border-top: 1px solid var(--line);
}

.chat-input-stack {
  display: contents;
}

.chat-input-stack .prompt-wrap {
  min-width: 0;
  min-height: 46px;
  padding: 8px 12px;
  align-content: center;
  gap: 0;
}

.chat-input-stack .prompt-wrap > span {
  display: none;
}

.chat-input-stack .prompt-wrap:focus-within {
  border-color: rgba(20, 138, 122, 0.42);
  box-shadow: 0 0 0 3px rgba(20, 138, 122, 0.1);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.prompt-wrap {
  padding: 12px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.attachment-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.attachment-button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1px solid rgba(20, 138, 122, 0.2);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

.attachment-button:hover,
.attachment-button:focus-within {
  background: #d1eee8;
  border-color: rgba(20, 138, 122, 0.38);
}

.attachment-button:active {
  transform: translateY(1px);
}

.attachment-list {
  max-width: min(320px, 30vw);
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.attachment-chip {
  max-width: min(360px, 100%);
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-remove {
  width: 18px;
  height: 18px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
}

.attachment-remove:hover {
  color: var(--danger);
  background: #fde8e6;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 108px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  line-height: 1.45;
}

textarea::placeholder {
  color: #948c83;
}

#prompt {
  min-height: 72px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
}

#chatInput {
  min-height: 30px;
  max-height: 120px;
  padding: 2px 0;
  resize: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(126px, 1fr)) minmax(150px, 0.8fr);
  gap: 8px;
  align-items: end;
}

.controls label {
  gap: 5px;
  font-size: 11px;
}

select,
.generate-button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
}

.controls select,
.controls .generate-button {
  min-height: 40px;
}

select {
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.generate-button {
  border: 0;
  color: #ffffff;
  background: var(--accent);
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

.generate-button:hover {
  background: var(--accent-dark);
}

.generate-button:focus-visible,
.attachment-button:focus-visible,
.attachment-remove:focus-visible,
.mode-tab:focus-visible {
  outline: 3px solid rgba(20, 138, 122, 0.22);
  outline-offset: 2px;
}

.chat-submit {
  min-height: 46px;
}

.generate-button:active {
  transform: translateY(1px);
}

.generate-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.chat-message {
  width: fit-content;
  max-width: min(760px, 92%);
  min-width: 0;
  display: grid;
  gap: 6px;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message.assistant {
  align-self: flex-start;
}

.chat-role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.chat-message.user .chat-role {
  text-align: right;
}

.chat-body {
  min-width: 44px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.chat-body > * {
  margin-top: 0;
  margin-bottom: 0;
}

.chat-body > * + * {
  margin-top: 12px;
}

.chat-body h1,
.chat-body h2,
.chat-body h3,
.chat-body h4 {
  font-size: 1em;
  line-height: 1.35;
}

.chat-body ul,
.chat-body ol {
  padding-left: 1.3em;
}

.chat-body li + li {
  margin-top: 4px;
}

.chat-body .code-block {
  position: relative;
  max-width: 100%;
}

.chat-body pre {
  max-width: 100%;
  padding: 38px 12px 12px;
  overflow: auto;
  color: #f6f3ee;
  background: #191817;
  border-radius: 8px;
  white-space: pre;
}

.code-copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  min-height: 26px;
  padding: 0 9px;
  color: #f6f3ee;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.code-copy-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.chat-body code {
  padding: 2px 5px;
  background: rgba(25, 24, 23, 0.08);
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.chat-body pre code {
  padding: 0;
  color: inherit;
  background: transparent;
  border-radius: 0;
  white-space: inherit;
}

.chat-message.assistant.is-streaming .chat-body::after {
  content: "";
  display: inline-block;
  width: 0.42em;
  height: 1em;
  margin-left: 4px;
  border-radius: 2px;
  background: currentColor;
  vertical-align: -0.16em;
  animation: stream-caret 900ms steps(2, start) infinite;
}

.chat-message.assistant.is-complete .chat-body {
  border-color: rgba(20, 138, 122, 0.2);
}

.chat-message.user .chat-body {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  white-space: pre-wrap;
}

@keyframes stream-caret {
  50% {
    opacity: 0.18;
  }
}

@keyframes image-pulse {
  50% {
    transform: scale(0.985);
    box-shadow: 0 18px 46px rgba(20, 138, 122, 0.18);
  }
}

@keyframes image-sheen {
  from {
    transform: translateX(-42%) translateY(-18%) rotate(12deg);
  }

  to {
    transform: translateX(42%) translateY(18%) rotate(12deg);
  }
}

@keyframes loading-dots {
  0% {
    content: "";
  }

  25% {
    content: ".";
  }

  50% {
    content: "..";
  }

  75%,
  100% {
    content: "...";
  }
}

@media (max-width: 820px) {
  .shell {
    width: 100%;
    padding: 0;
    gap: 0;
  }

  .mode-tabs {
    width: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .mode-tab {
    flex: 1;
  }

  .workspace {
    min-height: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .topbar,
  .stage,
  .chat-stage,
  .composer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .status-pill {
    min-width: 72px;
    padding: 6px 10px;
  }

  .stage,
  .chat-stage {
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .empty-mark {
    width: min(220px, 58vw);
  }

  .composer {
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .prompt-wrap {
    padding: 10px;
  }

  textarea {
    min-height: 82px;
  }

  #prompt {
    min-height: 58px;
  }

  .controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .controls label {
    min-width: 0;
    gap: 4px;
    font-size: 11px;
  }

  select,
  .generate-button {
    min-height: 40px;
  }

  select {
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
  }

  .generate-button {
    grid-column: 1 / -1;
  }

  .chat-composer {
    grid-template-columns: minmax(0, 1fr) 82px 72px;
    gap: 6px;
    padding: 10px 12px;
  }

  .chat-input-stack .prompt-wrap {
    min-height: 42px;
    padding: 6px 10px;
  }

  #chatInput {
    min-height: 28px;
    font-size: 13px;
  }

  .attachment-row {
    position: relative;
    min-height: 42px;
  }

  .attachment-button {
    width: 100%;
    min-height: 42px;
    padding: 0 8px;
    font-size: 12px;
  }

  .attachment-list {
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    max-width: min(250px, calc(100vw - 24px));
    padding-bottom: 2px;
  }

  .chat-submit {
    grid-column: auto;
    min-height: 42px;
  }
}

@media (max-width: 460px) {
  .gallery {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }

  .image-preview-button {
    width: auto;
    max-width: 100%;
    height: min(42vh, 420px);
  }

  .image-card footer {
    padding: 7px 8px;
    gap: 8px;
  }

  .image-preview {
    padding: 12px;
  }

  .mode-tab {
    min-height: 36px;
  }

  .topbar {
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .eyebrow {
    font-size: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .stage,
  .chat-stage {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .empty-mark {
    width: min(180px, 52vw);
  }

  textarea {
    min-height: 74px;
  }

  #prompt {
    min-height: 54px;
  }
}
