@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
* { box-sizing: border-box; }
:root { color-scheme: light; --ink: #182e27; --muted: #4f665d; --paper: #fcfefb; --panel: #edf3ed; --line: #d5e0d8; --accent: #245e48; }
body { margin: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; color: var(--ink); background: var(--paper); font: 16px/1.55 Inter, system-ui, "Microsoft YaHei UI", sans-serif; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid #548c6b; outline-offset: 2px; }
.chat-header { display: flex; align-items: center; gap: 14px; justify-content: space-between; min-height: 62px; padding: max(10px, env(safe-area-inset-top)) clamp(12px, 3vw, 34px) 10px; background: #f3f7f3; border-bottom: 1px solid var(--line); }
.chat-brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 770; letter-spacing: -.045em; font-size: 1.16rem; white-space: nowrap; }
.chat-brand img { border-radius: 9px; }
.chat-header-actions, .chat-language, .chat-modes { display: flex; align-items: center; gap: 5px; }
.chat-account { display: flex; align-items: center; min-width: 0; gap: 8px; margin-inline-start: 5px; }
#account-identity { overflow: hidden; text-overflow: ellipsis; max-width: 16ch; white-space: nowrap; color: var(--muted); font-size: .84rem; }
.chat-language, .chat-modes { padding: 3px; border: 1px solid var(--line); border-radius: 10px; }
.mobile-modes { margin: 8px auto; width: min(100% - 24px, 330px); }
.mobile-modes button { flex: 1; min-height: 34px; }
.chat-language button, .chat-modes button { border: 0; border-radius: 7px; background: transparent; padding: 5px 8px; font-size: .84rem; white-space: nowrap; }
.chat-language button[aria-pressed="true"], .chat-modes button[aria-pressed="true"] { background: #dce9dd; font-weight: 650; }
.chat-action, .chat-primary { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 7px 12px; font-size: .89rem; white-space: nowrap; }
.chat-action:hover { background: #eaf1e9; }
.chat-primary { border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 640; }
.chat-primary:hover { background: #194936; }
.chat-layout { position: relative; display: grid; grid-template-columns: minmax(215px, 254px) minmax(0, 1fr); flex: 1; min-height: 0; }
.chat-sidebar { display: flex; overflow: auto; flex-direction: column; gap: 18px; padding: 17px 12px; border-inline-end: 1px solid var(--line); background: var(--panel); }
.chat-sidebar h2 { margin: 14px 7px 8px; font-size: .83rem; color: var(--muted); font-weight: 640; }
.new-chat { display: flex; align-items: center; gap: 9px; width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; text-align: start; font-weight: 650; }
.new-chat:hover { border-color: #87a694; }
.chat-get-app { margin-top: auto; color: var(--accent); padding: 7px; font-size: .88rem; }
.chat-get-app:hover { text-decoration: underline; }
.chat-list { display: grid; gap: 4px; }
.chat-list button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; width: 100%; background: transparent; border: 0; border-radius: 7px; padding: 7px; font-size: .9rem; }
.chat-list button:hover, .chat-list button[aria-current="true"] { background: #dce9de; }
.chat-list h3 { font-size: .86rem; margin: 9px 7px 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; }
.remote-sidebar { gap: 6px; }
.remote-sidebar .sidebar-top h2 { margin-block: 6px; }
.remote-new { margin-top: 10px; font-size: .9rem; }
.chat-main { display: grid; min-width: 0; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-toolbar { min-height: 44px; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 5px 13px; color: var(--muted); font-size: .83rem; border-bottom: 1px solid #e8eee8; }
#sidebar-toggle, .sidebar-toggle { display: none; }
#context-label, .chat-context { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-model-chip { min-width: 0; max-width: min(48%, 28ch); overflow: hidden; text-overflow: ellipsis; }
#remove-chat { margin-inline-start: auto; }
.chat-scroll { overflow-y: auto; overscroll-behavior: contain; }
.chat-content, .chat-composer { width: min(100% - 30px, 790px); margin-inline: auto; }
.chat-content { padding-block: 25px; }
.chat-welcome { max-width: 540px; margin: clamp(23px, 11vh, 120px) auto 20px; text-align: center; }
.chat-welcome img { border-radius: 14px; }
.chat-welcome h1 { margin: 12px 0 5px; font-size: clamp(1.6rem, 4vw, 2.45rem); line-height: 1.2; font-weight: 720; letter-spacing: -.05em; }
.chat-welcome p { margin: 10px 0 16px; color: var(--muted); }
.chat-welcome form { display: grid; text-align: start; gap: 8px; width: min(100%, 360px); margin-inline: auto; }
.chat-messages { display: grid; gap: 24px; }
.chat-message { max-width: min(100%, 69ch); min-width: 0; }
.chat-message[data-role="user"] { justify-self: end; background: #e4efe5; border-radius: 16px 16px 4px 16px; padding: 11px 15px; }
.chat-message[data-role="status"] { color: #7c3d2c; border-left: 2px solid #b97c65; padding-left: 10px; }
.chat-message-label { display: block; font-size: .76rem; color: var(--muted); font-weight: 670; margin-bottom: 5px; }
.chat-message pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
#older { display: block; margin: 0 auto 20px; }
.chat-composer { padding-block: 8px max(8px, env(safe-area-inset-bottom)); background: var(--paper); }
.chat-input-area { display: flex; align-items: end; gap: 7px; border: 1px solid #abbfb0; border-radius: 15px; background: #fff; padding: 8px; box-shadow: 0 7px 25px #2c5b4010; }
.chat-input-area:focus-within { border-color: #578a6a; }
.chat-input-area textarea { flex: 1; min-width: 0; resize: none; border: 0; padding: 5px 6px; line-height: 1.5; background: transparent; outline: 0; min-height: 40px; max-height: 142px; }
#chat-status, #remote-status { min-height: 19px; margin: 6px 0 0; font-size: .79rem; color: var(--muted); }
#chat-status.is-error, #remote-status.is-error { color: #943d27; }
.chat-dialog { width: min(440px, 100% - 26px); padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); color: var(--ink); }
.chat-dialog::backdrop { background: #14282080; }
.chat-dialog form { display: grid; gap: 8px; }
.chat-dialog header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.chat-dialog h2 { margin: 0; font-size: 1.42rem; }
.chat-dialog p { margin: 6px 0; color: var(--muted); font-size: .88rem; }
.chat-guest-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.chat-auth-modes { display: flex; gap: 4px; padding: 4px; border-radius: 11px; background: #edf2ed; }
.chat-auth-modes button { flex: 1; min-height: 39px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.chat-auth-modes button[aria-pressed="true"] { background: #fff; color: var(--accent); font-weight: 650; box-shadow: 0 1px 5px #25413913; }
.chat-register-fields { display: grid; gap: 5px; }
#sign-in-status:empty, #model-state:empty { display: none; }
.chat-model-list { display: grid; gap: 8px; }
.chat-model-list button {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 2px;
  min-height: 50px;
  padding: 10px 38px 10px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  text-align: start;
  font-weight: 670;
}
.chat-model-list button:hover, .chat-model-list button[aria-current="true"] { border-color: #9bbda9; background: #edf5ee; }
.chat-model-list button[aria-current="true"]::after { position: absolute; inset: 50% 14px auto auto; transform: translateY(-50%); color: var(--accent); content: "✓"; }
.chat-model-list small { color: var(--muted); font-weight: 450; }
.chat-message-files { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 6px; padding: 0; list-style: none; }
.chat-message-files li { padding: 3px 8px; border: 1px solid #bdd4c4; border-radius: 7px; background: #f8fbf8; font-size: .8rem; overflow-wrap: anywhere; }
.chat-incomplete { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; }
.chat-incomplete:empty { display: none; }
.chat-incomplete button { border: 0; border-radius: 8px; padding: 6px 10px; background: var(--panel); color: var(--ink); }
.chat-dialog input, .chat-dialog select, .sign-in input { min-width: 0; width: 100%; background: #fff; border: 1px solid #b4c6b9; border-radius: 8px; padding: 8px 10px; }
#custom-model, #remote-model-field { display: grid; gap: 6px; }
.sign-in { flex: 1; display: grid; overflow: auto; padding: clamp(16px, 5vw, 36px); place-items: center; }
.sign-in-card { width: min(100%, 430px); padding: clamp(21px, 5vw, 36px); background: #f3f7f3; border: 1px solid var(--line); border-radius: 20px; }
.sign-in-card img { border-radius: 14px; }
.sign-in-card h1 { margin: 10px 0 0; font-size: clamp(1.58rem, 5.5vw, 2.15rem); letter-spacing: -.04em; }
.sign-in-card p { margin: 8px 0 16px; color: var(--muted); font-size: .91rem; }
.sign-in-card form { display: grid; gap: 7px; }
.sign-in-card form button { margin-top: 9px; min-height: 42px; }
.sign-in-card a { color: var(--accent); text-decoration: underline; font-size: .86rem; }
.sign-in-card #sign-in-status { min-height: 1.4em; margin: 9px 0; }
@media (max-width: 700px) {
  #sidebar-toggle, .sidebar-toggle { display: inline-block; margin-inline-end: auto; }
  .chat-toolbar { justify-content: start; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-sidebar { position: absolute; z-index: 2; inset: 0 auto 0 0; width: min(83%, 300px); translate: -102% 0; visibility: hidden; box-shadow: 5px 0 20px #17342326; }
  .chat-sidebar.open { translate: 0; visibility: visible; }
  .chat-content { padding-block: 17px; }
}
@media (max-width: 490px) {
  .chat-header { flex-wrap: wrap; gap: 8px; min-height: 54px; }
  .chat-header-actions { gap: 4px; }
  #account-identity { max-width: 9ch; }
}

