/* 設計稿字型：思源黑體（Google Fonts 會依用到的字分段下載） */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;900&display=swap");

:root {
  --bg: #dfe8ed;
  --panel: #ffffff;
  --panel-2: #eef3f6;
  --text: #1f2d3a;
  --muted: #5b6b78;
  --accent: #048e94;
  --accent-2: #22c55e;
  --danger: #f97316;
  --border: #c7d7e4;
  --slate: #607e8a;
  --header-bg: linear-gradient(89.98deg, #edeae4 0.01%, #e0d5bf 99.99%);
  --header-border: #bea679;
  --system-bg: #cfd8db;
  --strong: #323333;
  --user-border: #4eb6ac;
  --input-border: #01bfa5;
  --voice-bg: #f5f5f5;
  --voice-border: #edeff1;
  --gold: #bea679;
}

* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }

body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 21px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.brand { display: flex; gap: 17px; align-items: flex-start; }

/* 設計稿的「APCUG 2026」字標圖（Figma 匯出的 SVG，內嵌為 data URI，不用改 Dockerfile 的 COPY 清單）；文字保留給螢幕閱讀器 */
.logo {
  flex-shrink: 0;
  width: 74.63px;
  height: 50.25px;
  font-size: 0;
  color: transparent;
  background: url("data:image/svg+xml,%3Csvg width='63' height='43' viewBox='0 0 63 43' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4.71005 14.22L4.02005 19.01H0.550049L3.84005 0.449951H8.83005L12.19 19.01H8.58005L7.89005 14.22H4.71005ZM6.30005 2.86995L4.96005 12.22H7.63005L6.29005 2.86995H6.30005Z' fill='%23323333'/%3E%3Cpath d='M12.74 19.47H8.18L7.49 14.68H5.1L4.41 19.47H0L3.45 0H9.2L12.73 19.47H12.74ZM8.98 18.55H11.65L8.46 0.91H4.24L1.11 18.55H3.64L4.32999 13.76H8.3L8.99 18.55H8.98ZM8.17 12.68H4.43999L5.85 2.81H6.75999L8.17 12.68ZM5.49 11.76H7.11L6.3 6.1L5.49 11.76Z' fill='%23323333'/%3E%3Cpath d='M14.4299 0.449951H22.2699L24.4399 1.90995V10.11L22.2699 11.57H17.8999V18.99H14.4299V0.449951ZM20.9699 9.14995V2.89995L20.2499 2.40995H17.8999V9.63995H20.2499L20.9699 9.14995Z' fill='%23323333'/%3E%3Cpath d='M18.36 19.47H13.98V0H22.42L24.91 1.68V10.37L22.42 12.05H18.37V19.47H18.36ZM14.89 18.55H17.44V11.13H22.13L23.98 9.88V2.16L22.13 0.91H14.89V18.55ZM20.39 10.09H17.44V1.95H20.39L21.43 2.65V9.39L20.39 10.09ZM18.36 9.18H20.11L20.51 8.91V3.15L20.11 2.88H18.36V9.19V9.18Z' fill='%23323333'/%3E%3Cpath d='M26.8999 1.91995L29.0699 0.449951H34.4099L36.5799 1.91995V6.08995H33.1099V2.89995L32.3899 2.40995H31.0899L30.3699 2.89995V16.52L31.0899 17.01H32.3899L33.1099 16.52V13.35H36.5799V17.54L34.4099 19.01H29.0699L26.8999 17.54V1.91995Z' fill='%23323333'/%3E%3Cpath d='M34.5499 19.47H28.9199L26.4299 17.79V1.68L28.9199 0H34.5499L37.0399 1.68V6.56H32.6599V3.15L32.2599 2.88H31.2399L30.8399 3.15V16.29L31.2399 16.56H32.2599L32.6699 16.29V12.9H37.0499V17.8L34.5599 19.48L34.5499 19.47ZM29.2099 18.55H34.2799L36.1299 17.3V13.8H33.5799V16.76L32.5399 17.46H30.9599L29.9199 16.76V2.65L30.9599 1.95H32.5399L33.5799 2.65V5.63H36.1299V2.16L34.2799 0.91H29.2099L27.3599 2.16V17.3L29.2099 18.55Z' fill='%23323333'/%3E%3Cpath d='M47.24 19.01H41.42L39.26 17.54V0.449951H42.73V16.52L43.45 17.01H45.22L45.94 16.52V0.449951H49.41V17.54L47.24 19.01Z' fill='%23323333'/%3E%3Cpath d='M47.3801 19.47H41.28L38.79 17.79V0H43.17V16.28L43.57 16.55H45.06L45.47 16.28V0H49.85V17.79L47.36 19.47H47.3801ZM41.56 18.55H47.1L48.95 17.3V0.91H46.4V16.76L45.36 17.46H43.31L42.2701 16.76V0.91H39.72V17.3L41.57 18.55H41.56Z' fill='%23323333'/%3E%3Cpath d='M52.3701 1.91995L54.5401 0.449951H60.2101L62.3801 1.91995V5.84995H58.9101V2.93995L58.1901 2.45995H56.5601L55.8401 2.93995V16.52L56.5601 17.01H58.1901L58.9101 16.52V11.44H57.1801V9.33995H62.3801V17.54L60.2101 19.01H54.5401L52.3701 17.54V1.91995Z' fill='%23323333'/%3E%3Cpath d='M60.3499 19.47H54.3999L51.9099 17.79V1.68L54.3999 0H60.3499L62.8399 1.68V6.31H58.4599V3.19L58.0599 2.92H56.7099L56.3099 3.19V16.28L56.7099 16.55H58.0599L58.4599 16.28V11.9H56.7299V8.89H62.8499V17.79L60.3599 19.47H60.3499ZM54.6799 18.55H60.0699L61.9199 17.3V9.8H57.6299V10.98H59.3599V16.76L58.3199 17.46H56.4099L55.3699 16.76V2.7L56.4099 2H58.3199L59.3599 2.7V5.39H61.9099V2.16L60.0599 0.91H54.6699L52.8199 2.16V17.3L54.6699 18.55H54.6799Z' fill='%23323333'/%3E%3Cpath d='M7.98486 33.6999L10.1549 32.2399H13.3249L14.0549 31.7499V26.4199L13.3249 25.9399H12.2449L11.5249 26.4199V28.6699H8.05487V25.3999L10.2249 23.9299H15.3549L17.5249 25.3999V32.8199L15.3549 34.2899H12.1749L11.4549 34.7699V40.4899H17.3749V42.4899H7.98486V33.6999Z' fill='%23323333'/%3E%3Cpath d='M17.8349 42.95H7.5249V33.46L10.0149 31.78H13.1949L13.5949 31.51V26.67L13.1949 26.4H12.3949L11.9949 26.67V29.13H7.6149V25.16L10.1049 23.48H15.5149L18.0049 25.16V33.07L15.5149 34.75H12.3349L11.9349 35.02V40.03H17.8649V42.95H17.8349ZM8.4449 42.03H16.9249V40.94H10.9949V34.53L12.0349 33.83H15.2149L17.0649 32.58V25.64L15.2149 24.39H10.3649L8.51491 25.64V28.21H11.0649V26.18L12.1049 25.48H13.4649L14.5049 26.18V31.99L13.4649 32.69H10.2849L8.43491 33.94V42.03H8.4449Z' fill='%23323333'/%3E%3Cpath d='M30.0549 41.0199L27.8849 42.4799H22.2149L20.0449 41.0199V25.3899L22.2149 23.9299H27.8849L30.0549 25.3899V41.0199ZM24.2449 25.9399L23.5249 26.4299V39.9999L24.2449 40.4899H25.8749L26.5949 39.9999V26.4299L25.8749 25.9399H24.2449Z' fill='%23323333'/%3E%3Cpath d='M28.035 42.95H22.085L19.595 41.27V25.16L22.085 23.48H28.035L30.525 25.16V41.27L28.035 42.95ZM22.355 42.03H27.745L29.595 40.78V25.64L27.745 24.39H22.355L20.505 25.64V40.78L22.355 42.03ZM26.005 40.95H24.095L23.055 40.25V26.19L24.095 25.49H26.005L27.045 26.19V40.25L26.005 40.95ZM24.385 40.03H25.735L26.135 39.76V26.67L25.735 26.4H24.385L23.985 26.67V39.76L24.385 40.03Z' fill='%23323333'/%3E%3Cpath d='M32.7349 33.6999L34.9049 32.2399H38.0849L38.8049 31.7499V26.4199L38.0849 25.9399H36.9949L36.2749 26.4199V28.6699H32.8049V25.3999L34.9749 23.9299H40.1049L42.2749 25.3999V32.8199L40.1049 34.2899H36.9249L36.2049 34.7699V40.4899H42.1249V42.4899H32.7349V33.6999Z' fill='%23323333'/%3E%3Cpath d='M42.5849 42.95H32.2749V33.46L34.7649 31.78H37.9449L38.3449 31.51V26.67L37.9449 26.4H37.1449L36.7449 26.67V29.13H32.3649V25.16L34.8549 23.48H40.2649L42.7549 25.16V33.07L40.2649 34.75H37.0849L36.6849 35.02V40.03H42.6149V42.95H42.5849ZM33.1949 42.03H41.6749V40.94H35.7449V34.53L36.7849 33.83H39.9649L41.8149 32.58V25.64L39.9649 24.39H35.1149L33.2649 25.64V28.21H35.8149V26.18L36.8549 25.48H38.2149L39.2549 26.18V31.99L38.2149 32.69H35.0349L33.1849 33.94V42.03H33.1949Z' fill='%23323333'/%3E%3Cpath d='M50.5849 25.9399H48.9949L48.2749 26.4299V32.6099L49.5749 31.7299H52.6849L54.8549 33.1899V41.0299L52.6849 42.4899H46.9749L44.8049 41.0299V25.3999L46.9749 23.9399H52.6149L54.7849 25.3999V29.0599H51.3149V26.4199L50.5949 25.9299L50.5849 25.9399ZM48.9949 33.7199L48.2749 34.2099V39.9999L48.9949 40.4899H50.6549L51.3749 39.9999V34.2099L50.6549 33.7199H48.9949Z' fill='%23323333'/%3E%3Cpath d='M52.815 42.95H46.825L44.335 41.27V25.16L46.825 23.48H52.745L55.235 25.16V29.52H50.855V26.67L50.455 26.4H49.145L48.745 26.67V31.74L49.445 31.27H52.835L55.325 32.95V41.27L52.835 42.95H52.815ZM47.115 42.03H52.545L54.395 40.78V33.43L52.545 32.18H49.715L47.815 33.46V26.18L48.855 25.48H50.725L51.765 26.18V28.6H54.315V25.64L52.465 24.39H47.105L45.255 25.64V40.78L47.105 42.03H47.115ZM50.795 40.95H48.855L47.815 40.25V33.98L48.855 33.28H50.795L51.835 33.98V40.25L50.795 40.95ZM49.135 40.03H50.515L50.915 39.76V34.46L50.515 34.19H49.135L48.735 34.46V39.76L49.135 40.03Z' fill='%23323333'/%3E%3C/svg%3E") center / contain no-repeat;
}

h1 { font-size: 18px; font-weight: 700; line-height: 27px; margin: 0; color: #37474f; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--accent-2); }
.dot.bad { background: var(--danger); }

main { flex: 1; display: grid; grid-template-columns: 1fr; gap: 0; min-height: 0; }
body.debug-mode main { grid-template-columns: 1fr 340px; }

.chat-pane { display: flex; flex-direction: column; min-height: 0; padding: 16px 22px; }
body:not(.debug-mode) .chat-pane { max-width: 960px; width: 100%; margin: 0 auto; padding: 16px 8px; }
body:not(.debug-mode) .side-pane,
body:not(.debug-mode) .source-control,
body:not(.debug-mode) .debug-badge,
body:not(.debug-mode) .mode-switch-link,
body:not(.debug-mode) .samples,
body:not(.debug-mode) .voice-picker,
body:not(.debug-mode) .auth-badge,
body:not(.debug-mode) .mute { display: none !important; }

.debug-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(249, 115, 22, 0.16);
  border: 1px solid var(--danger);
  color: #c2410c;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.debug-badge[hidden], .mode-switch-link[hidden], .side-pane[hidden], .source-control[hidden] { display: none; }
.mode-switch-link {
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.mode-switch-link:hover { border-color: var(--accent); color: var(--strong); }

.messages { flex: 1; overflow-y: auto; padding-right: 6px; }
main { background: var(--bg); }

.msg { display: flex; margin-bottom: 14px; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 15px;
  background: var(--panel);
  border: 1px solid var(--border);
  line-height: 1.65;
  white-space: pre-wrap;
  font-size: 14.5px;
}

.msg.user .bubble { background: var(--accent); border-color: var(--user-border); color: #fff; }
.msg.user .bubble .meta, .msg.user .bubble .sources a { color: #d7f2f2; }
.msg.assistant .bubble { background: var(--panel); }
.msg.system .bubble { background: var(--system-bg); border-color: var(--voice-border); color: var(--muted); padding: 12px 15px; font-size: 13px; }

.meta { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

.composer { display: flex; gap: 10px; margin-top: 12px; }

.composer input {
  flex: 1;
  height: 41px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--input-border);
  background: var(--panel);
  color: var(--text);
  font-size: 14.5px;
}
.composer input::placeholder { color: #9aa8b3; }
.composer input:focus-visible { outline: 2px solid var(--input-border); outline-offset: 1px; }

.composer button {
  border: none;
  height: 41px;
  border-radius: 10px;
  padding: 0 10px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
}

.send { background: var(--accent); color: #fff; min-width: 53px; }
.mic { background: var(--slate); color: #fff; width: 44px; font-size: 20px; border: 1px solid var(--slate) !important; }
.mic.recording { background: var(--danger); color: #fff; }
.mute { background: var(--slate); color: #fff; width: 44px; font-size: 20px; }
.mute[aria-pressed="true"] { background: var(--accent); color: #fff; }
.mute:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-badge { padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; white-space: nowrap; }
.auth-badge[hidden] { display: none; }
.lang-select {
  -webkit-appearance: none;
  appearance: none;
  padding: 2px 24px 2px 9px;
  border-radius: 999px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%231f2d3a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 9px center / 10px 6px;
  border: 1px solid rgba(4, 142, 148, 0.45);
  color: #1f2d3a;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}
.lang-select:hover, .lang-select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(4, 142, 148, 0.15);
}
.role-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(96, 126, 138, 0.12);
  border: 1px solid rgba(96, 126, 138, 0.4);
  color: #37474f;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.role-badge.role-athlete {
  background: rgba(4, 142, 148, 0.1);
  border-color: rgba(4, 142, 148, 0.45);
  color: #03666b;
}
.role-badge.role-staff {
  background: rgba(190, 166, 121, 0.18);
  border-color: var(--gold);
  color: #6b5428;
}
.auth-action-btn {
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.auth-action-btn:hover { opacity: 0.9; }
.auth-action-btn.logged-in {
  background: rgba(249, 115, 22, 0.1);
  color: #c2410c;
  border-color: rgba(249, 115, 22, 0.55);
}
.login-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  width: calc(100% - 32px);
  max-width: 440px;
  box-shadow: 0 20px 45px rgba(31, 45, 58, 0.18);
}
.login-dialog::backdrop { background: rgba(31, 45, 58, 0.45); }
.login-dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.login-dialog-head h2 { margin: 0; font-size: 16.5px; color: var(--strong); }
.login-dialog-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.login-dialog-close:hover { color: var(--text); background: var(--panel-2); }
.login-dialog-hint {
  margin: 0 0 14px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.login-mode-group { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.login-mode-group[hidden] { display: none !important; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.login-field input, .login-field select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.login-field input:focus-visible, .login-field select:focus-visible { outline: 2px solid var(--input-border); outline-offset: 1px; }
.login-demo-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed rgba(4, 142, 148, 0.5);
  background: rgba(4, 142, 148, 0.08);
  color: #03666b;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.login-demo-btn:hover { background: rgba(4, 142, 148, 0.14); }
.login-dialog-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #b91c1c;
  font-size: 12.5px;
  line-height: 1.45;
}
.login-dialog-error[hidden] { display: none; }
.login-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.login-cancel-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}
.login-submit-btn {
  padding: 8px 18px;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.debug-tool-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.debug-select {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12.5px;
}
.debug-action-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.debug-status-box {
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  word-break: break-word;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.voice-picker { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.voice-picker[hidden] { display: none; }
.voice-picker-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
/* 單列分段切換：選項多時在框內左右捲動，不換行 */
.voice-options { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 0; min-width: 0; overflow-x: auto; scrollbar-width: none; height: 33px; background: var(--voice-bg); border: 1px solid var(--voice-border); border-radius: 12px; }
.voice-options::-webkit-scrollbar { display: none; }
.voice-option {
  background: #fff;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  padding: 0 16px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.voice-option + .voice-option { border-left: 1px solid var(--voice-border); }
.voice-option[aria-pressed="true"] { background: var(--slate); color: #fff; font-weight: 700; border-left-color: transparent; }
/* 只有頭尾貼著外框的圓角，中間的選項維持直角（外框 overflow 會裁切） */
.voice-option[aria-pressed="true"] + .voice-option { border-left-color: transparent; }
.voice-option:focus-visible, .replay:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.replay {
  display: inline-block;
  margin-top: 8px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 12px;
  cursor: pointer;
}
.replay[aria-pressed="true"] { background: var(--accent); color: #fff; }

.samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}

.chip:hover { color: var(--text); border-color: var(--accent); }

.side-pane {
  background: #f4f7f9;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

.side-pane h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin: 18px 0 8px; }
.side-pane h2:first-child { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; }

.trace-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 8px;
  font-size: 12.5px;
}

.trace-item .tool-name { font-weight: 700; color: var(--accent); }
.trace-item code { color: var(--muted); word-break: break-all; font-size: 11.5px; }
.trace-empty { color: var(--muted); font-size: 12.5px; }

.quota { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12.5px; }

.notes { margin: 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }

.sources { margin-top: 10px; font-size: 12px; }
.sources a { color: var(--accent); display: block; margin-top: 4px; word-break: break-all; }
.bubble .text a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }
.bubble .text strong { color: var(--strong); font-weight: 700; }
.bubble .text.md-rendered { display: block; white-space: normal; }
.bubble .text .md-heading { margin: 10px 0 6px; font-size: 15.5px; font-weight: 700; color: var(--strong); line-height: 1.4; }
.bubble .text .md-heading:first-child { margin-top: 0; }
.bubble .text .md-p { margin: 6px 0; line-height: 1.65; }
.bubble .text .md-p:first-child { margin-top: 0; }
.bubble .text .md-p:last-child { margin-bottom: 0; }
.bubble .text .md-list { margin: 6px 0; padding-left: 20px; line-height: 1.65; }
.bubble .text .md-list li { margin: 3px 0; }
.bubble .text .md-inline-code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}
.bubble .text .md-pre {
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
}
.bubble .text .md-table-wrap { margin: 8px 0; overflow-x: auto; }
.bubble .text .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.bubble .text .md-table th,
.bubble .text .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.bubble .text .md-table th { background: var(--panel-2); color: var(--strong); font-weight: 700; }
.trace-item.cache-hit { border-left-color: var(--accent-2); }
.trace-item.cache-hit .tool-name { color: var(--accent-2); }

.topbar { gap: 16px; flex-wrap: wrap; }
.brand { min-width: 0; }
.brand > div { min-width: 0; }
.source-control { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.source-control label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.source-control select {
  max-width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.source-control select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-pane, .side-pane, .composer input { min-width: 0; }
.bubble, .subtitle, .trace-item { overflow-wrap: anywhere; }

@media (max-width: 900px) {
  body { height: 100dvh; }
  body.debug-mode { height: auto; min-height: 100dvh; }
  .topbar { padding: 18px 21px; }
  .brand { flex: 1 1 75%; }
  .source-control { order: 3; width: 100%; margin-left: 0; }
  .source-control select { flex: 1; width: 0; }
  main { display: flex; flex-direction: column; }
  .chat-pane { flex: 1; min-height: 0; padding: 16px 8px; }
  body.debug-mode .chat-pane { flex: none; min-height: 62dvh; }
  body.debug-mode .messages { max-height: 60dvh; }
  .side-pane { border-left: 0; border-top: 1px solid var(--border); }
  .bubble { max-width: 94%; }
  .composer { gap: 6px; }
  .composer button { flex-shrink: 0; }
  .voice-option { padding: 0 12px; }
  .status { font-size: 12px; }
}
@media (max-width: 640px) {
  .role-badge { font-size: 11px; padding: 2px 6px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
}
