:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-muted: #71717a;
  --label: #a1a1aa;
  --accent: #18181b;
  --sidebar-width: 320px;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  padding: 0;
}

.sidebar-col {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 10;
}

.sidebar {
  height: 100%;
  max-height: 100vh;
}

.sidebar-scroll {
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0.75rem;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1.25rem 1rem;
  background: var(--surface);
}

.section-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--label);
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.control-section {
  margin-bottom: 1.35rem;
}

.model-select {
  border-color: var(--border-strong);
  border-radius: 6px;
  font-weight: 500;
}

.compare-toggle {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  margin-top: 0.35rem;
}

.compare-toggle:hover {
  color: var(--text);
}

.char-count {
  font-size: 11px;
  color: var(--label);
}

.prompt-wrap {
  position: relative;
}

.prompt-input {
  border-color: var(--border-strong);
  border-radius: 8px;
  resize: vertical;
  min-height: 140px;
  padding-right: 2.25rem;
  font-size: 13px;
  line-height: 1.45;
}

.prompt-input:focus {
  border-color: #a1a1aa;
  box-shadow: 0 0 0 0.15rem rgba(24, 24, 27, 0.08);
}

.prompt-actions {
  position: absolute;
  right: 6px;
  bottom: 6px;
}

.btn-icon {
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--text);
}

.slot-upload {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}

.slot-add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 88px;
  padding: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  width: 100%;
  margin: 0;
}

.slot-add:hover {
  color: var(--text);
  background: #f0f0f0;
}

.slot-add i {
  font-size: 1.25rem;
}

.slot-filled {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem;
}

.slot-filled img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.slot-filled-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.system-prompt-link {
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.system-prompt-link:hover {
  color: var(--text);
}

.system-prompt-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
  min-height: 280px;
}

.hint-text {
  font-size: 11px;
  color: var(--label);
  margin-top: 0.4rem;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.param-name {
  flex: 0 0 110px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  margin: 0;
}

.param-control {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.slider-control input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #18181b;
}

.num-input {
  width: 72px;
  flex: 0 0 72px;
  text-align: center;
  font-size: 12px;
}

.format-group .btn {
  font-size: 12px;
  text-transform: lowercase;
}

.format-group .btn-check:checked + .btn {
  background: #18181b;
  border-color: #18181b;
  color: #fff;
}

.credits-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  font-size: 13px;
  font-weight: 500;
}

.credits-link {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.credits-link:hover {
  color: var(--text);
  text-decoration: underline;
}

.actions-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}

.image-count-block {
  flex: 0 0 auto;
}

.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
}

.stepper-btn {
  border: none;
  border-radius: 0;
  background: #fafafa;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text);
}

.stepper-btn:hover {
  background: #f0f0f0;
}

.stepper-value {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
}

.action-buttons {
  flex: 1;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.btn-get-code {
  white-space: nowrap;
  font-size: 13px;
}

.btn-generate {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  padding-left: 1rem;
  padding-right: 1rem;
}

.btn-generate:disabled {
  opacity: 0.7;
}

.reset-link {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--label);
  text-decoration: none;
  padding: 0;
}

.reset-link:hover {
  color: var(--text);
}

/* Feed */
.feed-col {
  min-height: 100vh;
  background: var(--bg);
}

.history-feed {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 1rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.empty-state {
  padding: 4rem 1rem;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.empty-subtitle {
  font-size: 13px;
}

.history-card {
  display: flex;
  align-items: stretch;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  padding: 0.55rem 0.75rem;
  min-height: 0;
}

.history-images {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0;
  background: transparent;
  justify-content: flex-start;
}

.history-image-item {
  margin: 0;
  position: relative;
  flex: 0 0 auto;
}

.history-image-btn {
  display: block;
  padding: 0;
  border: none;
  background: transparent;
  cursor: zoom-in;
  border-radius: 6px;
  overflow: hidden;
  line-height: 0;
}

.history-image-btn:focus-visible {
  outline: 2px solid #18181b;
  outline-offset: 2px;
}

.history-image-item img {
  width: 88px;
  height: 88px;
  max-width: none;
  max-height: none;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  box-shadow: none;
  border: 1px solid var(--border);
  transition: opacity 0.12s ease;
}

.history-ref-thumb img {
  width: 56px;
  height: 56px;
  opacity: 0.95;
}

.history-image-btn:hover img {
  opacity: 0.88;
}

.img-model-tag {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.1rem 0;
}

.history-body-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.history-meta {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--label);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-sep {
  margin: 0 0.3rem;
}

.history-prompt {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
}

.history-actions {
  display: flex;
  gap: 0.1rem;
  align-items: center;
  flex-shrink: 0;
}

.history-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0;
  background: transparent;
  border-top: none;
  font-size: 11px;
  margin-top: 0.1rem;
}

.footer-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.pill-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--label);
}

.pill-value {
  color: var(--text);
  font-weight: 500;
}

.image-preview-modal {
  background: #fff;
}

.image-preview-img {
  max-width: 100%;
  max-height: min(75vh, 820px);
  width: auto;
  height: auto;
  border-radius: 8px;
  object-fit: contain;
}

.code-snippet {
  background: #18181b;
  color: #f4f4f5;
  padding: 1rem;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.generating-overlay {
  opacity: 0.65;
  pointer-events: none;
}

/* Full-screen drop zone */
.drop-zone-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 244, 245, 0.92);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.drop-zone-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.drop-zone-overlay.is-uploading .drop-zone-content {
  border-color: #18181b;
  background: #fff;
}

.drop-zone-content {
  text-align: center;
  padding: 3rem 4rem;
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  max-width: 420px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone-overlay.is-active .drop-zone-content {
  border-color: #18181b;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.drop-zone-icon {
  font-size: 3rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  line-height: 1;
}

.drop-zone-overlay.is-active .drop-zone-icon {
  color: var(--text);
}

.drop-zone-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.drop-zone-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.drop-zone-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0.75rem 0 0;
}

@media (max-width: 991.98px) {
  .sidebar-col {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar {
    max-height: none;
  }

  .param-row {
    flex-direction: column;
    align-items: stretch;
  }

  .param-name {
    flex: none;
  }

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-buttons {
    flex-direction: column;
  }

  .history-card {
    flex-direction: column;
    align-items: stretch;
  }

  .history-images {
    flex-wrap: wrap;
  }

  .history-image-item img {
    width: 72px;
    height: 72px;
  }
}
