:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #eef1f7;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --accent: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --amber: #ff9f0a;

  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-soft: rgba(255, 255, 255, 0.42);
  --glass-border: rgba(255, 255, 255, 0.75);
  --popover: rgba(255, 255, 255, 0.94);
  --hairline: rgba(60, 60, 67, 0.12);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 24px 60px -20px rgba(40, 52, 90, 0.28), 0 2px 8px rgba(40, 52, 90, 0.06);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 6px 18px -8px rgba(40, 52, 90, 0.22);
  --blur: blur(28px) saturate(180%);

  --code-bg: rgba(28, 30, 38, 0.92);
  --code-text: #e6e8ee;
  --inline-code: rgba(118, 118, 128, 0.14);
  --user-bubble: linear-gradient(180deg, #2b8cff 0%, #0a6cff 100%);

  --b1: #a8c8ff; --b2: #d7c4ff; --b3: #b5f0de; --b4: #ffd9c7;
  color-scheme: light;
}

/* Dark theme: data-theme is set by theme.js (OS preference unless the user chose one). */
:root[data-theme="dark"] {
  --bg: #07080c;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #7c7c82;
  --accent: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --glass: rgba(30, 32, 40, 0.55);
  --glass-strong: rgba(38, 40, 50, 0.78);
  --glass-soft: rgba(44, 46, 58, 0.45);
  --glass-border: rgba(255, 255, 255, 0.09);
  --popover: rgba(34, 36, 44, 0.96);
  --hairline: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 30px 70px -24px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 8px 20px -10px rgba(0, 0, 0, 0.6);
  --code-bg: rgba(0, 0, 0, 0.55);
  --inline-code: rgba(255, 255, 255, 0.1);
  --b1: #1d3a8a; --b2: #4a2a7a; --b3: #0f4d47; --b4: #5a2c3a;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
body {
  /* App-like page: the document itself never scrolls or bounces, only the message list does. */
  position: fixed; inset: 0; width: 100%; margin: 0;
  font: 15px/1.5 var(--font); letter-spacing: -0.008em;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button, textarea, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; border-radius: 10px; }

/* ---------- backdrop: static mesh gradient (cheap to render, no animated blur) ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(42vw 42vw at 8% 6%, var(--b1) 0%, transparent 70%),
    radial-gradient(40vw 40vw at 96% 4%, var(--b2) 0%, transparent 70%),
    radial-gradient(44vw 44vw at 36% 104%, var(--b3) 0%, transparent 70%),
    radial-gradient(34vw 34vw at 92% 96%, var(--b4) 0%, transparent 70%),
    var(--bg);
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ---------- layout ---------- */
.shell {
  position: relative; z-index: 1; height: 100vh; height: var(--app-height, 100dvh);
  display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 920px);
  justify-content: center; gap: 28px; padding: 24px;
}
.stage { position: relative; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 12px; }
.window {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  border-radius: 28px;
}

/* ---------- titlebar ---------- */
.titlebar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--hairline);
  border-radius: 28px 28px 0 0;
}
.title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.title h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.022em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.subtitle { font-size: 12px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.leds { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.led-item {
  position: relative; display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; border-radius: 999px; cursor: default;
  font-size: 12px; font-weight: 550; color: var(--text-2);
  background: var(--glass-soft); border: 1px solid var(--hairline);
}
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 18%, transparent), 0 0 10px color-mix(in srgb, var(--red) 70%, transparent); }
.led-item[data-on="true"] .led { background: var(--green); box-shadow: 0 0 0 2px color-mix(in srgb, var(--green) 18%, transparent), 0 0 10px color-mix(in srgb, var(--green) 75%, transparent); }
.led-item[data-pending="true"] .led { animation: breathe 1.3s ease-in-out infinite; }
.tip {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 20; width: 270px;
  padding: 12px 14px; border-radius: 16px; background: var(--popover);
  font-size: 12.5px; font-weight: 400; line-height: 1.45; color: var(--text);
  opacity: 0; transform: translateY(-4px); pointer-events: none; transition: opacity 0.18s, transform 0.18s;
}
.tip b { font-weight: 650; }
.tip .muted { color: var(--text-2); }
.tip code { font-family: var(--mono); font-size: 11.5px; }
.led-item:hover .tip, .led-item:focus-visible .tip, .led-item:focus .tip { opacity: 1; transform: none; }
.led-item:focus { outline: none; }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--hairline); border-radius: 50%; background: var(--glass-soft);
  cursor: pointer; transition: background 0.15s, transform 0.15s;
}
.icon-btn:hover { background: var(--glass-strong); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; }
.actions { display: flex; align-items: center; gap: 8px; }
.icon-sun, [data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; min-width: 220px;
  display: grid; gap: 2px; padding: 6px; border-radius: 16px; background: var(--popover);
  animation: menu-in 0.16s ease-out;
}
.menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%;
  padding: 8px 12px; border: none; border-radius: 10px; background: none; cursor: pointer; text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--inline-code); outline: none; }
.menu b { font-weight: 600; font-size: 14px; }
.menu small { color: var(--text-3); font-size: 12px; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.banners { display: grid; gap: 8px; padding: 12px 20px 0; }
.banners:empty { display: none; }
.banner {
  display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px;
  font-size: 13px; background: var(--glass-strong); border: 1px solid var(--hairline);
}
.banner::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.banner.error::before { background: var(--red); box-shadow: 0 0 8px var(--red); }
.banner b { font-weight: 650; }

/* ---------- messages ---------- */
.messages {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 24px 28px 12px;
  scroll-behavior: smooth; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

.empty { text-align: center; padding: 11vh 8px 16px; }
.empty h2 { margin: 0 0 8px; font-size: 34px; font-weight: 700; letter-spacing: -0.035em; }
.empty p { margin: 0 auto 28px; max-width: 460px; color: var(--text-2); font-size: 15px; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 640px; margin: 0 auto; }
.suggestion {
  padding: 9px 15px; border-radius: 999px; cursor: pointer; font-size: 13.5px;
  background: var(--glass-soft); border: 1px solid var(--glass-border); box-shadow: var(--shadow-sm);
  transition: transform 0.15s, background 0.15s;
}
.suggestion:hover { background: var(--glass-strong); transform: translateY(-1px); }

.msg { max-width: 760px; min-width: 0; margin: 0 auto 18px; animation: rise 0.28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.msg-user .bubble {
  max-width: min(600px, 82%); padding: 9px 15px; border-radius: 20px 20px 6px 20px;
  background: var(--user-bubble); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 8px 20px -10px rgba(0, 110, 255, 0.6);
}
.msg-user .files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 82%; }
.msg-notice { text-align: center; font-size: 12.5px; color: var(--text-3); }

.answer { padding: 2px 4px; }
.activity { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.activity:empty { display: none; }
.step {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 12px; color: var(--text-2);
  background: var(--glass-soft); border: 1px solid var(--hairline);
}
.step .dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-3); }
.step[data-status="running"] .dot { background: var(--accent); animation: breathe 1s ease-in-out infinite; }
.step[data-status="done"] .dot { background: var(--green); }
.step[data-status="error"] .dot { background: var(--red); }
.step span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step b { font-weight: 600; color: var(--text); }

.typing { display: inline-flex; gap: 5px; padding: 12px 16px; border-radius: 18px; background: var(--glass-soft); border: 1px solid var(--hairline); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: breathe 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; } .typing i:nth-child(3) { animation-delay: 0.36s; }

.md { overflow-wrap: anywhere; line-height: 1.6; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.2em 0 0.4em; line-height: 1.3; letter-spacing: -0.02em; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.18em; } .md h3, .md h4 { font-size: 1.02em; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md pre { margin: 0 0 0.85em; }
.md ul, .md ol { padding-left: 1.35em; }
.md li + li { margin-top: 0.25em; }
.md code { font-family: var(--mono); font-size: 0.86em; background: var(--inline-code); padding: 0.12em 0.4em; border-radius: 6px; }
.md pre {
  position: relative; max-width: 100%; padding: 14px 16px; border-radius: 16px; overflow-x: auto; overscroll-behavior-x: contain;
  background: var(--code-bg); color: var(--code-text); font-size: 13px; line-height: 1.55;
}
.md pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.md blockquote { padding-left: 14px; border-left: 3px solid var(--hairline); color: var(--text-2); }
.md table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 14px; }
.md th, .md td { padding: 7px 11px; border-bottom: 1px solid var(--hairline); text-align: left; }
.md hr { border: none; border-top: 1px solid var(--hairline); margin: 1.2em 0; }
.code-copy {
  position: absolute; top: 8px; right: 8px; padding: 3px 10px; border-radius: 8px; font-size: 11.5px;
  background: rgba(255, 255, 255, 0.1); color: #d6dae3; border: 1px solid rgba(255, 255, 255, 0.16);
  cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.md pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.caret::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: var(--accent); animation: breathe 0.9s infinite; vertical-align: middle; }

.alert { margin-top: 10px; display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; background: color-mix(in srgb, var(--red) 12%, var(--glass-strong)); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.alert .alert-body { flex: 1; }
.alert.notice { background: var(--glass-soft); border-color: var(--hairline); color: var(--text-2); }
.pill-btn { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--hairline); background: var(--glass-strong); cursor: pointer; font-size: 12.5px; font-weight: 550; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.source {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 11px 5px 9px; border-radius: 999px; font-size: 12.5px; color: var(--text);
  background: var(--glass-soft); border: 1px solid var(--hairline); text-decoration: none;
  transition: background 0.15s;
}
.source:hover { background: var(--glass-strong); text-decoration: none; }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.source i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-3); }
.source[data-integration="jira"] i { background: #0a84ff; }
.source[data-integration="confluence"] i { background: #5e5ce6; }
.source[data-cited="true"] { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--text-3); }
.meta .usage { margin-left: auto; }
.ghost-btn { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: none; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; font-size: 12px; }
.ghost-btn:hover { background: var(--glass-soft); }
.ghost-btn:disabled { opacity: 0.4; cursor: default; }
.ghost-btn svg { width: 14px; height: 14px; }

/* ---------- attachments ---------- */
.file-chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 12px 0 6px; border-radius: 14px; max-width: 220px;
  background: var(--glass-strong); border: 1px solid var(--hairline); font-size: 12.5px;
}
.file-chip .thumb { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; flex: none; background: var(--inline-code); }
.file-chip .badge { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; color: #fff; background: linear-gradient(180deg, #8e8e93, #6e6e73); }
.file-chip .badge[data-kind="pdf"] { background: linear-gradient(180deg, #ff6b5e, #e5382b); }
.file-chip .badge[data-kind="text"] { background: linear-gradient(180deg, #5ac8fa, #0a84ff); }
.file-chip .name { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.file-chip .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .name small { color: var(--text-3); font-size: 11px; }
.file-chip.image-only { padding: 0; width: 64px; height: 64px; }
.file-chip.image-only .thumb { width: 64px; height: 64px; border-radius: 14px; }
.file-chip[data-state="uploading"] { opacity: 0.6; }
.file-chip[data-state="error"] { border-color: var(--red); }
.file-chip[data-state="error"] .name small { color: var(--red); }
.file-chip .remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; padding: 0; border: 2px solid var(--bg); cursor: pointer;
  background: var(--text); color: var(--bg); font-size: 11px; line-height: 1;
}

/* ---------- composer ---------- */
.composer { margin: 8px 20px 20px; border-radius: 26px; padding: 6px; background: var(--glass-strong); box-shadow: var(--shadow-sm); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--glass-border)); }
.tray { display: flex; flex-wrap: wrap; gap: 10px; padding: 10px 8px 6px; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea {
  flex: 1; min-height: 36px; max-height: 200px; resize: none; border: none; outline: none; background: none;
  padding: 7px 6px; line-height: 1.45; font-size: 15px;
}
.composer textarea::placeholder { color: var(--text-3); }
.attach-btn { border: none; background: var(--inline-code); }
.send-btn {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: none; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer; transition: transform 0.15s, background 0.15s;
}
.send-btn:disabled { background: var(--inline-code); color: var(--text-3); cursor: default; }
.send-btn:not(:disabled):active { transform: scale(0.92); }
.send-btn svg { width: 18px; height: 18px; }
.send-btn.stop { background: var(--text); color: var(--bg); }

.dropzone { position: absolute; inset: 0; z-index: 30; padding: 14px; border-radius: 28px; background: color-mix(in srgb, var(--bg) 40%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dropzone-inner { height: 100%; display: grid; place-items: center; border-radius: 22px; border: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); font-weight: 600; font-size: 16px; pointer-events: none; }

/* ---------- Marvin ---------- */
.marvin { position: relative; width: 100%; max-width: 330px; }
.marvin .mv-svg { width: 100%; height: auto; overflow: visible; cursor: pointer; filter: drop-shadow(0 18px 30px rgba(30, 40, 70, 0.18)); }
.marvin-mini { display: none; width: 40px; height: 40px; flex: none; }
.marvin-mini .mv-svg { width: 40px; height: 40px; overflow: visible; }

.mv-white { stroke: rgba(90, 100, 115, 0.35); stroke-width: 1; }
.mv-seam { fill: none; stroke: rgba(60, 70, 85, 0.16); stroke-width: 1.6; stroke-linecap: round; }
.mv-shine { fill: #fff; opacity: 0.75; }
.mv-gloss { fill: #fff; opacity: 0.55; }
.mv-socket { fill: rgba(40, 50, 62, 0.1); }
.mv-lid { stroke: rgba(80, 90, 102, 0.75); stroke-width: 3; stroke-linecap: round; fill: none; }
.mv-spark { fill: #fff; opacity: 0.9; }
.mv-glint { fill: #fff; opacity: 0.28; }
.mv-fingers { fill: none; stroke: #2a2f35; stroke-width: 4.5; stroke-linecap: round; }
.mv-sole { fill: #2a2f35; }
.mv-collar { fill: #1d2125; }
.mv-floor { fill: rgba(20, 30, 60, 0.16); }
.mv-light { fill: #9aa3ae; transition: fill 0.4s; }
.mv-eyeball { transform-box: fill-box; transform-origin: center; transition: transform 0.09s ease-in; }
.mv-svg.is-blinking .mv-eyeball { transform: scaleY(0.07); }
.mv-svg .mv-body { animation: sigh 7s ease-in-out infinite; transform-origin: 150px 455px; }
.mv-svg.is-thinking .mv-light { fill: #64d2ff; animation: breathe 1.1s ease-in-out infinite; }
.mv-svg.is-error .mv-light { fill: var(--red); }

.mv-bubble {
  position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  width: max-content; max-width: 280px; padding: 11px 15px; border-radius: 20px;
  background: var(--glass-strong); font-size: 13.5px; line-height: 1.4; color: var(--text); text-align: center;
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.mv-bubble::after {
  content: ""; position: absolute; left: 50%; top: 100%; width: 14px; height: 14px; margin-top: -7px;
  background: var(--glass-strong); border-right: 1px solid var(--glass-border); border-bottom: 1px solid var(--glass-border);
  transform: translateX(-50%) rotate(45deg);
}
.mv-bubble.is-leaving { opacity: 0; transition: opacity 0.35s; }

@keyframes sigh { 0%, 78%, 100% { transform: translateY(0); } 86% { transform: translateY(3px) scaleY(0.99); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .stage { display: none; }
  .marvin-mini { display: block; }
  .titlebar { padding-left: 12px; }
}
@media (max-width: 640px) {
  .shell { padding: 0; gap: 0; overflow: hidden; }
  .window { border-radius: 0; border: none; overflow: hidden; }
  .titlebar { border-radius: 0; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
  .actions { gap: 4px; }
  .titlebar .icon-btn { width: 32px; height: 32px; }
  .subtitle { display: none; }
  .title-long { display: none; }
  .led-label { display: none; }
  .leds { gap: 4px; }
  .led-item { padding: 8px; }
  /* Tooltips become a full-width sheet under the title bar (tap a LED to show it). */
  .tip { position: fixed; top: calc(64px + env(safe-area-inset-top)); left: 12px; right: 12px; width: auto; }
  .messages { padding: 16px 14px 8px; }
  .msg-user .bubble, .msg-user .files { max-width: 88%; }
  .source span { max-width: 230px; }
  .composer { margin: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .empty { padding-top: 7vh; }
  .empty h2 { font-size: 28px; }
  .meta .usage { display: none; }
}
/* iOS zooms into inputs smaller than 16px on focus, which makes the whole page pan around. */
@media (max-width: 640px), (pointer: coarse) {
  .composer textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}
