/* fuse.css — the entire Fuse design system. Hand-written, no build step, light only.
   Bump ASSET_V in dashboard/templating.py on EVERY change to this file. */

/* ---------------- tokens ---------------- */
:root {
  --ink: #0f172a;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --accent: #f97316;
  --accent-deep: #ea580c;
  --accent-tint: #ffedd5;
  --accent-wash: #fff7ed;
  --ok: #15803d;
  --ok-tint: #dcfce7;
  --warn: #b45309;
  --warn-tint: #fef3c7;
  --err: #b91c1c;
  --err-tint: #fee2e2;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-lift: 0 10px 24px rgba(15, 23, 42, 0.12);
}

/* ---------------- base ---------------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
}
body.wash { background: var(--slate-50); }
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 1.75rem 0 0.6rem; }
a { color: inherit; }
small { color: var(--slate-500); }
code {
  font-size: 12px;
  background: var(--slate-100);
  border-radius: 4px;
  padding: 0.1rem 0.3rem;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.error { color: var(--err); }
form.inline { display: inline; }

/* ---------------- layout ---------------- */
.container { max-width: 60rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.container--wide { max-width: 74rem; }
.container--narrow { max-width: 34rem; }
.container--auth { max-width: 26rem; padding-top: 4rem; }

/* ---------------- chrome ---------------- */
.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--slate-100);
  flex-wrap: wrap;
}
.wordmark {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}
.wordmark .dot { color: var(--accent); font-size: 0.8em; }
.site-nav { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-600);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
}
.site-nav a:hover { background: var(--slate-100); color: var(--ink); }
.site-nav a.admin-link { font-weight: 500; }
.header-spacer { flex: 1; }
.bell {
  text-decoration: none;
  font-size: 1.05rem;
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
}
.bell:hover { background: var(--slate-100); }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.user-name { font-size: 13px; color: var(--slate-500); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-block;
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.35;
}
.btn:hover { border-color: var(--slate-400); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: #1e293b; border-color: #1e293b; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--danger { background: #fff; border-color: var(--err); color: var(--err); }
.btn--danger:hover { background: var(--err-tint); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--slate-600); }
.btn--ghost:hover { background: var(--slate-100); border-color: transparent; }
.btn--sm { font-size: 12.5px; padding: 0.25rem 0.7rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------- forms ---------------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
textarea,
select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  max-width: 100%;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.field { display: block; margin: 0 0 1rem; }
.field > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-600);
  margin-bottom: 0.3rem;
}
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field textarea,
.field select { width: 100%; }
.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 14px;
  margin: 0 0 0.9rem;
}

/* ---------------- cards ---------------- */
.card {
  background: #fff;
  border: 1px solid var(--slate-100);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.25rem;
}
.card > h2:first-child { margin-top: 0; }
.card--row { display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.2rem; }
.card--row .grow { flex: 1; min-width: 0; }

/* ---------------- hero / catalog (loud) ---------------- */
.hero { text-align: center; padding: 2rem 0 1.25rem; }
.hero h1 { font-size: 2rem; margin: 0 0 0.35rem; }
.hero p { color: var(--slate-500); margin: 0 0 1.25rem; }
.search-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  max-width: 34rem;
  margin: 0 auto 1rem;
}
.search-input {
  flex: 1;
  font: inherit;
  font-size: 15px;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--slate-200);
  border-radius: 999px;
  background: var(--slate-50);
}
.search-input:focus {
  background: #fff;
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.chip-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0 0 0.75rem;
}
.chip {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  border: 1px solid transparent;
}
.chip--all { background: var(--slate-100); color: var(--slate-600); }
.chip--active { box-shadow: inset 0 0 0 1.5px currentColor; font-weight: 700; }
.shelf {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 1.75rem 0 0.75rem;
}
.shelf h2 { margin: 0; }
.shelf a { font-size: 13px; font-weight: 600; color: var(--slate-500); text-decoration: none; }
.shelf a:hover { color: var(--ink); }
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 1rem;
}
.app-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: #fff;
  border: 1px solid var(--slate-100);
  border-radius: var(--r-lg);
  padding: 0.9rem;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.app-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.app-tile__icon {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: var(--slate-100);
}
.app-tile__icon img { width: 100%; height: 100%; object-fit: cover; }
.app-tile__name { font-weight: 700; font-size: 14px; color: var(--ink); }
.app-tile__meta { font-size: 12px; color: var(--slate-500); }
.badge--new {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  z-index: 1;
}
.tile--ghost {
  border: 2px dashed var(--slate-200);
  background: var(--slate-50);
  box-shadow: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--slate-500);
  font-weight: 600;
  min-height: 11rem;
}
.tile--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: none;
  box-shadow: none;
}

/* ---------------- page head / detail ---------------- */
.page-head {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin: 0 0 1.5rem;
}
.page-head h1 { margin: 0 0 0.3rem; }
.page-head__icon {
  width: 6.5rem;
  height: 6.5rem;
  border-radius: var(--r-lg);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 800;
  color: #fff;
  overflow: hidden;
  background: var(--slate-100);
}
.page-head__icon img { width: 100%; height: 100%; object-fit: cover; }
.page-head__meta {
  font-size: 13px;
  color: var(--slate-500);
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.page-head__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.shots { display: flex; gap: 0.6rem; overflow-x: auto; padding-bottom: 0.5rem; margin: 0 0 1.25rem; }
.shots img { height: 10rem; border-radius: var(--r-md); border: 1px solid var(--slate-100); }
.stars { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; font-size: 14px; }

/* ---------------- workbench (quiet) ---------------- */
.chat {
  border: 1px solid var(--slate-100);
  border-radius: var(--r-lg);
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 1rem;
  max-height: 28rem;
  overflow-y: auto;
}
.msg {
  max-width: 85%;
  padding: 0.5rem 0.8rem;
  border-radius: var(--r-md);
  margin: 0 0 0.6rem;
  font-size: 14px;
  overflow-wrap: break-word;
}
.msg-user {
  margin-left: auto;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-user strong { font-weight: 600; }
.msg-assistant {
  margin-right: auto;
  background: var(--slate-100);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.tool-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--slate-500);
  margin: 0 0 0.4rem;
  padding-left: 0.25rem;
}
.tool-line.error { color: var(--err); }
.question {
  background: var(--warn-tint);
  padding: 0.5rem 0.8rem;
  border-radius: var(--r-sm);
  font-size: 14px;
}
.composer { margin-top: 0.75rem; }
.composer textarea { width: 100%; border-radius: var(--r-md); }
.composer-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; align-items: center; }

/* ---------------- tables (quiet) ---------------- */
.table-wrap { overflow-x: auto; }
table.table { border-collapse: collapse; width: 100%; font-size: 14px; background: #fff; }
.table th {
  position: sticky;
  top: 0;
  background: var(--slate-50);
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--slate-200);
}
.table td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}
.table tbody tr:hover td, .table > tr:hover td { background: var(--slate-50); }
.notif--unread td { font-weight: 700; }

/* ---------------- banners / empty ---------------- */
.banner {
  border-radius: var(--r-md);
  padding: 0.6rem 1rem;
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 1rem;
}
.banner--ok { background: var(--ok-tint); color: var(--ok); }
.banner--warn { background: var(--warn-tint); color: var(--warn); }
.banner--err { background: var(--err-tint); color: var(--err); }
.empty { text-align: center; color: var(--slate-500); padding: 2rem 1rem; font-size: 14px; }
.empty__emoji { display: block; font-size: 1.8rem; margin-bottom: 0.4rem; }
.empty p { margin: 0; }

/* ---------------- auth (signin / deactivated) ---------------- */
.auth-card {
  background: #fff;
  border: 1px solid var(--slate-100);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  padding: 2.5rem 2rem;
  text-align: center;
}
.auth-card .wordmark { font-size: 1.8rem; }
.auth-card h1 { margin: 1rem 0 0.4rem; }
.auth-card p { color: var(--slate-500); }

/* ---------------- category tints (8, hash-indexed via cat_tint) ---------------- */
.tint-0 { background: #ffedd5; color: #9a3412; } /* orange */
.tint-1 { background: #dbeafe; color: #1e40af; } /* blue */
.tint-2 { background: #dcfce7; color: #166534; } /* green */
.tint-3 { background: #f3e8ff; color: #6b21a8; } /* purple */
.tint-4 { background: #fce7f3; color: #9d174d; } /* pink */
.tint-5 { background: #ccfbf1; color: #115e59; } /* teal */
.tint-6 { background: #fef3c7; color: #92400e; } /* amber */
.tint-7 { background: #e2e8f0; color: #334155; } /* slate */

/* ---------------- tile gradients (8, hash-indexed via tile_gradient) ---------------- */
.grad-0 { background: linear-gradient(135deg, #fb923c, #ea580c); } /* orange */
.grad-1 { background: linear-gradient(135deg, #60a5fa, #2563eb); } /* blue */
.grad-2 { background: linear-gradient(135deg, #4ade80, #16a34a); } /* green */
.grad-3 { background: linear-gradient(135deg, #c084fc, #7c3aed); } /* purple */
.grad-4 { background: linear-gradient(135deg, #f472b6, #db2777); } /* pink */
.grad-5 { background: linear-gradient(135deg, #2dd4bf, #0d9488); } /* teal */
.grad-6 { background: linear-gradient(135deg, #fbbf24, #d97706); } /* amber */
.grad-7 { background: linear-gradient(135deg, #94a3b8, #475569); } /* slate */

/* ---------------- small screens (mobile pass, Task 7) ---------------- */
@media (max-width: 40rem) {
  .site-header { gap: 0.5rem; padding: 0.6rem 0.9rem; }
  .user-name { display: none; }
  .site-nav a { padding: 0.3rem 0.55rem; font-size: 13px; }
  .container { padding: 1rem 0.9rem 2.5rem; }
  .container--auth { padding-top: 4rem; }
  .hero { padding: 1.25rem 0 1rem; }
  .hero h1 { font-size: 1.5rem; }
  .search-row { flex-direction: column; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0.7rem; }
  .tile--ghost { min-height: 9rem; }
  .page-head__icon { width: 5rem; height: 5rem; font-size: 2rem; }
  .card { padding: 1rem; }
  .card--row { flex-wrap: wrap; padding: 0.9rem 1.2rem; }
  .table th, .table td { padding: 0.4rem 0.5rem; font-size: 13px; }
}

/* ---------------- workspace (builder three-zone: rail | chat | preview) ---------------- */
.container--workspace { max-width: none; padding: 0.75rem 1rem 1rem; }
.workspace {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  height: calc(100vh - 6rem);
  min-height: 30rem;
}
.ws-rail {
  flex: none;
  width: 56px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.25rem 0 0.25rem 6px;
}
.ws-rail__btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--slate-600);
  font: inherit;
  padding: 0.45rem 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
}
.ws-rail__btn:hover { background: var(--slate-100); color: var(--ink); }
.ws-rail__btn.is-active { color: var(--ink); }
.ws-rail__btn.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}
.ws-rail__glyph { font-size: 1.1rem; line-height: 1.2; }
.ws-rail__label { font-size: 11px; font-weight: 600; letter-spacing: -0.02em; max-width: 100%; }

.ws-tabs { display: none; }
.ws-tab {
  flex: 1;
  border: 1px solid var(--slate-200);
  background: #fff;
  color: var(--slate-600);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}
.ws-tab.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.ws-chat {
  position: relative;
  flex: 0 1 38%;
  min-width: 24rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ws-back { flex: none; margin: 0 0 0.5rem; }
.ws-chat #banner { flex: none; }
.ws-chat .chat { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
.ws-chat .composer { flex: none; }

.ws-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #fff;
  border: 1px solid var(--slate-100);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lift);
  padding: 1.1rem 1.2rem;
  overflow-y: auto;
}
.ws-panel[hidden] { display: none; }
.ws-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 0.75rem;
}
.ws-panel__head h2 { margin: 0; font-size: 1rem; }
.ws-panel__close {
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.95rem;
  color: var(--slate-500);
  padding: 0.2rem 0.5rem;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.ws-panel__close:hover { background: var(--slate-100); color: var(--ink); }

.ws-preview {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.ws-preview__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0 0 0.6rem;
}
.ws-preview__head h2 { margin: 0; font-size: 1rem; }
.ws-preview__spacer { flex: 1; }
.ws-preview__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  border: 1px solid var(--slate-200);
  border-radius: var(--r-lg);
  background: var(--slate-50);
  overflow: hidden;
}
.ws-preview__frame { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.ws-preview__empty { margin: auto; text-align: center; color: var(--slate-500); font-size: 14px; }
.ws-preview__caption { flex: none; font-size: 12px; color: var(--slate-500); margin: 0.5rem 0 0; }

/* below the page breakpoint: horizontal rail + Chat|Preview tabs */
@media (max-width: 52rem) {
  .workspace { flex-direction: column; height: auto; min-height: 0; }
  .ws-rail { flex-direction: row; width: auto; padding: 0 0 0.25rem; gap: 0.15rem; }
  .ws-rail__btn { width: auto; flex: none; padding: 0.35rem 0.6rem; }
  .ws-rail__btn.is-active::before {
    left: 20%;
    right: 20%;
    top: auto;
    bottom: 0;
    width: auto;
    height: 3px;
  }
  .ws-tabs { display: flex; gap: 0.5rem; margin: 0 0 0.75rem; }
  .ws-chat { min-width: 0; }
  .ws-chat .chat { height: 55vh; }
  .ws-preview__body { flex: none; height: 60vh; }
  .workspace[data-tab="chat"] .ws-preview { display: none; }
  .workspace[data-tab="preview"] .ws-chat { display: none; }
}
