/* Ask TiE — public interface. Visual reference: Design/ask-tie-homepage-mockup.png */
:root {
  --red: #e2111b;
  --red-dark: #b80d15;
  --red-tint: #fdecec;
  --charcoal: #1d1f23;
  --text: #2b2e33;
  --muted: #5d636b;
  --subtle: #8a9098;
  --pale: #f4f4f5;
  --pale-2: #ececee;
  --line: #e2e3e6;
  --white: #ffffff;
  --amber-bg: #fff6df;
  --amber-line: #f0d48a;
  --amber-text: #6b4e00;
  --focus: #1a5fd0;
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar: 330px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--red-dark); }
img, svg { display: block; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--charcoal); color: #fff; padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ layout */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  background: var(--pale);
  display: flex;
  flex-direction: column;
  padding: 24px 22px 18px;
  overflow-y: auto;
  position: relative;   /* contains its own scrolled content, like .view */
  border-right: 1px solid var(--pale-2);
}

.brand { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; width: fit-content; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  background: var(--red); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 34px;
  line-height: 1; padding: 6px 9px 7px; letter-spacing: -1px; border-radius: 2px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 19px; line-height: 1.02; letter-spacing: .3px; color: var(--charcoal); }
.brand-tag { font-size: 8.5px; letter-spacing: 2.6px; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-top: 4px; }


.btn-new {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 1.5px solid var(--red); color: var(--red); background: var(--white);
  border-radius: 8px; padding: 11px 16px; font-weight: 600; font-size: 17px; cursor: pointer;
}
.btn-new:hover { background: var(--red-tint); }
.btn-new .icon { width: 22px; height: 22px; stroke-width: 2; }

.side-label { font-size: 15px; font-weight: 600; color: var(--muted); margin: 28px 0 8px; }
.side-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 10px; border: 0; background: none;
  font-size: 17px; color: var(--charcoal); text-align: left; text-decoration: none; border-radius: 8px; cursor: pointer;
}
.side-link:hover, .side-link[aria-current="page"] { background: var(--pale-2); }
.side-link .icon { color: var(--charcoal); }
.side-divider { border: 0; border-top: 1px solid #d9dadd; margin: 20px 0 0; }

.recent { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.recent .side-link { font-size: 15.5px; padding: 8px 10px; }
.recent .side-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .icon { width: 21px; height: 21px; }
.recent-empty { font-size: 14px; color: var(--subtle); padding: 4px 10px; margin: 0; }

.sidebar-foot { margin-top: auto; padding-top: 18px; }

/* ------------------------------------------------------------------ main */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 36px; border-bottom: 1px solid var(--line); background: var(--white);
}
.menu-btn { display: none; border: 0; background: none; padding: 6px; margin-left: -6px; border-radius: 8px; cursor: pointer; }
.topbar-title { min-width: 0; }
.topbar-title h1 { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 800; color: var(--charcoal); line-height: 1.2; }
.topbar-title p { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 22px; }
.visit-link { display: inline-flex; align-items: center; gap: 6px; color: var(--charcoal); text-decoration: none; font-size: 16px; white-space: nowrap; }
.visit-link:hover { text-decoration: underline; }
.visit-link .icon { width: 16px; height: 16px; stroke-width: 2; }
.topbar-sep { width: 1px; height: 36px; background: var(--line); }
/* BETA badge immediately after the title (approved by Kamal, Stage A, 21 Oct 2026): small and understated, in the existing palette.
   Stage B3: beside "Ask TiE" in the branded sidebar on desktop, and in the top bar on mobile (where the sidebar is hidden); exactly one
   is shown in each layout. */
.beta-badge {
  display: inline-block; vertical-align: middle; position: relative; top: -2px; margin-left: 8px; padding: 1px 6px; border: 1px solid var(--red);
  border-radius: 4px; background: #fff; color: var(--red-dark); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; line-height: 1.5; white-space: nowrap;
}
.beta-mobile { display: none; }
/* The header title: "Explore TiE" beside the branded sidebar; "Ask TiE" (with BETA) on phones, where the sidebar is a drawer. The tagline
   is left out when the title area is too narrow for it on one line (narrow windows, 125–150 % zoom), as on phones, so the header keeps its height. */
.title-brand { display: none; }
.topbar-title { flex: 1 1 auto; container-type: inline-size; }
@container (max-width: 410px) { .topbar-title p { display: none; } }
.btn-join {
  background: var(--red); color: #fff; text-decoration: none; font-weight: 700; padding: 11px 26px; border-radius: 8px; white-space: nowrap;
}
.btn-join:hover { background: var(--red-dark); }

.banner {
  background: var(--amber-bg); border-bottom: 1px solid var(--amber-line); color: var(--amber-text);
  font-size: 14px; padding: 8px 36px; display: flex; gap: 8px; align-items: center;
}
.banner .icon { width: 18px; height: 18px; }

/* The scroll container is also the containing block of absolutely positioned content inside it (the visually hidden “opens in a new
   tab” text of answer links), so that content scrolls and clips with the conversation instead of lengthening the page itself. */
.view { flex: 1; overflow-y: auto; scroll-behavior: smooth; position: relative; }
.view:focus { outline: none; }

/* ------------------------------------------------------------------ welcome */
.welcome { max-width: 1080px; margin: 0 auto; padding: 44px 32px 8px; text-align: center; }
.hero-icon { width: 92px; height: 92px; margin: 0 auto 18px; color: var(--red); }
.hero-icon .icon { width: 92px; height: 92px; stroke-width: 1.6; }
.welcome h2 {
  font-family: var(--font-display); font-size: clamp(30px, 4.2vw, 46px); font-weight: 800; color: var(--charcoal);
  letter-spacing: -.6px; line-height: 1.12; margin: 0 0 12px;
}
.welcome .lead { font-size: clamp(17px, 1.9vw, 22px); color: var(--muted); margin: 0 0 20px; }
.stat-pill {
  display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px;
  background: var(--pale); border-radius: 12px; padding: 9px 26px; color: var(--text); font-size: 17px; margin-bottom: 26px;
}
.stat-pill span + span::before { content: "•"; margin-right: 14px; color: var(--muted); }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; text-align: left; }
.card {
  display: flex; align-items: center; gap: 20px; padding: 26px 26px 26px 28px; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left; width: 100%;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
  transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: #c9cbd0; box-shadow: var(--shadow); }
.card .icon { color: var(--red); width: 44px; height: 44px; stroke-width: 1.6; }
.card-text { flex: 1; min-width: 0; }
.card-text strong { display: block; font-size: 20px; color: var(--charcoal); font-weight: 700; margin-bottom: 4px; }
.card-text span { color: var(--muted); font-size: 17px; }
.card .chev { color: var(--charcoal); width: 22px; height: 22px; }

/* ------------------------------------------------------------------ conversation */
.thread { max-width: 860px; margin: 0 auto; padding: 32px 32px 12px; display: flex; flex-direction: column; gap: 26px; }
.msg-user { align-self: flex-end; max-width: 80%; background: var(--pale); border-radius: 16px 16px 4px 16px; padding: 12px 18px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--charcoal); }
.msg-ai { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: start; }
.avatar {
  width: 36px; height: 36px; border-radius: 8px; background: var(--red); color: #fff; font-weight: 800; font-size: 13px;
  display: grid; place-items: center; letter-spacing: -.3px; font-family: var(--font-display);
}
.msg-body { min-width: 0; }
.answer { color: var(--text); overflow-wrap: anywhere; }
.answer p { margin: 0 0 12px; }
.answer p:last-child { margin-bottom: 0; }
.answer ul { margin: 0 0 12px; padding-left: 22px; }
.answer li { margin: 4px 0; }
.answer strong { color: var(--charcoal); }
.answer .table-wrap { overflow-x: auto; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 8px; }
.answer table { border-collapse: collapse; width: 100%; font-size: 15px; }
.answer th, .answer td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: normal; }
.answer td:first-child, .answer th:first-child { white-space: nowrap; }
.answer th { background: var(--pale); font-weight: 600; }
.answer tr:last-child td { border-bottom: 0; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; border-radius: 999px; padding: 3px 10px; font-weight: 600; }
.tag .icon { width: 14px; height: 14px; stroke-width: 2.2; }
.tag-review { background: var(--amber-bg); color: var(--amber-text); border: 1px solid var(--amber-line); }
.tag-info { background: var(--pale); color: var(--muted); }

.note {
  display: flex; gap: 10px; background: var(--pale); border-radius: 8px; padding: 10px 14px; font-size: 14.5px; color: var(--muted); margin-top: 14px;
}
.note .icon { width: 18px; height: 18px; margin-top: 2px; }

.distance-info { margin-top: 10px; font-size: 14px; color: var(--muted); }
.distance-info summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 2px 4px; cursor: pointer; border-radius: 6px; list-style: none; font-weight: 600; }
.distance-info summary::-webkit-details-marker { display: none; }
.distance-info summary .icon { width: 16px; height: 16px; }
.distance-info summary:hover { color: var(--charcoal); text-decoration: underline; }
.distance-info p { margin: 4px 0 0; background: var(--pale); border-radius: 8px; padding: 8px 12px; }

/* Official branding illustrations (brand-visuals.js): shown unchanged on white, scaled to fit; selecting one opens it full size. */
.brand-visuals { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.brand-visual { margin: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.brand-visual a { display: block; cursor: zoom-in; }
.brand-visual img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: contain; background: #fff; }
/* A group (V16): the photographs side by side, wrapping to one per row on narrow screens; each keeps its own proportions. */
.brand-group .brand-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line); }
.brand-group img { max-height: 360px; }
.brand-visual figcaption { padding: 8px 12px 10px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text); background: var(--pale); }
.brand-source { color: var(--muted); }

.sources { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.sources h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--subtle); margin: 0 0 8px; font-weight: 700; }
.sources ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.sources a { color: var(--red-dark); text-decoration: none; }
.sources a:hover { text-decoration: underline; }
.sources .ext { display: inline; width: 13px; height: 13px; vertical-align: -1px; margin-left: 3px; }
.sources .checked { color: var(--subtle); }

.msg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; font-size: 14.5px; cursor: pointer; color: var(--charcoal);
}
.chip:hover { border-color: #c4c6cb; background: var(--pale); }
.fb { display: inline-flex; gap: 4px; margin-left: auto; }
.fb button { border: 0; background: none; padding: 6px; border-radius: 6px; cursor: pointer; color: var(--subtle); }
.fb button:hover { color: var(--charcoal); background: var(--pale); }
.fb button[aria-pressed="true"] { color: var(--red); }
.fb .icon { width: 19px; height: 19px; }
.fb-thanks { font-size: 13px; color: var(--muted); }
/* "Not helpful" reasons (Continuous Learning Phase 1): a small optional row below the reply's actions; wraps on a phone. */
.fb-reasons { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.fb-reasons[hidden] { display: none; }
.chip-sm { padding: 4px 11px; font-size: 13px; }
.chip[aria-pressed="true"] { border-color: var(--red); color: var(--red); }
.fb-comment { font-size: 13px; color: var(--muted); }

.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; padding-top: 6px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; background: var(--red); border-radius: 50%; animation: blink 1.2s infinite ease-in-out both; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }

.error-box { border: 1px solid #f3c2c4; background: #fff5f5; color: #8a1016; border-radius: 8px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.error-box button { border: 1px solid #e3a3a6; background: #fff; border-radius: 6px; padding: 4px 12px; cursor: pointer; color: #8a1016; }

/* ------------------------------------------------------------------ composer */
.composer-wrap { padding: 12px 32px 6px; background: linear-gradient(to bottom, rgba(255,255,255,0), #fff 18px); }
.composer-inner { max-width: 1080px; margin: 0 auto; }
.is-chat .composer-inner { max-width: 860px; }
.composer {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); box-shadow: var(--shadow);
  padding: 16px 16px 14px 24px; display: grid; grid-template-columns: 1fr auto; gap: 10px 14px; align-items: end;
}
.composer:focus-within { border-color: #b9bcc2; }
.composer textarea {
  grid-column: 1 / 2; border: 0; resize: none; outline: none; font-size: 18px; line-height: 1.45; min-height: 30px; max-height: 180px;
  padding: 4px 0; background: transparent;
}
.composer textarea::placeholder { color: var(--subtle); }
.send {
  grid-column: 2; grid-row: 1; align-self: end; width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: var(--red); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.send:hover { background: var(--red-dark); }
.send:disabled { background: #e9a3a6; cursor: not-allowed; }
.send .icon { width: 24px; height: 24px; stroke-width: 2.4; }
/* Disclaimer directly beneath the chat input (approved by Kamal, Stage A, 21 Oct 2026): always visible, centred, subtle grey. */
.composer-disclaimer { text-align: center; font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: 6px;
}
.link-btn .icon { width: 16px; height: 16px; }
.link-btn:hover { color: var(--red-dark); text-decoration: underline; }
.notice {
  margin: 0 auto 18px; max-width: 520px; padding: 10px 14px; border-radius: var(--radius); background: var(--pale);
  color: var(--charcoal); font-size: 14.5px; text-align: center;
}

/* Privacy · About Ask TiE: one small, muted line at the foot of the sidebar, below Help & feedback (28 Oct 2026; there is no footer
   in the chat area). The GeoNames attribution (CC BY 4.0) is in About Ask TiE, under Data attribution. */
.side-meta { margin: 2px 0 0; padding: 0 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.side-meta button { border: 0; background: none; padding: 2px 0; font: inherit; color: inherit; cursor: pointer; }
.side-meta button:hover, .side-meta button:focus-visible { color: var(--charcoal); text-decoration: underline; }
.about-sub { margin: 18px 0 4px; font-size: 14px; color: var(--muted); }
#about-geo a { color: inherit; }

/* Phone keyboards (Beta 2): on touch devices the script sets --app-height and --app-top to the visible area (window.visualViewport: its
   height and, when iPhone Safari pans it down the page, its offset), so the question box stays just above the keyboard; elsewhere, and in
   browsers without dvh, the approved layout is unchanged (offset 0). */
@supports (height: 100dvh) {
  .app { height: var(--app-height, 100dvh); margin-top: var(--app-top, 0px); }
}

/* ------------------------------------------------------------------ directory */
.page { max-width: 1080px; margin: 0 auto; padding: 32px 32px 40px; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-family: var(--font-display); font-size: 32px; font-weight: 800; margin: 0; color: var(--charcoal); }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px 11px 42px; font-size: 16px; background: var(--white);
}
.search input:focus { border-color: #b9bcc2; outline: none; box-shadow: 0 0 0 3px rgba(26, 95, 208, .15); }
.search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--subtle); }
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.chapter-card {
  display: flex; flex-direction: column; gap: 4px; height: 100%; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: inherit; background: var(--white);
}
.chapter-card:hover { border-color: #c4c6cb; box-shadow: var(--shadow); }
.chapter-card strong { font-size: 17px; color: var(--charcoal); }
.chapter-card span { font-size: 14px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--radius); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; margin-bottom: 16px; font-size: 15px; }
.back:hover { color: var(--charcoal); }
.back .icon { width: 18px; height: 18px; transform: rotate(180deg); }
.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.detail-grid > div { display: flex; flex-direction: column; gap: 18px; }
[tabindex="-1"]:focus { outline: none; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.panel h3 { margin: 0 0 12px; font-size: 18px; color: var(--charcoal); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; color: var(--charcoal); overflow-wrap: anywhere; }
.unknown { color: var(--subtle); font-style: italic; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; background: var(--red); color: #fff; border: 0; border-radius: 8px;
  padding: 11px 20px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary .icon { width: 18px; height: 18px; stroke-width: 2; }
.document-meta { color: var(--muted); font-size: 14px; margin: 0; }.btn-secondary {
  display: inline-flex; align-items: center; gap: 8px; background: var(--white); color: var(--charcoal); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 18px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-secondary:hover { background: var(--pale); }
.actions-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ------------------------------------------------------------------ dialog */
dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--text);
}
dialog::backdrop { background: rgba(20, 22, 26, .45); }
.dialog-body { padding: 24px 26px; }
.dialog-body h2 { margin: 0 0 12px; font-size: 22px; color: var(--charcoal); }
.dialog-body p { margin: 0 0 12px; }
.dialog-body label { display: block; font-weight: 600; margin: 12px 0 6px; }
.dialog-body textarea { width: 100%; min-height: 120px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; resize: vertical; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 26px 22px; }
.form-status { font-size: 14px; color: var(--muted); min-height: 20px; margin-top: 8px; }

.scrim { display: none; }
.short { display: none; }
.chapter-grid .empty { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  :root { --sidebar: 272px; }
  .card { padding: 20px; gap: 16px; }
  .card-text strong { font-size: 18px; }
  .card-text span { font-size: 15.5px; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 40; transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.18);
  }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(20, 22, 26, .4); z-index: 30; }
  .menu-btn { display: inline-grid; place-items: center; }
  .topbar { padding: 10px 16px; gap: 10px; }
  .topbar-title h1 { font-size: 20px; }
  .topbar-title p { display: none; }
  .topbar-actions { gap: 12px; }
  .topbar-sep { display: none; }
  .visit-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .long { display: none; }
  .short { display: inline; }
  .beta-badge { font-size: 10px; margin-left: 6px; padding: 0 5px; }
  .beta-mobile { display: inline-block; }
  .title-explore { display: none; }
  .title-brand { display: inline; }
  .composer-disclaimer { font-size: 12px; margin-top: 6px; }
  .btn-join { padding: 9px 16px; }
  .banner { padding: 7px 16px; font-size: 13px; }
  .welcome { padding: 26px 16px 4px; }
  .hero-icon, .hero-icon .icon { width: 64px; height: 64px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 16px; }
  .card .icon { width: 34px; height: 34px; }
  .stat-pill { font-size: 15px; padding: 8px 16px; }
  .thread { padding: 20px 16px 8px; }
  .msg-user { max-width: 92%; }
  .msg-ai { grid-template-columns: 1fr; gap: 8px; }
  .avatar { width: 28px; height: 28px; font-size: 11px; }
  .composer-wrap { padding: 8px 12px calc(6px + env(safe-area-inset-bottom)); }
  .composer { padding: 12px 12px 12px 16px; }
  .composer textarea { font-size: 16px; }
  .send { width: 46px; height: 46px; }
  .page { padding: 20px 16px 32px; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.muted-inline { color: var(--subtle); font-size: 14px; }

/* Official TiE logo (approved by Kamal Agarwala, 16 Oct 2026) */
.brand-logo { width: 112px; height: auto; }
.avatar { background: transparent; }
.avatar img { width: 32px; height: auto; }
@media (max-width: 860px) { .brand-logo { width: 96px; } .avatar img { width: 26px; } }

/* Downloads page */
.download-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.download-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px; border: 1px solid var(--line, #e5e5e5); border-radius: 12px; background: #fff; }
.download-card p { margin: 4px 0; }
.download-card .muted { color: var(--muted, #6b6b6b); font-size: 0.875rem; }
.download-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-download, .btn-open { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; text-decoration: none; font-weight: 600; }
.btn-download { background: var(--red, #e2111b); color: #fff; }
.btn-open { border: 1px solid var(--line, #d0d0d0); color: inherit; }
.btn-download .icon { width: 18px; height: 18px; }
@media (max-width: 600px) { .download-card { flex-direction: column; } }

/* The privacy contact before Kamal supplies it: visibly a placeholder (a public deployment refuses to start without the real address). */
.placeholder-text { color: var(--red-dark); font-style: italic; }

/* ------------------------------------------------------------------ full-height layout (CTO, 25 Oct 2026)
   Like a chat application: the page itself never scrolls. The app fills the viewport (100dvh); only the conversation panel and, when
   needed, the sidebar's recent conversations scroll. The welcome screen shrinks with the available height and is centred in its panel;
   the composer stays anchored below it. On very short viewports the panels scroll locally rather than clip anything.
   Public page only: the admin page (html.admin-page) also loads this stylesheet and is an ordinary scrolling document (28 Oct 2026: with
   the lock, long admin forms could not be scrolled to their Save and Publish buttons). */
html:not(.admin-page), html:not(.admin-page) > body { overflow: hidden; overscroll-behavior: none; }
.app { grid-template-rows: minmax(0, 1fr); }
.sidebar, .main { min-height: 0; }

.view { display: flex; flex-direction: column; overscroll-behavior: contain; }
.view > section { flex: none; width: 100%; }
.welcome { margin: auto; padding: clamp(12px, 3vh, 40px) 32px clamp(8px, 2vh, 20px); }
.hero-icon, .hero-icon .icon { width: clamp(44px, 8vh, 92px); height: clamp(44px, 8vh, 92px); }
.hero-icon { margin-bottom: clamp(6px, 1.6vh, 18px); }
.welcome h2 { font-size: clamp(26px, min(4.2vw, 5vh), 46px); margin-bottom: clamp(6px, 1.2vh, 12px); }
.welcome .lead { font-size: clamp(16px, min(1.9vw, 2.4vh), 22px); margin-bottom: clamp(10px, 2vh, 20px); }
.stat-pill { font-size: clamp(14px, 2vh, 17px); padding: clamp(5px, 1vh, 9px) 22px; margin-bottom: clamp(12px, 2.6vh, 26px); }
.cards { gap: clamp(10px, 1.8vh, 18px); }
.card { gap: clamp(12px, 1.6vw, 20px); padding: clamp(12px, 2.6vh, 26px) clamp(16px, 2vw, 26px); }
.card .icon { width: clamp(30px, 5vh, 44px); height: clamp(30px, 5vh, 44px); }
.card .chev { width: 20px; height: 20px; }
.card-text strong { font-size: clamp(16px, 2.3vh, 20px); }
.card-text span { font-size: clamp(14px, 2vh, 17px); }

.topbar { padding-top: clamp(8px, 1.8vh, 16px); padding-bottom: clamp(8px, 1.8vh, 16px); }
.composer-wrap { padding-top: 8px; }
.composer { padding: clamp(10px, 1.6vh, 16px) 16px clamp(10px, 1.4vh, 14px) 24px; }
.composer-disclaimer { margin-top: 6px; }

.sidebar { overflow-y: auto; padding-top: clamp(12px, 2.6vh, 24px); padding-bottom: clamp(10px, 2vh, 18px); }
.brand-logo { width: clamp(64px, 11vh, 112px); }
.btn-new { padding-top: clamp(7px, 1.2vh, 11px); padding-bottom: clamp(7px, 1.2vh, 11px); }
.side-label { margin: clamp(10px, 2.4vh, 28px) 0 clamp(4px, .8vh, 8px); }
.side-link { padding-top: clamp(5px, 1vh, 10px); padding-bottom: clamp(5px, 1vh, 10px); }
.side-divider { margin-top: clamp(10px, 2vh, 20px); }
/* The recent list takes the remaining height and scrolls on its own; the padding keeps keyboard focus rings visible inside it. */
.recent { flex: 1 1 auto; min-height: 48px; overflow-y: auto; overscroll-behavior: contain; padding: 3px; margin: -3px; }
.recent:empty { flex: none; min-height: 0; padding: 0; margin: 0; }
.sidebar-foot { padding-top: clamp(6px, 1.6vh, 18px); }

/* Short laptop screens and browser zoom: the large icon goes first, then spacing tightens, so the questions and cards keep their room. */
@media (max-height: 740px) {
  .hero-icon { display: none; }
}
@media (max-height: 640px) {
  .welcome { padding-top: 8px; }
  .welcome h2 { margin-bottom: 4px; }
  .welcome .lead { margin-bottom: 8px; }
  .stat-pill { margin-bottom: 10px; }
  .cards { gap: 8px; }
  .card { padding-top: 10px; padding-bottom: 10px; }
}
/* Very short viewports (a phone held sideways, heavy zoom): the panels scroll locally instead of clipping anything. The conversation
   panel already scrolls on its own, so the question box stays anchored below it; this includes an iPhone with the keyboard open
   (Chrome on iOS: 344px of 666, 2 Nov 2026), where a scrolling main column had left the box below the visible area. */
@media (max-height: 420px) {
  .sidebar { overflow-y: auto; }
  .recent { flex: none; overflow: visible; }
}

/* Phones: safe areas (notches, home indicator) and compact cards, so the welcome screen and composer fit. */
@media (max-width: 860px) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .composer-wrap { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  /* The drawer scrolls as a whole, so its recent list is never squeezed. */
  .sidebar { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .recent { flex: none; min-height: 0; overflow: visible; }
  .welcome { padding: 16px max(16px, env(safe-area-inset-left)) 8px; }
  .hero-icon { display: none; }
  .card { padding: 10px 12px; gap: 12px; }
  .card .icon { width: 28px; height: 28px; }
  .card-text strong { font-size: 16px; margin-bottom: 2px; }
  .card-text span { font-size: 14px; }
  .composer { padding: 10px 10px 10px 14px; }
}

/* ------------------------------------------------------------------ sidebar brand: official logo + "Ask TiE" wordmark (Product Owner, 30 Oct 2026)
   The official TiE logo, unchanged, beside the wordmark: "Ask" in charcoal and "TiE" in the red token (the display typeface, no web font),
   a small "Public Beta" beside it and "Your AI Guide to TiE" beneath (Product Owner, public beta decision, USER-072). The same block heads the mobile navigation drawer. The conversation
   header no longer repeats the brand on desktop ("Explore TiE"); on phones, where the sidebar is a drawer, it keeps "Ask TiE" (measured in
   Chrome by scripts/check-sidebar-brand.ps1). */
.sidebar { --logo-w: clamp(44px, 7vh, 56px); }
.brand-block { margin-bottom: clamp(10px, 1.8vh, 18px); }
.brand { flex-direction: row; align-items: center; gap: 12px; width: auto; max-width: 100%; }
.sidebar .brand-logo { width: var(--logo-w); height: auto; flex: none; }
.brand-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.brand-wordmark { display: flex; align-items: center; gap: 8px; }
.brand-name { font-size: 24px; line-height: 1.1; letter-spacing: 0; white-space: nowrap; }
.brand-tie { color: var(--red); }
.brand-block .beta-badge { top: 0; margin-left: 0; font-size: 10px; padding: 0 5px; }
.brand-sub { font-size: 13.5px; line-height: 1.3; color: var(--muted); }
@media (max-width: 1100px) { .sidebar { --logo-w: 44px; } .brand { gap: 10px; } .brand-sub { font-size: 12px; } }
/* The separate "Ask TiE" heading is gone; the vertical space it used goes to Recent conversations. */
.sidebar .side-label { margin: clamp(8px, 1.6vh, 20px) 0 clamp(3px, .6vh, 6px); }
.sidebar .side-nav .side-link { padding-top: clamp(4px, .75vh, 8px); padding-bottom: clamp(4px, .75vh, 8px); }
.sidebar .side-divider { margin-top: clamp(6px, 1.2vh, 14px); }
.sidebar .recent { min-height: 72px; }
.sidebar .recent:empty { min-height: 0; }
@media (max-width: 860px) {
  .sidebar { --logo-w: 52px; }
  .sidebar .recent { min-height: 0; }
}

/* Phone header ("Ask TiE"): "Ask" in the heading colour and "TiE" in the official red token, same family, weight, size and baseline. */
.topbar-title .title-tie { color: var(--red); }

.dialog-body h3 { margin: 16px 0 4px; font-size: 16px; color: var(--charcoal); }
