@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/montserrat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/montserrat-latin-700-normal.woff2') format('woff2'); }

/* Mind Therapy Clinic palette (mtc-web-app/src/global-styles.css):
   main #007cbb, hover #1567b3, light #d8f0ff, highlight #00b4e1,
   accent #f08b1e / #df7505, grey #555555, light grey #afafaf,
   success #64a523, alert #d85353, secondary accent #923a8b. */
:root {
  --mtc-blue: #007cbb;
  --mtc-blue-hover: #1567b3;
  --mtc-blue-light: #d8f0ff;
  --mtc-highlight: #00b4e1;
  --mtc-orange: #f08b1e;
  --mtc-orange-hover: #df7505;
  --mtc-grey: #555555;
  --mtc-light-grey: #afafaf;
  --mtc-success: #64a523;
  --mtc-alert: #d85353;

  --bg: #ffffff;
  --bg-elev: #f5f8fb;
  --bg-sidebar: #eef4f9;
  --fg: #1f2a33;
  --fg-muted: var(--mtc-grey);
  --border: #d9e3ec;
  --accent: var(--mtc-blue);
  --accent-hover: var(--mtc-blue-hover);
  --accent-fg: #ffffff;
  --accent-soft: var(--mtc-blue-light);
  --cta: var(--mtc-orange);
  --cta-hover: var(--mtc-orange-hover);
  --cta-fg: #ffffff;
  --danger: var(--mtc-alert);
  --success: var(--mtc-success);
  --bubble-user: #e4eef6;
  --radius: 12px;
  --font: 'Montserrat', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14191e;
    --bg-elev: #1c242b;
    --bg-sidebar: #10161b;
    --fg: #e8eef3;
    --fg-muted: #9fb0bd;
    --border: #2b3741;
    --accent: #2a9fde;
    --accent-hover: var(--mtc-highlight);
    --accent-fg: #0b1116;
    --accent-soft: #10344a;
    --cta: var(--mtc-orange);
    --cta-hover: #ffa23e;
    --cta-fg: #1a1208;
    --bubble-user: #243039;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--fg); background: var(--bg); font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 280px 1fr 0; height: 100vh; transition: grid-template-columns .2s; }
.app.panel-open { grid-template-columns: 280px 1fr 420px; }
.app.sidebar-collapsed { grid-template-columns: 0 1fr 0; }
.app.sidebar-collapsed.panel-open { grid-template-columns: 0 1fr 420px; }

/* Sidebar */
.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.sidebar-top { padding: 14px 12px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; margin-bottom: 12px; }
.brand-lg { font-size: 24px; justify-content: center; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--mtc-blue), var(--mtc-highlight)); color: #fff; font-size: 15px; font-weight: 700; }
.brand-lg .brand-mark { width: 36px; height: 36px; font-size: 20px; }
.sidebar-search { padding: 0 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-search input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.toggle { font-size: 12px; color: var(--fg-muted); display: flex; gap: 6px; align-items: center; }
.article-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.article-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; }
.article-item:hover { background: var(--bg-elev); }
.article-item.active { background: var(--accent-soft); }
.article-item .t { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article-item .m { display: block; font-size: 12px; color: var(--fg-muted); }
.article-item.archived .t { text-decoration: line-through; color: var(--fg-muted); }
.list-empty { padding: 12px; color: var(--fg-muted); font-size: 13px; }
.sidebar-bottom { border-top: 1px solid var(--border); padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-signout { display: flex; gap: 0; white-space: nowrap; }
.sidebar-signout #sign-out-all { font-size: 12px; padding-left: 4px; }
.user-chip { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.user-chip img, .user-chip .initial { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-weight: 600; flex: none; }
.user-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.main-header { display: flex; align-items: baseline; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.main-title { font-weight: 700; color: var(--accent); letter-spacing: .2px; }
.main-subtitle { color: var(--fg-muted); font-size: 13px; }
.sidebar-toggle { align-self: center; }
.thread { flex: 1; overflow-y: auto; padding: 24px 0; }
.empty { max-width: 640px; margin: 10vh auto 0; text-align: center; padding: 0 20px; }
.empty-mark { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--mtc-blue), var(--mtc-highlight)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 28px; margin: 0 auto 16px; }
.empty h1 { font-size: 26px; margin: 0 0 8px; font-weight: 700; }
.empty p { color: var(--fg-muted); margin: 0 0 20px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.suggestion { border: 1px solid var(--border); background: var(--bg-elev); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.suggestion:hover { border-color: var(--accent); }

.msg { display: flex; gap: 14px; max-width: 760px; margin: 0 auto 22px; padding: 0 20px; }
.msg-avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--bg-elev); }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, var(--mtc-blue), var(--mtc-highlight)); color: #fff; }
.msg-body { min-width: 0; flex: 1; }
.msg.user .msg-content { background: var(--bubble-user); border-radius: var(--radius); padding: 10px 14px; display: inline-block; white-space: pre-wrap; }
.msg-content p { margin: 0 0 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content ul, .msg-content ol { margin: 6px 0 10px; padding-left: 22px; }
.msg-content code { background: var(--bg-elev); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.msg-content pre { background: var(--bg-elev); padding: 10px; border-radius: 8px; overflow-x: auto; }
.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin: 0 1px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--fg); font-size: 11px; font-weight: 600; cursor: pointer; vertical-align: 2px; line-height: 1; }
.cite:hover { background: var(--accent); color: var(--accent-fg); }
.msg-citations { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.source-chip { border: 1px solid var(--border); background: var(--bg-elev); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.source-chip:hover { border-color: var(--accent); }
.source-chip b { color: var(--accent); }
.chip-who { color: var(--fg-muted); }
.article-meta a { color: var(--accent); text-decoration: none; }
.article-meta a:hover { text-decoration: underline; }
a.btn { text-decoration: none; display: inline-block; }
.msg.error .msg-content { color: var(--danger); }
.retry { margin-left: 8px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Publish card */
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); padding: 14px; margin-top: 10px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card label { display: block; font-size: 12px; color: var(--fg-muted); margin: 8px 0 4px; }
.card input, .card select, .card textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.card textarea { min-height: 180px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: flex-end; }
.card .note { font-size: 12px; color: var(--fg-muted); }
.card.published { border-color: var(--success); }

/* Composer */
.composer { padding: 10px 20px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.composer-box { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 8px 14px; background: var(--bg-elev); }
.composer-box:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; outline: none; max-height: 200px; line-height: 1.4; padding: 6px 0; }
.send { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--cta); color: var(--cta-fg); cursor: pointer; }
.send:hover:not(:disabled) { background: var(--cta-hover); }
.send:disabled { opacity: .4; cursor: default; }
.composer-hint { max-width: 760px; margin: 6px auto 0; font-size: 11px; color: var(--fg-muted); text-align: center; }
.composer-notice { max-width: 760px; margin: 0 auto 8px; font-size: 13px; color: var(--danger); }

/* Panel */
.panel { border-left: 1px solid var(--border); background: var(--bg-elev); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.panel-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-body { padding: 14px; overflow-y: auto; flex: 1; }
.article-meta { font-size: 12px; color: var(--fg-muted); margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.article-body h1, .article-body h2, .article-body h3 { font-size: 16px; margin: 14px 0 6px; }
.article-body p { margin: 0 0 10px; }
.article-body ul, .article-body ol { padding-left: 22px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.revisions { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.revisions h4 { margin: 0 0 6px; font-size: 13px; }
.revision { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--fg-muted); padding: 4px 0; }
.draft-badge { display: inline-block; font-size: 11px; background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; margin-left: 6px; }
.edit-form label { display: block; font-size: 12px; color: var(--fg-muted); margin: 8px 0 4px; }
.edit-form input, .edit-form select, .edit-form textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.edit-form textarea { min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Buttons */
.btn { border: 1px solid var(--border); background: var(--bg); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--accent); }
.btn-cta { background: var(--cta); color: var(--cta-fg); border-color: var(--cta); font-weight: 600; }
.btn-cta:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { color: var(--fg); background: var(--bg-elev); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; }
.btn-lg { padding: 12px; font-size: 16px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Sign-in page */
.signin-page { display: grid; place-items: center; min-height: 100vh; background: var(--bg-sidebar); padding: 20px; }
.signin-card { background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 36px 32px; max-width: 420px; width: 100%; text-align: center; }
.signin-lead { color: var(--fg-muted); margin: 16px 0 24px; font-size: 14.5px; }
.signin-foot { color: var(--fg-muted); font-size: 12px; margin: 18px 0 0; }

/* Google's standard sign-in button (branding guidelines): light theme by default,
   dark theme under prefers-color-scheme: dark. */
.gsi-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid #747775; background: #ffffff; color: #1f1f1f; font: 500 14px/1 'Roboto', 'Montserrat', system-ui, sans-serif; text-decoration: none; letter-spacing: .25px; transition: box-shadow .15s, background .15s; }
.gsi-button:hover { background: #f8f9fa; box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); }
.gsi-button:focus-visible { outline: 2px solid var(--mtc-blue); outline-offset: 2px; }
.gsi-logo { display: inline-grid; place-items: center; width: 20px; height: 20px; }
@media (prefers-color-scheme: dark) {
  .gsi-button { background: #131314; color: #e3e3e3; border-color: #8e918f; }
  .gsi-button:hover { background: #1f1f20; }
}

@media (max-width: 900px) {
  .app, .app.panel-open, .app.sidebar-collapsed, .app.sidebar-collapsed.panel-open { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .app:not(.sidebar-collapsed) .sidebar { transform: none; }
  .panel { position: fixed; inset: 0 0 0 15%; z-index: 21; }
}
