:root {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
	color-scheme: light dark;
	--background: #f2f2f7;
	--surface: #ffffff;
	--ink: #1c1c1e;
	--muted: #6c6c72;
	--accent: #007aff;
	--accent-wash: #e9f2ff;
	--line: #3c3c431f;
	--fill: #e9e9ee;
	--bubble: #e9e9eb;
	--chrome: #f8f8fbd9;
	--switch: #34c759;
	--danger: #c93631;
	--notice-bg: #fff7e8;
	--notice-ink: #87612c;
	--icon-filter: none;
	--accent-filter: invert(38%) sepia(99%) saturate(3600%) hue-rotate(197deg) brightness(104%) contrast(104%);
	--safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
	--safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
	--nav-height: calc(66px + var(--safe-bottom));
	color: var(--ink);
	background: var(--background);
	-webkit-font-smoothing: antialiased;
	-webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; min-width: 320px; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; -webkit-tap-highlight-color: transparent; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; border: 0; color: inherit; touch-action: manipulation; transition: background-color .15s, opacity .15s, transform .15s; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:not(:disabled):active { opacity: .65; transform: scale(.98); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button img { width: 20px; height: 20px; flex-shrink: 0; filter: var(--icon-filter); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; font-weight: 650; }
h2 { font-size: 20px; font-weight: 650; }
::selection { background: var(--accent-wash); color: var(--ink); }
.shell { max-width: 560px; height: 100dvh; margin: auto; display: flex; flex-direction: column; background: var(--background); position: relative; isolation: isolate; }
.header { min-height: 60px; padding: calc(12px + var(--safe-top)) 20px 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--chrome); -webkit-backdrop-filter: blur(20px) saturate(1.4); backdrop-filter: blur(20px) saturate(1.4); border-bottom: .5px solid var(--line); }
.connection-status { display: flex; align-items: center; gap: 6px; }
#retry-connection { min-height: 44px; min-width: 44px; background: transparent; color: var(--accent); font-size: 13px; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand > img { width: 28px; height: 28px; border-radius: 7px; }
.brand > span { font-size: 11px; color: var(--muted); margin-left: 1px; }
#connection { font-size: 12px; color: var(--muted); max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice { padding: 9px 20px; color: var(--notice-ink); background: var(--notice-bg); font-size: 12px; line-height: 1.6; flex-shrink: 0; border-bottom: .5px solid var(--line); }
.login-screen { flex: 1; min-height: 0; overflow-y: auto; padding: 24px 24px 32px; overscroll-behavior-y: contain; }
.login-identity { text-align: center; padding: 8px 0 27px; }
.login-identity > img { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 17px; box-shadow: 0 4px 10px #0000000a; }
.login-identity h2 { font-size: 28px; line-height: 1.25; font-weight: 700; }
.access-field { background: var(--surface); padding: 13px 16px 9px; border-radius: 12px; }
.access-field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 1px; }
input:where(:not([type="checkbox"]):not([type="radio"])), select, textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: var(--ink); background: var(--surface); font-size: 17px; }
textarea { resize: vertical; line-height: 1.6; max-height: 36dvh; }
input::placeholder, textarea::placeholder { color: #8b8b93; opacity: 1; }
.access-field > input { border: 0; padding: 9px 0; min-height: 44px; border-radius: 2px; }
.auth-field + .auth-field { margin-top: 10px; }
.auth-modes { margin-bottom: 16px; }
.auth-note { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.auth-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 0 12px; margin-top: 8px; }
.auth-links button { min-height: 44px; padding: 6px 2px; background: transparent; color: var(--accent); font-size: 12px; }
#recovery-username { display: block; margin: 18px 0 8px; font-size: 13px; overflow-wrap: anywhere; }
#recovery-output { resize: none; font-family: ui-monospace, monospace; font-size: 15px; overflow-wrap: anywhere; }
#recovery-dialog .dialog-actions { flex-wrap: wrap; }
#credentials-dialog input { font-size: 16px; }
.check { display: flex; align-items: center; gap: 11px; font-size: 14px; line-height: 1.55; color: var(--ink); cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 20px; height: 20px; margin: 0; flex-shrink: 0; cursor: pointer; }
.consent-group { margin-top: 18px; background: var(--surface); border-radius: 12px; padding-inline: 16px; }
.consent-group .check { min-height: 52px; padding-block: 13px; }
.consent-group .check + .check { border-top: .5px solid var(--line); }
.consent-group .check > span { min-width: 0; overflow-wrap: anywhere; }
.primary, .secondary { min-height: 44px; padding: 11px 18px; border-radius: 10px; font-size: 16px; font-weight: 500; }
.primary { color: #fff; background: var(--accent); }
.secondary { color: var(--accent); background: var(--accent-wash); }
#login { width: 100%; margin-top: 24px; height: 50px; font-weight: 600; }
.privacy { margin-top: 16px; font-size: 13px; color: var(--muted); line-height: 1.8; }
.privacy summary { min-height: 44px; padding-block: 13px; color: var(--accent); cursor: pointer; }
.privacy p, #privacy-copy p { margin: 13px 0; }
#app { flex: 1; min-height: 0; overflow: hidden; padding-bottom: var(--nav-height); }
.view { animation: view-in .18s ease-out; }
.view-heading { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding-block: 10px 16px; gap: 12px; }
.view-heading > h2 { font-size: 32px; line-height: 1.15; font-weight: 750; }
.icon { width: 44px; height: 44px; border-radius: 50%; background: transparent; padding: 0; flex-shrink: 0; }
.icon img { width: 19px; height: 19px; }
.view-heading > .icon { color: var(--accent); background: var(--surface); }
.view-heading > .icon img { filter: var(--accent-filter); }
.icon:hover { background: var(--fill); }
.add-memory img { width: 22px; height: 22px; }
.chat-view { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.chat-view > .view-heading { padding-inline: 20px; flex-shrink: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 18px; display: flex; flex-direction: column; gap: 18px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; overscroll-behavior-y: contain; }
.message { max-width: 90%; font-size: 16px; line-height: 1.55; flex-shrink: 0; min-width: 0; animation: message-in .16s ease-out; }
.message.user { align-self: flex-end; max-width: 86%; }
.message .meta { display: flex; align-items: center; gap: 7px; margin: 0 10px 6px; font-size: 11px; color: var(--muted); line-height: 1.4; }
.message.user .meta { justify-content: flex-end; }
.message p { padding: 12px 15px; border-radius: 18px 18px 18px 5px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bubble); }
.message.user p { color: #fff; background: var(--accent); border-radius: 18px 18px 5px 18px; }
.rating { display: flex; gap: 0; margin-top: 3px; padding-left: 3px; }
.rating button { width: 44px; height: 44px; }
.rating button img { width: 16px; height: 16px; opacity: .55; }
.rating button[aria-pressed="true"] { background: var(--accent-wash); }
.rating button[aria-pressed="true"] img { opacity: 1; filter: var(--accent-filter); }
.failed { color: var(--danger); font-size: 13px; }
.empty { padding: 52px 12px; color: var(--muted); text-align: center; font-size: 15px; line-height: 1.7; }
.empty::before { content: ''; display: block; width: 38px; height: 38px; background: url('/icons/bookmark.svg') center / contain no-repeat; filter: var(--icon-filter); opacity: .25; margin: 0 auto 16px; }
.pending-link { flex-shrink: 0; min-height: 44px; padding: 9px 13px; margin: 0 20px 10px; border-radius: 10px; background: var(--surface); color: var(--accent); font-size: 14px; justify-content: flex-start; gap: 9px; }
.pending-link::before { content: ''; width: 17px; height: 17px; background: url('/icons/bookmark.svg') center / contain no-repeat; filter: var(--accent-filter); }
.chat-status { min-height: 0; color: var(--muted); font-size: 12px; padding: 0 20px 8px; line-height: 1.6; }
.chat-status:empty { display: none; }
.thinking { width: 100%; min-width: 0; flex-shrink: 0; color: var(--muted); animation: message-in .18s ease-out; }
.thinking > summary { display: flex; align-items: center; gap: 9px; min-height: 44px; cursor: pointer; list-style: none; font-size: 14px; }
.thinking > summary::-webkit-details-marker { display: none; }
.thinking > summary::after { content: ''; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); margin: 0 4px 4px; flex-shrink: 0; }
.thinking:not([open]) > summary::after { transform: rotate(-45deg); margin-bottom: 0; }
.thinking-indicator { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--accent); border-right-color: var(--accent); border-radius: 50%; flex-shrink: 0; animation: thinking-spin 1s linear infinite; }
.thinking-label { min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-weight: 500; animation: thinking-pulse 1.8s ease-in-out infinite; }
.thinking-elapsed { min-width: 44px; margin-left: auto; font-size: 11px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.thinking-progress { margin: 3px 0 5px 8px; padding: 4px 0 5px 17px; border-left: 1px solid var(--line); font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.thinking-overview { margin: 8px 0 8px 8px; padding-left: 17px; border-left: 2px solid var(--accent); }
.thinking-overview > span { font-size: 11px; color: var(--accent); }
.thinking-summary { margin-top: 5px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-summary { margin: 0 0 8px 8px; font-size: 12px; color: var(--muted); }
.reply-summary > summary { min-height: 44px; padding-block: 12px; cursor: pointer; }
.message .reply-summary > p { padding: 2px 0 3px 12px; border-left: 1px solid var(--line); border-radius: 0; font-size: 13px; line-height: 1.75; background: transparent; }
@keyframes thinking-spin { to { transform: rotate(360deg); } }
@keyframes thinking-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.composer { flex-shrink: 0; border-top: .5px solid var(--line); padding: 10px 16px 9px; background: var(--chrome); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.composer textarea { height: 58px; resize: none; min-height: 44px; padding: 11px 14px; border-radius: 16px; border-color: var(--line); background: var(--surface); }
.compose-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 6px; }
.compose-actions .check { min-height: 44px; font-size: 12px; color: var(--muted); margin-right: auto; gap: 8px; }
#message-count { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.send { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.send img { width: 23px; height: 23px; filter: invert(1); }
input[role="switch"] { position: relative; appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border: 0; border-radius: 100px; background: #b7b7bf; transition: background-color .18s; }
input[role="switch"]::before { content: ''; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px #00000026; transition: transform .18s; }
input[role="switch"]:checked { background: var(--switch); }
input[role="switch"]:checked::before { transform: translateX(20px); }
input[role="switch"]:disabled { opacity: .45; cursor: not-allowed; }
.compose-actions input[role="switch"] { width: 36px; height: 22px; }
.compose-actions input[role="switch"]::before { width: 18px; height: 18px; }
.compose-actions input[role="switch"]:checked::before { transform: translateX(14px); }
.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(560px, 100%); height: var(--nav-height); display: grid; grid-template-columns: repeat(3, 1fr); padding: 5px 12px var(--safe-bottom); background: var(--chrome); -webkit-backdrop-filter: blur(24px) saturate(1.5); backdrop-filter: blur(24px) saturate(1.5); border-top: .5px solid var(--line); z-index: 2; }
.tabs > button { position: relative; flex-direction: column; gap: 5px; background: transparent; min-height: 44px; font-size: 10px; font-weight: 500; color: var(--muted); border-radius: 8px; }
.tabs > button img { width: 23px; height: 23px; opacity: .5; }
.tabs > button[aria-current="page"] { color: var(--accent); }
.tabs > button[aria-current="page"] img { filter: var(--accent-filter); opacity: 1; }
#tab-count { position: absolute; left: calc(50% + 7px); top: 1px; min-width: 17px; height: 17px; padding-inline: 4px; display: grid; place-items: center; color: #fff; background: #ff453a; border-radius: 50px; font-size: 10px; font-weight: 600; }
.page-view { height: 100%; overflow-y: auto; padding: 0 20px 26px; overscroll-behavior-y: contain; scrollbar-width: thin; }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border-radius: 10px; background: var(--fill); margin: 0 0 22px; }
.segments button { min-height: 40px; border-radius: 7px; font-size: 14px; color: var(--muted); background: transparent; }
.segments button[aria-pressed="true"] { color: var(--ink); background: var(--surface); font-weight: 600; box-shadow: 0 1px 4px #00000012; }
.segments span { font-size: 11px; font-variant-numeric: tabular-nums; opacity: .7; }
.memory-list { display: flex; flex-direction: column; gap: 14px; }
.memory { padding: 17px 16px 7px; border: 0; border-radius: 14px; background: var(--surface); }
.memory .tag { font-size: 12px; color: var(--muted); margin-bottom: 9px; }
.memory p { font-size: 16px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.memory details { color: var(--muted); font-size: 12px; line-height: 1.7; margin-top: 9px; }
.memory details summary { min-height: 32px; padding-block: 6px; cursor: pointer; }
.memory details p { font-size: 13px; margin-top: 5px; border-left: 2px solid var(--line); padding-left: 10px; }
.memory-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; padding-top: 6px; border-top: .5px solid var(--line); }
.memory-footer > .icon:first-child { margin-right: auto; }
.memory-footer .icon img { filter: var(--accent-filter); }
.memory-footer .primary, .memory-footer .secondary { min-height: 44px; font-size: 14px; padding: 9px 15px; }
.memory-footer .secondary { background: transparent; color: var(--muted); }
.memory-footer .primary { background: var(--accent-wash); color: var(--accent); }
.settings-field { display: flex; align-items: center; gap: 15px; min-height: 54px; padding: 0 16px; border-radius: 12px; background: var(--surface); }
.settings-field label { flex-shrink: 0; font-size: 16px; }
.settings-field input { text-align: right; border: 0; padding-right: 0; background: transparent; font-size: 16px; }
fieldset { margin: 24px 0; padding: 0; border: 0; min-width: 0; }
legend { font-size: 13px; color: var(--muted); margin: 0 0 9px 15px; }
.radio-group { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; padding: 0 16px; }
.radio-group > label { display: flex; align-items: center; justify-content: space-between; min-height: 50px; gap: 10px; font-size: 15px; cursor: pointer; }
.radio-group > label + label { border-top: .5px solid var(--line); }
.radio-group > label:has(input:checked) { color: var(--accent); }
.length-setting .radio-group { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 2px; border-radius: 10px; background: var(--fill); }
.length-setting label { position: relative; min-height: 42px; justify-content: center; border: 0; border-radius: 7px; font-size: 14px; }
.length-setting label + label { border: 0; }
.length-setting input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.length-setting label:has(input:checked) { color: var(--ink); background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px #00000014; }
.length-setting label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.profile-check { justify-content: space-between; min-height: 66px; padding: 13px 16px; border-radius: 12px; background: var(--surface); margin-bottom: 22px; font-size: 14px; }
#profile-form > .primary { width: 100%; height: 48px; }
.account-actions { display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; padding: 0 16px; margin-top: 26px; }
.account-actions > button { min-height: 52px; padding: 10px 0; justify-content: flex-start; color: var(--accent); background: transparent; gap: 12px; font-size: 15px; }
.account-actions > button + button { border-top: .5px solid var(--line); }
.account-actions > button img { width: 19px; height: 19px; filter: var(--accent-filter); }
.danger-text { width: 100%; background: var(--surface); color: var(--danger); min-height: 50px; border-radius: 12px; margin-top: 18px; font-size: 15px; }
dialog { width: min(460px, calc(100% - 32px)); max-height: calc(100dvh - 40px); padding: 22px; border: 0; border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 16px 70px #00000020; overscroll-behavior: contain; }
dialog::backdrop { background: #00000040; -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog[open] { animation: dialog-in .2s ease-out; }
dialog .view-heading { min-height: 44px; padding: 0; margin-bottom: 15px; }
dialog .view-heading > h2 { font-size: 20px; font-weight: 650; }
dialog .view-heading > .icon { background: var(--fill); width: 44px; height: 44px; }
dialog .view-heading > .icon img { width: 17px; height: 17px; filter: var(--icon-filter); opacity: .6; }
dialog form > label { display: block; font-size: 13px; color: var(--muted); margin: 17px 0 8px; }
dialog input, dialog select, dialog textarea { background: var(--background); border-color: transparent; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
dialog .dialog-actions .secondary { background: transparent; }
#confirm-dialog { width: min(310px, calc(100% - 48px)); border-radius: 16px; padding: 23px 20px 0; text-align: center; background: var(--chrome); -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px); }
#confirm-title { font-size: 17px; font-weight: 650; }
#confirm-detail { margin-top: 10px; color: var(--ink); font-size: 13px; line-height: 1.65; }
#confirm-dialog .dialog-actions { margin: 22px -20px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border-top: .5px solid var(--line); }
#confirm-dialog button { background: transparent; color: var(--accent); min-height: 48px; border-radius: 0; font-size: 16px; }
#confirm-dialog button + button { border-left: .5px solid var(--line); font-weight: 600; }
#confirm-dialog.destructive button[value="confirm"] { color: var(--danger); }
#privacy-copy { color: var(--muted); font-size: 14px; line-height: 1.8; }
.toast { position: fixed; bottom: calc(82px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: min(480px, calc(100% - 32px)); padding: 12px 18px; border-radius: 12px; font-size: 13px; line-height: 1.6; background: #252527eb; color: white; box-shadow: 0 4px 20px #00000012; -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); z-index: 5; pointer-events: none; }
.sr-only { position: absolute; height: 1px; width: 1px; clip: rect(0, 0, 0, 0); overflow: hidden; white-space: nowrap; }
@keyframes view-in { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes message-in { from { opacity: .5; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 600px) {
	#memory-editor, #privacy-dialog { position: fixed; inset: auto 0 0; margin: 0 auto; width: 100%; max-height: calc(100dvh - max(24px, env(safe-area-inset-top))); border-radius: 20px 20px 0 0; padding: 22px 20px max(24px, var(--safe-bottom)); }
	#memory-editor .dialog-actions { padding-top: 6px; }
}
@media (max-width: 360px) {
	.header, .notice { padding-inline: 16px; }
	.login-screen { padding-inline: 20px; }
	.login-identity h2 { font-size: 26px; }
	.page-view { padding-inline: 16px; }
	.chat-view > .view-heading, .messages { padding-inline: 16px; }
	.view-heading > h2 { font-size: 30px; }
	.compose-actions { gap: 7px; }
	.compose-actions .check { font-size: 11px; }
	.message { max-width: 94%; }
}
@media (max-height: 520px) {
	.header { min-height: 48px; padding-block: 7px; }
	.view-heading { min-height: 58px; padding-block: 8px; }
	.view-heading > h2 { font-size: 27px; }
	.composer { padding-block: 7px; }
	.composer textarea { height: 44px; }
	.compose-actions { padding-top: 3px; }
}
@media (min-width: 700px) { .shell { box-shadow: 0 0 0 1px var(--line), 0 0 50px #00000004; } }
@media (prefers-color-scheme: dark) {
	:root { --background: #000; --surface: #1c1c1e; --ink: #f5f5f7; --muted: #a0a0a8; --accent: #0a84ff; --accent-wash: #102c4e; --line: #54545870; --fill: #2c2c2e; --bubble: #262629; --chrome: #161618eb; --switch: #30d158; --danger: #ff6961; --notice-bg: #302616; --notice-ink: #dfbf86; --icon-filter: invert(1); }
	input[role="switch"] { background: #505054; }
	.segments button[aria-pressed="true"], .length-setting label:has(input:checked) { background: #525255; }
	.toast { background: #39393de8; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }