/* picassOx — dark atelier theme */
:root {
  --bg: #0b0b0f;
  --bg-2: #12121a;
  --panel: #17171f;
  --line: #26262f;
  --ink: #e8e6e3;
  --muted: #8a8a96;
  --accent: #e8e6e3;
  --danger: #ff6b6b;
  --gold: #d4af37;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 600px at 70% -10%, #1a1a26 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: "Space Grotesk", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.logo {
  font-family: "Press Start 2P", monospace;
  font-size: 18px; letter-spacing: 1px; color: var(--ink);
}
.logo-o { color: var(--gold); }
.tagline { color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 8px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  max-width: 1180px; margin: 0 auto; padding: 24px 22px 60px;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ---------- canvas ---------- */
.canvas-col { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.canvas-frame {
  position: relative;
  border: 1px solid var(--line);
  outline: 4px solid #000;
  box-shadow: 0 0 0 1px #333, 0 20px 60px rgba(0,0,0,.6);
  line-height: 0;
  max-width: 100%;
}
#board {
  width: 100%; height: auto; display: block;
  image-rendering: pixelated;
  cursor: crosshair;
  touch-action: none;
}
.thinking-veil {
  position: absolute; inset: 0;
  background: rgba(5,5,10,.72);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.veil-inner { text-align: center; color: var(--ink); }
.veil-inner div { margin-top: 12px; font-size: 14px; letter-spacing: .5px; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto;
  border: 3px solid #333; border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ---------- status ---------- */
.statusbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.phase-chip {
  font-family: "Press Start 2P", monospace;
  font-size: 9px; padding: 8px 10px; border-radius: 4px;
}
.phase-user { background: #20202c; color: var(--ink); border: 1px solid #3a3a48; }
.phase-ai   { background: #2a2313; color: var(--gold); border: 1px solid #57491c; animation: pulse 1.2s ease-in-out infinite; }
.phase-done { background: #12251a; color: #7ddba3; border: 1px solid #245c3c; }
@keyframes pulse { 50% { opacity: .55; } }
.flip-budget, .pass-info { color: var(--muted); font-size: 14px; }

.artwork-meta { text-align: center; max-width: 640px; }
.meta-title { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.meta-inspired { color: var(--muted); font-size: 13px; font-style: italic; margin-top: 4px; }

/* ---------- panel ---------- */
.panel { display: flex; flex-direction: column; gap: 16px; }
.panel-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.panel-section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--muted); margin-bottom: 8px;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 12px; }

.palette { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.swatch {
  width: 34px; height: 34px; border-radius: 6px; cursor: pointer;
  border: 2px solid transparent; outline: 1px solid rgba(255,255,255,.15);
}
.swatch.active { border-color: var(--gold); outline-color: var(--gold); transform: scale(1.08); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  background: #22222e; color: var(--ink);
  border: 1px solid #34343f; border-radius: 7px;
  padding: 9px 14px; font-size: 14px; cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .05s;
}
.btn:hover:not(:disabled) { background: #2c2c3a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: #efece6; color: #111; border-color: #efece6; font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: #fff; }
.btn-big { width: 100%; margin-bottom: 8px; padding: 12px; font-size: 15px; }
.btn-danger { border-color: #5c2b2b; color: #ff9b9b; }
.btn-danger:hover:not(:disabled) { background: #33201f; }
.btn-ghost { background: transparent; }

.log {
  font-size: 12.5px; line-height: 1.55; max-height: 180px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.log-line { border-left: 2px solid var(--line); padding-left: 8px; }
.log-line.muted { color: var(--muted); }
.log-line.ai { border-left-color: var(--gold); }
.log-line.err { border-left-color: var(--danger); color: #ffb3b3; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4,4,8,.75);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.drawer, .modal {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal { max-width: 860px; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.drawer-head h2 { font-size: 18px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field select {
  width: 100%;
  background: #101017; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 9px 11px; font-size: 14px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: #4a4a5c; }
.field input[type="range"] { width: 100%; accent-color: var(--gold); }
.field-inline { display: flex; gap: 10px; align-items: flex-start; }
.field-inline input { margin-top: 3px; accent-color: var(--gold); }
.field-inline span { margin: 0; }
.field-inline em { color: var(--muted); font-style: normal; font-size: 12px; }
.drawer-actions { margin-top: 18px; display: flex; justify-content: flex-end; }
.muted { color: var(--muted); }

/* ---------- gallery ---------- */
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px; margin-top: 10px;
}
.gallery-item { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #000; }
.gallery-item img { width: 100%; display: block; image-rendering: pixelated; }
.gallery-item .gi-body { padding: 8px 10px 10px; }
.gallery-item .gi-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-item .gi-date { font-size: 11px; color: var(--muted); margin: 2px 0 8px; }
.gallery-item .btn { padding: 5px 9px; font-size: 12px; }

/* ---------- trace bar (optional, bottom) ---------- */
.tracebar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 190px;
  background: rgba(13, 13, 19, .96);
  border-top: 1px solid var(--gold);
  box-shadow: 0 -12px 40px rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  z-index: 40; /* below overlays so settings/gallery stay usable */
}
.tracebar.expanded { height: 52vh; }
.trace-head {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
}
.trace-title {
  font-family: "Press Start 2P", monospace;
  font-size: 9px; color: var(--gold); letter-spacing: 1px;
}
.trace-summary { color: var(--muted); font-size: 12px; }
.trace-toggle {
  display: flex; align-items: center; gap: 5px;
  color: var(--muted); font-size: 12px; cursor: pointer; user-select: none;
}
.trace-toggle input { accent-color: var(--gold); margin: 0; }
.tracebar.no-think .trace-think { display: none; }
.trace-think .trace-msg { color: #b9a8e8; }
.trace-think .trace-chip { background: #221a30; color: #b9a8e8; }
.trace-spacer { flex: 1; }
.btn-mini { padding: 3px 9px; font-size: 12px; }
#btnTrace.attn { color: var(--gold); animation: pulse 1.2s ease-in-out infinite; }

.trace-log {
  flex: 1; overflow-y: auto;
  padding: 8px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.6;
}
.trace-line { border-left: 2px solid var(--line); padding-left: 10px; margin-bottom: 5px; }
.trace-time { color: #5b5b68; margin-right: 8px; }
.trace-chip {
  display: inline-block; min-width: 44px; text-align: center;
  font-size: 10px; letter-spacing: .5px; text-transform: uppercase;
  border-radius: 3px; padding: 1px 5px; margin-right: 8px;
  background: #20202c; color: var(--muted);
}
.trace-req { background: #14202e; color: #7fb3e8; }
.trace-res { background: #12251a; color: #7ddba3; }
.trace-val { background: #2a2313; color: var(--gold); }
.trace-err { background: #2e1414; color: #ff9b9b; }
.trace-msg { word-break: break-word; }
.trace-line details { display: inline-block; margin-left: 8px; }
.trace-line summary {
  cursor: pointer; color: var(--muted); font-size: 11px;
  user-select: none; display: inline-block;
}
.trace-line summary:hover { color: var(--ink); }
.trace-line pre {
  white-space: pre-wrap; word-break: break-word;
  background: #101017; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; margin-top: 6px;
  max-height: 220px; overflow-y: auto;
  font-size: 11.5px;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1d1d28; border: 1px solid #3a3a4a;
  color: var(--ink); padding: 11px 18px; border-radius: 9px;
  font-size: 14px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
