:root {
  --bg: #f8f6ff;
  --surface: rgba(253, 252, 255, 0.88);
  --surface-solid: #fdfcff;
  --accent: #7c6daf;
  --accent-deep: #675896;
  --accent-soft: #eee9f8;
  --user-bubble: #7c6daf;
  --user-color: #7c6daf;
  --user-text: #fff;
  --ai-bubble: rgba(255, 255, 255, 0.91);
  --ai-color: #ffffff;
  --bubble-opacity: 76%;
  --ai-border: #e8e0f0;
  --text: #2d2933;
  --muted: #867b96;
  --danger: #a84646;
  --shadow: 0 16px 48px rgba(70, 54, 102, 0.12);
  --header-height: calc(68px + env(safe-area-inset-top));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 29rem),
    radial-gradient(circle at 93% 88%, color-mix(in srgb, var(--user-color) 14%, transparent), transparent 30rem),
    var(--bg-image, none);
  background-position: center, center, center;
  background-size: auto, auto, cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
button, textarea, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.is-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(100%, 920px);
  min-width: 0;
  height: 100%;
  overflow: hidden;
  margin: 0 auto;
  position: relative;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-inline: 1px solid color-mix(in srgb, var(--ai-border) 55%, transparent);
}
body.has-bg-image .app-shell { background: transparent; }

.chat-header {
  position: absolute;
  z-index: 14;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  height: var(--header-height);
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  border-bottom: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  pointer-events: none;
}

.identity,
.header-actions {
  min-height: 56px;
  border: 1px solid color-mix(in srgb, white 46%, var(--ai-border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--ai-color) var(--bubble-opacity), transparent);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--text) 14%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.36);
  -webkit-backdrop-filter: blur(24px) saturate(128%);
  backdrop-filter: blur(24px) saturate(128%);
  pointer-events: auto;
}
.identity { display: flex; min-width: 0; max-width: min(68vw, 430px); align-items: center; gap: 8px; padding: 0 16px 0 7px; }
.header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 2px; padding: 0 6px; }
.avatar, .empty-mark, .login-mark {
  display: grid;
  place-items: center;
  color: var(--text);
  background: transparent;
}
.model-glyph { display: block; width: 72%; height: 72%; background: currentColor; -webkit-mask: url('/model-icon.svg') center / contain no-repeat; mask: url('/model-icon.svg') center / contain no-repeat; }
.avatar { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 15px; font-size: 24px; }
.identity-copy { min-width: 0; }
.identity-copy h1 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 18px; font-weight: 600; letter-spacing: 0.03em; }
.presence { display: flex; align-items: center; gap: 5px; margin-top: 2px; color: var(--muted); font-size: 11px; }
.presence-dot { width: 6px; height: 6px; border-radius: 999px; background: #aaa0b5; transition: background 180ms ease, box-shadow 180ms ease; }
.presence-dot.is-online { background: #72a27b; box-shadow: 0 0 0 3px rgba(114, 162, 123, 0.13); }
.presence-dot.is-busy { background: #b79467; box-shadow: 0 0 0 3px rgba(183, 148, 103, 0.13); }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 14px; color: var(--accent); background: transparent; cursor: pointer; transition: background 160ms ease, opacity 160ms ease; }
.icon-button:hover { background: var(--accent-soft); }
.icon-button:active { opacity: 0.68; }
.icon-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.messages {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: calc(var(--header-height) + 14px) clamp(14px, 4vw, 32px) 22px;
  scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }
.chat-scroll-jumps {
  position: absolute;
  z-index: 12;
  top: 50%;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 5px;
  border: 1px solid color-mix(in srgb, var(--ai-border) 78%, transparent);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(5px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--text) 12%, transparent);
  backdrop-filter: blur(12px) saturate(120%);
  transition: opacity 180ms ease, transform 180ms ease;
}
.chat-scroll-jumps.is-visible { opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); }
.chat-scroll-jumps button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 999px; color: var(--accent); background: transparent; cursor: pointer; touch-action: manipulation; transition: background-color 120ms ease, transform 120ms ease; }
.chat-scroll-jumps button:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.chat-scroll-jumps button:active { background: color-mix(in srgb, var(--accent) 12%, transparent); transform: scale(0.94); }
.chat-scroll-jumps svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-state { display: grid; min-height: 100%; place-content: center; justify-items: center; gap: 15px; color: var(--muted); text-align: center; }
.empty-state p { max-width: 260px; margin: 0; font-size: 13px; line-height: 1.7; }
.empty-mark { width: 58px; height: 58px; border-radius: 21px; font-size: 33px; opacity: 0.72; }

.message-row { display: flex; width: 100%; margin: 0 0 15px; animation: rise 220ms cubic-bezier(0.16, 1, 0.3, 1); }
.message-row.user { justify-content: flex-end; }
.message-row.assistant { justify-content: flex-start; }
.message-column { max-width: min(78%, 650px); min-width: 0; }
.message-bubble {
  padding: 11px 15px;
  border-radius: 19px;
  font-size: 15px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  box-shadow: 0 6px 18px rgba(62, 47, 88, 0.055);
}
.message-row.assistant .message-bubble > :first-child { margin-top: 0; }
.message-row.assistant .message-bubble > :last-child { margin-bottom: 0; }
.message-row.assistant .message-bubble p { margin: 0 0 0.72em; }
.message-row.assistant .message-bubble h1,
.message-row.assistant .message-bubble h2,
.message-row.assistant .message-bubble h3,
.message-row.assistant .message-bubble h4,
.message-row.assistant .message-bubble h5,
.message-row.assistant .message-bubble h6 { margin: 0.9em 0 0.45em; line-height: 1.32; }
.message-row.assistant .message-bubble h1 { font-size: 1.34em; }
.message-row.assistant .message-bubble h2 { font-size: 1.23em; }
.message-row.assistant .message-bubble h3 { font-size: 1.13em; }
.message-row.assistant .message-bubble h4,
.message-row.assistant .message-bubble h5,
.message-row.assistant .message-bubble h6 { font-size: 1em; }
.message-row.assistant .message-bubble ul,
.message-row.assistant .message-bubble ol { margin: 0.42em 0 0.75em; padding-left: 1.5em; white-space: normal; }
.message-row.assistant .message-bubble li { margin: 0.22em 0; }
.message-row.assistant .message-bubble blockquote { margin: 0.6em 0; padding: 0.15em 0 0.15em 0.85em; border-left: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); color: color-mix(in srgb, currentColor 78%, var(--muted)); white-space: pre-wrap; }
.message-row.assistant .message-bubble code { border-radius: 5px; padding: 0.12em 0.34em; background: color-mix(in srgb, var(--text) 9%, transparent); font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 0.9em; }
.message-row.assistant .message-bubble pre { max-width: 100%; margin: 0.65em 0 0.8em; overflow-x: auto; border: 1px solid color-mix(in srgb, currentColor 12%, transparent); border-radius: 11px; padding: 11px 12px; background: color-mix(in srgb, var(--text) 7%, var(--surface-solid)); white-space: pre; -webkit-overflow-scrolling: touch; }
.message-row.assistant .message-bubble pre code { padding: 0; background: transparent; font-size: 0.86em; }
.message-row.assistant .message-bubble pre.markdown-code-block,
.thinking-text pre.markdown-code-block { position: relative; padding-right: 58px; }
.code-copy-button {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  border-radius: 10px;
  padding: 0;
  color: color-mix(in srgb, currentColor 70%, var(--muted));
  background: color-mix(in srgb, var(--surface-solid) 82%, transparent);
  box-shadow: 0 3px 10px rgba(55, 43, 78, 0.06);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 120ms ease;
}
.code-copy-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.code-copy-button:hover { color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 66%, var(--surface-solid)); }
.code-copy-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.code-copy-button:active { transform: scale(0.92); }
.code-copy-button.is-copied { color: var(--accent-deep); border-color: color-mix(in srgb, var(--accent) 38%, transparent); background: color-mix(in srgb, var(--accent-soft) 78%, var(--surface-solid)); }
.code-copy-button.is-failed { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, transparent); }
.message-row.assistant .message-bubble a { color: color-mix(in srgb, var(--accent) 84%, currentColor); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
.message-row.assistant .message-bubble a:focus-visible { border-radius: 3px; outline: 2px solid var(--accent); outline-offset: 2px; }
.message-row.assistant .message-bubble hr { height: 1px; margin: 0.85em 0; border: 0; background: color-mix(in srgb, currentColor 18%, transparent); }
.message-row.assistant .message-bubble del { opacity: 0.72; }
.message-row.assistant .message-bubble .task-list { padding-left: 0.2em; list-style: none; }
.message-row.assistant .message-bubble .task-list-item { display: flex; align-items: baseline; gap: 0.48em; }
.message-row.assistant .message-bubble .task-list-item input { width: 1em; height: 1em; margin: 0; accent-color: var(--accent); }
.message-row.user .message-bubble { color: var(--user-text); border: 1px solid color-mix(in srgb, var(--user-color) 36%, transparent); background: color-mix(in srgb, var(--user-color) var(--bubble-opacity), transparent); border-bottom-right-radius: 6px; backdrop-filter: blur(15px) saturate(125%); }
.message-row.assistant .message-bubble { color: var(--text); border: 1px solid var(--ai-border); border-bottom-left-radius: 6px; background: color-mix(in srgb, var(--ai-color) var(--bubble-opacity), transparent); backdrop-filter: blur(15px) saturate(125%); }
.message-row.commentary .message-bubble { color: color-mix(in srgb, var(--text) 88%, var(--accent)); background: color-mix(in srgb, var(--ai-bubble) 88%, var(--accent-soft)); }
.message-attachments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; min-width: min(52vw, 300px); }
.message-attachments.has-text { margin-top: 10px; }
.message-image { display: block; overflow: hidden; min-height: 80px; border-radius: 12px; background: color-mix(in srgb, var(--text) 7%, transparent); }
.message-image img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.message-file { display: flex; grid-column: 1 / -1; min-width: 0; align-items: center; gap: 8px; border: 1px solid color-mix(in srgb, currentColor 15%, transparent); border-radius: 11px; padding: 8px 10px; color: inherit; background: color-mix(in srgb, var(--surface-solid) 24%, transparent); text-decoration: none; }
.message-file svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.message-file span { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message-meta { display: flex; min-height: 34px; align-items: center; gap: 8px; padding-inline: 2px; }
.message-row.user .message-meta { justify-content: flex-end; }
.message-stamp { display: flex; min-width: 0; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; opacity: 0.82; }
.message-note::after { content: "·"; margin-left: 5px; }
.message-time { white-space: nowrap; }
.message-actions { display: flex; align-items: center; gap: 8px; margin-left: -7px; }
.message-action, .context-close {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  transition: color 140ms ease, background 140ms ease, opacity 140ms ease, transform 120ms ease;
}
.message-action { opacity: 0.72; }
.message-action svg, .context-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.message-action:hover, .message-action:focus-visible { color: var(--accent); background: var(--accent-soft); opacity: 1; }
.message-action.is-danger:hover, .message-action.is-danger:focus-visible { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.message-action:active, .context-close:active { transform: scale(0.92); }
.message-action:focus-visible, .context-close:focus-visible, .compose-mode:focus-visible, .confirm-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stream-cursor { display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -0.1em; border-radius: 2px; background: var(--accent); animation: blink 1s steps(1) infinite; }

.work-card { width: min(88%, 680px); margin: 2px 0 13px 9px; border: 1px solid color-mix(in srgb, var(--ai-border) 86%, transparent); border-radius: 15px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 57%, transparent); box-shadow: 0 5px 18px rgba(55, 43, 78, 0.045); backdrop-filter: blur(14px); animation: rise 180ms ease-out; }
.work-card summary { display: flex; min-height: 48px; align-items: center; gap: 9px; padding: 8px 11px; cursor: pointer; list-style: none; user-select: none; }
.work-card summary::-webkit-details-marker { display: none; }
.work-icon { display: grid; width: 29px; height: 29px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); }
.work-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.work-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.work-copy strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.work-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.work-state { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.work-card.is-running .work-state { color: var(--accent); }
.work-card.is-running .work-icon { animation: workPulse 1.4s ease-in-out infinite; }
.work-card.is-failed .work-state { color: var(--danger); }
.work-chevron { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform 150ms ease; }
.work-card[open] .work-chevron { transform: rotate(180deg); }
.work-detail { display: grid; gap: 10px; margin: 0 10px 10px; border-top: 1px solid var(--ai-border); padding: 10px 2px 1px; }
.work-detail section { min-width: 0; }
.work-detail label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.work-detail pre { max-height: 260px; overflow: auto; margin: 0; border-radius: 10px; padding: 9px 10px; color: color-mix(in srgb, var(--text) 88%, var(--accent)); background: color-mix(in srgb, var(--bg) 64%, transparent); font: 10px/1.58 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; white-space: pre-wrap; }
.work-detail footer { min-height: 12px; color: var(--muted); font-size: 9px; text-align: right; }

.thinking-card { width: min(82%, 630px); margin: 2px 0 13px 9px; border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--ai-border)); border-radius: 15px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 51%, transparent); box-shadow: 0 5px 18px rgba(55, 43, 78, 0.035); backdrop-filter: blur(14px); animation: rise 180ms ease-out; }
.thinking-card summary { display: flex; min-height: 48px; align-items: center; gap: 9px; padding: 8px 11px; cursor: pointer; list-style: none; user-select: none; touch-action: manipulation; }
.thinking-card summary::-webkit-details-marker { display: none; }
.thinking-card summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 13px; }
.thinking-icon { display: grid; width: 29px; height: 29px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 72%, transparent); }
.thinking-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.thinking-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.thinking-copy strong { font-size: 12px; font-weight: 650; }
.thinking-copy small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.thinking-state { flex: 0 0 auto; color: var(--muted); font-size: 10px; }
.thinking-card.is-running .thinking-state { color: var(--accent); }
.thinking-card.is-running .thinking-icon { animation: workPulse 1.4s ease-in-out infinite; }
.thinking-card.is-failed .thinking-state { color: var(--danger); }
.thinking-chevron { width: 15px; height: 15px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; transition: transform 150ms ease; }
.thinking-card[open] .thinking-chevron { transform: rotate(180deg); }
.thinking-detail { margin: 0 10px 10px; border-top: 1px solid color-mix(in srgb, var(--accent) 12%, var(--ai-border)); padding: 10px 2px 1px; }
.thinking-text { max-height: 300px; overflow: auto; margin: 0; border-radius: 10px; padding: 10px 11px; color: color-mix(in srgb, var(--text) 90%, var(--accent)); background: color-mix(in srgb, var(--bg) 57%, transparent); font: 12px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; overflow-wrap: anywhere; white-space: pre-wrap; }
.thinking-text > :first-child { margin-top: 0; }
.thinking-text > :last-child { margin-bottom: 0; }
.thinking-text p { margin: 0 0 0.7em; }
.thinking-text h1,
.thinking-text h2,
.thinking-text h3,
.thinking-text h4,
.thinking-text h5,
.thinking-text h6 { margin: 0.85em 0 0.4em; line-height: 1.35; }
.thinking-text h1 { font-size: 1.28em; }
.thinking-text h2 { font-size: 1.2em; }
.thinking-text h3 { font-size: 1.12em; }
.thinking-text h4,
.thinking-text h5,
.thinking-text h6 { font-size: 1em; }
.thinking-text ul,
.thinking-text ol { margin: 0.4em 0 0.7em; padding-left: 1.45em; white-space: normal; }
.thinking-text li { margin: 0.18em 0; }
.thinking-text blockquote { margin: 0.55em 0; padding: 0.1em 0 0.1em 0.75em; border-left: 3px solid color-mix(in srgb, var(--accent) 65%, transparent); color: color-mix(in srgb, currentColor 78%, var(--muted)); }
.thinking-text code { border-radius: 4px; padding: 0.1em 0.3em; background: color-mix(in srgb, var(--text) 9%, transparent); font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 0.92em; }
.thinking-text pre { max-width: 100%; margin: 0.6em 0 0.75em; overflow-x: auto; border: 1px solid color-mix(in srgb, currentColor 12%, transparent); border-radius: 9px; padding: 9px 10px; background: color-mix(in srgb, var(--text) 7%, var(--surface-solid)); white-space: pre; -webkit-overflow-scrolling: touch; }
.thinking-text pre code { padding: 0; background: transparent; }
.thinking-text a { color: color-mix(in srgb, var(--accent) 84%, currentColor); text-underline-offset: 0.16em; }
.thinking-text a:focus-visible { border-radius: 3px; outline: 2px solid var(--accent); outline-offset: 2px; }
.thinking-text hr { height: 1px; margin: 0.75em 0; border: 0; background: color-mix(in srgb, currentColor 18%, transparent); }
.thinking-text del { opacity: 0.72; }
.thinking-text .task-list { padding-left: 0.15em; list-style: none; }
.thinking-text .task-list-item { display: flex; align-items: baseline; gap: 0.45em; }
.thinking-text .task-list-item input { width: 1em; height: 1em; margin: 0; accent-color: var(--accent); }

.activity { position: absolute; z-index: 4; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); display: flex; transform: translateX(-50%); align-items: center; gap: 8px; max-width: calc(100% - 32px); border: 1px solid rgba(232, 224, 240, 0.8); border-radius: 999px; padding: 7px 12px; color: var(--muted); background: rgba(253, 252, 255, 0.88); box-shadow: 0 8px 24px rgba(63, 49, 90, 0.09); backdrop-filter: blur(16px); font-size: 11px; }
.activity-dots { display: flex; align-items: center; gap: 3px; }
.activity-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); animation: dot 1.15s ease-in-out infinite; }
.activity-dots i:nth-child(2) { animation-delay: 0.14s; }
.activity-dots i:nth-child(3) { animation-delay: 0.28s; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(88vw, 480px); border-radius: 12px; padding: 9px 13px; color: #fff; background: rgba(55, 45, 66, 0.9); box-shadow: var(--shadow); font-size: 12px; text-align: center; }

.composer { position: relative; z-index: 6; width: 100%; min-width: 0; max-width: 100%; overflow: visible; padding: 10px clamp(12px, 3vw, 24px) calc(12px + env(safe-area-inset-bottom)); background: transparent; }
.command-palette { position: absolute; z-index: 8; right: clamp(12px, 3vw, 24px); bottom: calc(100% - 3px); left: clamp(12px, 3vw, 24px); max-height: min(52dvh, 430px); overflow: hidden; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--ai-border)); border-radius: 22px; background: color-mix(in srgb, var(--surface-solid) 80%, transparent); box-shadow: 0 18px 54px rgba(48, 38, 66, .18); backdrop-filter: blur(24px) saturate(1.14); -webkit-backdrop-filter: blur(24px) saturate(1.14); transform-origin: bottom center; animation: commandIn 150ms ease-out; }
.command-palette-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 15px 8px; color: var(--accent-deep); font-size: 12px; font-weight: 700; }
.command-palette-head small { color: var(--muted); font-size: 10px; font-weight: 500; }
.command-list { max-height: min(44dvh, 360px); overflow-y: auto; overscroll-behavior: contain; padding: 3px 7px 8px; scrollbar-width: thin; }
.command-option { display: grid; width: 100%; min-height: 52px; grid-template-columns: minmax(84px, auto) 1fr; align-items: center; gap: 12px; border: 0; border-radius: 15px; padding: 8px 10px; color: var(--text); background: transparent; text-align: left; touch-action: manipulation; }
.command-option:active { background: var(--accent-soft); transform: scale(.99); }
.command-option code { color: var(--accent-deep); font: 700 13px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; }
.command-option span { overflow: hidden; color: var(--muted); font-size: 12px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.command-empty { padding: 24px 16px; color: var(--muted); font-size: 12px; text-align: center; }
.compose-context { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--ai-border)); border-radius: 17px; padding: 8px 7px 8px 12px; background: color-mix(in srgb, var(--surface-solid) 90%, transparent); box-shadow: 0 7px 22px rgba(72, 56, 104, 0.08); backdrop-filter: blur(16px); }
.compose-context-copy { min-width: 0; flex: 1; }
.compose-context-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--accent-deep); font-size: 11px; font-weight: 650; }
.compose-context p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.compose-modes { display: flex; flex: 0 0 auto; gap: 2px; border-radius: 999px; padding: 2px; background: var(--accent-soft); }
.compose-mode { min-width: 48px; min-height: 40px; border: 0; border-radius: 999px; padding: 0 9px; color: var(--muted); background: transparent; cursor: pointer; touch-action: manipulation; font-size: 11px; }
.compose-mode.is-active { color: var(--accent-deep); background: var(--surface-solid); box-shadow: 0 2px 7px rgba(72, 56, 104, 0.1); }
.context-close { flex: 0 0 auto; }
.composer-surface { position: relative; width: 100%; min-width: 0; max-width: 100%; min-height: 64px; overflow: hidden; border: 1px solid color-mix(in srgb, white 46%, var(--ai-border)); border-radius: 30px; background: color-mix(in srgb, var(--ai-color) var(--bubble-opacity), transparent); box-shadow: 0 10px 26px rgba(40, 28, 72, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.34); -webkit-backdrop-filter: blur(24px) saturate(128%); backdrop-filter: blur(24px) saturate(128%); }
#message-input { display: block; width: 100%; min-height: 62px; max-height: 144px; resize: none; overflow-y: auto; border: 0; outline: 0; padding: 20px 58px 18px 56px; color: var(--text); background: transparent; font-size: 16px; line-height: 1.5; }
#message-input::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
.send-button, .stop-button { position: absolute; right: 9px; bottom: 8px; display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; cursor: pointer; transition: opacity 160ms ease, filter 160ms ease, transform 120ms ease; }
.send-button { border: 0; color: #fff; background: var(--accent); box-shadow: 0 5px 14px rgba(92, 76, 137, 0.24); }
.send-button:disabled { cursor: default; opacity: 0.34; box-shadow: none; }
.send-button:not(:disabled):hover { filter: brightness(1.05); }
.send-button:not(:disabled):active, .stop-button:active { transform: scale(0.95); }
.stop-button { border: 1px solid var(--accent); color: var(--accent); background: var(--ai-bubble); }
.send-button svg, .stop-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.stop-button svg rect { fill: currentColor; stroke: none; }
.attachment-button { position: absolute; left: 8px; bottom: 8px; display: grid; width: 40px; height: 40px; place-items: center; border: 0; border-radius: 50%; color: var(--accent); background: transparent; cursor: pointer; }
.attachment-button:hover { background: var(--accent-soft); }
.attachment-button:active { transform: scale(.94); }
.attachment-button svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attachment-tray { display: flex; width: calc(100% - 6px); min-width: 0; max-width: calc(100% - 6px); gap: 8px; overflow-x: auto; margin: 0 3px 8px; padding: 2px 1px; scrollbar-width: none; }
.attachment-tray::-webkit-scrollbar { display: none; }
.attachment-chip { position: relative; display: flex; width: 180px; min-width: 180px; height: 58px; align-items: center; gap: 8px; overflow: hidden; border: 1px solid var(--ai-border); border-radius: 15px; padding: 6px 34px 6px 7px; background: color-mix(in srgb, var(--surface-solid) 80%, transparent); backdrop-filter: blur(14px); }
.attachment-chip > img, .attachment-chip-icon { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 10px; object-fit: cover; }
.attachment-chip-icon { display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.attachment-chip-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.attachment-chip-copy { display: grid; min-width: 0; gap: 3px; }
.attachment-chip-copy strong, .attachment-chip-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip-copy strong { font-size: 11px; font-weight: 600; }
.attachment-chip-copy small { color: var(--muted); font-size: 9px; }
.attachment-chip.is-error small { color: var(--danger); }
.attachment-chip > i { position: absolute; left: 0; bottom: 0; height: 2px; border-radius: 2px; background: var(--accent); transition: width 120ms linear; }
.attachment-remove { position: absolute; top: 9px; right: 5px; display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: transparent; }
.attachment-remove svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.confirm-dialog { width: min(calc(100% - 32px), 390px); max-width: 390px; border: 0; padding: 0; color: var(--text); background: transparent; }
.confirm-dialog::backdrop { background: rgba(29, 24, 37, 0.36); backdrop-filter: blur(5px); }
.confirm-card { border: 1px solid var(--ai-border); border-radius: 25px; padding: 24px; background: var(--surface-solid); box-shadow: 0 24px 70px rgba(40, 31, 54, 0.22); text-align: center; }
.confirm-icon { display: grid; width: 46px; height: 46px; margin: 0 auto 13px; place-items: center; border-radius: 16px; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.confirm-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.confirm-card h2 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 19px; font-weight: 600; }
.confirm-card p { margin: 10px 0 22px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confirm-actions button { min-height: 46px; border: 1px solid var(--ai-border); border-radius: 14px; color: var(--text); background: transparent; cursor: pointer; touch-action: manipulation; }
.confirm-actions .danger-action { border-color: transparent; color: #fff; background: var(--danger); }
.confirm-actions button:active { opacity: 0.72; }
.confirm-actions button:disabled { cursor: wait; opacity: 0.5; }

.theme-dialog { width: min(calc(100% - 24px), 480px); max-width: 480px; border: 0; padding: 0; color: var(--text); background: transparent; }
.theme-dialog::backdrop { background: rgba(29, 24, 37, 0.32); backdrop-filter: blur(5px); }
.theme-card { max-height: calc(100dvh - 24px); overflow-y: auto; border: 1px solid var(--ai-border); border-radius: 26px; padding: 22px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 91%, transparent); box-shadow: 0 24px 70px rgba(40, 31, 54, 0.22); backdrop-filter: blur(24px); }
.theme-head { display: flex; align-items: center; justify-content: space-between; }
.theme-head h2 { margin: 0; font: 600 21px/1.3 Georgia, "Noto Serif SC", serif; }
.theme-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 20px 0; }
.theme-presets button { display: grid; min-height: 54px; place-items: center; gap: 4px; border: 1px solid var(--ai-border); border-radius: 13px; color: var(--text); background: transparent; font-size: 10px; cursor: pointer; }
.theme-presets button:active { background: var(--accent-soft); }
.theme-presets button.is-active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 24%, transparent); }
.theme-presets i { width: 20px; height: 20px; border: 5px solid color-mix(in srgb, var(--swatch) 22%, white); border-radius: 50%; background: var(--swatch); box-shadow: 0 2px 5px color-mix(in srgb, var(--swatch) 25%, transparent); }
.theme-presets .theme-custom-preset { grid-column: 1 / -1; display: flex; min-height: 48px; justify-content: flex-start; gap: 10px; padding: 8px 12px; text-align: left; }
.theme-custom-preset svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-custom-preset span, .theme-custom-preset strong, .theme-custom-preset small { display: block; }
.theme-custom-preset strong { font-size: 11px; font-weight: 600; }
.theme-custom-preset small { margin-top: 2px; color: var(--muted); font-size: 9px; line-height: 1.35; }
.theme-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-fields label { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--ai-border); border-radius: 13px; padding: 8px 10px 8px 12px; color: var(--muted); font-size: 11px; }
.theme-fields input[type="color"] { width: 30px; height: 30px; border: 0; padding: 0; border-radius: 9px; background: transparent; overflow: hidden; }
.theme-range-label { grid-column: 1 / -1; flex-wrap: wrap; }
.theme-range-label output { margin-left: auto; color: var(--accent); }
.theme-range-label input { width: 100%; accent-color: var(--accent); }
.theme-background-field { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; align-items: center; gap: 8px; margin-top: 10px; border: 1px solid var(--ai-border); border-radius: 15px; padding: 10px; }
.theme-background-copy { min-width: 0; }
.theme-background-copy strong, .theme-background-copy span { display: block; }
.theme-background-copy strong { color: var(--text); font-size: 12px; font-weight: 600; }
.theme-background-copy span { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.theme-background-preview { width: 48px; height: 38px; overflow: hidden; border: 1px solid var(--ai-border); border-radius: 10px; background: var(--accent-soft); }
.theme-background-preview.is-empty { display: none; }
.theme-background-preview img { width: 100%; height: 100%; object-fit: cover; }
.theme-background-action { display: inline-flex; min-height: 36px; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--ai-border); border-radius: 11px; padding: 0 10px; color: var(--accent); background: transparent; cursor: pointer; font-size: 10px; }
.theme-background-action:hover { background: var(--accent-soft); }
.theme-background-action:active { opacity: 0.72; }
.theme-background-action:disabled { cursor: wait; opacity: 0.48; }
.theme-background-action.danger { color: var(--danger); }
.theme-background-action svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.theme-actions button { min-height: 44px; border: 1px solid var(--ai-border); border-radius: 13px; color: var(--text); background: transparent; cursor: pointer; }
.theme-actions .theme-done { border-color: transparent; color: #fff; background: var(--accent); }

.command-dialog { width: min(calc(100% - 24px), 480px); max-width: 480px; border: 0; padding: 0; color: var(--text); background: transparent; }
.command-dialog::backdrop { background: rgba(29, 24, 37, .32); backdrop-filter: blur(5px); }
.command-card { max-height: min(78dvh, 620px); overflow: hidden; border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--ai-border)); border-radius: 26px; padding: 20px; background: color-mix(in srgb, var(--surface-solid) 88%, transparent); box-shadow: 0 24px 70px rgba(40, 31, 54, .22); backdrop-filter: blur(26px) saturate(1.12); -webkit-backdrop-filter: blur(26px) saturate(1.12); }
.command-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.command-dialog-head h2 { margin: 0; font: 600 20px/1.3 Georgia, "Noto Serif SC", serif; }
.command-dialog-body { max-height: min(57dvh, 450px); overflow-y: auto; margin-top: 15px; color: var(--text); font-size: 13px; line-height: 1.6; overscroll-behavior: contain; }
.command-dialog-body > p { margin: 0; color: var(--muted); }
.command-result-list { display: grid; gap: 7px; }
.command-result { display: grid; width: 100%; min-height: 50px; gap: 3px; border: 1px solid var(--ai-border); border-radius: 15px; padding: 10px 12px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 62%, transparent); text-align: left; }
button.command-result { cursor: pointer; touch-action: manipulation; }
button.command-result:active { border-color: var(--accent); background: var(--accent-soft); }
.command-result strong { font-size: 13px; font-weight: 650; }
.command-result small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.command-result.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
.command-field { display: grid; gap: 7px; color: var(--muted); font-size: 11px; }
.command-field input, .command-field textarea { width: 100%; border: 1px solid var(--ai-border); border-radius: 14px; outline: 0; padding: 11px 12px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 72%, transparent); }
.command-field textarea { min-height: 100px; resize: vertical; }
.command-field input:focus, .command-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.command-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.command-dialog-actions button { min-height: 44px; border: 1px solid var(--ai-border); border-radius: 13px; padding: 0 16px; color: var(--text); background: transparent; touch-action: manipulation; }
.command-dialog-actions .primary { border-color: transparent; color: #fff; background: var(--accent); }
.command-json { margin: 0; overflow-wrap: anywhere; color: var(--muted); font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }

.login-screen { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 22% 12%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 28rem), var(--bg); }
.login-card { width: min(calc(100vw - 40px), 390px); max-width: 100%; border: 1px solid var(--ai-border); border-radius: 30px; padding: 35px 30px 30px; color: var(--text); background: color-mix(in srgb, var(--surface-solid) 90%, transparent); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.16); backdrop-filter: blur(24px); }
.login-mark { width: 56px; height: 56px; margin-bottom: 22px; border-radius: 20px; font-size: 32px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 0.16em; }
.login-card h2 { margin: 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 25px; font-weight: 600; }
.login-copy { margin: 11px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.login-card label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.login-card input { width: 100%; height: 48px; border: 1px solid var(--ai-border); border-radius: 14px; outline: 0; padding: 0 13px; color: var(--text); background: var(--surface-solid); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 109, 175, 0.12); }
.login-error { min-height: 18px; margin: 7px 2px 6px; color: var(--danger); font-size: 11px; }
.login-card button { width: 100%; min-height: 48px; border: 0; border-radius: 14px; color: #fff; background: var(--accent); cursor: pointer; font-weight: 600; transition: filter 160ms ease, opacity 160ms ease; }
.login-card button:hover { filter: brightness(1.04); }
.login-card button:active { opacity: 0.76; }

@keyframes rise { from { opacity: 0; transform: translateY(7px); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes dot { 0%, 65%, 100% { transform: translateY(0); opacity: 0.35; } 32% { transform: translateY(-3px); opacity: 1; } }
@keyframes workPulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); } }
@keyframes commandIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }

@media (max-width: 560px) {
  :root { --header-height: calc(68px + env(safe-area-inset-top)); }
  .app-shell { border: 0; }
  .chat-header { padding-inline: 10px; }
  .identity { max-width: calc(100% - 64px); }
  .avatar { width: 38px; height: 38px; border-radius: 14px; font-size: 22px; }
  .identity-copy h1 { font-size: 17px; }
  .messages { padding: calc(var(--header-height) + 12px) 12px 18px; }
  .chat-scroll-jumps { right: 7px; }
  .message-column { max-width: 86%; }
  .message-bubble { padding: 10px 13px; font-size: 15px; border-radius: 17px; }
  .message-action { opacity: 0.78; }
  .composer { padding-inline: 10px; }
  .command-palette { right: 10px; left: 10px; }
  .composer-surface { border-radius: 30px; }
  .work-card { width: calc(100% - 18px); margin-left: 4px; }
  .work-detail pre { max-height: 210px; }
  .thinking-card { width: calc(100% - 18px); margin-left: 4px; }
  .thinking-text { max-height: 240px; }
  .theme-dialog { width: calc(100% - 18px); margin-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .theme-card { border-radius: 24px; padding: 19px 15px 16px; }
  .theme-presets { gap: 5px; }
  .theme-fields { gap: 6px; }
  .theme-background-field { grid-template-columns: minmax(0, 1fr) auto auto auto; }
  .theme-background-action span { display: none; }
  .theme-background-action { width: 36px; padding: 0; }
  .login-card { padding: 30px 23px 25px; border-radius: 26px; }
}

@media (hover: hover) and (pointer: fine) {
  .message-action { opacity: 0.16; }
  .message-row:hover .message-action, .message-action:focus-visible { opacity: 0.78; }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root { --header-height: 56px; }
  .chat-header { padding-top: 0; }
  .messages { padding-top: calc(var(--header-height) + 8px); }
  .composer { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
