:root {
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at top right, #1a2035, #0b0f19);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --danger-color: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: 'Inter', sans-serif; 
  background: var(--bg-gradient); 
  background-color: var(--bg-color);
  color: var(--text-primary); 
  height: 100vh;
  overflow: hidden;
}

.screen { display: none; height: 100vh; width: 100vw; flex-direction: column; }
.screen.active { display: flex; }

/* Utils */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}
.btn-primary {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-outline:hover { background: var(--glass-bg); }
.btn-danger {
  background: var(--danger-color);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-icon { background: transparent; border: none; color: var(--text-primary); font-size: 1.2rem; cursor: pointer; }

/* Login Screen */
#screen-login { justify-content: center; align-items: center; }
.login-container {
  padding: 40px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.login-container .logo { font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.login-container .subtitle { color: var(--text-secondary); margin-bottom: 32px; }

/* Header */
.app-header {
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  background: rgba(11, 15, 25, 0.8);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 100;
}
.app-header .logo { font-weight: 700; font-size: 1.2rem; }
.user-info { display: flex; align-items: center; gap: 16px; }

/* Projects */
.projects-main { padding: 40px; max-width: 1200px; margin: 0 auto; width: 100%; overflow-y: auto; }
.projects-header { display: flex; justify-content: space-between; margin-bottom: 32px; }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.project-card {
  height: 200px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.project-card:hover { transform: translateY(-4px); box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5); border-color: var(--accent-color); }
.project-card { position: relative; }
.project-card h3 { font-size: 1.2rem; margin-bottom: 8px; padding-right: 32px; }
.project-card .btn-delete-project {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s, color 0.2s;
}
.project-card:hover .btn-delete-project,
.project-card .btn-delete-project:focus-visible { opacity: 1; }
.project-card .btn-delete-project:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger-color);
  color: var(--danger-color);
}
.project-card .meta { color: var(--text-secondary); font-size: 0.85rem; }

/* Editor */
.editor-workspace { display: flex; flex: 1; height: calc(100vh - 64px); }
.sidebar-screens { width: 220px; border-right: 1px solid rgba(255,255,255,0.05); padding: 24px 16px; background: #0b0f19; display: flex; flex-direction: column; }
.screens-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.screen-item { padding: 10px 16px; border-radius: 8px; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; font-size: 0.95rem; }
.screen-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.screen-item.active { background: rgba(99,102,241,0.15); color: var(--text-primary); font-weight: 500; border: 1px solid rgba(99,102,241,0.3); }
.screen-item.locked { opacity: 0.4; cursor: not-allowed; }

.sidebar-left { width: 340px; border-right: 1px solid rgba(255,255,255,0.05); display: flex; flex-direction: column; background: #0f1115; }
.editor-canvas { flex: 1; background: #1a1c23; position: relative; display: flex; justify-content: center; align-items: center; overflow: hidden; }

/* Left Sidebar - Chat & Tools */
.chat-history { flex: 1; padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }
.msg.user { color: #d1d5db; font-size: 0.95rem; line-height: 1.5; padding-right: 10px; }
.assets-pill { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,0.08); padding: 4px 10px; border-radius: 6px; font-size: 0.8rem; color: #9ca3af; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.pill:hover { background: rgba(255,255,255,0.12); }

.reasoning-block { border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; overflow: hidden; }
.reasoning-header { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; background: rgba(255,255,255,0.02); color: #9ca3af; font-size: 0.85rem; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05); }
.reasoning-list { list-style: none; padding: 12px 14px; font-size: 0.8rem; color: #6b7280; display: flex; flex-direction: column; gap: 8px; background: rgba(0,0,0,0.2); }
.tool-run { padding: 12px 14px; background: rgba(0,0,0,0.2); }
.tool-name { display: inline-block; color: #c084fc; font-family: monospace; font-size: 0.8rem; margin-bottom: 6px; background: rgba(192, 132, 252, 0.1); padding: 2px 6px; border-radius: 4px; }
.tool-run p { font-size: 0.8rem; color: #6b7280; line-height: 1.4; }

/* Glowing Chat Input */
.chat-input-container { padding: 0 24px 24px 24px; }
.chat-input-container.drag-over .glowing-border { box-shadow: 0 0 24px rgba(99,102,241,0.75); }

/* Attachment chips above the chat textarea (file picker, paste, drag & drop) */
.attachment-strip { display: none; flex-wrap: wrap; gap: 8px; }
.attachment-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 180px;
  padding: 4px 22px 4px 4px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.attachment-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 5px; display: block; }
.attachment-chip span:not(.attachment-file-icon) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip .attachment-file-icon { font-size: 1rem; padding: 0 2px; }
.attachment-chip.uploading { opacity: 0.6; }
.attachment-chip.error { border-color: #ef4444; color: #fca5a5; }
.attachment-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  padding: 2px 4px;
}
.attachment-remove:hover { color: #fff; }

/* Attachments shown inside a sent chat message */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg-attachments img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--glass-border);
}
.msg-attachments a { font-size: 0.75rem; color: var(--text-secondary); text-decoration: underline; }

.glowing-border {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6, #ef4444);
  padding: 2px;
  border-radius: 16px;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}
.chat-input-inner {
  background: #0f1115;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-input {
  background: transparent;
  border: none;
  color: white;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 0.9rem;
  height: 40px;
}
.chat-input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-send {
  background: linear-gradient(135deg, #a855f7, #3b82f6);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  transition: opacity 0.2s;
}
.btn-send:hover { opacity: 0.9; }

/* Canvas specifics (Mobile Frame) */
.zoom-controls { position: absolute; bottom: 24px; right: 24px; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); padding: 6px; border-radius: 24px; display: flex; align-items: center; gap: 12px; border: 1px solid rgba(255,255,255,0.1); color: #9ca3af; font-size: 0.85rem; }
.mobile-frame {
  width: 375px; 
  aspect-ratio: 393 / 852; 
  background: #f8fafc; 
  border-radius: 46px; 
  border: 14px solid #000;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8), inset 0 0 0 2px rgba(255,255,255,0.1);
  overflow: hidden;
  position: relative;
  display: flex; flex-direction: column;
  color: #0f172a;
}
.dynamic-island {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 35px;
  background: #000;
  border-radius: 20px;
  z-index: 10;
}
.dummy-app-header { padding: 40px 24px 20px 24px; background: #fff; }
.dummy-app-header h3 { font-size: 1.4rem; margin-bottom: 4px; font-weight: 600; }
.dummy-app-header p { color: #64748b; font-size: 0.9rem; }
.dummy-search { margin: 0 24px 24px; background: #f1f5f9; padding: 12px 16px; border-radius: 12px; color: #94a3b8; display: flex; align-items: center; gap: 8px; font-size: 0.95rem; }
.dummy-categories { display: flex; padding: 0 24px; gap: 16px; margin-bottom: 32px; overflow-x: hidden; }
.cat-item { width: 64px; height: 64px; border-radius: 16px; background: #e2e8f0; flex-shrink: 0; }
.cat-item:first-child { background: linear-gradient(135deg, #3b82f6, #2dd4bf); }
.dummy-content-card { margin: 0 24px; flex: 1; }
.dummy-content-card h4 { font-size: 1.1rem; margin-bottom: 16px; font-weight: 600; }
.card-img { width: 100%; height: 200px; border-radius: 20px; background: linear-gradient(135deg, #cbd5e1, #94a3b8); }



/* Chat messages (dynamic) */
.msg.assistant { color: #a5b4fc; font-size: 0.95rem; line-height: 1.5; padding-right: 10px; }
.msg.thinking { color: #6b7280; font-style: italic; }

/* Project dialogs */
dialog#new-project-dialog,
dialog#delete-project-dialog {
  background: #0f1115;
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  width: 360px;
}
dialog#new-project-dialog::backdrop,
dialog#delete-project-dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog#new-project-dialog h3,
dialog#delete-project-dialog h3 { margin-bottom: 16px; }
dialog#new-project-dialog label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin: 12px 0 6px; }
dialog#new-project-dialog select,
dialog#new-project-dialog input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: inherit;
}
dialog#new-project-dialog .dialog-actions,
dialog#delete-project-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
dialog#delete-project-dialog .dialog-text { font-size: 0.9rem; line-height: 1.5; color: var(--text-secondary); }
dialog#delete-project-dialog .dialog-text strong { color: var(--text-primary); }



/* Sibling variant switcher */
.variant-switcher { position: absolute; top: 24px; left: 24px; display: flex; gap: 8px; z-index: 10; }
.variant-btn.active { border-color: var(--accent-color); background: rgba(99,102,241,0.15); }

/* Taste learning: 👍/👎 rating controls (variant grid + single-screen bar) */
.rating-bar { position: absolute; top: 24px; right: 24px; z-index: 10; }
.rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11,15,25,0.85);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 6px 10px;
}
.rate-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  filter: grayscale(1) opacity(0.55);
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}
.rate-btn:hover { filter: none; background: rgba(255,255,255,0.06); }
.rate-btn.active-like { filter: none; border-color: #10b981; background: rgba(16,185,129,0.15); }
.rate-btn.active-dislike { filter: none; border-color: #ef4444; background: rgba(239,68,68,0.15); }
.rate-note {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  padding: 6px 12px;
  width: 190px;
}
.rate-note:focus { outline: none; border-color: var(--accent-color); }

/* Taste-profile refresh button, pinned under the screens list */
.taste-btn { margin-top: auto; font-size: 0.8rem; white-space: nowrap; }

/* Kickoff panel: the Home-screen starting point, where the user writes a brief
   and hand-picks design-pool references before the first generation. */
.kickoff {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.kickoff-inner { width: 100%; max-width: 900px; }
.kickoff h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 6px; }
.kickoff .kickoff-lead { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 28px; }
.kickoff-section { margin-bottom: 28px; }
.kickoff-section > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.kickoff-section .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.kickoff textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.9rem;
}
.kickoff textarea:focus { outline: none; border-color: var(--accent-color); }

.pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.pool-item {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: rgba(255,255,255,0.04);
  transition: border-color 0.15s, transform 0.15s;
}
.pool-item:hover { transform: translateY(-3px); border-color: rgba(99,102,241,0.5); }
.pool-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pool-item.selected { border-color: var(--accent-color); }
.pool-item .pool-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}
.pool-item.selected .pool-check { display: flex; }
.pool-item .pool-tags {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 8px 6px;
  font-size: 0.65rem;
  line-height: 1.3;
  color: #e2e8f0;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Per-reference note: "what I like about this one". Shown only once the
   reference above it is selected. */
.pool-cell { display: flex; flex-direction: column; gap: 6px; }
.pool-note {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 6px 8px;
  width: 100%;
}
.pool-note:focus { outline: none; border-color: var(--accent-color); }

/* Zoom control on each pool tile. The tile's own click toggles selection, so
   the magnifier has to be a separate target rather than sharing it. */
.pool-item .pool-zoom {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: zoom-in;
  /* Visible at rest, not hover-only: the control has to be discoverable, and
     a hover-gated one simply does not exist on a touch screen. */
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s;
}
.pool-item:hover .pool-zoom,
.pool-item .pool-zoom:focus { opacity: 1; }
.pool-item .pool-zoom:hover { background: rgba(0,0,0,0.85); }

/* Full-size reference viewer, opened from a tile's zoom control. */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6,8,14,0.93);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
}
.lightbox-stage {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  max-height: 100%;
  min-width: 0;
}
.lightbox-img {
  max-height: calc(100vh - 64px);
  max-width: min(58vw, 880px);
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: #0b0f19;
}
.lightbox-side {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--text-primary);
}
.lightbox-counter { font-size: 0.75rem; color: var(--text-secondary); }
.lightbox-tags { font-size: 0.8rem; color: #a5b4fc; line-height: 1.4; }
.lightbox-desc {
  font-size: 0.8rem;
  line-height: 1.55;
  max-height: 38vh;
  overflow-y: auto;
}
.lightbox-select { width: 100%; }
.lightbox-select.active { border-color: var(--accent-color); background: rgba(99,102,241,0.18); }
.lightbox-note {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 8px 10px;
  width: 100%;
}
.lightbox-note:focus { outline: none; border-color: var(--accent-color); }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { color: #fff; }
.lightbox-nav {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255,255,255,0.15); }

/* Narrow viewports: the side panel drops under the image instead of
   squeezing it to a sliver. */
@media (max-width: 900px) {
  .lightbox { padding: 20px; }
  .lightbox-stage { flex-direction: column; align-items: center; overflow-y: auto; }
  .lightbox-img { max-width: 100%; max-height: 55vh; }
  .lightbox-side { width: 100%; max-width: 520px; }
}

/* Baseline block: the approved Home screen shown on every other category's
   kickoff panel, so the design foundation is visible before generating. */
.baseline-box {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 14px;
}
.baseline-thumb {
  width: 84px;
  aspect-ratio: 393 / 852;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}
.baseline-text { min-width: 0; }
.baseline-text strong { display: block; font-size: 0.85rem; margin-bottom: 6px; }
.baseline-text .meta {
  font-size: 0.75rem;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.kickoff-footer { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.kickoff-footer .supervise-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.kickoff-footer .supervise-toggle input { accent-color: var(--accent-color); cursor: pointer; }

/* Supervisor verdict under a variant in the selection grid. */
.review-badge {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  max-width: 320px;
  text-align: center;
  cursor: help;
}
.review-badge.good { border-color: rgba(16,185,129,0.45); color: #6ee7b7; }
.review-badge.ok { border-color: rgba(99,102,241,0.45); color: #a5b4fc; }
.review-badge.weak { border-color: rgba(245,158,11,0.5); color: #fcd34d; }
.kickoff-footer .variant-count { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-secondary); }
.kickoff-footer select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.85rem;
}
.kickoff-footer .kickoff-status { color: var(--text-secondary); font-size: 0.85rem; }
