:root {
  color-scheme: light dark;
  --bg: #f6f5f3;
  --panel-bg: #ffffff;
  --border: #ddd8d1;
  --text: #26241f;
  --muted: #706b62;
  --accent: #8a5a44;
  --accent-hover: #714739;
  --disclosure-bg: #f2e6e0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0 0 2rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 10px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  background: #fbfaf8;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: #f4ede9;
}

.dropzone-prompt {
  text-align: center;
  color: var(--muted);
  padding: 1rem;
}

.dropzone-prompt p {
  margin: 0.25rem 0;
}

.dropzone-prompt .or {
  font-size: 0.85rem;
}

#preview-image {
  display: none;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
}

#preview-image.visible {
  display: block;
}

.dropzone.has-image .dropzone-prompt {
  display: none;
}

#file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

button#analyze-btn {
  margin-top: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.15s ease;
}

button#analyze-btn:disabled {
  background: #c9c2ba;
  cursor: not-allowed;
}

button#analyze-btn:not(:disabled):hover {
  background: var(--accent-hover);
}

.status-message {
  min-height: 1.2rem;
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

.status-message.error {
  color: #b3261e;
}

.status-message.loading {
  color: var(--muted);
}

.results-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.recommendations-panel {
  margin-top: 1.5rem;
}

.recommendations-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

.recommendations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.recommendation-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
}

.recommendation-swatch {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.recommendation-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.recommendation-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.recommendation-reason {
  font-size: 0.78rem;
  color: var(--muted);
}

.recommendation-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.art-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.find-art-btn {
  align-self: flex-start;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.find-art-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.find-art-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.art-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.art-card {
  display: flex;
  flex-direction: column;
  width: 120px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}

.art-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  background: #eee7e1;
}

.art-info {
  padding: 0.4rem;
}

.art-title {
  font-size: 0.75rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.art-meta {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.perspective-note {
  margin: -0.5rem 0 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.perspective-note.corrected::before {
  content: "\2713 ";
}

/* FTC 16 CFR Part 255 disclosure, shown immediately above any set of affiliate-linked
   art results (find-art panel and each chat response) - see app.js's buildDisclosureBanner.
   Colored (not black/gray), contrasts with both the panel background and body text,
   sized at least as large as the page's base text, and requires no scrolling or
   clicking to see since it's always the first thing rendered above the results it
   applies to. */
.affiliate-disclosure {
  background: var(--disclosure-bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.perspective-note.uncorrected::before {
  content: "\26A0 ";
}

.results {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.swatch-color {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.swatch-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.swatch-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.swatch-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.swatch-bar-track {
  margin-top: 0.25rem;
  height: 6px;
  border-radius: 3px;
  background: #eee7e1;
  overflow: hidden;
}

.swatch-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.chat-panel {
  margin-top: 1.5rem;
}

.chat-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: -0.25rem;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 420px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.chat-message {
  max-width: 80%;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.chat-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
}

.chat-message.note {
  align-self: flex-start;
  font-style: italic;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--border);
}

.chat-message.assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
}

.chat-artwork-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
  align-self: flex-start;
  max-width: 100%;
}

.chat-art-card {
  position: relative;
}

.chat-art-feedback {
  display: flex;
  gap: 0.3rem;
  padding: 0.2rem 0.4rem;
}

.feedback-btn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

.feedback-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.feedback-btn.selected {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.feedback-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

#chat-form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

#chat-input {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text);
  font-size: 0.9rem;
}

#chat-send-btn {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 0.9rem;
}

#chat-send-btn:disabled,
#chat-input:disabled {
  background: #c9c2ba;
  cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --panel-bg: #262421;
    --border: #3a3733;
    --text: #ece8e2;
    --muted: #a39c92;
    --accent: #c98a6b;
    --accent-hover: #d99b7d;
    --disclosure-bg: #3a2e27;
  }

  .dropzone {
    background: #221f1c;
  }

  .dropzone.drag-over {
    background: #2c2621;
  }

  .swatch-bar-track {
    background: #38342f;
  }
}
