/* Koodesign — AI Design Studio */

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

:root {
  --bg: #1e1e1f;
  --panel: #2c2c2e;
  --panel-2: #242426;
  --border: #3a3a3c;
  --text: #ebebf5;
  --muted: #98989f;
  --accent: #0a84ff;
  --gold: #ffd60a;
  --danger: #ff453a;
  --radius: 10px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { background: #3a3a3c; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2b95ff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:focus-visible, .icon-btn:focus-visible, .rate:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon-btn {
  background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer;
  width: 28px; height: 28px; color: var(--muted); font-size: 15px;
}
.icon-btn:hover:not(:disabled) { background: #3a3a3c; color: var(--text); }
.icon-btn.on { color: var(--gold); }
.icon-btn.on.reject { color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ── header ──────────────────────────────────────────────────────────────── */
#studio-header {
  height: 52px; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--panel-2);
}
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.crumb { color: var(--muted); padding-left: 12px; border-left: 1px solid var(--border); }

/* ── layout ──────────────────────────────────────────────────────────────── */
#studio-main { display: flex; height: calc(100% - 52px); }
#contest-list {
  width: 240px; flex-shrink: 0; border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px 8px; background: var(--panel-2);
}
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 0 8px 8px; }
.contest-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  border-radius: 8px; padding: 8px; cursor: pointer;
}
.contest-item:hover { background: var(--panel); }
.contest-item.active { background: #0a84ff22; }
.ci-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#board { flex: 1; overflow-y: auto; padding: 24px 28px 120px; }
.empty { max-width: 560px; margin: 12vh auto; text-align: center; }
.empty h2 { font-size: 24px; margin-bottom: 12px; }
.empty p { color: var(--muted); margin-bottom: 20px; }

#board-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 8px; }
#board-head h1 { font-size: 22px; }
#brief-view { margin: 8px 0 20px; color: var(--muted); }
#brief-view summary { cursor: pointer; }
#brief-view pre { white-space: pre-wrap; font: inherit; margin-top: 8px; padding: 12px; background: var(--panel-2); border-radius: var(--radius); }

.round { margin-bottom: 32px; }
.round-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.round-head h3 { font-size: 15px; }

.concept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }

/* ── concept card ────────────────────────────────────────────────────────── */
.concept {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: border-color .15s, opacity .15s;
}
.concept.starred { border-color: var(--gold); }
.concept.rejected { opacity: .55; }
.concept.winner { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.art {
  width: 100%; background: #111; display: grid; place-items: center; cursor: zoom-in;
  max-height: 420px;
}
.concept:not(.ready) .art { cursor: default; min-height: 200px; }
.art svg { width: 100%; height: 100%; display: block; }
.art-msg { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; text-align: center; font-size: 12px; }
.concept-head { display: flex; align-items: center; gap: 4px; padding: 10px 10px 0 12px; }
.c-title { font-weight: 600; }
.rationale { padding: 6px 12px 0; font-size: 12px; color: var(--muted); }
.rating { display: flex; gap: 2px; padding: 8px 10px 0; }
.rate { background: none; border: none; cursor: pointer; color: #48484a; font-size: 14px; padding: 2px 3px; }
.rate.on { color: var(--gold); }
.comment {
  margin: 8px 10px 10px; resize: vertical; min-height: 44px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px;
}

.spinner {
  width: 22px; height: 22px; border: 2px solid #48484a; border-top-color: var(--accent);
  border-radius: 50%; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ── next round bar ──────────────────────────────────────────────────────── */
#next-round {
  position: fixed; bottom: 16px; left: calc(240px + 28px); right: 28px;
  display: flex; gap: 8px; padding: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 999px; box-shadow: 0 8px 24px #0006;
}
#direction { flex: 1; background: transparent; border: none; padding: 0 12px; outline: none; }

/* ── dialogs ─────────────────────────────────────────────────────────────── */
dialog {
  margin: auto; background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px; width: min(560px, 92vw); max-height: 90vh;
}
dialog::backdrop { background: #000a; }
dialog h2 { font-size: 18px; margin-bottom: 14px; }
dialog label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; }
dialog input:not([type=color]), dialog select, dialog textarea {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}
dialog code { font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
dialog p { margin-bottom: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg-actions.column { flex-direction: column; align-items: stretch; }
.form-error { color: var(--danger); margin-top: 8px; font-size: 13px; }

.palette { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; position: relative; }
.swatch.add { display: grid; place-items: center; background: var(--panel-2); color: var(--muted); }
.swatch.add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

#dlg-preview { width: min(1200px, 95vw); }
.preview-wrap { display: flex; gap: 20px; }
#preview-svg { flex: 1; min-width: 0; background: #111; border-radius: 8px; display: grid; place-items: center; }
#preview-svg svg { max-width: 100%; max-height: 78vh; display: block; }
.preview-side { width: 260px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
#preview-rationale { color: var(--muted); margin: 8px 0; }

/* ── toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; top: 64px; left: 50%; transform: translate(-50%, -20px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { border-color: var(--danger); }
#toast.warn { border-color: var(--gold); }

@media (max-width: 800px) {
  #contest-list { display: none; }
  #next-round { left: 12px; right: 12px; }
  .preview-wrap { flex-direction: column; }
  .preview-side { width: auto; }
}

/* ── projects ────────────────────────────────────────────────────────────── */
.pad { padding: 0 8px 8px; }
#ungrouped-title { margin-top: 16px; }
.project-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; border-radius: 8px; padding: 8px; cursor: pointer;
}
.project-item:hover { background: var(--panel); }
.project-item.active { background: #0a84ff22; }
.project-item .ci-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.dots { display: inline-flex; gap: 2px; flex-shrink: 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.dots:empty::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #48484a; }
.sub-list { margin: 0 0 6px 14px; border-left: 1px solid var(--border); padding-left: 4px; }

.crumbs { margin-bottom: 6px; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

#project-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 20px; }
#project-head h1 { font-size: 22px; margin: 2px 0 4px; }
#project-brand { max-width: 680px; }
.palette.static { margin-top: 8px; }
.palette.static .swatch { cursor: default; width: 22px; height: 22px; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
h3.section { font-size: 15px; margin: 18px 0 10px; }

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.asset { background: var(--panel); border: 1px solid var(--gold); border-radius: var(--radius); overflow: hidden; padding-bottom: 8px; }
.asset .art { cursor: pointer; max-height: 260px; }

.contest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.contest-card {
  text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; cursor: pointer; min-height: 72px; display: flex; flex-direction: column; gap: 4px;
}
.contest-card:hover { border-color: #5a5a5e; }
.contest-card.add { align-items: center; justify-content: center; color: var(--accent); border-style: dashed; }
.note { background: #0a84ff1a; border: 1px solid #0a84ff55; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.grid-msg { grid-column: 1 / -1; }

.nav { display: flex; gap: 4px; padding-left: 12px; border-left: 1px solid var(--border); }
.nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { color: var(--text); background: var(--panel); }

/* export menu in preview */
.export-box { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.export-row { display: flex; gap: 6px; }
.export-row select { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.export-box .chk { display: flex; align-items: center; gap: 6px; }
