:root {
  --bg: #f1f4fa;
  --sidebar: #f7f9fc;
  --card: #ffffff;
  --soft: #f7f9fc;
  --text: #1a2332;
  --muted: #7a8799;
  --line: #e3e8ef;
  --line-strong: #b7c5d8;
  --accent: #3b5bdb;
  --accent-soft: #e8eefc;
  --select: #3b5bdb;
  --mint: #c8e6c9;
  --sky: #c5dff8;
  --sand: #f3e4b8;
  --lavender: #ddd6f3;
  --danger: #c62828;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(28, 36, 48, 0.04), 0 8px 24px rgba(28, 36, 48, 0.06);
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-button { display: none; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--select); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.85em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
strong { font-weight: 600; }
.status { min-height: 1.2em; margin: 0.5rem 0 0; font-size: 0.88rem; }
.status.error { color: var(--danger); }
.hint { font-size: 0.8rem; margin: 0.35rem 0 0.5rem; }
.callout { margin: 0; font-size: 0.88rem; }

/* The hidden attribute always wins (buttons and labels set their own display). */
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: var(--text); }

button, a.ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}
button.ghost, a.ghost, .ghost-file {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 500;
}
button.ghost:hover, a.ghost:hover, .ghost-file:hover { background: #fff; border-color: #cfd7e3; text-decoration: none; }
button.danger, .danger { color: var(--danger); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.82rem; }
.btn-block { width: 100%; justify-content: center; }
.icon { width: 34px; justify-content: center; padding: 0.35rem 0; }
.ghost-file { display: inline-flex; align-items: center; border-radius: 10px; cursor: pointer; margin: 0; }
.ghost-file input { display: none; }

input, select, textarea {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 111, 237, 0.25); border-color: var(--select); }
input:not([type="file"]):invalid:not(:placeholder-shown) { border-color: var(--danger); }
textarea { resize: vertical; min-height: 72px; }
label { display: block; margin: 0.55rem 0; color: var(--muted); font-size: 0.86rem; font-weight: 500; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #4a5568;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.id-chip {
  font-weight: 500;
  font-size: 0.75rem;
  background: #eef5ff;
  color: #2a55b8;
  padding: 0.05rem 0.4rem;
  border-radius: 6px;
  margin-left: 0.35rem;
}

/* —— Shell —— */
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 1.1rem 0.9rem;
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.35rem 0.55rem 1.1rem; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--mint), var(--sky));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.brand strong { display: block; font-size: 0.95rem; }
.brand span { display: block; font-size: 0.75rem; color: var(--muted); }

.nav-label {
  margin: 0.85rem 0.55rem 0.35rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.side-nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.side-nav button, .side-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: #4a5568;
  font-weight: 500;
  padding: 0.65rem 0.75rem;
  border-radius: 999px;
  text-decoration: none;
}
.side-nav button:hover, .side-nav .nav-link:hover { background: rgba(255, 255, 255, 0.65); }
.side-nav button.active, .side-nav .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: none; }
.nav-ico { width: 1.25rem; text-align: center; opacity: 0.75; font-size: 0.85rem; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.admin-chip { display: flex; align-items: center; gap: 0.65rem; padding: 0.45rem 0.35rem; }
.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--lavender), var(--sky));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.admin-chip strong { display: block; font-size: 0.88rem; }
.admin-chip span { display: block; font-size: 0.72rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace { display: flex; flex-direction: column; min-width: 0; }
.page-header { padding: 1.35rem 1.75rem 0.5rem; }
.page-header h1 { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header .muted { margin: 0.2rem 0 0; font-size: 0.9rem; }
.page-back { margin: 0 0 0.35rem !important; font-size: 0.85rem; }
.page-back a { color: var(--muted); }
.page-back a.ghost { color: var(--text); }

main { padding: 0.85rem 1.75rem 2rem; display: flex; flex-direction: column; gap: 1rem; }
.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 1rem; }

.tabbar {
  display: inline-flex;
  align-self: flex-start;
  gap: 0.25rem;
  background: #e4e9f0;
  border-radius: 999px;
  padding: 0.25rem;
}
.tabbar button {
  background: transparent;
  border: none;
  color: #4a5568;
  font-weight: 500;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
}
.tabbar button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

/* —— Cards / forms —— */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(227, 232, 239, 0.9);
  padding: 1.1rem 1.25rem 1.25rem;
}
.card-head { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.5rem; }
.card-head h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.card-head .muted { margin: 0.15rem 0 0; font-size: 0.82rem; }
.card-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.accent-mint { background: var(--mint); }
.accent-sky { background: var(--sky); }
.accent-sand { background: var(--sand); }

.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 1rem; align-items: end; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form > button { margin: 0.55rem 0; justify-self: start; }
.row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.75rem; }

.preview-box {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  font-family: var(--mono);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
}
details summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }

/* —— Home —— */
.home-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(197, 223, 248, 0.55), transparent 55%),
    radial-gradient(ellipse at 100% 0%, rgba(200, 230, 201, 0.4), transparent 50%),
    var(--card);
}
.home-kicker { margin: 0 0 0.35rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.home-hero h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.home-hero .muted { margin: 0.35rem 0 0; }
.home-hero-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; }
.home-stat { display: block; text-align: left; color: var(--text); border: 1px solid var(--line); }
.home-stat:hover { border-color: var(--line-strong); }
.home-stat-label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }
.home-stat strong { display: block; font-size: 1.75rem; letter-spacing: -0.03em; line-height: 1.1; margin-bottom: 0.25rem; }
.home-stat .muted { font-size: 0.8rem; font-weight: 400; }

.home-list, .users-list, .avatar-list { display: flex; flex-direction: column; gap: 0.4rem; }
.home-list-item, .avatar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-weight: 500;
}
.home-list-item:hover, .avatar-row:hover { border-color: var(--line); background: #fff; }
.avatar-row { background: #fff; border-color: var(--line); padding: 0.8rem 0.9rem; }
.avatar-row:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.home-list-avatar, .avatar-thumb {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #e8f1fb;
  color: #3a5a7a;
  font-weight: 650;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar-thumb { width: 48px; height: 48px; border-radius: 12px; }
.avatar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.home-list-text { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1; }
.home-list-text strong { font-size: 0.93rem; }
.home-list-text .muted { font-size: 0.8rem; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-list-card { padding: 0.65rem !important; }
.user-row { display: flex; align-items: center; gap: 0.4rem; }
.user-row .home-list-item { flex: 1; min-width: 0; }
.button-link { display: inline-block; padding: 0.35rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none; }
.home-list-item.inactive { opacity: 0.6; }
.pill-off { background: #fdeceb; color: var(--danger); }

/* —— Templates —— */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }
.template-grid .empty-hint { grid-column: 1 / -1; margin: 0; }
.template-card {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.template-preview img { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; background: #e8edf3; display: block; }
.preview-empty {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.85rem;
}
.template-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }

/* —— Media —— */
.add-media-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.add-media-grid form { display: flex; flex-direction: column; }
.add-media-grid form button { align-self: flex-start; margin-top: 0.35rem; }

/* Media list (user page, Media tab): one row per media, a click opens media.html. */
.media-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.media-toolbar input[type="search"] { flex: 1 1 220px; max-width: 360px; width: auto; }
.media-toolbar select { width: auto; }
/* Columns: thumb, name, [user,] type, [size,] used, settings, added, arrow. Header and rows share the c-* classes. */
.media-list-head, .media-row {
  display: grid;
  grid-template-columns: var(--sel,) 48px minmax(0, 1fr) 96px 76px 56px minmax(110px, 170px) 112px 14px;
  gap: 0 0.9rem;
  align-items: center;
}
.with-user .media-list-head, .with-user .media-row {
  grid-template-columns: var(--sel,) 48px minmax(0, 1fr) minmax(90px, 150px) 96px 56px minmax(110px, 150px) 104px 14px;
}
.media-list-head {
  padding: 0 0.6rem 0.45rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.media-row { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); border-radius: 8px; color: inherit; text-decoration: none; }
.media-row:last-child { border-bottom: none; }
.media-row:hover, .media-row:focus-visible { background: var(--soft); text-decoration: none; }
.media-row .media-thumb img, .media-row .media-icon { width: 48px; height: 48px; border-radius: 8px; font-size: 0.7rem; }
.media-row .media-icon.kind-video, .media-row .media-icon.kind-video_link { font-size: 1.1rem; }
.media-row .c-name { min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.media-row .c-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.media-row .c-name .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; }
.media-row .c-size, .media-row .c-date, .media-row .c-user { font-size: 0.82rem; color: var(--muted); }
.media-row .c-size, .media-row .c-date { white-space: nowrap; }
.media-row .c-user { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.media-row .c-flags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.media-row .c-go { color: var(--muted); font-size: 1.25rem; text-align: right; }
/* Row selection: a checkbox column in front, bulk-action bar above the list. */
.selectable { --sel: 22px; }
.media-link { display: contents; color: inherit; text-decoration: none; }
.media-row:focus-within { background: var(--soft); }
.media-row.selected { background: #eef5ff; }
.media-row .c-select, .media-list-head .c-select { display: flex; align-items: center; justify-content: center; }
.c-select input { width: auto; margin: 0; cursor: pointer; }
.media-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; min-height: 2.6rem; padding: 0.3rem 0.6rem; margin-bottom: 0.4rem; border-radius: 8px; color: var(--muted); font-size: 0.85rem; }
.media-bulk:not(.active) .bulk-count { font-weight: 400; }
.media-bulk.active { background: #eef5ff; color: var(--text); font-size: 0.95rem; }
.media-bulk .bulk-msg:empty { display: none; }
.toolbar-spacer { margin-left: auto; }
.pill-none { background: transparent; color: var(--muted); font-weight: 500; }
.pill-custom { background: #e5eefc; color: #2a55b8; }
.media-empty { margin: 0; padding: 1rem 0.2rem 0.4rem; }
@media (max-width: 900px) {
  .media-list-head, .media-row, .with-user .media-list-head, .with-user .media-row { grid-template-columns: var(--sel,) 48px minmax(0, 1fr) 88px 14px; }
  .c-size, .c-user, .c-used, .c-flags, .c-date { display: none; }
}

/* One media's page (media.html). */
.media-page { display: flex; flex-direction: column; gap: 1rem; max-width: 980px; }
.media-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.media-view { border-radius: 10px; overflow: hidden; background: #0b0d12; display: grid; place-items: center; min-height: 180px; }
.media-view img, .media-view video { display: block; max-width: 100%; max-height: 360px; }
.media-view.is-text { background: var(--soft); border: 1px solid var(--line); }
.media-view pre { margin: 0; padding: 0.8rem; width: 100%; max-height: 300px; overflow: auto; white-space: pre-wrap; word-break: break-word; font-size: 0.8rem; }
.media-view-note { padding: 1.2rem; text-align: center; color: var(--muted); font-size: 0.9rem; line-height: 1.6; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; margin: 0.9rem 0 0; font-size: 0.88rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; line-height: 1.7; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.two-col textarea { width: 100%; }
.media-page textarea { width: 100%; }
.danger-card { border-color: #f1c9c7; }

/* Tabs of a media page: Default + one per avatar using it. Each section says whether it uses the default. */
#media-tabs { flex-wrap: wrap; border-radius: 18px; margin-bottom: 0.9rem; }
#media-tabs .dot { display: inline-block; width: 0.45rem; height: 0.45rem; margin-left: 0.25rem; border-radius: 50%; background: var(--select); vertical-align: middle; }
.tab-body { display: flex; flex-direction: column; gap: 1rem; }
.tab-hint { margin: 0; font-size: 0.85rem; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-bottom: 0.35rem; }
.section-head .section-h { margin: 0; }
.section-state { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.section-summary { margin: 0.2rem 0 0; font-size: 0.9rem; color: #4a5568; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  margin: 0;
  min-height: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }
@media (max-width: 900px) { .media-detail, .two-col { grid-template-columns: 1fr; } }

.media-thumb img, .media-icon {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  background: #e8edf3;
  color: #4a5568;
}
.media-icon.kind-pdf { background: #fde2e1; color: #b3261e; }
.media-icon.kind-text { background: #e3f0e4; color: #2e6b34; }
.media-icon.kind-video_link { background: #ebe5f8; color: #5b3fa6; font-size: 1.4rem; }
.media-icon.kind-video { background: #ebe5f8; color: #5b3fa6; font-size: 1.4rem; }
.media-icon.kind-model { background: #e0eefc; color: #1f5fa8; font-size: 1.1rem; font-weight: 700; }

/* 3D setup: preview + rotation / spin / animation controls, description, then the screen layout. */
.model-edit { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.6rem; width: 100%; max-width: 760px; }
.model-edit h4 { margin: 0.4rem 0 0; font-size: 0.9rem; }
.model-edit > label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }
.model-setup { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(200px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 760px) { .model-setup { grid-template-columns: 1fr; } }
.model-preview { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: radial-gradient(circle at 50% 40%, #2a3140, #0b0d12); }
.model-preview model-viewer, .layout-media.is-model model-viewer { width: 100%; height: 100%; --poster-color: transparent; }
.layout-media.is-model { background: transparent; box-shadow: none; }
.layout-media.is-model model-viewer { pointer-events: none; }
.model-controls { display: flex; flex-direction: column; gap: 0.55rem; font-size: 0.85rem; }
.model-controls label { display: flex; flex-direction: column; gap: 0.2rem; }
.model-controls label.check { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0.4rem; }
.model-controls label.check input { width: auto; margin: 0; }
.model-controls input[type="range"] { width: 100%; }
.model-controls .val { color: var(--muted, #6b7280); font-variant-numeric: tabular-nums; }

/* Screen layout editor: same fit maths as the Unreal HUD (WebHud/index.html layoutMedia). */
.layout-edit { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 0.5rem; width: 100%; max-width: 760px; }
.layout-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #0b0d12 center / cover no-repeat;
  user-select: none;
  touch-action: none;
}
.layout-screen::after {
  content: "chat";
  position: absolute;
  right: 2%;
  bottom: 3%;
  width: 26%;
  height: 30%;
  border-radius: 6px;
  background: rgba(30, 34, 44, 0.75);
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.layout-media {
  position: absolute;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  outline: 2px solid var(--select);
  cursor: grab;
  background: #1d1a2b;
  color: #cfc4f5;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  z-index: 1;
}
.layout-media:active { cursor: grabbing; }
.layout-media img, .layout-media video { width: 100%; height: 100%; display: block; pointer-events: none; }
.hud-edit { display: grid; grid-template-columns: minmax(0, 2fr) minmax(200px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .hud-edit { grid-template-columns: 1fr; } }
.layout-screen.hud-screen::after { display: none; }
.hud-controls { display: flex; flex-direction: column; gap: 0.55rem; font-size: 0.85rem; }
.hud-controls label { display: flex; flex-direction: column; gap: 0.2rem; }
.hud-controls input[type="range"] { width: 100%; }
.hud-chat {
  position: absolute;
  display: flex;
  flex-direction: column;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(14, 16, 22, var(--hud-opacity, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  outline: 2px solid var(--select);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  color: #e8eaf0;
  font-size: calc(0.5rem * var(--hud-text, 1));
  cursor: grab;
  z-index: 1;
}
.hud-chat:active { cursor: grabbing; }
.hud-chat-head { display: flex; align-items: center; gap: 0.35em; padding: 0.5em 0.8em; background: rgba(255, 255, 255, 0.05); font-weight: 600; }
.hud-chat-head .dot { width: 0.6em; height: 0.6em; border-radius: 50%; background: #37d0a0; }
.hud-chat-body { flex: 1; display: flex; flex-direction: column; gap: 0.4em; padding: 0.6em 0.8em; overflow: hidden; }
.hud-bubble { align-self: flex-start; max-width: 85%; padding: 0.35em 0.6em; border-radius: 0.6em; background: rgba(255, 255, 255, 0.07); }
.hud-bubble.user { align-self: flex-end; background: rgba(79, 140, 255, 0.2); }
.hud-chat-input { margin: 0.5em; padding: 0.4em 0.6em; border-radius: 0.5em; border: 1px solid rgba(255, 255, 255, 0.12); color: #9aa0ae; }
.layout-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; font-size: 0.82rem; }
.layout-controls input[type="range"] { flex: 1; min-width: 120px; }

/* On / off switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; font-size: 0.8rem; color: var(--muted); flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: #cfd6e0; position: relative; transition: background 0.15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 0.15s; }
.switch input:checked + .track { background: #2e9d5b; }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch .switch-text { min-width: 2.6rem; }
.switch input:focus-visible + .track { outline: 2px solid var(--select); outline-offset: 2px; }
.avatar-row-wrap { display: flex; align-items: center; gap: 0.75rem; }
.avatar-row-wrap .avatar-row { flex: 1; min-width: 0; }
.avatar-row.off { opacity: 0.55; }

/* —— Avatar editor —— */
.editor-bar { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; position: sticky; top: 0.5rem; z-index: 5; }
.editor-title { flex: 1; min-width: 0; }
.editor-title h2 { margin: 0; font-size: 1.1rem; }
.editor-title .muted { font-size: 0.82rem; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
.section-h { margin: 0 0 0.35rem; font-size: 1rem; }

.picker { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pick-card {
  width: 118px;
  flex-direction: column;
  align-items: stretch;
  padding: 0.35rem;
  background: var(--soft);
  border: 2px solid var(--line);
  color: var(--text);
  font-weight: 500;
  gap: 0.3rem;
}
.pick-card:hover { border-color: var(--line-strong); }
.pick-card.selected { border-color: var(--select); background: #eef5ff; }
.pick-photo {
  height: 76px;
  border-radius: 8px;
  background: #e8edf3;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
}
.pick-card.none .pick-photo { font-size: 1.5rem; }
.pick-photo img { width: 100%; height: 100%; object-fit: cover; }
.pick-name { font-size: 0.8rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 0.75rem; margin: 1rem 0 0.45rem; }
.list-head h4 { margin: 0; font-size: 0.92rem; }
.list-head .muted { margin: 0.1rem 0 0; font-size: 0.8rem; }
.row-list { display: flex; flex-direction: column; gap: 0.4rem; counter-reset: rule; }
.edit-row { display: grid; gap: 0.4rem; align-items: center; }
.edit-row input { margin: 0; }
.rule-row { grid-template-columns: 1.6rem 1fr auto auto; }
.rule-row .drag-num::before { counter-increment: rule; content: counter(rule) "."; color: var(--muted); font-size: 0.85rem; }
.pron-row { grid-template-columns: 1fr 1fr auto; }

.provider-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; }
@media (max-width: 1400px) {
  .provider-grid { grid-template-columns: repeat(2, 1fr); }
}
.provider { border: 1px solid var(--line); border-radius: 10px; padding: 0.35rem 0.85rem 0.6rem; margin: 0; min-width: 0; }
.provider legend { font-weight: 650; font-size: 0.88rem; padding: 0 0.35rem; }

/* An avatar's knowledge bank: a list of what it uses (rows look like the Media list's) and a popup to add more. */
.check-line { display: flex; align-items: center; gap: 0.5rem; margin: 0.8rem 0 0; color: var(--text); font-size: 0.9rem; font-weight: 500; cursor: pointer; }
.check-line input { width: auto; margin: 0; }
.languages-block { margin-top: 0.9rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }
.languages-block .section-h { margin: 0 0 0.2rem; font-size: 0.95rem; }
.lang-list { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin-top: 0.4rem; }
.lang-item { display: flex; align-items: center; gap: 0.4rem; margin: 0; color: var(--text); font-size: 0.9rem; cursor: pointer; }
.lang-item input { width: auto; margin: 0; }
.knowledge-filter { max-width: 320px; margin: 0.5rem 0; }
.knowledge-head, .knowledge-row { grid-template-columns: 48px minmax(0, 1fr) 96px minmax(120px, 200px) 160px; }
.knowledge-head { margin-top: 0.5rem; }
.knowledge-row .c-actions { display: flex; justify-content: flex-end; gap: 0.35rem; }
.knowledge-list { margin-bottom: 0.5rem; }
.picker-dialog {
  width: min(860px, 94vw);
  max-height: 88vh;
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(28, 36, 48, 0.3);
}
.picker-dialog[open] { display: flex; flex-direction: column; gap: 0.6rem; }
.picker-dialog::backdrop { background: rgba(20, 28, 40, 0.45); }
.picker-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.picker-top .section-h { margin: 0; }
.picker-list { overflow: auto; min-height: 200px; max-height: 54vh; border-top: 1px solid var(--line); }
.pick-row { grid-template-columns: 28px 48px minmax(0, 1fr) 96px 76px; margin: 0; cursor: pointer; }
.pick-row input { width: auto; margin: 0; }
.pick-row:has(input:checked) { background: #eef5ff; }
.picker-more { display: block; margin: 0.7rem auto; }
.picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.7rem; border-top: 1px solid var(--line); }
@media (max-width: 900px) {
  .knowledge-head, .knowledge-row { grid-template-columns: 48px minmax(0, 1fr) 160px; }
  .knowledge-head .c-kind, .knowledge-row .c-kind { display: none; }
  .pick-row { grid-template-columns: 28px 48px minmax(0, 1fr) 88px; }
}.btn-link { font-size: 0.85rem; white-space: nowrap; }

/* —— Login —— */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(200, 230, 201, 0.55), transparent 45%),
    radial-gradient(ellipse at 80% 0%, rgba(197, 223, 248, 0.5), transparent 40%),
    var(--bg);
}
.login-card { width: min(420px, 100%); background: var(--card); border-radius: 16px; padding: 1.75rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card h1 { margin: 0 0 0.35rem; font-size: 1.45rem; letter-spacing: -0.02em; }
.login-card .muted { margin: 0 0 1rem; }
.login-card button { width: 100%; justify-content: center; margin-top: 0.75rem; }

/* ---- Data tab + Analytics overview ---- */
.inline-input { display: flex; align-items: center; gap: 0.5rem; color: var(--text); margin-top: 0.35rem; }
.inline-input input { width: 7rem; margin: 0; }
.data-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; padding: 0.75rem 1rem; }
.data-filters label { margin: 0; }
.data-filters select { min-width: 220px; }
#an-status:empty, #ov-status:empty { display: none; }
.data-range-label { margin-left: auto; font-size: 0.85rem; align-self: center; }
.segmented { display: inline-flex; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { background: transparent; border: none; padding: 0.35rem 0.75rem; border-radius: 8px; font-size: 0.85rem; color: var(--muted); box-shadow: none; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0.85rem; }
.kpi { display: flex; flex-direction: column; gap: 0.2rem; }
.kpi-label { font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.kpi strong { font-size: 1.6rem; letter-spacing: -0.03em; line-height: 1.15; }
.kpi .muted { font-size: 0.78rem; }
.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.data-grid > .card { min-width: 0; }
.chart-box { position: relative; height: 240px; }
.chart-box.short { height: 190px; }
.chart-box.donut { height: 180px; width: 180px; flex-shrink: 0; }
.list-head.first { margin-top: 0; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th { text-align: left; font-weight: 600; font-size: 0.78rem; color: var(--muted); padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td, .data-table tr.clickable:focus td { background: var(--soft); }
.data-table td.clip { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.link { background: none; border: none; padding: 0; color: var(--select); font-weight: 500; box-shadow: none; text-align: left; cursor: pointer; }
button.link:hover { text-decoration: underline; background: none; }
.tag { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.tag.bad { color: var(--danger); border-color: #f3c7c7; background: #fdf0f0; }
.rank-list { list-style: none; margin: 0.25rem 0 0; padding: 0; counter-reset: rank; display: flex; flex-direction: column; }
.rank-list > li { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); counter-increment: rank; }
.rank-list > li:last-child { border-bottom: none; }
.rank-list > li::before { content: counter(rank); min-width: 1.4rem; color: var(--muted); font-size: 0.8rem; padding-top: 0.1rem; }
.rank-list > li.empty::before { content: none; }
.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.rank-text { font-size: 0.88rem; overflow-wrap: anywhere; }
.rank-sub { font-size: 0.76rem; }
.rank-count { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.wordings summary { font-size: 0.76rem; font-weight: 500; color: var(--muted); }
.wordings ul { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.8rem; color: #4a5568; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); font-size: 0.8rem; }
.chip-x { background: none; border: none; padding: 0 0.1rem; font-size: 1rem; line-height: 1; color: var(--muted); box-shadow: none; }
.split-row { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.stat-list { display: grid; grid-template-columns: auto auto; gap: 0.35rem 1rem; margin: 0; font-size: 0.86rem; flex: 1; }
.stat-list dt { color: var(--muted); }
.stat-list dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.conv-search { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.conv-search input { flex: 1; min-width: 220px; margin: 0; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.6rem; font-size: 0.85rem; }
.row-actions.tight { margin-top: 0; }
.conv-head h3 { margin: 0.25rem 0 0; font-size: 1.05rem; }
.conv-head p { margin: 0.2rem 0 0.75rem; font-size: 0.85rem; }
.timeline { display: flex; flex-direction: column; gap: 0.6rem; max-width: 860px; }
.tl-turn { display: flex; flex-direction: column; gap: 0.3rem; }
.tl-row { display: flex; align-items: flex-start; gap: 0.6rem; }
.tl-row.avatar { padding-left: 4.6rem; }
.tl-time { width: 4rem; flex-shrink: 0; font-size: 0.74rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 0.45rem; }
.bubble { padding: 0.5rem 0.75rem; border-radius: 12px; font-size: 0.9rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.bubble.visitor { background: #eef5ff; border: 1px solid #d6e4fb; }
.bubble.avatar { background: var(--soft); border: 1px solid var(--line); }
.tl-error { display: block; color: var(--danger); font-size: 0.8rem; margin-top: 0.25rem; }
.tl-meta { padding-left: 4.6rem; font-size: 0.74rem; }
.tl-marker { display: flex; align-items: baseline; gap: 0.6rem; font-size: 0.85rem; }
.tl-marker .tl-time { padding-top: 0; }
.tl-ico { width: 1.2rem; text-align: center; color: var(--muted); }
.tl-marker.bad .tl-ico { color: var(--danger); }
.retention-form { display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap; }
.retention-form label { margin: 0; }
.retention-form button { margin-bottom: 0.1rem; }

@media (max-width: 1000px) {
  .provider-grid { grid-template-columns: 1fr; }
  .editor-grid { grid-template-columns: 1fr; }
  .data-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-nav button, .side-nav .nav-link { width: auto; }
  .nav-label { width: 100%; }
  .sidebar-footer { border-top: none; padding-top: 0.5rem; }
  .grid-form, .add-media-grid { grid-template-columns: 1fr; }
  .home-stats { grid-template-columns: 1fr 1fr; }
}

/* Gestures page (gestures.html): one card per gesture with on/off, the variant and its preview clip. */
.gestures-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.gestures-bar .muted { margin: 0; }
.gestures-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.gesture-card .gesture-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.gesture-card .gesture-head .muted { margin: 0; font-size: 0.82rem; }
.gesture-card .gesture-body { display: flex; gap: 0.9rem; align-items: center; margin-top: 0.8rem; }
.gesture-card .gesture-variant { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); flex: 1; min-width: 0; }
.gesture-card .gesture-preview { width: 140px; height: 190px; border-radius: 10px; overflow: hidden; background: #e9edf2; flex-shrink: 0; position: relative; }
.gesture-card .gesture-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.gesture-card .gesture-missing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; font-size: 0.78rem; text-align: center; }
.gesture-card.is-off .gesture-body { opacity: 0.45; }
@media (max-width: 520px) { .gestures-grid { grid-template-columns: 1fr; } }

/* Actions (plan Part K): the list on the user page and the step-by-step page (action.html). */
.act-list-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.act-list-head label { min-width: 240px; }
.act-list { display: flex; flex-direction: column; gap: 0.7rem; }
.act-item { display: flex; justify-content: space-between; gap: 1rem; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.act-item.is-off .act-item-main { opacity: 0.5; }
.act-item-title { display: flex; align-items: center; gap: 0.5rem; }
.act-item-main .muted { margin: 0.25rem 0 0; font-size: 0.85rem; }
.act-flow { margin: 0.45rem 0 0; font-size: 0.85rem; line-height: 1.6; }
.act-arrow { color: var(--muted); margin: 0 0.15rem; }
.act-item-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 0.6rem; flex-shrink: 0; }
.pill-blue { background: #e5eefc; color: #2a55b8; }
.act-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; position: sticky; top: 0.5rem; z-index: 5; margin-bottom: 1rem; }
.act-bar .muted { margin: 0; }
.act-start { margin-bottom: 1rem; }
.act-start .hint { margin: 0.3rem 0 0; }
.act-step { margin-bottom: 1rem; }
.act-step-head { display: flex; gap: 0.8rem; align-items: flex-start; margin-bottom: 0.8rem; }
.act-step-head .muted { margin: 0; font-size: 0.85rem; }
.act-step-n { width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--select); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.act-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1rem; align-items: start; }
.act-grid .span-all { grid-column: 1 / -1; }
.act-enabled { justify-self: end; align-self: center; }
.act-fields { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.6rem; }
.act-field-card { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.8rem; background: #fafbfd; }
.act-field-top { display: grid; grid-template-columns: 2fr 1fr auto auto; gap: 0.6rem; align-items: end; }
.act-field-card .hint { margin: 0.35rem 0 0; font-size: 0.8rem; }
.act-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.4rem 0; }
.act-choice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.act-choice:has(input:checked) { border-color: var(--select); background: #f2f6fe; }
.act-choice > span { display: flex; flex-direction: column; gap: 0.15rem; }
.act-choice .muted { font-size: 0.8rem; }
.act-sub { margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.act-sub .hint { margin: 0; font-size: 0.8rem; }
.act-header input { flex: 1; min-width: 8rem; }
.act-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.35rem 0 0.2rem; font-size: 0.78rem; }
.chip-btn { padding: 0.15rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 0.78rem; cursor: pointer; box-shadow: none; color: var(--text); }
.chip-btn:hover { border-color: var(--select); color: var(--select); }
.act-card-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.2rem; align-items: start; }
.act-checks { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin: 0.3rem 0 0.6rem; }
.act-more { margin-top: 0.6rem; }
.act-more summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.act-preview-wrap { position: sticky; top: 5rem; }
.act-lang { margin-bottom: 0.5rem; }
.act-lang .active { border-color: var(--select); color: var(--select); }
.act-says { font-size: 0.85rem; margin: 0.6rem 0 0; }
.small { font-size: 0.85rem; }
/* The visitor-screen card, drawn like the HUD card. */
.hud-card-preview { background: #141a24; color: #f2f5f9; border-radius: 14px; padding: 0.9rem 1rem; box-shadow: 0 6px 18px rgba(0,0,0,0.18); border-top: 4px solid #2e9d5b; font-size: 0.88rem; }
.hud-card-preview.kind-review { border-top-color: #e3a72f; }
.hud-card-preview.kind-failure { border-top-color: #d64545; }
.hud-card-preview .hc-badge { display: inline-block; font-size: 0.68rem; letter-spacing: 0.04em; padding: 0.1rem 0.45rem; border-radius: 6px; background: rgba(255,255,255,0.12); margin-bottom: 0.45rem; }
.hud-card-preview .hc-title { font-weight: 700; font-size: 1rem; margin-bottom: 0.5rem; }
.hud-card-preview .hc-row, .hud-card-preview .hc-highlight { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0; border-top: 1px solid rgba(255,255,255,0.08); }
.hud-card-preview .hc-row span, .hud-card-preview .hc-highlight span { color: #aab4c3; }
.hud-card-preview .hc-highlight b { color: #7fd3a2; }
.hud-card-preview .hc-footer { margin-top: 0.5rem; font-size: 0.75rem; color: #aab4c3; }
@media (max-width: 860px) {
  .act-grid, .act-choices, .act-card-layout { grid-template-columns: 1fr; }
  .act-field-top { grid-template-columns: 1fr 1fr; }
  .act-item { flex-direction: column; }
  .act-item-side { flex-direction: row; align-items: center; }
  .act-preview-wrap { position: static; }
}
/* MarsX CRM (crm.html). */
.crm-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-bottom: 1.1rem; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 0.35rem; box-shadow: var(--shadow); }
.crm-tabs button { background: none; border: none; box-shadow: none; padding: 0.5rem 0.95rem; border-radius: 10px; color: #5b6778; font-weight: 600; cursor: pointer; }
.crm-tabs button:hover { background: var(--soft); color: var(--text); }
.crm-tabs button.active { background: var(--accent-soft); color: var(--accent); }
/* Files and Payments: their own buttons in the page header, apart from the sales tabs. */
.workspace > .page-header:has(.crm-quick) { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.crm-quick { display: flex; gap: 0.5rem; }
.crm-quick-btn { background: #fff; color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 0.6rem 1.05rem; border-radius: 12px; font-weight: 600; }
.crm-quick-btn:hover { border-color: var(--accent); color: var(--accent); }
.crm-quick-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.crm-toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.8rem; }
.crm-toolbar .muted { margin: 0; }
.crm-toolbar input[type=search] { min-width: 220px; }
.spacer { flex: 1; }
.crm-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.crm-tile { --tone: var(--accent); --tone-soft: var(--accent-soft); display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; padding: 0.9rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: #fff; text-align: left; cursor: pointer; box-shadow: var(--shadow); color: var(--text); font-weight: 500; }
.crm-tile .tile-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft); font-size: 1.05rem; margin-bottom: 0.2rem; }
.crm-tile b { color: var(--tone); }
.crm-tile.t-blue { --tone: #3b5bdb; --tone-soft: #e8eefc; }
.crm-tile.t-violet { --tone: #7048e8; --tone-soft: #efe9fd; }
.crm-tile.t-green { --tone: #2f9e44; --tone-soft: #e6f6ea; }
.crm-tile.t-amber { --tone: #e67700; --tone-soft: #fff1db; }
.crm-tile.t-teal { --tone: #0c8599; --tone-soft: #e0f5f7; }
.crm-tile.t-rose { --tone: #d6336c; --tone-soft: #fde8ef; }
.crm-tile.static { cursor: default; }
.crm-tile b { font-size: 1.4rem; }
.crm-tile span { font-size: 0.8rem; color: var(--muted); }
.crm-tile.t-good b { color: #2e9d5b; }
.crm-tile:not(.static):hover { border-color: var(--tone, var(--select)); transform: translateY(-1px); }
.crm-funnel { margin-bottom: 1rem; }
.crm-funnel-steps { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.5rem; }
.crm-funnel-step { display: grid; grid-template-columns: 190px 1fr 2.5rem; gap: 0.8rem; align-items: center; }
.crm-funnel-step span { font-size: 0.85rem; color: #4a5566; }
.crm-funnel-bar { height: 10px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); overflow: hidden; }
.crm-funnel-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #748ffc, var(--accent)); }
.crm-funnel-step b { font-size: 1rem; color: var(--accent); text-align: right; }
.crm-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.crm-two .card > .muted { margin: 0 0 0.6rem; font-size: 0.82rem; }
.crm-row { display: flex; justify-content: space-between; gap: 0.8rem; align-items: center; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.crm-row .muted { font-size: 0.82rem; }
.crm-row.is-late { background: linear-gradient(90deg, #fdeceb 0, transparent 60%); box-shadow: inset 3px 0 0 #e03131; padding-left: 0.6rem; }
.crm-row-side { display: flex; gap: 0.4rem; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
/* Tasks (2026-11-24): only the checkbox marks done; the title opens the task. Done tasks stay at the bottom, faded. */
.crm-task-main { display: flex; gap: 0.6rem; align-items: flex-start; min-width: 0; }
.crm-task-check { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; cursor: pointer; }
.crm-row.is-done b { text-decoration: line-through; color: var(--muted, #6b7280); }
.crm-row.is-done { opacity: 0.75; }
.crm-task-done { margin-top: 0.5rem; }
.is-click { cursor: pointer; }
.is-click:hover { background: #f6f8fb; }
.due { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.due-late { color: #c0392b; font-weight: 600; }
.due-today { color: #b7791f; font-weight: 600; }
.crm-pill { display: inline-block; padding: 0.12rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: #eef1f5; color: #4a5566; white-space: nowrap; }
.p-not_contacted, .p-new, .p-idea { background: #eef1f5; color: #6b7685; }
.p-contacted, .p-planned { background: #e5eefc; color: #2a55b8; }
.p-talking, .p-discovery { background: #e8f0ff; color: #1f4fd1; }
.p-demo { background: #efe8fd; color: #6b3fc9; }
.p-proposal, .p-negotiation { background: #fff4dd; color: #a8660a; }
.p-client, .p-won, .p-published, .p-done { background: #e3f5ea; color: #217a45; }
.p-lost, .p-not_interested, .p-high { background: #fdeceb; color: #c0392b; }
.p-on_hold, .p-dormant, .p-postponed { background: #f3f0e8; color: #7a6a45; }
.p-medium { background: #fff4dd; color: #a8660a; }
.p-counted { background: #e5eefc; color: #2a55b8; font-weight: 500; }
.crm-prio { display: inline-block; min-width: 2em; text-align: center; padding: 0.1rem 0.4rem; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.prio-ap { background: #1c2430; color: #fff; }
.prio-a { background: #dfe6f0; color: #1c2430; }
.prio-b { background: #f1f3f6; color: #6b7685; }
.crm-table tbody tr { cursor: pointer; }
.crm-table tbody tr:hover { background: #f6f8fb; }
.crm-table td .muted { font-size: 0.78rem; }
.crm-who { font-size: 0.72rem; }
.crm-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; box-shadow: -8px 0 30px rgba(0,0,0,0.12); padding: 1.1rem 1.2rem 2rem; overflow-y: auto; transform: translateX(105%); transition: transform 0.2s ease; z-index: 50; }
.crm-panel.open { transform: none; }
.crm-panel-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.crm-panel-head h2 { margin: 0 0 0.3rem; font-size: 1.25rem; }
.crm-panel-actions { margin: 0.8rem 0; }
.crm-panel h4 { margin: 1.1rem 0 0.3rem; font-size: 0.9rem; }
.crm-next { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; padding: 0.6rem 0.8rem; border-radius: 10px; background: #f2f6fe; margin-bottom: 0.7rem; }
.crm-next span { font-size: 0.75rem; color: var(--muted); }
.crm-next.is-late { background: #fdeceb; }
.crm-kvs { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 1rem; }
.crm-kv { display: flex; flex-direction: column; font-size: 0.85rem; }
.crm-kv span { font-size: 0.72rem; color: var(--muted); }
.crm-kv b { font-weight: 500; word-break: break-word; }
.crm-notes { white-space: pre-wrap; font-size: 0.85rem; background: #fafbfd; border-radius: 8px; padding: 0.6rem 0.7rem; }
.crm-audit { font-size: 0.75rem; margin-top: 1.2rem; }
.crm-timeline { display: flex; flex-direction: column; }
.crm-event { display: flex; gap: 0.7rem; padding: 0.55rem 0.3rem; border-top: 1px solid var(--line); font-size: 0.86rem; }
.crm-event .muted { font-size: 0.8rem; white-space: pre-wrap; }
.crm-event-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; margin-top: 0.3rem; flex-shrink: 0; background: #b7c5d8; }
.k-call, .k-whatsapp { background: #2f6fed; }
.k-meeting, .k-visit { background: #6b3fc9; }
.k-demo { background: #e3a72f; }
.k-proposal { background: #2e9d5b; }
.k-email, .k-linkedin { background: #3aa0c8; }
.crm-timeline-wide { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0 0.8rem; }
.crm-day { font-size: 0.78rem; font-weight: 700; color: var(--muted); padding: 0.7rem 0 0.3rem; }
.crm-board { display: grid; grid-template-columns: repeat(8, minmax(190px, 1fr)); gap: 0.6rem; overflow-x: auto; padding-bottom: 0.6rem; }
.crm-col { background: #eef1f5; border-radius: 12px; padding: 0.5rem; min-height: 180px; display: flex; flex-direction: column; gap: 0.5rem; }
.crm-col.over { outline: 2px dashed var(--select); }
.crm-col-head { font-size: 0.85rem; padding: 0.2rem 0.3rem; }
.crm-col-head .muted { font-size: 0.75rem; }
.crm-col[data-stage=won] { background: #e9f6ee; }
.crm-col[data-stage=lost] { background: #f8eded; }
.crm-card { background: #fff; border-radius: 10px; padding: 0.55rem 0.65rem; box-shadow: 0 1px 2px rgba(0,0,0,0.08); cursor: grab; font-size: 0.85rem; }
.crm-card.dragging { opacity: 0.5; }
.crm-card .muted { font-size: 0.78rem; }
.crm-card-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; font-size: 0.78rem; margin-top: 0.3rem; }
.crm-card-next { font-size: 0.78rem; margin-top: 0.35rem; color: var(--text); }
.crm-card-next.warn { color: #c0392b; }
.crm-task-group { margin-bottom: 0.8rem; }
.crm-task-group .section-h .muted { font-weight: 500; font-size: 0.85rem; }
.crm-bar-cell { min-width: 140px; }
.crm-bar { display: inline-block; width: 90px; height: 7px; border-radius: 99px; background: #e3e8ef; overflow: hidden; vertical-align: middle; margin-right: 0.4rem; }
.crm-bar span { display: block; height: 100%; background: #2e9d5b; }
.crm-fixes { font-size: 0.86rem; line-height: 1.6; padding-left: 1.2rem; }
.crm-dialog { border: none; border-radius: 14px; padding: 1.1rem 1.2rem; width: min(680px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,0.25); }
.crm-dialog::backdrop { background: rgba(20, 26, 36, 0.35); }
.crm-dialog h3 { margin: 0 0 0.8rem; }
.crm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.9rem; }
.crm-form-grid label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.82rem; color: var(--muted); }
.crm-form-grid label.full { grid-column: 1 / -1; }
.crm-form-grid .hint { font-size: 0.72rem; }
.crm-form-actions { margin-top: 0.9rem; }
@media (max-width: 900px) {
  .crm-two, .crm-form-grid, .crm-kvs { grid-template-columns: 1fr; }
  .crm-funnel-steps { grid-template-columns: repeat(3, 1fr); }
}.crm-toolbar input, .crm-toolbar select { width: auto; flex: 0 1 auto; margin: 0; }
.crm-toolbar input[type=search] { flex: 1 1 220px; max-width: 360px; }
.crm-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.crm-table th.sortable:hover { color: var(--select); }
.crm-table th.sorted { color: var(--text); }
.crm-meetings { margin-bottom: 1rem; }
.crm-meetings > .muted { margin: 0 0 0.6rem; font-size: 0.82rem; }
.crm-meeting { cursor: pointer; }
.p-planned { background: #e5eefc; color: #2a55b8; }
.p-cancelled { background: #f1f3f6; color: #6b7685; text-decoration: line-through; }
.crm-changes { margin-top: 1.1rem; }
.crm-changes summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.crm-hist { padding: 0.5rem 0; border-top: 1px solid var(--line); font-size: 0.84rem; }
.crm-hist-when { font-size: 0.75rem; }
.crm-change { font-size: 0.8rem; margin-top: 0.15rem; }
.crm-change span { color: var(--muted); }
.account-links { display: flex; gap: 0.4rem; margin: 0.4rem 0; flex-wrap: wrap; }
.password-card { max-width: 480px; }
.password-form { display: flex; flex-direction: column; gap: 0.7rem; }
.password-form .hint { font-size: 0.75rem; }
.team-actions { white-space: nowrap; }.crm-table tr.crm-group td { background: #f2f6fe; font-weight: 700; font-size: 0.85rem; color: var(--select); cursor: default; }
.crm-table tr.crm-group:hover td { background: #f2f6fe; }

/* Team: what a member can open (team.js) */
.perm-box { border: 1px solid var(--line, #e3e7ee); border-radius: 10px; padding: 0.4rem 0.8rem 0.7rem; margin: 0.3rem 0 0; }
.perm-box legend { font-weight: 600; font-size: 0.85rem; padding: 0 0.3rem; color: var(--text, #1d2433); }
.perm-title { margin: 0.55rem 0 0.25rem; font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.perm-grid { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
.perm-clients { max-height: 9rem; overflow: auto; margin-top: 0.3rem; }
.perm-check { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 0.35rem !important; font-size: 0.85rem !important; color: var(--text, #1d2433) !important; }
.team-access { font-size: 0.82rem; max-width: 22rem; }
/* A member with "view only": buttons that change things are hidden (the server refuses them anyway). */
body.view-only button.primary, body.view-only form button[type="submit"], body.view-only button.danger, body.view-only .row-toggle,
body.view-only .row-delete, body.view-only [data-go-tab="users"].primary { display: none !important; }

/* CRM Payments tab */
.fin-result { margin-bottom: 1rem; }
.fin-result p { margin: 0; }
.fin-result-line { font-size: 1.05rem; margin-top: 0.3rem !important; }
.fin-big { font-size: 1.35rem; font-weight: 700; color: var(--accent, #2f6fed); margin-left: 0.4rem; }
.fin-plus { color: #1f8a4c; font-weight: 600; }
.fin-minus { color: #c0392b; font-weight: 600; }
.fin-partner.fin-me { border-color: var(--accent, #2f6fed); }
.fin-locked { opacity: 0.85; }
.fin-locked td { cursor: not-allowed; }
.data-table .num { text-align: right; white-space: nowrap; }
.fin-setup-row { display: grid; grid-template-columns: 1fr 90px; gap: 0.4rem 0.6rem; margin: 0.4rem 0 0.7rem; }
.fin-setup-row .fin-accounts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; }

/* Avatar editor: automatic switch ElevenLabs <-> EchoNova */
.failover-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 16px; margin-top: 8px; }
.failover-grid label { display: flex; flex-direction: column; gap: 4px; }

/* CRM Work log */
.wl-day { margin-bottom: 0.8rem; }
.wl-person { cursor: pointer; margin: 0.15rem 0 0.5rem; }
.wl-group h4 { margin: 0.6rem 0 0.25rem; font-size: 0.9rem; }
.wl-group ul { margin: 0; padding-left: 1.2rem; }
.wl-group li { margin: 0.15rem 0; }
.wl-tiles .crm-tile { cursor: default; }
.crm-subtabs { margin-bottom: 0.8rem; }

/* ---- CRM Today (owner, 2026-11-24: easier to read): greeting, one to-do list, coming up, then numbers. ---- */
.today-hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1.2rem 1.4rem; margin-bottom: 1rem; border-radius: 16px; color: #fff; background: linear-gradient(120deg, #3b5bdb 0%, #5c7cfa 55%, #748ffc 100%); box-shadow: 0 10px 30px rgba(59, 91, 219, 0.25); }
.today-hero h2 { margin: 0; font-size: 1.35rem; }
.today-hero p { margin: 0.25rem 0 0; opacity: 0.95; }
.today-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.today-hero .today-actions button.primary { background: #fff; color: var(--accent); }
.today-hero .today-actions button.ghost { color: #fff; border-color: rgba(255, 255, 255, 0.55); }
.today-hero .today-actions button.ghost:hover { background: rgba(255, 255, 255, 0.15); }
.today-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1rem; margin-bottom: 1.2rem; align-items: start; }
.today-grid .card > .muted, .crm-two .card > .muted { margin: 0 0 0.6rem; font-size: 0.82rem; }
.today-sub { margin: 1.3rem 0 0.6rem; font-size: 1.02rem; }
.today-kind { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 0.1rem 0.45rem; border-radius: 6px; margin-right: 0.3rem; vertical-align: 1px; }
.today-kind.k-task { background: #fde8ef; color: #c2255c; }
.today-kind.k-follow { background: #e8eefc; color: #3b5bdb; }
.today-empty { padding: 1.1rem; text-align: center; border-radius: 12px; background: #e6f6ea; color: #2b8a3e; font-weight: 600; }
.today-empty.small { background: var(--soft); color: var(--muted); font-weight: 500; font-size: 0.88rem; }
@media (max-width: 900px) {
  .today-grid, .crm-two { grid-template-columns: 1fr; }
  .crm-funnel-step { grid-template-columns: 120px 1fr 2rem; }
}
