:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191b20;
  --panel-strong: #21242b;
  --text: #f4f5f7;
  --muted: #a7adb8;
  --line: #343844;
  --accent: #18b6a7;
  --accent-strong: #36d6c4;
  --danger: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(24, 182, 167, 0.14), transparent 38%),
    radial-gradient(circle at 85% 8%, rgba(255, 199, 95, 0.11), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.workspace,
.field-grid,
.actions,
.answer-head,
.status {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.8rem);
}

h2 {
  font-size: 1.25rem;
}

.status {
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 27, 32, 0.78);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ffd166;
  box-shadow: 0 0 0 4px rgba(255, 209, 102, 0.12);
}

.status.ready .status-dot {
  background: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(54, 214, 196, 0.14);
}

.status.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.14);
}

.workspace {
  align-items: stretch;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(25, 27, 32, 0.9);
  box-shadow: var(--shadow);
}

.composer {
  width: min(520px, 100%);
  padding: 18px;
}

.answer-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.field-grid {
  gap: 12px;
}

.field-grid label:first-child {
  flex: 1;
}

.field-grid label:last-child {
  width: 150px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.system-label,
.question-label {
  margin-top: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 12px;
  line-height: 1.55;
}

input:focus,
textarea:focus,
.dropzone:focus,
.dropzone.dragover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 182, 167, 0.16);
}

.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  min-height: 96px;
  padding: 14px;
  border: 1px dashed #59606f;
  border-radius: 8px;
  background: rgba(33, 36, 43, 0.66);
  cursor: pointer;
  outline: none;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(24, 182, 167, 0.18);
  color: var(--accent-strong);
  font-size: 1.7rem;
  font-weight: 700;
}

.dropzone strong {
  display: block;
  color: var(--text);
  font-size: 1rem;
}

.dropzone p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.thumb {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: white;
  cursor: pointer;
}

.actions {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.primary {
  background: var(--accent);
  color: #04110f;
  font-weight: 800;
}

.secondary,
.icon-button {
  border-color: var(--line);
  background: var(--panel-strong);
}

.answer-head {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.answer {
  flex: 1;
  min-height: 520px;
  padding: 20px;
  color: #e7ebef;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: auto;
}

.answer.loading::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 3px;
  background: var(--accent-strong);
  vertical-align: -0.12em;
  animation: blink 0.9s steps(2, start) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    flex-direction: column;
  }

  .composer {
    width: 100%;
  }

  .answer {
    min-height: 360px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1240px);
    padding: 16px 0;
  }

  .field-grid {
    flex-direction: column;
  }

  .field-grid label:last-child {
    width: 100%;
  }

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