:root {
  color-scheme: light dark;
  /* Same palette as the Android app (app/src/main/kotlin/dev/xiaoman/app/ui/Theme.kt). */
  --bg: #f7f9f6;
  --surface: #fff;
  --surface-low: #f0f4ef;
  --text: #202c25;
  --muted: #637168;
  --line: #e0e7df;
  --primary: #1e6b52;
  --primary-soft: #e1f0e8;
  --on-primary-soft: #174332;
  --success: #1e6b52;
  --danger: #b3261e;
  --warning: #7a5a12;
  --shadow: 0 8px 28px rgb(23 67 50 / 6%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--bg); }
body { margin: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; color: var(--text); background: var(--bg); overflow: hidden; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; font-size: 16px; }
button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 15px; background: var(--surface); color: var(--text); cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
button.primary { color: #fff; background: var(--primary); border-color: var(--primary); font-weight: 600; }
button.danger { color: var(--danger); }
a { color: var(--primary); text-underline-offset: 3px; overflow-wrap: anywhere; }
input, textarea, select { width: 100%; padding: 12px; color: var(--text); border: 1px solid var(--line); border-radius: 12px; background: var(--bg); min-height: 46px; min-width: 0; }
textarea { resize: none; line-height: 1.5; max-height: 132px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
h1 { font-size: 25px; line-height: 1.35; letter-spacing: -.6px; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 0 0 14px; }
h3 { font-size: 17px; margin: 8px 0 12px; line-height: 1.5; }
p { line-height: 1.65; margin: 8px 0; }
.muted { color: var(--muted); font-size: 14px; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(12px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 12px max(20px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 10px; }
.brand strong { display: block; font-size: 19px; letter-spacing: -.4px; }
.brand span { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
#connection { color: var(--muted); font-size: 12px; flex-shrink: 0; }
#connection button { min-height: 36px; padding: 7px 10px; font-size: 13px; }
.notice { flex-shrink: 0; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); color: var(--warning); background: var(--primary-soft); font-size: 14px; line-height: 1.6; display: flex; align-items: center; justify-content: space-between; gap: 10px; max-height: 24vh; overflow-y: auto; }
.notice-close { padding: 4px 8px; font-size: 13px; flex-shrink: 0; background: transparent; border: 0; }
main { flex: 1; min-height: 0; width: 100%; max-width: 820px; margin: 0 auto; }
.page { height: 100%; }
.chat-page { display: flex; flex-direction: column; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding: 20px 0 10px; }
.messages:empty { flex: 0; padding: 0; }
.message { margin: 0 0 15px; display: flex; flex-direction: column; align-items: flex-start; animation: appear .18s ease-out; }
.message.user { align-items: flex-end; }
.bubble { background: var(--surface); padding: 12px 15px; border: 1px solid var(--line); border-radius: 17px 17px 17px 5px; max-width: 90%; line-height: 1.7; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.user .bubble { background: var(--primary); color: #fff; border-color: var(--primary); border-radius: 17px 17px 5px 17px; }
.reply .bubble { background: var(--surface-low); border-color: var(--surface-low); }
.user a { color: #fff; }
.event-line { font-size: 13px; color: var(--muted); line-height: 1.7; padding: 3px 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.success, .success .event-line { color: var(--success); }
.failure, .failure .event-line, .error .event-line { color: var(--danger); }
.warning .event-line { color: var(--warning); }
.action-card { border: 1px solid var(--line); border-radius: 16px; padding: 16px; background: var(--surface); width: 100%; max-width: 560px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 600; }
.arguments { font-size: 13px; line-height: 1.65; padding: 12px; border-radius: 10px; background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow-y: auto; }
.card-result { color: var(--muted); font-size: 14px; margin-bottom: 0; white-space: pre-wrap; }
.card-result:empty { display: none; }
.question-form { display: flex; align-items: flex-end; gap: 8px; }
.question-form label { flex: 1; min-width: 0; font-size: 14px; }
.question-form input { margin-top: 6px; }
.question-form button { flex-shrink: 0; }
.empty-chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 10px; text-align: center; }
.hello-icon { width: 68px; height: 68px; border-radius: 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.empty-chat p { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.examples { display: flex; flex-direction: column; width: 100%; max-width: 390px; gap: 9px; }
.examples button { text-align: left; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 14px; }
.examples span { color: var(--primary); margin-left: 8px; }
.model-hint { padding: 8px 0; color: var(--muted); font-size: 13px; text-align: center; flex-shrink: 0; }
.model-hint button { font-size: 13px; min-height: 34px; padding: 4px 9px; margin-left: 4px; color: var(--primary); border: 0; background: transparent; }
.thinking { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 6px 4px 10px; flex-shrink: 0; }
.thinking-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: pulse 1.3s ease-in-out infinite; }
.composer { display: flex; gap: 9px; padding: 10px 0 12px; flex-shrink: 0; align-items: flex-end; }
.composer textarea { background: var(--surface); height: 49px; }
.composer button { min-height: 49px; flex-shrink: 0; }
.scroll-page { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding: 25px max(18px, env(safe-area-inset-right, 0px)) 30px max(18px, env(safe-area-inset-left, 0px)); }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-heading p { font-size: 14px; color: var(--muted); margin: 0; }
.badge { font-size: 12px; white-space: nowrap; color: var(--primary); background: var(--primary-soft); border-radius: 30px; padding: 7px 10px; margin-top: 3px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
#page-services > .toolbar { margin-bottom: 12px; }
#page-services > .toolbar button { font-size: 14px; }
#test-notice { margin: 10px 0 16px; overflow-wrap: anywhere; }
.catalog-group { margin-bottom: 24px; }
.catalog-group > h2 { font-size: 16px; color: var(--muted); padding-left: 2px; margin-bottom: 10px; }
.service-item { background: var(--surface); border: 1px solid var(--line); padding: 15px; border-radius: 14px; margin-bottom: 9px; }
.service-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.service-toggle { display: flex; align-items: center; gap: 11px; min-height: 44px; flex: 1; cursor: pointer; }
.service-toggle strong { font-size: 16px; }
.switch { appearance: none; -webkit-appearance: none; width: 44px; min-width: 44px; height: 27px; min-height: 27px; border-radius: 20px; position: relative; background: var(--line); border: 1px solid var(--line); padding: 0; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 18%); transition: transform .15s; }
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { transform: translateX(17px); }
.switch:disabled { opacity: .4; cursor: default; }
.source-tag { color: var(--muted); background: var(--bg); border: 1px solid var(--line); padding: 3px 7px; font-size: 11px; border-radius: 6px; flex-shrink: 0; }
.service-item > p { margin: 6px 0; }
.service-keys { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 12px; }
.apply-link { font-size: 13px; width: fit-content; min-height: 30px; display: flex; align-items: center; margin-top: -5px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin: 0 0 18px; }
.fields { display: flex; flex-direction: column; gap: 15px; }
.fields label { display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.5; }
.fields p { margin: 0; }
.fields > button { align-self: flex-start; }
.secret-field { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.secret-field input { border: 0; border-radius: 0; flex: 1; }
.secret-field input:focus-visible { outline-offset: -3px; }
.secret-field button { border: 0; border-radius: 0; font-size: 13px; padding: 10px; background: transparent; color: var(--primary); flex-shrink: 0; min-width: 48px; }
.custom-item { padding: 16px 0; border-top: 1px solid var(--line); margin-top: 16px; }
.custom-item:last-child { padding-bottom: 0; }
.custom-item .service-top button { font-size: 13px; min-height: 38px; }
.custom-item p { overflow-wrap: anywhere; }
.test-result { font-size: 13px; margin: 10px 0 0; line-height: 1.5; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.data-actions button { font-size: 14px; }
.version { text-align: center; color: var(--muted); font-size: 12px; margin-top: 25px; }
.bottom-nav { display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line); padding: 6px max(12px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); flex-shrink: 0; }
.bottom-nav button { border: 0; background: transparent; color: var(--muted); width: 33.333%; max-width: 260px; display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: 11px; padding: 5px 10px; border-radius: 12px; }
.bottom-nav button span { font-size: 23px; height: 27px; line-height: 27px; }
.bottom-nav button.active { color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); background: rgb(0 0 0 / 45%); z-index: 10; }
.access-card { background: var(--surface); width: 100%; max-width: 400px; border-radius: 20px; padding: 24px; max-height: 100%; overflow-y: auto; }
.access-card > p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.access-card .toolbar { justify-content: flex-end; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
noscript { position: fixed; inset: 20%; padding: 20px; background: var(--surface); border: 1px solid var(--line); z-index: 20; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-color-scheme: dark) {
  :root { --bg: #121815; --surface: #1b231f; --surface-low: #202a24; --text: #e3ebe5; --muted: #a5b4aa; --line: #35463c; --primary: #8bd6b5; --primary-soft: #204d3c; --on-primary-soft: #cdeedd; --success: #8bd6b5; --danger: #ffb4ab; --warning: #e9c46a; --shadow: none; }
  button.primary, .user .bubble { background: #1e6b52; border-color: #1e6b52; color: #fff; }
  .switch:checked { background: #1e6b52; border-color: #1e6b52; }
}
@media (min-width: 768px) {
  .app-header { padding-left: max(24px, calc((100vw - 780px) / 2)); padding-right: max(24px, calc((100vw - 780px) / 2)); }
  .chat-page { padding-left: 24px; padding-right: 24px; }
  .scroll-page { padding-left: 24px; padding-right: 24px; }
  .bubble { max-width: 80%; }
  .empty-chat { padding-top: 45px; padding-bottom: 45px; }
}
@media (max-height: 500px) {
  .brand span { display: none; }
  .app-header { padding-top: calc(6px + env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
  .empty-chat { justify-content: flex-start; padding-top: 15px; }
  .hello-icon { display: none; }
  .bottom-nav button { flex-direction: row; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.memory-list { margin-top: 12px; }
.memory-item { border-top: 1px solid var(--line); padding: 14px 0; }
.memory-item:first-child { border-top: 0; padding-top: 4px; }
.memory-item .service-top button { font-size: 13px; min-height: 38px; }
.memory-lines { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.memory-tag { display: inline-block; font-size: 12px; color: var(--on-primary-soft); background: var(--primary-soft); border-radius: 6px; padding: 1px 6px; margin-right: 2px; }
.memory-time { font-size: 12px; margin: 6px 0 0; }
#memory-panel .service-top h2 { margin: 0; }
#memory-count { font-size: 12px; }
.warning-text { color: var(--warning); font-size: 14px; }
.unavailable { color: var(--warning); }
button.inline-link { min-height: 28px; padding: 0 6px; border: 0; background: transparent; color: var(--primary); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
