/* Bram + Pro Infra portal styles. */
:root {
  --blue: #1f6fd1;
  --blue-dark: #195bb0;
  --blue-soft: #e8f1fc;
  --ink: #12213a;
  --muted: #6b7a90;
  --line: #e3e9f2;
  --bg: #f6f9fd;
  --surface: #ffffff;
  --bubble: #eef2f8;
  --green: #1d9a5b;
  --green-soft: #e3f5ec;
  --radius: 14px;
  --shadow: 0 8px 28px rgba(18, 33, 58, 0.12);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(31, 111, 209, 0.45); outline-offset: 2px; }
.composer input:focus-visible { outline: none; }  /* the composer shows focus on its border */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Portal layout ---------- */
.portal { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
/* The sidebar stays in view while the page scrolls; it scrolls by itself when Recent is long. */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line); padding: 22px 14px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
}
.logo { display: block; font-size: 30px; font-weight: 800; letter-spacing: -1px; margin: 0 8px 28px; text-decoration: none; }
.logo .pro { color: var(--blue); }
.logo .infra { color: #13b3c9; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink); text-decoration: none;
}
.nav a:hover { background: var(--blue-soft); }
.nav a[aria-current="page"] { background: var(--blue); color: #fff; }
.nav svg { width: 20px; height: 20px; flex: none; }

/* Recent conversations under the menu */
.recents { margin-top: 26px; min-height: 0; flex: 1 1 auto; overflow-y: auto; }
.recents h2 { margin: 0 12px 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.recents ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.recents a {
  display: block; padding: 8px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recents a small { display: block; color: var(--muted); font-size: 12px; }
.recents a:hover { background: var(--blue-soft); }
.recents a.active { background: var(--blue-soft); font-weight: 600; }
.recents .empty { padding: 4px 12px; color: var(--muted); font-size: 13px; }
/* On wide screens Recent replaces the conversation picker on Home. */
@media (min-width: 901px) { .thread-bar select { display: none; } }

.main { display: flex; flex-direction: column; min-width: 0; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
/* The logged-in user sits at the bottom of the sidebar; the menu opens upwards. */
.user-menu { position: relative; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.user-menu > .user { background: none; border: 0; border-radius: 10px; padding: 8px; width: 100%; text-align: left; }
.user-menu [data-user-name] { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu > .user:hover, .user-menu > .user[aria-expanded="true"] { background: var(--blue-soft); }
.user-menu .caret { width: 16px; height: 16px; color: var(--muted); transform: rotate(180deg); }  /* the menu opens upwards */
.user-menu .menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 20; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
}
.user-menu .menu a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
.user-menu .menu a:hover, .user-menu .menu a[aria-current="page"] { background: var(--blue-soft); }
.user-menu .menu svg { width: 18px; height: 18px; flex: none; }
.initials {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 13px; font-weight: 600; flex: none;
}

.view { padding: 28px 28px 104px; max-width: 1100px; width: 100%; }
.greeting h1 { margin: 0; font-size: 28px; }
.greeting p { margin: 4px 0 0; color: var(--muted); font-size: 16px; }

.hero { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 8px 0 20px; }
.hero img { width: 92px; height: 92px; border-radius: 50%; }
.hero h2 { margin: 0; font-size: 28px; }
.hero p { margin: 2px 0 0; color: var(--muted); }

/* ---------- Composer ---------- */
.composer {
  display: flex; align-items: center; gap: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 14px;
}
.composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 111, 209, 0.15); }
.composer input[type="text"] { flex: 1; border: 0; outline: 0; background: none; padding: 8px 4px; min-width: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: none; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--blue-soft); color: var(--blue); }
.icon-btn svg { width: 20px; height: 20px; }
.send-btn { background: var(--blue); color: #fff; }
.send-btn:hover { background: var(--blue-dark); color: #fff; }
.send-btn:disabled { background: #c9d4e3; cursor: default; }
.mic-btn { background: var(--blue); color: #fff; border-radius: 50%; }
.mic-btn:hover { background: var(--blue-dark); color: #fff; }
.mic-btn.listening { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(31, 111, 209, 0.25); } }

.attachment {
  display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 6px 10px;
  background: var(--blue-soft); border-radius: 8px; font-size: 13px;
}
.attachment button { border: 0; background: none; color: var(--muted); padding: 0 2px; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 14px 0 22px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--blue-soft); font-size: 14px;
}
.chip:hover { border-color: var(--blue); }
.chip svg { width: 18px; height: 18px; color: var(--blue); }

/* ---------- Messages ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg .avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; }
.msg-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; max-width: min(640px, 100%); }
.bubble { background: var(--bubble); padding: 10px 14px; border-radius: 4px 14px 14px 14px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child, .bubble ul:last-child, .bubble ol:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 0 0 8px; padding-left: 20px; }
.bubble.error { background: #fdecec; color: #9b1c1c; }
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-body { align-items: flex-end; }
.msg.user .bubble { background: var(--blue); color: #fff; border-radius: 14px 4px 14px 14px; }
.msg time { font-size: 12px; color: var(--muted); }
.typing span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 0.3; } }

.file-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-width: 200px;
  background: var(--blue-soft); border-radius: 10px;
}
.file-card .file-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--blue); color: #fff; }
.file-card .file-icon svg { width: 20px; height: 20px; }
.file-card strong { display: block; font-size: 14px; font-weight: 600; }
.file-card small { color: var(--muted); }

/* ---------- Project proposal card ---------- */
.project-card {
  display: grid; grid-template-columns: 170px 1fr auto; gap: 18px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface);
}
.project-card .thumb { width: 170px; height: 100px; border-radius: 10px; overflow: hidden; }
.project-card .thumb svg { width: 100%; height: 100%; display: block; }
.project-card h3 { margin: 0; font-size: 17px; }
.project-card .where { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin: 2px 0 10px; }
.project-card .where svg { width: 15px; height: 15px; }
.project-card .fields { display: flex; flex-wrap: wrap; gap: 18px; }
.project-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.project-card select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); min-width: 170px; }
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px;
  background: var(--bubble); color: var(--muted); font-size: 13px;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa6b6; }
.status.created { background: var(--green-soft); color: var(--green); }
.status.created::before { background: var(--green); }
.primary-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 10px;
  background: var(--blue); color: #fff; font-weight: 600; white-space: nowrap;
}
.primary-btn:hover { background: var(--blue-dark); }
.primary-btn:disabled { background: #c9d4e3; cursor: default; }
.primary-btn svg { width: 18px; height: 18px; }
.secondary-btn { padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }

/* ---------- Action confirmation card ---------- */
.action-card { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: var(--radius); padding: 14px; background: var(--surface); display: grid; gap: 12px; }
.action-head { display: flex; gap: 12px; align-items: flex-start; }
.action-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); flex: none; }
.action-icon svg { width: 20px; height: 20px; }
.action-head strong { display: block; }
.action-head small { color: var(--muted); }
.action-details { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.action-details dt { max-width: 26ch; overflow-wrap: anywhere; }
.action-details dt { color: var(--muted); }
.action-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.action-items { margin: 0; padding: 0 0 0 22px; display: grid; gap: 12px; }
.action-items > li { padding-left: 4px; }
.action-items > li::marker { color: var(--blue); font-weight: 700; }
.action-items > li + li { border-top: 1px solid var(--line); padding-top: 12px; }
.action-item-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; align-items: baseline; }
.action-items small { display: block; color: var(--muted); margin: 2px 0 6px; }
.action-item-status { font-size: 13px; font-weight: 600; white-space: nowrap; }
.action-item-status.ok { color: var(--green); }
.action-item-status.bad { color: #b42318; white-space: normal; flex-basis: 100%; }
.action-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.action-buttons button:disabled { opacity: 0.6; cursor: default; }
.action-card .status { justify-self: start; margin: 0; }
.status.failed { background: #fdecec; color: #9b1c1c; }
.status.failed::before { background: #d64545; }

/* ---------- Dialog ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(18, 33, 58, 0.35); }
dialog form { padding: 22px; display: grid; gap: 12px; }
dialog h2 { margin: 0 0 4px; font-size: 20px; }
dialog label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
dialog input, dialog textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--ink); width: 100%; min-width: 0; }
dialog textarea { resize: vertical; }
dialog .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 30px; }
.tile {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px;
  background: var(--blue-soft); text-decoration: none; color: var(--ink);
}
.tile:hover { outline: 1px solid var(--blue); }
.tile > svg:first-child { width: 30px; height: 30px; color: var(--blue); flex: none; }
.tile strong { display: block; font-size: 14px; }
.tile small { color: var(--muted); font-size: 12px; }
.tile .chev { margin-left: auto; width: 18px; height: 18px; color: var(--muted); flex: none; }

/* ---------- Projects view ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; margin-top: 18px; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; background: #fafcff; }
.empty { color: var(--muted); padding: 24px 0; }
.view h1 { margin: 0; font-size: 26px; }
.lead { color: var(--muted); margin: 4px 0 0; }
.muted { color: var(--muted); }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.toolbar input, .toolbar select, .status-select {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface);
}
.toolbar input { flex: 1; min-width: 220px; }
.table-wrap { overflow-x: auto; }
.table td small.desc { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; max-width: 340px; }
.status-select { padding: 6px 10px; font-size: 13px; }

/* ---------- Reports and settings ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.stat strong { display: block; font-size: 30px; color: var(--blue); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.panel p { line-height: 1.5; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 28px; align-items: center; gap: 10px; margin: 10px 0; font-size: 14px; }
.bar { height: 10px; background: var(--bubble); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.bar-row b { text-align: right; }
.deadlines { list-style: none; margin: 0; padding: 0; }
.deadlines li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.deadlines li:last-child { border-bottom: 0; }
.deadlines small { display: block; color: var(--muted); }
.deadlines span { white-space: nowrap; color: var(--muted); }
.account { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.account small { display: block; color: var(--muted); font-size: 13px; }
.initials.big { width: 52px; height: 52px; font-size: 18px; }
#download-box { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 6px 0 4px; }
#download-box .primary-btn { text-decoration: none; }
#download-box .empty { padding: 0; }
.integrations { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 14px; }
.integrations li { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.integrations small { display: block; color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.primary-btn.small, .secondary-btn.small { padding: 6px 12px; font-size: 13px; text-decoration: none; }
#integrations-note { margin: 0 0 12px; }
.steps { color: var(--muted); font-size: 14px; padding-left: 20px; line-height: 1.6; margin-bottom: 0; }
/* ---------- Home as a chat (once a conversation has started) ---------- */
#view-home { display: flex; flex-direction: column; }
#view-home.chatting { min-height: 100vh; padding-bottom: 0; }
#view-home.chatting .greeting,
#view-home.chatting .hero,
#view-home.chatting .chips,
#view-home.chatting .tiles { display: none; }
#view-home.chatting .thread-bar { order: 1; margin: 0 0 16px; }
#view-home.chatting .thread { order: 2; flex: 1; }
#view-home.chatting .thread > * { scroll-margin-bottom: 140px; }
/* The dock floats 24px above the bottom of the screen; messages fade out behind it. */
#view-home.chatting .composer-dock {
  order: 3; position: sticky; bottom: 0; z-index: 2;
  margin: 8px -28px 0; padding: 28px 28px 24px;
  background: linear-gradient(to bottom, rgba(246, 249, 253, 0), var(--bg) 40%);
}
#view-home.chatting .composer { box-shadow: 0 6px 24px rgba(18, 33, 58, 0.14); border-radius: 16px; }
#view-home.chatting .composer:focus-within { box-shadow: 0 0 0 3px rgba(31, 111, 209, 0.15), 0 6px 24px rgba(18, 33, 58, 0.14); }
#view-home.chatting #portal-attachment { margin: 0 0 8px; }
#view-home:not(.chatting) #portal-attachment { margin-top: 8px; }
#view-home:not(.chatting) .composer-dock { display: flex; flex-direction: column-reverse; }
#view-home:not(.chatting) #new-conversation { display: none; }  /* nothing to start over yet */

.empty-state { margin-top: 24px; padding: 40px 24px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state img { width: 72px; height: 72px; border-radius: 50%; }
.empty-state h2 { margin: 12px 0 6px; font-size: 18px; }
.empty-state p { margin: 0 auto 18px; max-width: 520px; color: var(--muted); line-height: 1.5; }
.empty-state .primary-btn { text-decoration: none; }

/* ---------- Conversations, project page, tasks ---------- */
.thread-bar { display: flex; justify-content: flex-end; gap: 10px; margin: -6px 0 14px; flex-wrap: wrap; }
.thread-bar select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--surface); flex: 0 1 320px; min-width: 0; }
.thread-bar .secondary-btn { padding: 8px 14px; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin-bottom: 10px; font-size: 14px; }
.back:hover { color: var(--blue); }
.head-actions { display: flex; gap: 10px; align-items: center; }
.head-actions .status-select { padding: 9px 12px; font-size: 14px; }
.project-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.project-link:hover { color: var(--blue); text-decoration: underline; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.tasks { list-style: none; margin: 0; padding: 0; }
.tasks li { border-bottom: 1px solid var(--line); }
.tasks li:last-child { border-bottom: 0; }
.tasks li.empty { padding: 8px 0; border: 0; }
.task label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; cursor: pointer; font-size: 14px; }
.task input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--blue); flex: none; }
.task small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.late small { color: #b42318; }
.task-form { display: grid; grid-template-columns: 1fr 150px auto; gap: 8px; margin-top: 14px; }
.task-form input { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.task-form input:first-of-type { grid-column: 1 / -1; }
@media (max-width: 520px) { .task-form { grid-template-columns: 1fr 1fr; } .task-form button { grid-column: 1 / -1; justify-content: center; } }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 12px; background: var(--bg); }

/* ---------- Floating widget ---------- */
.bram-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 1000;
  display: flex; align-items: center; gap: 10px; padding: 6px 22px 6px 6px; border: 0; border-radius: 999px;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 15px; box-shadow: var(--shadow);
}
.bram-launcher .face { position: relative; }
.bram-launcher img { width: 40px; height: 40px; border-radius: 50%; border: 2px solid #fff; display: block; }
.bram-launcher .face::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px;
  border-radius: 50%; background: #2bc46b; border: 2px solid #fff;
}
.bram-panel {
  position: fixed; right: 20px; bottom: 84px; z-index: 1000;
  width: min(380px, calc(100vw - 32px)); height: min(560px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bram-panel.expanded { width: min(720px, calc(100vw - 32px)); height: calc(100vh - 120px); }
.bram-panel header { display: flex; align-items: center; gap: 12px; padding: 14px 14px 10px 16px; border-bottom: 1px solid var(--line); }
.bram-panel header img { width: 46px; height: 46px; border-radius: 50%; }
.bram-panel header strong { display: block; font-size: 17px; }
.bram-panel header small { color: var(--muted); }
.bram-panel header .actions { margin-left: auto; display: flex; }
.bram-panel .thread { flex: 1; overflow-y: auto; padding: 14px; }
.bram-panel .project-card { grid-template-columns: 1fr; }
.bram-panel .project-card .thumb { width: 100%; }
.bram-panel footer { padding: 10px 12px 12px; border-top: 1px solid var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .portal { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .nav { min-width: 0; }
  .sidebar { padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); position: static; height: auto; overflow: visible; }
  .recents { display: none; }  /* phones keep the conversation picker on Home */
  .logo { margin: 0 0 10px; font-size: 24px; }
  .nav { grid-auto-flow: column; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .view { padding: 20px 16px 32px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .panels { grid-template-columns: 1fr; }
  .project-card { grid-template-columns: 1fr; }
  .project-card .thumb { width: 100%; }
}
@media (max-width: 900px) {
  /* The user's initials sit at the right of the sidebar row. */
  .portal { position: relative; }
  .sidebar .user-menu { position: absolute; top: 10px; right: 16px; margin: 0; padding: 0; border: 0; z-index: 1; }
  .user-menu > .user { width: auto; padding: 4px 8px 4px 4px; }
  .user-menu .menu { top: calc(100% + 6px); bottom: auto; left: auto; min-width: 200px; }
  .user-menu .caret { transform: none; }
  .nav { mask-image: linear-gradient(to right, #000 85%, transparent); -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); padding-right: 24px; }
  #view-home.chatting { min-height: calc(100vh - 112px); }
  #view-home.chatting .composer-dock { margin: 8px -16px 0; padding: 24px 16px 16px; }
}
@media (max-width: 640px) {
  /* Projects as cards */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border-bottom: 1px solid var(--line); padding: 12px 14px; }
  .table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
  .table td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
  .table td.cell-name { display: block; padding-bottom: 6px; }
  .table td.cell-name small.desc { max-width: none; }
  .action-details { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .thread-bar select { flex: 1 1 auto; }
  .action-details dd { margin-bottom: 6px; }
  .action-details dt { max-width: none; }
  dialog .row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .tiles { grid-template-columns: 1fr; }
  .user [data-user-name] { display: none; }
  /* Launcher: just Bram's face, so it covers less */
  body:not(.embedded) .bram-launcher { padding: 6px; right: 14px; bottom: 14px; font-size: 0; gap: 0; }
  body:not(.embedded) .bram-launcher img { width: 46px; height: 46px; }
  .view { padding-bottom: 88px; }
}

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px; text-align: center;
}
.login-card img { width: 84px; height: 84px; border-radius: 50%; }
.login-card h1 { margin: 10px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 16px; color: var(--muted); }
.login-card form { display: grid; gap: 12px; }
.login-card input { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.login-card .primary-btn { justify-content: center; }

/* ---------- Desktop app window (static/app.html) ----------
   The desktop app sizes its transparent window to whatever is showing,
   so the widget fills the window instead of floating over a page. */
body.embedded { background: transparent; overflow: hidden; }
body.embedded .bram-launcher { right: 10px; bottom: 10px; }
body.embedded .bram-panel,
body.embedded .bram-panel.expanded { right: 10px; bottom: 74px; width: calc(100vw - 20px); height: calc(100vh - 84px); }
/* Electron has no speech recognition service. */
body.in-desktop-app [data-mic] { display: none; }
