/* Image Studio */

:root {
  --bg: #ffffff;
  --sidebar: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e8e8ee;
  --border: #e4e4ea;
  --border-strong: #d2d2db;
  --text: #16161d;
  --text-2: #4a4a57;
  --muted: #777784;
  --accent: #6246ea;
  --accent-hover: #5034d8;
  --accent-soft: #efebff;
  --accent-fg: #ffffff;
  --user-bubble: #f0edfe;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --success: #12b76a;
  --success-text: #067647; /* green text on light backgrounds (readable contrast) */
  --warning: #b54708;
  --warning-soft: #fff6e5;
  --shimmer: rgba(255, 255, 255, .55);
  --toast: #1d1d25;
  --shadow: 0 1px 2px rgba(16, 16, 29, .05), 0 4px 14px rgba(16, 16, 29, .06);
  --shadow-lg: 0 16px 48px rgba(16, 16, 29, .2);
  --radius: 14px;
  --radius-sm: 10px;
  /* Latin text: the system UI font. Chinese: Noto Sans SC (思源黑体, loaded in index.html), then the system Chinese fonts. */
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111116;
    --sidebar: #17171d;
    --surface: #1c1c23;
    --surface-2: #23232b;
    --surface-3: #2d2d37;
    --border: #2a2a33;
    --border-strong: #3a3a46;
    --text: #ececf1;
    --success-text: #47cd89;
    --text-2: #c0c0cc;
    --muted: #8f8f9c;
    --accent: #8b74ff;
    --accent-hover: #9c88ff;
    --accent-soft: #29234a;
    --user-bubble: #262140;
    --danger: #f97066;
    --danger-soft: #2a1716;
    --danger-border: #55302d;
    --warning: #fdb022;
    --warning-soft: #33260e;
    --shimmer: rgba(255, 255, 255, .06);
    --toast: #2e2e38;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: none; display: block; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 10px 12px;
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; }

/* EN / 中文 switch next to the app name */
.lang-switch {
  display: inline-flex;
  margin: 0 6px 14px auto; /* the brand has 14px padding below */
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch button:hover { color: var(--text); }
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.lang-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 15.5px;
  letter-spacing: -.01em;
  padding: 2px 8px 14px;
}

.brand-mark, .avatar {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #7c5cff, #e14bd8);
  flex: none;
}
/* App mark: the brain on a soft accent square (same look as the Multi-agent button) */
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); }
.brand-mark .icon { width: 18px; height: 18px; }

.new-project {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-weight: 560;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.new-project:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
  padding: 18px 10px 6px;
}

.project-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  outline-offset: -2px;
}
.project-item:hover { background: var(--surface-3); }
.project-item.active { background: var(--surface); box-shadow: var(--shadow); }

.project-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex: none;
  background: var(--surface-3);
}
.project-thumb.placeholder { display: grid; place-items: center; color: var(--muted); }
.project-thumb.placeholder .icon { width: 16px; height: 16px; }

.project-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.project-name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-meta.busy { color: var(--accent); }

.project-actions { display: none; gap: 2px; }
.project-item:hover .project-actions,
.project-item:focus-within .project-actions { display: flex; }

.empty-note { color: var(--muted); font-size: 13px; padding: 4px 10px; margin: 0; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  margin-top: 8px;
  padding: 12px 8px 0;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.foot-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 12.5px;
  padding: 6px 8px;
  margin: -6px -8px 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.foot-btn:hover { background: var(--surface-3); }
.foot-link { color: var(--accent); font-weight: 560; font-size: 12px; }
.status { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex: none; }
.status-dot.demo { background: var(--warning); }

/* ---------- Buttons ---------- */

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex: none;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 7px; }
.icon-btn.sm .icon { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 560;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn .icon { width: 16px; height: 16px; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger-border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.only-mobile { display: none !important; }
.sidebar-backdrop { display: none; }

/* ---------- Main ---------- */

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.title-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.01em;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 6px 8px;
  margin-left: -8px;
  border-radius: 8px;
  text-overflow: ellipsis;
}
.title-input:hover { border-color: var(--border); }
.title-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.view-tabs { display: flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; flex: none; }
.view-tabs button {
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 560;
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.count {
  font-size: 11.5px;
  background: var(--surface-3);
  padding: 0 7px;
  border-radius: 999px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.mode-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  background: var(--warning-soft);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Thread ---------- */

.thread {
  max-width: 840px;
  margin: 0 auto;
  padding: 28px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }

.msg-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.msg.user {
  align-self: flex-end;
  max-width: min(82%, 620px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.msg.user .bubble {
  background: var(--user-bubble);
  padding: 10px 14px;
  border-radius: 18px 18px 6px 18px;
}

.ref-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; justify-content: flex-end; }
.ref-thumb {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border-radius: 9px;
  cursor: zoom-in;
  display: block;
  background: var(--surface-3);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .15s;
}
.link-btn .icon { width: 13px; height: 13px; }
.link-btn:hover { color: var(--text); background: var(--surface-2); }
.msg:hover .link-btn, .link-btn:focus-visible { opacity: 1; }

.msg.assistant { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 30px; height: 30px; border-radius: 9px; }
.avatar .icon { width: 16px; height: 16px; }
.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 1px; }

.image-grid { display: flex; flex-wrap: wrap; gap: 10px; }

.image-card {
  position: relative;
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
  max-width: 100%;
  box-shadow: var(--shadow);
}
.image-card img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }

.image-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.image-card:hover .image-actions, .image-card:focus-within .image-actions { opacity: 1; }
.image-actions .icon-btn {
  background: rgba(17, 17, 24, .6);
  color: #fff;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.image-actions .icon-btn:hover { background: rgba(17, 17, 24, .82); color: #fff; }
.image-actions .icon-btn.delete:hover { background: #d92d20; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
}

.demo-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 560px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--warning-soft);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.demo-note .icon { width: 16px; height: 16px; color: var(--warning); margin-top: 1px; }
.demo-note strong { color: var(--warning); }

/* loading */
.image-card.loading {
  display: grid;
  place-items: center;
  box-shadow: none;
  border: 1px solid var(--border);
}
.shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 25%, var(--shimmer) 50%, transparent 75%) var(--surface-2);
  background-size: 220% 100%;
  animation: shimmer 1.5s linear infinite;
}
.loading-label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  padding: 6px 13px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 160% 0; } to { background-position: -60% 0; } }

/* error */
.error-card {
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-width: 560px;
}
.error-title { display: flex; gap: 7px; align-items: center; font-weight: 600; color: var(--danger); }
.error-title .icon { width: 16px; height: 16px; }
.error-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); font-size: 13.5px; margin: 4px 0 10px; }
.error-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* empty project */
.empty { text-align: center; padding: 7vh 4px 8px; display: flex; flex-direction: column; align-items: center; }
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin: 0 auto 16px;
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty h2, .welcome h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.015em; font-weight: 680; }
.empty p, .welcome p { margin: 0 auto; color: var(--muted); max-width: 440px; }

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 28px;
  width: 100%;
  max-width: 660px;
  text-align: left;
}
.suggestion {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.suggestion:hover { border-color: var(--accent); }
.suggestion strong { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.suggestion strong .icon { width: 15px; height: 15px; color: var(--accent); }
.suggestion span {
  font-size: 12.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Composer ---------- */

.composer { flex: none; padding: 6px 24px 14px; max-width: 940px; width: 100%; margin: 0 auto; }

.composer-box {
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 10px 10px 8px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }

.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0 10px; align-items: center; }
.attachment {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.attachment img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attachment-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 9.5px;
  text-align: center;
  background: rgba(0, 0, 0, .58);
  color: #fff;
  padding: 1px 0;
}
.attachment-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  cursor: pointer;
  padding: 0;
}
.attachment-remove .icon { width: 12px; height: 12px; }
.attachments-count { font-size: 12px; color: var(--muted); padding-left: 2px; }

#prompt {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  background: transparent;
  color: var(--text);
  padding: 4px 0;
  min-height: 30px;
  max-height: 220px;
  display: block;
}
#prompt::placeholder { color: var(--muted); }

/* Pickers wrap inside .composer-tools; the send button keeps its own column, so it always sits on the pickers' last row. */
.composer-bar { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; }
.composer-tools { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.composer-bar .send-btn { margin-left: auto; }
@media (max-width: 760px) {
  .select > span, .dims { display: none; }
  .select { padding-left: 6px; }
}

.select {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0 4px 0 10px;
  height: 32px;
  cursor: pointer;
}
.select select {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 6px 2px;
  cursor: pointer;
  outline: none;
}
.select select option { background: var(--surface); color: var(--text); }
.select:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.select select:disabled { cursor: default; opacity: .75; }
.model-select select { max-width: 210px; text-overflow: ellipsis; }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: transparent; }

.dims { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.send-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: background .15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.send-btn.busy .icon { display: none; }
.send-btn.busy::after {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.composer-hint { font-size: 12px; color: var(--muted); text-align: center; margin: 8px 0 0; }
.composer-hint.warn { color: var(--warning); }

/* ---------- Gallery ---------- */

.gallery {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.gallery-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: box-shadow .15s, transform .15s;
}
.gallery-item:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.gallery-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: zoom-in;
}
.gallery-item:hover .image-actions,
.gallery-item:focus-within .image-actions { opacity: 1; }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--surface-2); }
.gallery-caption { padding: 9px 11px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gallery-caption .p {
  font-size: 12.5px;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-caption .m { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gallery-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 12vh 0; }

/* ---------- Welcome ---------- */

.welcome { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; }
.welcome-card { max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.welcome .btn { margin-top: 20px; }

/* ---------- Drop overlay ---------- */

.drop-overlay {
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--accent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
  z-index: 20;
  pointer-events: none;
}

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, .86);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.lightbox-inner { display: flex; gap: 24px; max-width: 1280px; width: 100%; max-height: 100%; align-items: center; justify-content: center; }
#lbImage {
  max-width: calc(100% - 324px);
  max-height: calc(100vh - 56px);
  max-height: calc(100dvh - 56px);
  object-fit: contain;
  border-radius: 10px;
  min-width: 0;
  background: #222;
}
.lightbox-side { width: 300px; flex: none; color: #ececf1; display: flex; flex-direction: column; gap: 12px; }
.lb-prompt { font-size: 14px; line-height: 1.55; max-height: 45vh; overflow: auto; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.lb-meta { font-size: 12.5px; color: #a3a3b0; margin: 0; font-variant-numeric: tabular-nums; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lb-actions .btn { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .16); }
.lb-actions .btn:hover { background: rgba(255, 255, 255, .18); }
.lb-actions .btn.danger { color: #ffb4ab; }
.lb-actions .btn.danger:hover { background: rgba(217, 45, 32, .45); border-color: rgba(255, 180, 171, .4); }
.lb-close { position: absolute; top: 14px; right: 14px; color: #fff; }
.lb-close:hover { background: rgba(255, 255, 255, .14); color: #fff; }

/* ---------- Model setup dialog ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(10, 10, 14, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 920px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 20px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-sub { margin: 4px 0 14px; color: var(--muted); font-size: 13px; }
.modal-sub code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.models-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.models-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  padding: 8px 12px;
  position: sticky;
  top: 0;
}
.models-table td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.models-table tr.not-ready td { color: var(--text-2); }
.models-table td .btn { margin-top: 6px; }
.cell-note { color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 320px; }
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  white-space: nowrap;
}
.badge.ok { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success-text); }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--toast);
  color: #fff;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
  white-space: pre-wrap;
  max-width: 540px;
  transition: opacity .25s, transform .25s;
}
.toast.error { background: #c4271c; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Scrollbars ---------- */

.scroll, .project-list, .lb-prompt { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- Creative director ---------- */

.link-btn.visible { opacity: 1; color: var(--accent); }
.link-btn.visible:hover { color: var(--accent-hover); }

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px 0 9px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: none;
}
.mode-btn .icon { width: 16px; height: 16px; }
.mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.mode-btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.avatar.brain { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }

.agent-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; max-width: 680px; }

.thinking {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 8px 14px;
  font-variant-numeric: tabular-nums;
  align-self: flex-start;
}
.thinking.small { font-size: 13px; padding: 6px 12px; }

.version-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  width: 100%;
}
.version {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.version.picked { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.version-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.version-head strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
  flex: none;
}
.chip .icon { width: 12px; height: 12px; }
.chip.ok { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success-text); }
.version-media { width: 100%; max-width: 100%; border-radius: var(--radius-sm); box-shadow: none; }
.image-card.version-media img { border-radius: var(--radius-sm); }
.version-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  text-align: center;
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  min-height: 140px;
}
.version-error .error-text { margin: 0; font-size: 12.5px; max-height: 6.5em; overflow: auto; }
.version-focus { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.version-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.version-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.btn.picked-btn { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.version-prompt summary { font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.version-prompt summary:hover { color: var(--text); }
.version-prompt pre {
  margin: 6px 0 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  max-height: 220px;
  overflow: auto;
}

.pick-box, .memory-card, .review, .questions {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 680px;
}
.pick-box, .memory-card { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.pick-title, .review-head { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 13.5px; }
.pick-title .icon, .review-head .icon { width: 16px; height: 16px; color: var(--accent); }
.pick-feedback {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.pick-feedback:focus { outline: none; border-color: var(--accent); }
.memory-card ul { margin: 0; padding-left: 20px; font-size: 13.5px; }
.memory-line { font-size: 13px; color: var(--text-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.memory-line.ok { color: var(--success-text); }
.memory-line.warn { color: var(--warning); }

.question-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.question { display: flex; flex-direction: column; gap: 6px; }
.question-text { font-size: 13.5px; font-weight: 600; }
.question-text.big { font-size: 14.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  line-height: 1.35;
  max-width: 100%;
}
.chip-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.chip-btn.default { border-style: dashed; }
.chip-btn.chosen { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip-btn:disabled { cursor: default; opacity: .7; }
.chip-btn .rec { color: var(--warning); }

.review-summary { margin: 0; font-size: 13.5px; color: var(--text-2); }
.review-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.review-row { display: flex; flex-direction: column; gap: 3px; font-size: 13px; background: var(--surface-2); border-radius: 9px; padding: 8px 10px; }
.review-title { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; }
.score { font-size: 11.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; }
.pro { color: var(--success-text); }
.con { color: var(--text-2); }
.issues { margin: 2px 0 0; padding-left: 16px; color: var(--danger); }
.recommendation { display: flex; gap: 7px; align-items: flex-start; font-size: 13.5px; font-weight: 550; }
.recommendation .icon { width: 16px; height: 16px; color: var(--warning); margin-top: 2px; flex: none; }

.setup-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 7px 12px;
  margin-bottom: 8px;
}
.setup-banner .icon { width: 16px; height: 16px; }
.setup-banner .link-btn { margin-left: auto; }

.brief-cta { margin-top: 16px; }

/* ---------- Brief tab ---------- */

.brief { max-width: 880px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.brief-intro { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brief-intro h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.brief-intro p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 520px; }
.brief-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.brief-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.brief-card-head h3 { margin: 0; font-size: 15px; }
.brief-card-head p { margin: 2px 0 0; }
.brief-text {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  font: 13px/1.6 ui-monospace, "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  color: var(--text);
}
.brief-text:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.gallery-item.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- Composer: project picker + cost estimate ---------- */

.composer-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px 0 6px; flex-wrap: wrap; }
.project-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
  min-width: 0;
  max-width: 100%;
}
.project-pick .icon { width: 15px; height: 15px; color: var(--accent); flex: none; }
.project-pick select {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  cursor: pointer;
  outline: none;
  max-width: 260px;
  text-overflow: ellipsis;
  padding: 2px 0;
}
.project-pick select option { background: var(--surface); color: var(--text); }
.estimate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.estimate:hover { border-color: var(--accent); color: var(--text); }
.estimate-label { color: var(--muted); font-weight: 500; }
.estimate-myr { color: var(--muted); font-weight: 500; }
.estimate-more { color: var(--muted); font-size: 10px; }
.estimate-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 8px 11px;
  margin-bottom: 8px;
  line-height: 1.5;
}

/* ---------- Project info form ---------- */

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-size: 13px; font-weight: 600; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.field-input {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--surface-2);
  color: var(--text);
  resize: vertical;
  line-height: 1.5;
}
.field-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }

/* ---------- Memory view ---------- */

.md { font-size: 13.5px; line-height: 1.6; overflow-wrap: anywhere; }
.md h3, .md h4, .md h5 { margin: 14px 0 6px; font-size: 14.5px; }
.md h3:first-child, .md h4:first-child { margin-top: 0; }
.md ul { margin: 4px 0 8px; padding-left: 20px; }
.md li.sub { margin-left: 18px; list-style: circle; }
.md p { margin: 4px 0; color: var(--text-2); }
.md-scroll { max-height: 460px; overflow: auto; padding-right: 4px; }
.path {
  display: block;
  font: 12.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
  overflow-wrap: anywhere;
  color: var(--text-2);
}

@media (max-width: 640px) {
  .field-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .version-grid { grid-template-columns: minmax(0, 1fr); }
  .brief { padding: 16px; }
}

/* ---------- Touch devices: no hover, so always show actions ---------- */

@media (hover: none) {
  .project-actions { display: flex; }
  .image-actions, .link-btn { opacity: 1; }
}

/* ---------- Tablet / phone ---------- */

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 288px;
    max-width: 86vw;
    z-index: 40;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .app.sidebar-open .sidebar { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .38); z-index: 35; display: none; }
  .app.sidebar-open .sidebar-backdrop { display: block; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 0 10px 0 8px; gap: 6px; }
  .title-input { margin-left: 0; }
  .thread { padding: 20px 16px 10px; }
  .composer { padding: 4px 12px 12px; }
  .gallery { padding: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .lightbox { padding: 56px 16px 16px; }
  .lightbox-inner { flex-direction: column; gap: 14px; overflow-y: auto; }
  #lbImage { max-width: 100%; max-height: 62vh; }
  .lightbox-side { width: 100%; }
}

@media (max-width: 560px) {
  .view-tabs button { padding: 5px 9px; }
  .msg.user { max-width: 92%; }
  .suggestions { grid-template-columns: minmax(0, 1fr); }
  .composer-hint:not(.warn) { display: none; }
  .model-select select { max-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ==========================================================================
   Layout like Claude Code: chat in the middle, settings in one window,
   images in a side panel.
   ========================================================================== */

/* ---------- Top bar: project name + two quiet buttons ---------- */

.top-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.top-btn:hover { background: var(--surface-2); color: var(--text); }
.top-btn.on { background: var(--accent-soft); color: var(--accent); }
.top-btn .icon { width: 17px; height: 17px; }
.top-btn .count { background: var(--surface-3); }
.top-btn.on .count { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* ---------- Sidebar footer: one Settings button ---------- */

.sidebar-foot { padding: 8px 0 0; }
.foot-btn {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
}
.foot-btn > .icon { width: 18px; height: 18px; color: var(--text-2); }
.foot-text { display: flex; flex-direction: column; min-width: 0; }
.foot-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.foot-sub { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Images panel on the right ---------- */

.app.images-open { grid-template-columns: 276px minmax(0, 1fr) 340px; }
.images-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.panel-head { height: 58px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.images-panel .gallery { padding: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: none; }

/* ---------- Settings window ---------- */

.settings-modal { padding: 24px; }
.settings-card {
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 980px;
  height: min(760px, 100%);
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  overflow: hidden;
}
.settings-nav {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.settings-group { display: flex; flex-direction: column; gap: 2px; }
.settings-group-label { font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 2px; }
.settings-group-sub { font-size: 12.5px; font-weight: 600; color: var(--text-2); padding: 0 10px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  text-align: left;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.settings-nav-item .icon { width: 16px; height: 16px; color: var(--muted); }
.settings-nav-item:hover { background: var(--surface-3); color: var(--text); }
.settings-nav-item.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.settings-nav-item.active .icon { color: var(--accent); }
.settings-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 24px; flex: none; }
.settings-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.settings-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 24px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.settings-intro { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.settings-intro-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.settings-intro-row .settings-intro { flex: 1; min-width: 240px; }
.brief-text.tall { min-height: 340px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 0; border-top: 1px solid var(--border); }
.setting-text { min-width: 0; max-width: 520px; }
.setting-title { font-weight: 600; font-size: 14px; }
.setting-control { flex: none; }

.segmented { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; }
.segmented button { border: 0; background: transparent; min-width: 38px; padding: 5px 12px; border-radius: 7px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-ui { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .15s; pointer-events: none; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .switch-ui { background: var(--accent); }
.switch input:checked + .switch-ui::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.brain-status { display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.brain-status .status-dot { margin-top: 7px; }

.lang-options { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14.5px;
  font-weight: 560;
  cursor: pointer;
  text-align: left;
}
.lang-option:hover { border-color: var(--accent); }
.lang-option.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.lang-option .icon { color: var(--accent); }

/* ---------- Designer agents: checklist and team before they start ---------- */

.plan-card {
  border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.plan-section { display: flex; flex-direction: column; gap: 8px; }
.plan-head { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 14px; }
.plan-head .icon { width: 16px; height: 16px; color: var(--accent); }
.plan-note { margin: -4px 0 0; max-width: none; }
.req-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.req-row { display: flex; align-items: center; gap: 6px; }
.req-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  background: var(--surface);
  color: var(--text);
}
.req-input:focus { outline: none; border-color: var(--accent); }
.req-kind {
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 5px 4px;
  cursor: pointer;
  flex: none;
}
.req-kind option { background: var(--surface); color: var(--text); }
.req-kind.must, .kind-tag.must { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.req-kind.avoid, .kind-tag.avoid { background: var(--danger-soft); color: var(--danger); }
.req-kind.style, .kind-tag.style { background: var(--surface-3); color: var(--text-2); }
.kind-tag { display: inline-block; font-size: 11px; font-weight: 650; border-radius: 5px; padding: 1px 6px; margin-right: 6px; white-space: nowrap; }
.agent-list { display: flex; flex-direction: column; gap: 6px; }
.agent-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 10px; }
.agent-row.off { opacity: .5; }
.agent-row.off strong { text-decoration: line-through; }
.agent-row-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.agent-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.agent-focus { font-size: 12.5px; color: var(--text-2); }
.agent-role { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 560; }
.agent-role .icon { width: 13px; height: 13px; color: var(--accent); }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }

.req-summary { font-size: 13px; }
.req-summary summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text-2); font-weight: 560; user-select: none; }
.req-summary summary .icon { width: 14px; height: 14px; color: var(--accent); }
.req-view { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }

/* ---------- Designer agents at work ---------- */

.version.working { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.image-card.busy img { opacity: .45; filter: saturate(.6); }
.image-card.busy .loading-label { position: absolute; inset: auto 0 0 0; margin: 8px; }
.agent-now { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; margin-top: 5px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }
.check-badge { align-self: flex-start; font-size: 12px; font-weight: 650; border-radius: 999px; padding: 2px 9px; }
.check-badge.ok { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success-text); }
.check-badge.warn { background: var(--warning-soft); color: var(--warning); }
.tries { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.try-thumb { position: relative; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 7px; padding: 0; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.try-thumb.final { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.try-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.try-thumb span { position: absolute; right: 1px; bottom: 1px; font-size: 9.5px; font-weight: 700; color: #fff; background: rgba(17, 17, 24, .72); border-radius: 4px; padding: 0 3px; }
.version-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.revise-box { display: flex; flex-direction: column; gap: 6px; }
.check-list, .step-list { margin: 6px 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2); }
.check-list li { display: flex; gap: 6px; }
.check-list .mark { font-weight: 700; flex: none; }
.check-list li.ok .mark { color: var(--success-text); }
.check-list li.no .mark { color: var(--danger); }
.step-list { border-left: 2px solid var(--border); padding-left: 9px; }
.step-list .step.error, .step-list .step.check_failed { color: var(--danger); }
.detail-label { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Comparison: checklist per version ---------- */

.qa-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.qa-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.qa-table th { background: var(--surface-2); font-weight: 650; text-align: center; padding: 6px 8px; white-space: nowrap; }
.qa-table th:first-child { text-align: left; }
.qa-table td { border-top: 1px solid var(--border); padding: 6px 8px; }
.qa-cell { text-align: center; font-weight: 700; width: 56px; }
.qa-cell.ok { color: var(--success-text); }
.qa-cell.no { color: var(--danger); background: var(--danger-soft); }

/* ---------- Smaller screens ---------- */

@media (max-width: 1180px) {
  .app.images-open { grid-template-columns: 276px minmax(0, 1fr); }
  .images-panel { position: fixed; inset: 0 0 0 auto; width: min(360px, 92vw); z-index: 45; box-shadow: var(--shadow-lg); }
}
@media (max-width: 860px) {
  .app.images-open { grid-template-columns: minmax(0, 1fr); }
  .settings-modal { padding: 0; }
  .settings-card { height: 100%; max-width: none; border-radius: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; gap: 4px; padding: 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-group { flex-direction: row; align-items: center; gap: 2px; }
  .settings-group-label, .settings-group-sub { display: none; }
  .settings-nav-item { white-space: nowrap; width: auto; }
  .settings-body { padding: 4px 16px 20px; }
  .setting-row { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ==========================================================================
   Agent board: every project's director and designers in one place
   ========================================================================== */

.board-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 560;
  cursor: pointer;
  text-align: left;
}
.board-btn .icon { width: 17px; height: 17px; }
.board-btn:hover { background: var(--surface-3); color: var(--text); }
.board-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.board-btn.active > .icon { color: var(--accent); }
.board-btn-label { flex: 1; }
.board-badges { display: inline-flex; gap: 4px; }
.board-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 20px;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.board-badge.working { background: var(--accent-soft); color: var(--accent); }
.board-badge.working .pulse { width: 6px; height: 6px; margin: 0; }
.board-badge.attention { background: var(--warning-soft); color: var(--warning); }

.project-name { display: flex; align-items: center; gap: 6px; }
.project-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.project-dot.working { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.project-dot.attention { background: #f59e0b; }

.board { max-width: 1120px; margin: 0 auto; padding: 28px 24px 40px; display: flex; flex-direction: column; gap: 26px; }
.board-head { display: flex; align-items: flex-start; gap: 10px; }
.board-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.015em; }
.board-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 620px; }
.board-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 9vh 16px; color: var(--muted); text-align: center; }
.board-empty .icon { width: 30px; height: 30px; }
.board-empty p { margin: 0; max-width: 420px; }
.board-section h2 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.board-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.board-card.state-approve, .board-card.state-pick, .board-card.state-memory, .board-card.state-answer { border-color: color-mix(in srgb, #f59e0b 55%, var(--border)); }
.board-card.state-planning, .board-card.state-working, .board-card.state-comparing { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.board-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.board-project { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13.5px; min-width: 0; }
.board-project span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-project .icon { width: 14px; height: 14px; color: var(--accent); }
.board-state { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 2px 9px; background: var(--surface-2); color: var(--text-2); }
.board-state .pulse { width: 6px; height: 6px; margin: 0; }
.board-state.state-planning, .board-state.state-working, .board-state.state-comparing { background: var(--accent-soft); color: var(--accent); }
.board-state.state-approve, .board-state.state-pick, .board-state.state-memory, .board-state.state-answer { background: var(--warning-soft); color: var(--warning); }
.board-state.state-done { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success-text); }
.board-state.state-failed { background: var(--danger-soft); color: var(--danger); }
.board-request { margin: 0; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.board-note { margin: 0; font-size: 12.5px; color: var(--text-2); }
.board-agents { display: flex; flex-direction: column; gap: 6px; }
.board-agent { display: flex; align-items: center; gap: 10px; min-width: 0; }
.board-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.board-thumb .icon { width: 16px; height: 16px; }
.board-agent.working .board-thumb { opacity: .6; }
.board-agent-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.board-agent-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.board-agent-head strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-agent-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); min-width: 0; }
.board-agent-line span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-agent-line .pulse { width: 6px; height: 6px; margin: 0; }
.board-agent.failed .board-agent-line { color: var(--danger); }
.board-rec { display: flex; gap: 7px; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.board-rec .icon { width: 14px; height: 14px; color: var(--accent); flex: none; margin-top: 2px; }
.board-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }

@media (max-width: 860px) {
  .board { padding: 16px 14px 28px; }
  .board-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ==========================================================================
   Pixel studio: the AI team above the chat (characters from assets/pixel.js)
   ========================================================================== */

:root { --studio-wall: #f3f1fb; --studio-floor: #e3ddf6; --studio-tile: #d8d0f1; --studio-ink: #1b1b26; }
@media (prefers-color-scheme: dark) {
  :root { --studio-wall: #191922; --studio-floor: #232035; --studio-tile: #2b2742; --studio-ink: #ececf1; }
}

.pixel-sprite {
  display: inline-block;
  flex: none;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-position: 0 0;
  animation: px-frames var(--px-speed, 1s) steps(var(--px-steps, 2)) infinite;
}
.pixel-sprite.still { animation: none; }
@keyframes px-frames { from { background-position: 0 0; } to { background-position: var(--px-end) 0; } }

.studio {
  flex: none;
  position: relative;
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, var(--studio-tile) 46px 48px) bottom / 100% 34% no-repeat,
    linear-gradient(to bottom, var(--studio-wall) 0 66%, var(--studio-floor) 66% 100%);
}
.studio-head { position: absolute; top: 8px; left: 14px; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
.studio-head .icon { width: 14px; height: 14px; color: var(--accent); }
.studio-hint { font-weight: 400; color: var(--muted); }
.studio-floor {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 34px 14px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.station {
  flex: none;
  width: 128px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 4px 2px 6px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.station:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.station.selected { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 0 0 0 2px var(--accent); }
.station.ghost { cursor: default; opacity: .55; }
.station.ghost:hover { background: transparent; }

.station .bubble {
  position: relative;
  max-width: 124px;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--studio-ink);
  background: var(--surface);
  border: 2px solid var(--studio-ink);
  box-shadow: 2px 2px 0 var(--studio-ink);
  padding: 2px 6px;
  margin-bottom: 6px;
  white-space: normal;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  animation: bubble-float 2.4s ease-in-out infinite;
}
.station.act-wait .bubble { background: var(--warning-soft); }
.station.act-sad .bubble { background: var(--danger-soft); }
.station.act-happy .bubble, .station.act-wave .bubble { background: color-mix(in srgb, var(--success) 16%, var(--surface)); }
.station.act-idle .bubble, .station.act-read .bubble { animation: none; opacity: .85; font-weight: 500; }
@keyframes bubble-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

.station-stage { display: flex; align-items: flex-end; justify-content: center; height: 74px; gap: 0; }
.station-name { font-size: 12px; font-weight: 650; white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.station-model { font-size: 10.5px; color: var(--muted); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }

/* props, drawn with plain boxes to stay pixel-like */
.prop { display: block; flex: none; position: relative; margin-bottom: 6px; }
.desk { width: 34px; height: 20px; background: #7a4b2a; box-shadow: inset 0 -4px 0 #5e3a20; }
.laptop { position: absolute; left: 6px; top: -13px; width: 20px; height: 13px; background: #2a2a38; border: 2px solid #3a3a4a; }
.laptop.on { background: #8fd3ff; animation: screen-blink .8s steps(2) infinite; }
@keyframes screen-blink { 50% { background: #c8ecff; } }
.easel { width: 38px; height: 54px; }
.easel::before, .easel::after { content: ""; position: absolute; bottom: 0; width: 3px; height: 34px; background: #7a4b2a; }
.easel::before { left: 8px; transform: rotate(8deg); }
.easel::after { right: 8px; transform: rotate(-8deg); }
.easel-canvas { position: absolute; z-index: 1; top: 0; left: 2px; width: 34px; height: 30px; background: #fffdf6; border: 2px solid #7a4b2a; overflow: hidden; }
.easel-canvas img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shelf { width: 28px; height: 44px; background: #6b4226; padding: 3px; display: flex; flex-direction: column; justify-content: space-around; }
.shelf span { display: block; height: 9px; background: repeating-linear-gradient(90deg, #c94f4f 0 4px, #4f7fc9 4px 7px, #e0b04a 7px 10px, #4fae7a 10px 13px); }
.stand { width: 32px; height: 40px; }
.stand .frame { position: absolute; width: 18px; height: 16px; background: #fffdf6; border: 2px solid #b8902f; }
.stand .frame:first-child { left: 0; top: 2px; }
.stand .frame:last-child { right: 0; top: 14px; }
.station.role-memory .station-stage, .station.role-designer .station-stage { flex-direction: row-reverse; }

/* ---------- one agent up close ---------- */

.agent-pop-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(10, 10, 14, .22); display: flex; align-items: flex-start; justify-content: center; padding: 96px 16px 16px; }
.agent-pop {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.agent-pop-close { position: absolute; top: 10px; right: 10px; }
#agentPopLive, #agentPopAsk { display: flex; flex-direction: column; gap: 12px; }
.pop-head { display: flex; align-items: center; gap: 14px; padding-right: 28px; }
.pop-portrait {
  width: 104px; height: 104px; flex: none; display: grid; place-items: center; border-radius: 12px;
  background: linear-gradient(to bottom, var(--studio-wall) 0 70%, var(--studio-floor) 70% 100%);
}
.pop-title { min-width: 0; }
.pop-title h3 { margin: 0; font-size: 17px; }
.pop-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mood-tag { font-size: 11.5px; font-weight: 650; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.mood-tag.act-sad { background: var(--danger-soft); color: var(--danger); }
.mood-tag.act-wait { background: var(--warning-soft); color: var(--warning); }
.mood-tag.act-happy, .mood-tag.act-wave { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success-text); }
.pop-say { font-size: 14px; font-weight: 600; background: var(--surface-2); border-radius: 10px; padding: 8px 11px; }
.pop-section { display: flex; flex-direction: column; gap: 8px; margin: 0; }

/* ---------- team report and small faces ---------- */

.team-report { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 6px 10px; }
.team-minis { display: flex; flex: none; }
.team-minis .pixel-sprite { margin-right: -5px; }
.version-who { display: inline-flex; align-items: center; gap: 4px; min-width: 0; }
.version-who strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 860px) {
  .studio-floor { justify-content: flex-start; padding-top: 34px; }
  .studio-hint { display: none; }
  .agent-pop-wrap { padding-top: 64px; }
}

/* Images panel: Save all to folder */
.panel-head #saveAllBtn { margin-left: auto; margin-right: 6px; }

/* ==========================================================================
   Image viewer: ‹ › to step through the project's images
   ========================================================================== */

.lightbox { padding: 28px 76px; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}
.lb-nav .icon { width: 24px; height: 24px; }
.lb-nav:hover:not(:disabled) { background: rgba(255, 255, 255, .26); }
.lb-nav:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-nav:disabled { opacity: .25; cursor: default; }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 16px; }
.lb-count {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: #e4e4ec;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, .4);
  padding: 3px 11px;
  border-radius: 999px;
}
@media (max-width: 860px) {
  .lightbox { padding: 56px 16px 16px; }
  .lb-nav { top: 40%; width: 40px; height: 40px; background: rgba(0, 0, 0, .5); }
  .lb-nav.prev { left: 6px; }
  .lb-nav.next { right: 6px; }
}

/* The designer's name on a version card (same agent in every project) */
.version-who-name { font-size: 12px; font-weight: 650; color: var(--accent); white-space: nowrap; }

/* ==========================================================================
   Agent office: one AI team at their desks, working on every project
   ========================================================================== */

/* Office button beside ALL HUB */
.office-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 2px 14px auto; /* the brand has 14px padding below */
  padding: 3px 11px 3px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  flex: none;
}
.office-btn:hover { border-color: var(--accent); color: var(--accent); }
.office-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.office-btn.active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.office-btn-face { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); overflow: hidden; display: inline-flex; align-items: flex-end; justify-content: center; }
.office-btn + .only-mobile { margin: 0 0 14px 4px; }

.office { max-width: 1180px; margin: 0 auto; padding: 26px 24px 40px; display: flex; flex-direction: column; gap: 18px; }
.office-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.office-title { flex: 1; min-width: 240px; }
.office-title h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.015em; }
.office-title p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 660px; }
.office-stats { display: flex; gap: 6px; align-items: center; padding-top: 6px; }
.office-stats .board-badge { padding: 2px 10px; font-size: 12px; }

.office-room {
  --o-ink: #2a2233;
  --o-text: #2a2233;
  --o-wall: #f4efe4;
  --o-wall-line: #ebe3d2;
  --o-floor: #dcc6a3;
  --o-floor-line: #ceb58e;
  --o-desk: #94603f;
  --o-desk-top: #b57d55;
  --o-skirting: #7a4e31;
  --o-chair: #555a7a;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid var(--o-ink);
  box-shadow: 5px 5px 0 var(--o-ink);
  background: var(--o-floor);
  color: var(--o-text);
}
@media (prefers-color-scheme: dark) {
  .office-room {
    --o-ink: #0d0b13;
    --o-text: #efe9f7;
    --o-wall: #2b2737;
    --o-wall-line: #322d40;
    --o-floor: #3d3249;
    --o-floor-line: #463a54;
    --o-desk: #6b4530;
    --o-desk-top: #85593d;
    --o-skirting: #4c3222;
    --o-chair: #3a3e58;
  }
}

.office-wall {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 70px 112px;
  gap: 18px;
  align-items: start;
  padding: 18px 22px 16px;
  background: repeating-linear-gradient(90deg, var(--o-wall) 0 38px, var(--o-wall-line) 38px 40px);
  border-bottom: 8px solid var(--o-skirting);
}
/* The windows show the sky at your local time (colours and sun position come from app.js). */
.office-window {
  position: relative;
  height: 100px;
  border: 4px solid var(--o-ink);
  border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(var(--sky-top, #54acff), var(--sky-bottom, #c9e8ff));
  transition: background 2s;
}
.office-window::before, .office-window::after { content: ""; position: absolute; background: var(--o-ink); z-index: 2; }
.office-window::before { left: 50%; top: 0; bottom: 0; width: 4px; margin-left: -2px; }
.office-window::after { top: 50%; left: 0; right: 0; height: 4px; margin-top: -2px; }
.office-window > span { position: absolute; }
.office-window .stars {
  inset: 0;
  opacity: var(--night, 0);
  background:
    radial-gradient(circle at 12% 16%, #fff7cf 0 1.4px, transparent 2px),
    radial-gradient(circle at 33% 38%, #fff7cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 57% 12%, #fff7cf 0 1.4px, transparent 2px),
    radial-gradient(circle at 81% 44%, #fff7cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 22% 58%, #fff7cf 0 1px, transparent 1.6px),
    radial-gradient(circle at 69% 28%, #fff7cf 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 90% 14%, #fff7cf 0 1px, transparent 1.6px);
}
.office-window .sun {
  display: none;
  left: var(--sun-x, 50%);
  top: var(--sun-y, 30%);
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border-radius: 50%;
  background: var(--sun-color, #fff3a6);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--sun-color, #fff3a6) 35%, transparent), 0 0 26px var(--sun-color, #fff3a6);
}
.office-window.has-sun .sun { display: block; }
/* A crescent: a lit edge cast by a transparent disc */
.office-window .moon { right: 14px; top: 12px; width: 20px; height: 20px; border-radius: 50%; box-shadow: -6px 3px 0 0 #f6f0c4; opacity: var(--night, 0); }
.office-window .cloud {
  left: -44px;
  width: 36px;
  height: 11px;
  border-radius: 10px;
  background: var(--cloud, #fff);
  opacity: calc(1 - var(--night, 0) * .6);
  animation: cloud-drift 22s linear infinite;
}
.office-window .cloud.one { top: 22px; }
.office-window .cloud.two { top: 46px; width: 26px; animation-delay: -11s; }
@keyframes cloud-drift { to { transform: translateX(170px); } }
/* Far-away buildings; their windows light up at night */
.office-window .skyline { left: 0; right: 0; bottom: 0; height: 32%; display: flex; align-items: flex-end; gap: 2px; z-index: 1; }
.office-window .skyline span { position: relative; flex: 1; height: 60%; background: var(--city, #8a99c2); }
.office-window .skyline span:nth-child(2) { height: 100%; }
.office-window .skyline span:nth-child(3) { height: 45%; }
.office-window .skyline span:nth-child(4) { height: 82%; }
.office-window .skyline span:nth-child(5) { height: 55%; }
.office-window .skyline span::after {
  content: "";
  position: absolute;
  inset: 4px 3px 0;
  background: radial-gradient(circle, #ffd76a 0 1.3px, transparent 1.6px) 0 0 / 6px 6px;
  opacity: calc(var(--night, 0) * .95);
}

.whiteboard {
  min-height: 150px;
  padding: 10px 12px 12px;
  background: #fdfdfb;
  color: #1f1d29;
  border: 5px solid #b8bcc8;
  outline: 3px solid var(--o-ink);
  border-radius: 6px;
}
.wb-title { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 12.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; color: #4b4b5c; }
.wb-count { background: #6246ea; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; letter-spacing: 0; }
.wb-tasks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px 10px; }
.wb-task {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px 8px;
  border: 0;
  background: #fff6b0;
  color: #2a2233;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, .16);
  transform: rotate(-.7deg);
  transition: transform .12s, box-shadow .12s;
}
.wb-tasks li:nth-child(even) .wb-task { background: #d7f0ff; transform: rotate(.8deg); }
.wb-tasks li:nth-child(3n) .wb-task { background: #ffe1ec; }
.wb-task:hover { transform: rotate(0) translateY(-2px); box-shadow: 3px 4px 0 #6246ea; }
.wb-task:focus-visible { outline: 3px solid #6246ea; outline-offset: 2px; }
.wb-task::before { content: ""; position: absolute; top: -4px; left: 50%; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: #e5484d; box-shadow: 0 1px 0 rgba(0, 0, 0, .3); }
.wb-task.state-planning::before, .wb-task.state-working::before, .wb-task.state-comparing::before { background: #6246ea; }
.wb-task.state-done::before { background: #30a46c; }
.wb-task.state-done, .wb-task.state-failed { opacity: .72; }
.wb-project { display: flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 750; min-width: 0; }
.wb-project .icon { width: 13px; height: 13px; flex: none; }
.wb-project span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-request { font-size: 12px; line-height: 1.35; color: #4a4458; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wb-meta { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; margin-top: auto; padding-top: 2px; font-size: 11px; font-weight: 650; color: #5b5470; }
.wb-state { display: inline-flex; align-items: center; gap: 4px; }
.wb-state .pulse { width: 6px; height: 6px; margin: 0; }
.wb-who { color: #6246ea; }
.wb-empty { margin: 0; font-size: 13px; color: #6b6b7b; }

.office-wall-side { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.office-clock { position: relative; width: 50px; height: 50px; border-radius: 50%; background: #fff; border: 4px solid var(--o-ink); }
.office-clock .hand { position: absolute; left: 50%; bottom: 50%; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #2a2233; transform-origin: 50% 100%; }
.office-clock .hand.hour { height: 12px; }
.office-clock .hand.minute { height: 17px; width: 2px; margin-left: -1px; }
.office-plant { position: relative; width: 44px; height: 62px; }
.office-plant::before { content: ""; position: absolute; bottom: 0; left: 9px; width: 26px; height: 22px; box-sizing: border-box; background: #c8643b; border: 3px solid var(--o-ink); border-radius: 2px 2px 7px 7px; }
.office-plant::after {
  content: "";
  position: absolute;
  bottom: 20px;
  left: 3px;
  width: 38px;
  height: 40px;
  background:
    radial-gradient(circle at 28% 62%, #3fae6a 0 9px, transparent 10px),
    radial-gradient(circle at 72% 58%, #2f9a5a 0 10px, transparent 11px),
    radial-gradient(circle at 50% 26%, #4ec47d 0 11px, transparent 12px);
}

.office-floor {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 18px 26px;
  background:
    repeating-linear-gradient(90deg, transparent 0 78px, var(--o-floor-line) 78px 80px),
    repeating-linear-gradient(0deg, var(--o-floor) 0 38px, var(--o-floor-line) 38px 40px);
}
.desk-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px 26px; }
.desk-row.team { padding-top: 18px; border-top: 3px dashed color-mix(in srgb, var(--o-ink) 22%, transparent); }

.desk-station {
  position: relative;
  width: 178px;
  padding: 6px 5px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--o-text);
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.desk-station:hover { background: color-mix(in srgb, #fff 22%, transparent); }
.desk-station:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.desk-station.selected { background: color-mix(in srgb, #fff 30%, transparent); box-shadow: inset 0 0 0 3px var(--accent); }
.desk-station .bubble {
  position: relative;
  max-width: 170px;
  min-height: 22px;
  padding: 2px 7px;
  margin-bottom: 2px;
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 600;
  text-align: center;
  color: #2a2233;
  background: #fff;
  border: 2px solid var(--o-ink);
  box-shadow: 2px 2px 0 var(--o-ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  animation: bubble-float 2.4s ease-in-out infinite;
}
.desk-station.act-wait .bubble { background: #fff1c2; }
.desk-station.act-sad .bubble { background: #ffe0dc; }
.desk-station.act-happy .bubble, .desk-station.act-wave .bubble { background: #dcf5e4; }
.desk-station.act-idle .bubble, .desk-station.act-read .bubble { animation: none; font-weight: 500; }

.seat { position: relative; display: block; width: 168px; height: 124px; }
.seat .chair {
  position: absolute;
  left: 50%;
  bottom: 38px;
  width: 60px;
  height: 78px;
  margin-left: -30px;
  background: var(--o-chair);
  border: 3px solid var(--o-ink);
  border-radius: 14px 14px 4px 4px;
}
.seat > .pixel-sprite { position: absolute; left: 50%; bottom: 28px; margin-left: -36px; }
.office-desk {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 46px;
  background: var(--o-desk);
  border: 3px solid var(--o-ink);
  border-radius: 6px 6px 3px 3px;
  box-shadow: inset 0 9px 0 var(--o-desk-top);
}
.desk-gear { position: absolute; left: 8px; bottom: 100%; margin-bottom: -3px; display: flex; align-items: flex-end; }
.od-monitor { position: relative; display: block; width: 54px; height: 40px; margin-bottom: 8px; background: #2b2f45; border: 3px solid var(--o-ink); border-radius: 4px; }
.od-monitor::after { content: ""; position: absolute; left: 50%; top: 100%; width: 12px; height: 8px; margin: 3px 0 0 -6px; background: var(--o-ink); }
.od-monitor img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.od-monitor.on { background: #3a4170; box-shadow: 0 0 0 2px #8bd3ff, 0 0 16px rgba(139, 211, 255, .6); animation: screen-glow 1.6s ease-in-out infinite; }
.od-monitor.on img { opacity: 1; }
.od-monitor.small { width: 36px; height: 28px; }
.od-monitors { display: flex; gap: 4px; }
@keyframes screen-glow { 50% { box-shadow: 0 0 0 2px #8bd3ff, 0 0 6px rgba(139, 211, 255, .3); } }
.od-laptop { position: relative; display: block; width: 46px; height: 30px; margin: 0 0 6px 10px; background: #c9cbe0; border: 3px solid var(--o-ink); border-radius: 4px 4px 0 0; }
.od-laptop::after { content: ""; position: absolute; left: -12px; right: -12px; top: 100%; height: 6px; background: var(--o-ink); border-radius: 0 0 3px 3px; }
.od-laptop.on { background: #e6ddff; box-shadow: 0 0 14px rgba(182, 166, 255, .8); }
.od-books { display: flex; align-items: flex-end; gap: 2px; margin: 0 0 0 6px; }
.od-books span { display: block; width: 11px; height: 32px; background: #e5484d; border: 2px solid var(--o-ink); }
.od-books span:nth-child(2) { height: 26px; background: #3e63dd; }
.od-books span:nth-child(3) { height: 36px; background: #12a594; }
.desk-mug { position: absolute; right: 14px; bottom: 100%; width: 15px; height: 17px; margin-bottom: -3px; background: #fff; border: 3px solid var(--o-ink); border-radius: 0 0 5px 5px; }
.desk-mug::after { content: ""; position: absolute; right: -9px; top: 2px; width: 6px; height: 7px; border: 3px solid var(--o-ink); border-left: 0; border-radius: 0 5px 5px 0; }

.nameplate { display: flex; flex-direction: column; align-items: center; margin-top: 3px; line-height: 1.25; }
.nameplate strong { font-size: 13px; color: #2a2233; background: #fff8e1; border: 2px solid var(--o-ink); border-radius: 4px; padding: 0 9px; }
.nameplate span { margin-top: 3px; max-width: 168px; font-size: 11px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-task { display: inline-flex; align-items: center; gap: 4px; max-width: 170px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: color-mix(in srgb, #fff 55%, transparent); color: #2a2233; }
.desk-task .icon { width: 12px; height: 12px; flex: none; }
.desk-task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-task.on { background: var(--accent); color: #fff; }

/* Office agent card */
.office-jobs { display: flex; flex-direction: column; gap: 6px; }
.office-job {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.office-job:hover { border-color: var(--accent); }
.office-job > .icon { width: 15px; height: 15px; color: var(--accent); flex: none; }
.office-job-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.office-job-text strong { font-size: 13px; }
.office-job-text span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.office-for { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.office-for .select { flex: 1; min-width: 0; }
.office-for select { width: 100%; max-width: none; }

@media (max-width: 860px) {
  .office { padding: 16px 12px 28px; gap: 14px; }
  .office-wall { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .office-window, .office-wall-side { display: none; }
  .office-floor { padding: 18px 6px 20px; }
  .desk-row { gap: 12px 6px; }
  .desk-station { width: 158px; }
  .seat { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .office-window .cloud, .od-monitor.on, .desk-station .bubble { animation: none; }
  .office-window { transition: none; }
}

/* "Add project info" tip in a conversation without project info (optional) */
.info-tip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.info-tip-icon { font-size: 16px; flex: none; }
.info-tip-text { flex: 1 1 320px; min-width: 0; }
.info-tip-text strong { color: var(--warning); }
.info-tip-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.info-tip .link-btn { color: var(--muted); }

/* Stop: shown next to Send while anything runs in this conversation */
.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  flex: none;
  margin-left: auto;
}
.stop-btn .icon { width: 14px; height: 14px; color: var(--danger); }
.stop-btn:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }
.stop-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stop-btn:disabled { opacity: .6; cursor: default; }
.composer-bar .stop-btn:not([hidden]) + .send-btn { margin-left: 0; }

.stopped-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
}
.stopped-text { flex: 1 1 220px; display: inline-flex; align-items: center; gap: 7px; }
.stopped-text .icon { width: 14px; height: 14px; color: var(--muted); flex: none; }
.version-error.stopped .error-title { color: var(--muted); }
.wb-task.state-stopped { opacity: .72; }
.wb-task.state-stopped::before { background: #8f8f9c; }
