/* Matches client/src/theme/palettes.ts's "dark" (Original) palette exactly —
   the website used to carry its own violet-tinted neutral/surface colors,
   independent of the real in-app theme; this keeps both in sync so the
   account website and the app read as the same product. */
:root {
  --bg: #0e1211;
  --bg-elevated: #141918;
  --bg-card: #181f1d;
  --bg-card-alt: #1e2624;
  --border: #2a3331;
  --text-primary: #ecf1ef;
  --text-secondary: #9aacaa;
  --text-muted: #788987;
  --accent: #339487;
  --accent-bright: #4bb8a9;
  --success: #6fbf8a;
  --warning: #d9a25c;
  --danger: #d9705f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg);
}

.wrap { max-width: 640px; margin: 0 auto; padding: 32px 20px 80px; }

.nav { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 32px; }
@media (max-width: 640px) {
  .nav .brand { width: 100%; margin-bottom: 6px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
}
.nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 9px;
  transition: color 0.15s ease, background 0.15s ease;
}
.nav a:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.05); }
.nav a.active { color: var(--accent-bright); background: rgba(51, 148, 135, 0.14); }
.nav .brand { display: inline-flex; align-items: center; font-weight: 800; font-size: 18px; color: var(--text-primary); margin-right: auto; padding: 0; }
.nav .brand:hover { background: none; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 16px; color: var(--text-secondary); margin: 0 0 16px; font-weight: 500; line-height: 1.5; }
p.muted { color: var(--text-muted); font-size: 13px; }

label { display: block; font-size: 13px; color: var(--text-secondary); font-weight: 600; margin-bottom: 6px; margin-top: 14px; }
input, select, textarea {
  width: 100%;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(51, 148, 135, 0.22);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }

button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  margin-top: 16px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 14px rgba(51, 148, 135, 0.28);
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
button.secondary { background: var(--bg-card-alt); color: var(--accent-bright); box-shadow: none; border: 1px solid var(--border); }
button.secondary:hover:not(:disabled) { background: var(--bg-elevated); filter: none; }
button:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
button svg { flex-shrink: 0; }

.pack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.pack {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
}
.pack .amount { font-size: 20px; font-weight: 800; }
.pack .bonus { color: var(--success); font-size: 12px; margin-top: 4px; }

.balance { font-size: 32px; font-weight: 800; color: var(--accent-bright); }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }

.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--bg-card-alt); color: var(--text-secondary); }
.pill.ok { background: var(--success); color: #08130e; }
.pill.err { background: var(--danger); color: #1a0508; }
.mcp-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.mcp-item:last-child { border-bottom: none; }
.mcp-item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.mcp-item-head .name { font-weight: 700; }
.mcp-item .url { color: var(--text-muted); font-size: 13px; word-break: break-all; }
.mcp-actions { display: flex; gap: 8px; margin-top: 10px; }
.mcp-actions button { width: auto; margin-top: 0; padding: 8px 14px; font-size: 13px; }
details.tool { margin-top: 10px; }
details.tool summary { cursor: pointer; color: var(--accent-bright); font-size: 13px; font-weight: 600; }
pre.schema { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 12px; overflow-x: auto; color: var(--text-secondary); margin-top: 8px; }

@keyframes mcp-spin { to { transform: rotate(360deg); } }
@keyframes mcp-pop { from { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.15); } to { transform: scale(1); opacity: 1; } }
.mcp-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.mcp-status .icon { display: inline-block; width: 16px; height: 16px; }
.mcp-status.connecting .icon { border: 2px solid var(--border); border-top-color: var(--accent-bright); border-radius: 50%; animation: mcp-spin 0.7s linear infinite; }
.mcp-status.success .icon, .mcp-status.error .icon { animation: mcp-pop 0.35s ease; border-radius: 50%; text-align: center; line-height: 16px; font-size: 11px; color: #fff; }
.mcp-status.success .icon { background: var(--success); color: #08130e; }
.mcp-status.error .icon { background: var(--danger); }

/* Owner panel — History access section. A real, permanent per-user audit
   record (server/src/routes/owner.ts's /users/:id/history), deliberately
   more detailed than the plain toggle-row list elsewhere on this page:
   each entry is its own bordered card so a long session of real prompts,
   images, and videos reads as a real timeline, not a wall of text. */
.history-search { display: flex; gap: 8px; margin-bottom: 14px; }
.history-search input { margin-top: 0; flex: 1; min-width: 0; }
.history-search button { width: auto; margin-top: 0; padding: 0 16px; flex-shrink: 0; }
.history-summary { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.history-section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 20px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.history-section-label:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.history-entry {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card-alt);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.history-entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.history-role {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(51, 148, 135, 0.14);
  color: var(--accent-bright);
}
.history-role.assistant { background: rgba(111, 191, 138, 0.14); color: var(--success); }
.history-time { font-size: 12px; color: var(--text-muted); margin-left: auto; }
.history-content { font-size: 13.5px; color: var(--text-primary); white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.history-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.history-attachment img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.history-attachment a { color: var(--accent-bright); text-decoration: none; font-weight: 600; }
.history-attachment a:hover { text-decoration: underline; }

/* Build page — real Projects + real streaming chat on web, laid out as two
   distinct panels (a sidebar-like project list + a main chat panel) rather
   than one undifferentiated block. */
.build-wrap { max-width: 1080px; }
.build-header { margin-bottom: 20px; }
.build-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 760px) { .build-layout { grid-template-columns: minmax(0, 1fr); } }

.panel-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0 0 14px; }

.new-project-form { display: flex; gap: 8px; margin-bottom: 18px; }
.new-project-form input { margin-top: 0; flex: 1; min-width: 0; }
.new-project-form button { width: auto; margin-top: 0; padding: 0 16px; flex-shrink: 0; }

.project-list { display: flex; flex-direction: column; gap: 8px; max-height: 460px; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.project-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.project-item:hover { border-color: rgba(51, 148, 135, 0.4); }
.project-item.active { border-color: var(--accent); background: rgba(51, 148, 135, 0.14); }
.project-item .info { flex: 1; min-width: 0; }
.project-item .title { font-weight: 700; font-size: 14px; }
.project-item .preview { color: var(--text-muted); font-size: 12px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .chevron { color: var(--text-muted); flex-shrink: 0; }
.project-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 8px; }

.chat-panel-card { display: flex; flex-direction: column; height: 620px; padding: 0; overflow: hidden; }
.chat-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-panel-header .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.chat-panel-header.active .dot { background: var(--success); }
.chat-panel-header .name { font-weight: 700; font-size: 15px; }

.chat-messages { flex: 1; overflow-x: hidden; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.msg-group { display: flex; flex-direction: column; gap: 4px; max-width: 85%; min-width: 0; }
.msg-group.user { align-self: flex-end; align-items: flex-end; }
.msg-group.assistant { align-self: flex-start; align-items: flex-start; }
.msg-role { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0 4px; }
.msg {
  min-width: 0;
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}
.msg pre.schema { max-width: 100%; overflow-x: auto; white-space: pre; }
.msg-group.user .msg { background: var(--accent); color: #fff; }
.msg-group.assistant .msg { background: var(--bg-card-alt); border: 1px solid var(--border); }

.chat-input-row { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input-row textarea { flex: 1; min-width: 0; resize: none; min-height: 46px; max-height: 120px; }
.chat-input-row button { width: auto; margin-top: 0; padding: 0 22px; flex-shrink: 0; align-self: flex-end; height: 46px; }
.empty-hint { color: var(--text-muted); font-size: 13px; text-align: center; margin: auto; max-width: 260px; line-height: 1.6; }

/* Legal pages (privacy.html / terms.html) — a long-form reading layout
   inside the same card system as the rest of the site, plus a highlight
   for placeholder values (domain/support email/legal entity) that aren't
   real yet, so nothing gets mistaken for a live value. */
.legal-updated { color: var(--text-muted); font-size: 13px; margin: -4px 0 20px; }
.legal-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 24px; padding: 0; list-style: none; }
.legal-toc a { color: var(--text-secondary); text-decoration: none; font-size: 13px; font-weight: 600; }
.legal-toc a:hover { color: var(--accent-bright); }
.callout { background: rgba(255, 196, 102, 0.1); border: 1px solid rgba(255, 196, 102, 0.35); border-radius: 14px; padding: 16px 18px; margin-bottom: 24px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.callout strong { color: var(--warning); }
.policy section { margin-bottom: 28px; }
.policy section:last-child { margin-bottom: 0; }
.policy h3 { font-size: 17px; margin: 0 0 10px; letter-spacing: -0.01em; }
.policy p { font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin: 0 0 12px; }
.policy ul { margin: 0 0 12px; padding-left: 20px; }
.policy li { font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 6px; }
.policy li strong { color: var(--text-primary); }
.placeholder { background: rgba(255, 196, 102, 0.16); color: var(--warning); border-radius: 5px; padding: 1px 6px; font-weight: 600; font-size: 0.95em; }
.legal-footer-links { display: flex; gap: 16px; justify-content: center; margin-top: 24px; }
.legal-footer-links a { color: var(--text-muted); font-size: 13px; text-decoration: underline; }
