:root {
  color-scheme: light;
  --bg: #fbfbf9;
  --sidebar: #f1f2ef;
  --surface: #ffffff;
  --field: #ffffff;
  --ink: #202327;
  --quiet: #5b6168;
  --line: #dcdedb;
  --hover: #e6e8e5;
  --soft: #e8edf3;
  --accent: #285079;
  --pro: #663bb9;
  --shadow: #1c222617;
  --motion-short: 140ms;
  --motion-panel: 220ms;
  --motion-ease: cubic-bezier(.2, .75, .25, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #222428;
    --sidebar: #191b1e;
    --surface: #2a2d31;
    --field: #2f3237;
    --ink: #f4f4f3;
    --quiet: #b2b7bd;
    --line: #41454c;
    --hover: #33363c;
    --soft: #343d49;
    --accent: #afceef;
    --pro: #c0a2ff;
    --shadow: #0004;
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #222428;
  --sidebar: #191b1e;
  --surface: #2a2d31;
  --field: #2f3237;
  --ink: #f4f4f3;
  --quiet: #b2b7bd;
  --line: #41454c;
  --hover: #33363c;
  --soft: #343d49;
  --accent: #afceef;
  --pro: #c0a2ff;
  --shadow: #0004;
}
*{box-sizing:border-box}
[hidden]{display:none!important}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, sans-serif;
}
button,textarea,input{font:inherit}
button{cursor:pointer;color:inherit}
button:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
button:disabled{cursor:default;opacity:.55}
.workspace {
  --history-width: 254px;
  display: grid;
  grid-template-columns: 0px minmax(0, 1fr);
  height: var(--viewport-height, 100dvh);
}
.workspace:has(.history-drawer[data-docked][open]) { grid-template-columns: var(--history-width) minmax(0, 1fr); }
@media (min-width: 900px) {
  .workspace { transition: grid-template-columns var(--motion-panel) var(--motion-ease); }
}
.shell { grid-area: 1 / 2; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: calc(60px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
}
.header-start { display: flex; align-items: center; gap: 5px; min-width: 0; }
.identity{display:flex;align-items:center;gap:8px;min-height:44px;font-size:16px;letter-spacing:-.025em;border:0;padding:0 8px 0 3px;background:none;border-radius:22px}
.identity:hover{background:var(--hover)}
.identity strong{white-space:nowrap}
.identity strong span{color:var(--accent)}
.mark{display:block;flex:none;width:33px;height:33px}
.profile-trigger{display:flex;flex:none;align-items:center;justify-content:center;gap:8px;min-width:44px;min-height:44px;padding:4px 5px 4px 10px;border:0;border-radius:99px;background:transparent;color:var(--quiet);font-size:13px;font-weight:650}
.profile-trigger:hover{background:var(--hover);color:var(--ink)}
.profile-avatar{display:grid;flex:none;place-items:center;width:33px;height:33px;border:1px solid var(--line);border-radius:50%;background:var(--soft);color:var(--accent)}
#chat {
  --chat-width: 780px;
  --chat-inset-left: max(16px, env(safe-area-inset-left));
  --chat-inset-right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  margin-inline: auto;
  padding: 0 0 max(18px, env(safe-area-inset-bottom));
}
#chat:not(.has-thread) { justify-content: center; padding-bottom: clamp(32px, 10vh, 96px); }
.chat-title {
  flex: none;
  overflow: hidden;
  margin: 5px 0 12px;
  color: var(--quiet);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hero { margin: 0 0 24px; text-align: center; font-size: clamp(25px, 4.5vw, 34px); font-weight: 590; letter-spacing: -.045em; line-height: 1.16; }
.hero,.chat-title,.composer {
  width: min(var(--chat-width), calc(100% - var(--chat-inset-left) - var(--chat-inset-right)));
  align-self: center;
}
.messages {
  display: grid;
  gap: 18px;
  padding: 6px max(var(--chat-inset-right), calc((100% - var(--chat-width)) / 2)) 18px max(var(--chat-inset-left), calc((100% - var(--chat-width)) / 2));
}
.messages:empty { display: none; }
.has-thread .messages { display: grid; flex: 1; min-height: 0; align-content: start; overflow-y: auto; overscroll-behavior: contain; }
.bubble { max-width: 100%; padding: 5px 0; overflow-wrap: anywhere; white-space: pre-wrap; justify-self: start; font-size: 16px; line-height: 1.62; }
.bubble.mine { max-width: min(90%, 580px); padding: 9px 15px; border-radius: 21px; background: var(--hover); justify-self: end; }
.bubble img { display: block; width: min(380px, 100%); margin-top: 7px; border-radius: 17px; }
.picture-view { display: block; max-width: 100%; padding: 0; border: 0; border-radius: 17px; background: none; cursor: zoom-in; }
.image-viewer[open] { display: grid; place-items: center; }
.image-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--viewport-height, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(52px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border: 0;
  background: #16181b;
  color: #fff;
}
.image-viewer::backdrop { background: #16181b; }
.image-viewer button { position: absolute; top: max(5px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); color: #fff; }
.image-viewer button:hover { background: #ffffff20; }
.image-viewer img { display: block; max-width: 100%; max-height: calc(var(--viewport-height, 100dvh) - 68px); object-fit: contain; }
.reply-progress { justify-self: start; padding: 7px 12px; color: var(--quiet); font-size: 13px; }
.bubble[data-new],.reply-progress { animation: message-enter var(--motion-short) var(--motion-ease) both; }
@media (min-width: 641px) {
  .messages > [data-first-turn] { animation-delay: 28ms; }
}
.bubble[data-new] img { animation: image-enter var(--motion-panel) var(--motion-ease) both; }
@keyframes message-enter { from { opacity: 0; transform: translateY(5px); } }
@keyframes image-enter { from { opacity: 0; } }
.reply-progress > div { display: flex; align-items: center; gap: 8px; }
.reply-image-icon { display: none; }
.reply-dots { display: inline-flex; align-items: center; gap: 4px; }
.reply-dots > span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: reply-dot 1.25s ease-in-out infinite; }
.reply-dots > span:nth-child(2) { animation-delay: 130ms; }
.reply-dots > span:nth-child(3) { animation-delay: 260ms; }
.reply-progress[data-kind="image"] {
  position: relative;
  isolation: isolate;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  width: min(256px, 85%, 42dvh);
  min-height: 150px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--accent);
}
.reply-progress[data-kind="image"]::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(115deg, transparent 8%, var(--soft) 50%, transparent 92%);
  animation: reply-image 2.35s ease-in-out infinite;
}
.reply-progress[data-kind="image"] .reply-image-icon { display: block; }
@keyframes reply-dot { 0%, 65%, 100% { opacity: .45; } 30% { opacity: 1; } }
@keyframes reply-image { from { transform: translateX(-105%); } to { transform: translateX(105%); } }
.composer { flex: none; padding: 4px 7px; background: var(--field); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 2px 12px var(--shadow); }
.composer-toolbar {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}
.composer-toolbar[data-voice-active="true"] > :not(.voice-session) { visibility: hidden; }
.voice-button {
  display: grid;
  flex: 0 0 40px;
  place-items: center;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--quiet);
}
.voice-button:enabled:hover { color: var(--ink); background: var(--hover); }
.voice-session {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.voice-session .send { margin-bottom: 0; }
.voice-status {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.25;
}
.voice-status #voice-time { font-variant-numeric: tabular-nums; }
.voice-indicator { display: none; }
.voice-session[data-phase="recording"] .voice-indicator,
.voice-session[data-phase="processing"] .voice-indicator {
  display: block;
  flex: 0 0 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: voice-pulse 1.35s ease-in-out infinite alternate;
}
.voice-session[data-phase="recording"] .voice-indicator { background: var(--danger); }
.voice-retry {
  flex: none;
  min-height: 40px;
  max-width: 45%;
  padding: 4px 9px;
  border: 0;
  border-radius: 14px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
}
@keyframes voice-pulse { from { opacity: .45; } to { opacity: 1; } }
.composer-tools { position: relative; flex: none; }
.composer-tools summary {
  display: grid;
  place-items: center;
  width: 40px;
  height: 44px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--quiet);
  cursor: pointer;
  list-style: none;
}
.composer-tools summary::-webkit-details-marker { display: none; }
.composer-tools summary:hover { color: var(--ink); background: var(--hover); }
.composer-tools[open] summary { color: var(--accent); }
.tool-menu {
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: calc(100vw - 54px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 10px 24px var(--shadow);
}
.composer-tools[open] .tool-menu { animation: menu-enter var(--motion-short) var(--motion-ease) both; }
@keyframes menu-enter { from { opacity: 0; transform: translateY(5px); } }
@supports selector(details::details-content) {
  .composer-tools::details-content {
    transition: content-visibility var(--motion-short);
    transition-behavior: allow-discrete;
  }
  .composer-tools .tool-menu {
    opacity: 0;
    transform: translateY(5px);
    pointer-events: none;
    transition: opacity var(--motion-short) ease, transform var(--motion-short) var(--motion-ease);
  }
  .composer-tools[open] .tool-menu { opacity: 1; transform: none; pointer-events: auto; animation: none; }
  @starting-style {
    .composer-tools[open] .tool-menu { opacity: 0; transform: translateY(5px); }
  }
}
.tool-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: 14px;
}
.tool-menu button:focus-visible { outline-offset: -2px; }
.tool-menu button:hover { background: var(--soft); }
.depth-tools summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 40px;
  gap: 6px;
  padding: 0 7px;
  font-size: 13px;
  font-weight: 650;
}
.depth-symbol { display: none; }
.depth-tools[data-deep="true"] summary { color: var(--accent); }
.depth-menu {
  width: min(222px, calc(100vw - 79px));
  max-width: none;
  right: 0;
  left: auto;
  padding: 7px 10px 8px;
}
.depth-heading { display: flex; justify-content: center; align-items: center; gap: 5px; margin-bottom: 3px; font-size: 13px; }
.depth-heading small { color: var(--quiet); font-size: 11px; }
.depth-tools[data-level="4"] .depth-heading strong { color: var(--pro); }
.scale {
  --progress: 0%;
  --scale-track: linear-gradient(to right, var(--accent) var(--progress), var(--line) var(--progress));
  display: block;
  width: 100%;
  height: 30px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.scale[data-level="1"] { --progress: 50%; }
.scale[data-level="2"] { --progress: 100%; }
.depth-rail { position: relative; }
.depth-track {
  --progress: 0%;
  position: absolute;
  inset: 5px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ink) var(--progress), var(--line) var(--progress));
  pointer-events: none;
}
.depth-track span { width: 3px; height: 3px; border-radius: 50%; background: var(--quiet); opacity: .75; }
.depth-tools[data-stops="2"] .depth-track span:not(:first-child):not(:last-child) { display: none; }
.depth-tools[data-level="1"] .depth-track { --progress: 25%; }
.depth-tools[data-level="2"] .depth-track { --progress: 50%; }
.depth-tools[data-level="3"] .depth-track { --progress: 75%; }
.depth-tools[data-level="1"][data-stops="2"] .depth-track { --progress: 100%; }
.depth-tools[data-level="4"] .depth-track {
  background: linear-gradient(100deg, #79a6ff, #9c63f5, #cfabff, #79a6ff) 0 50% / 220% 100%;
  animation: pro-flow 2.8s ease-in-out infinite alternate;
}
@keyframes pro-flow { to { background-position: 100% 50%; } }
#depth { position: relative; height: 22px; }
#depth::-webkit-slider-runnable-track { height: 12px; background: transparent; }
#depth::-moz-range-track { height: 12px; background: transparent; }
#depth::-webkit-slider-thumb { width: 17px; height: 17px; margin-top: -2.5px; border: 0; background: var(--ink); }
#depth::-moz-range-thumb { width: 17px; height: 17px; border: 0; background: var(--ink); }
.scale::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; background: var(--scale-track); }
.scale::-moz-range-track { height: 5px; border-radius: 99px; background: var(--scale-track); }
.scale::-webkit-slider-thumb {
  appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -6px;
  border: 2px solid var(--surface);
  border-radius: 99px;
  background: var(--accent);
}
.scale::-moz-range-thumb {
  box-sizing: border-box;
  width: 17px;
  height: 17px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}
.scale:focus-visible { border-radius: 8px; outline: 2px solid var(--accent); outline-offset: 2px; }
.scale:disabled { cursor: default; opacity: .55; }
textarea{resize:none;flex:1;min-height:44px;max-height:140px;min-width:0;color:var(--ink);background:transparent;border:0;border-radius:10px;padding:11px 4px;font-size:16px;line-height:22px}
textarea:focus { outline: none; }
textarea::placeholder { color: var(--quiet); opacity: 1; }
.send {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  height: 38px;
  margin-bottom: 3px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
}
.send:disabled { background: var(--hover); color: var(--quiet); opacity: .75; }
.send:enabled:hover { background: var(--accent); }
.send,.history-new,.history-icon,.profile-trigger,.profile-close,.voice-button,.composer-tools summary {
  transition: background-color var(--motion-short) ease, color var(--motion-short) ease, scale var(--motion-short) var(--motion-ease);
}
.send:enabled:active,.history-new:enabled:active,.voice-button:enabled:active { scale: .96; }
.notice{margin:9px 4px 2px;color:var(--accent);font-size:13px}
.attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: min(calc(100% - 4px), 224px);
  margin: 4px 0 2px 4px;
  padding: 4px 5px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--bg);
  vertical-align: top;
}
.attachment img{width:34px;height:34px;object-fit:cover;border-radius:8px}
.file-glyph{display:grid;place-items:center;flex:0 0 34px;height:34px;border-radius:8px;background:var(--soft);color:var(--accent)}
.file-glyph svg{width:18px;height:18px}
.attachment div{min-width:0;flex:1 1 auto}
.attachment strong,.attachment small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.attachment strong{font-size:13px}
.attachment small{color:var(--quiet);font-size:11px}
.attachment button{flex:none;width:32px;height:34px;border:0;border-radius:9px;background:transparent;color:var(--quiet);font-size:17px}
.attachment button:hover{background:var(--soft);color:var(--ink)}
.file-chip{display:block;margin-top:6px;color:var(--accent);font-size:13px;font-weight:650;overflow-wrap:anywhere}
.source-context {
  display: inline-flex;
  align-items: center;
  width: min(calc(100% - 8px), 260px);
  gap: 8px;
  margin: 4px 4px 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  vertical-align: top;
  animation: source-in 150ms ease-out;
}
.source-context-icon { display: grid; place-items: center; flex: 0 0 33px; height: 33px; border-radius: 8px; color: var(--accent); background: var(--soft); }
.source-context-label { flex: 1; min-width: 0; }
.source-context-label small { display: block; color: var(--quiet); font-size: 10px; }
.source-context-label strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.source-context button { flex: 0 0 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--quiet); font-size: 17px; }
.source-context button:hover { color: var(--ink); background: var(--soft); }
.history-file { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 7px; }
.history-file button { max-width: 100%; min-width: 0; min-height: 36px; padding: 4px 8px; border: 0; border-radius: 9px; background: var(--bg); color: var(--accent); font-size: 12px; font-weight: 650; }
.history-file button:hover { background: var(--surface); }
.history-file-download { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-file-download::before { content: "↓"; margin-inline-end: 5px; }
.history-file .history-file-context { background: transparent; color: var(--quiet); }
@keyframes source-in { from { opacity: 0; transform: translateY(3px); } }
.bubble a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  margin-top: 8px;
  padding: 0 10px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}
.account-dialog {
  --dialog-offset: translateY(10px) scale(.98);
  width: min(610px, calc(100% - 32px));
  max-width: none;
  max-height: calc(var(--viewport-height, 100dvh) - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 60px var(--shadow);
  overscroll-behavior: contain;
}
.account-dialog::backdrop { background: #050a1580; }
.account-panel { padding: 16px clamp(16px, 4vw, 24px); }
.account-heading,.profile-summary,.renewal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.account-heading h2:focus { outline: none; }
.profile-close { display: grid; flex: none; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; color: var(--quiet); background: transparent; }
.profile-close:hover { color: var(--ink); background: var(--soft); }
.profile-summary { padding: 12px 0 16px; }
.profile-summary-avatar { width: 44px; height: 44px; }
.profile-details { flex: 1; min-width: 0; }
.profile-details strong,.profile-details p { display: block; margin: 0; overflow-wrap: anywhere; }
.profile-details p,.plan-note { color: var(--quiet); font-size: 13px; }
.profile-badge { padding: 4px 9px; border-radius: 99px; background: var(--soft); color: var(--accent); font-size: 12px; font-weight: 650; }
.profile-section { padding: 15px 0; border-top: 1px solid var(--line); }
.profile-section h3 { margin: 0; font-size: 14px; }
.plan-note { margin: 2px 0 0; }
.plan-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.plan-card {
  display: grid;
  grid-template: "name factor" auto "price price" auto "footer footer" auto / minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
}
.plan-card[data-current] { border-color: var(--accent); background: var(--soft); }
.plan-card-name { grid-area: name; margin: 0; font-size: 15px; }
.plan-card-factor { grid-area: factor; justify-self: end; padding: 2px 7px; border-radius: 99px; background: var(--surface); color: var(--accent); font-size: 12px; font-weight: 700; }
.plan-card-price { grid-area: price; margin: 0; font-variant-numeric: tabular-nums; }
.plan-card-price strong { font-size: 17px; white-space: nowrap; }
.plan-card-price small { color: var(--quiet); font-size: 11px; white-space: nowrap; }
.plan-card-footer { grid-area: footer; display: grid; align-items: center; min-height: 40px; }
.plan-card-status { color: var(--quiet); text-align: center; font-size: 12px; }
.plan-card[data-current] .plan-card-status { color: var(--accent); font-weight: 650; }
.plan-action,.renewal-action { min-height: 40px; padding: 0 12px; border: 0; border-radius: 99px; font-size: 13px; font-weight: 650; }
.plan-action { background: var(--soft); color: var(--accent); }
.plan-action:hover { background: var(--accent); color: var(--bg); }
.plan-action[aria-disabled="true"] { opacity: .6; cursor: default; }
.renewal-row { padding-bottom: 4px; }
.renewal-action { border: 1px solid var(--line); background: transparent; }
.renewal-action:hover { background: var(--soft); color: var(--accent); }
.account-notice { margin: 0; color: var(--accent); font-size: 13px; }
.account-notice:not(:empty) { margin-top: 8px; }
@media (max-width: 520px) {
  .account-dialog { --dialog-offset: translateY(26px); inset: auto 0 0; width: 100%; max-height: calc(var(--viewport-height, 100dvh) - max(12px, env(safe-area-inset-top))); margin: 0; border-radius: 22px 22px 0 0; }
  .account-panel { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .plan-cards { grid-template-columns: minmax(0, 1fr); }
  .plan-card { grid-template: "name factor" auto "price footer" auto / minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 12px; }
  .plan-card-footer { min-height: 36px; }
  .plan-action { min-height: 36px; }
}
@media (max-width: 360px) { .profile-trigger-plan { display: none; } .profile-trigger { padding: 4px; } }
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}

.history-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--quiet);
}
.history-icon:hover { color: var(--ink); background: var(--hover); }
.history-drawer {
  --dialog-offset: translateX(-100%);
  inset: 0 auto 0 0;
  width: min(340px, 84vw);
  height: var(--viewport-height, 100dvh);
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-inline-end: 1px solid var(--line);
  border-radius: 0 28px 28px 0;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--ink);
  box-shadow: 8px 0 32px var(--shadow);
}
.history-drawer::backdrop { background: #03081580; }
:is(.history-drawer:not([data-docked]), .account-dialog)[open] {
  opacity: 1;
  transform: none;
  transition: opacity var(--motion-panel) var(--motion-ease), transform var(--motion-panel) var(--motion-ease);
}
:is(.history-drawer:not([data-docked]), .account-dialog)[open]::backdrop {
  opacity: 1;
  transition: opacity var(--motion-panel) var(--motion-ease);
}
@starting-style {
  :is(.history-drawer:not([data-docked]), .account-dialog)[open] { opacity: 0; transform: var(--dialog-offset); }
  :is(.history-drawer:not([data-docked]), .account-dialog)[open]::backdrop { opacity: 0; }
}
:is(.history-drawer:not([data-docked]), .account-dialog)[open][data-closing] {
  opacity: 0;
  transform: var(--dialog-offset);
  pointer-events: none;
}
:is(.history-drawer:not([data-docked]), .account-dialog)[open][data-closing]::backdrop { opacity: 0; }
.history-drawer[data-docked] {
  grid-area: 1 / 1;
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 0;
  box-shadow: none;
  transition: display var(--motion-panel);
  transition-behavior: allow-discrete;
}
.history-drawer[data-docked]:not([open]) { pointer-events: none; }
.history-drawer[data-docked] .history-panel { width: var(--history-width); }
body:has(.history-drawer:modal) { overflow: hidden; }
.history-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: max(12px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}
.history-heading { display: flex; flex: none; align-items: center; justify-content: space-between; }
.history-heading h2 { margin: 0 0 0 6px; font-size: 17px; letter-spacing: -.025em; }
.history-heading h2:focus { outline: none; }
.history-heading .history-icon { flex-basis: 44px; height: 44px; border-radius: 50%; }
.history-search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 21px;
  color: var(--quiet);
}
.history-search:focus-within { border-color: var(--accent); }
.history-search svg { flex: none; }
.history-search input { width: 100%; min-width: 0; padding: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 14px; }
.history-search input::placeholder { color: var(--quiet); }
.history-footer { display: flex; flex: none; padding: 10px 3px 0; border-top: 1px solid var(--line); }
.history-new {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 650;
}
.history-new:enabled:hover { background: color-mix(in srgb, var(--ink) 82%, var(--accent)); }
.history-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 3px; }
.history-empty { margin: 8px; color: var(--quiet); font-size: 13px; }
.history-group + .history-group { margin-top: 12px; }
.history-group h3 { margin: 6px 8px; color: var(--quiet); font-size: 12px; font-weight: 650; }
.history-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; margin-bottom: 2px; border-radius: 13px; }
.history-row:hover,.history-row:focus-within,.history-row:has([aria-expanded="true"]) { background: var(--hover); }
.history-row:has([aria-current="true"]) { background: var(--soft); }
.history-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 0;
  padding: 0 9px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  text-align: left;
}
.history-chat span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.history-chat[aria-current="true"] span { font-weight: 650; }
.history-chat small { flex: none; color: var(--quiet); font-size: 11px; }
.history-actions { display: grid; place-items: center; width: 40px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--quiet); font-size: 20px; }
.history-actions:hover,.history-actions[aria-expanded="true"] { color: var(--ink); }
.history-chat:focus-visible,.history-actions:focus-visible,.history-action-menu button:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .history-row:not(:hover):not(:focus-within):not(:has([aria-current="true"], [aria-expanded="true"])) .history-actions { opacity: 0; }
}
.history-action-menu {
  position: absolute;
  inset-inline-end: max(17px, env(safe-area-inset-right));
  z-index: 1;
  width: min(190px, calc(100% - 28px));
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: 0 8px 24px var(--shadow);
  transition: opacity var(--motion-short) ease, transform var(--motion-short) var(--motion-ease), display var(--motion-short);
  transition-behavior: allow-discrete;
}
.history-action-menu[hidden] { opacity: 0; transform: translateY(5px); pointer-events: none; }
@starting-style {
  .history-action-menu:not([hidden]) { opacity: 0; transform: translateY(5px); }
}
.history-action-menu button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-size: 13px; }
.history-action-menu button:hover,.history-action-menu button:focus-visible { background: var(--soft); }
.history-action-menu svg { flex: 0 0 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.history-action-menu .history-danger { color: var(--danger, #b34545); }
.history-edit { flex: none; padding: 10px; border: 1px solid var(--line); border-radius: 13px; }
.history-edit label,.history-edit p { display: block; margin: 0 0 6px; overflow-wrap: anywhere; font-size: 13px; font-weight: 650; }
.history-edit input { width: 100%; min-height: 38px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; }
.history-buttons { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
.history-buttons button { min-height: 36px; padding: 0 8px; border: 0; border-radius: 9px; background: var(--bg); font-size: 13px; }
.history-buttons .history-confirm { background: var(--soft); color: var(--accent); font-weight: 650; }
.history-status { margin: 0; color: var(--accent); font-size: 12px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --danger: #ffa7a7; }
}
:root[data-theme="dark"] { --danger: #ffa7a7; }

@media (max-width: 480px) {
  .depth-symbol { display: block; }
  #depth-label { display: none; }
  .history-search input { font-size: 16px; }
}

@media (max-width: 360px) {
  .composer { width: calc(100% - 24px); padding-inline: 4px; }
  .composer-toolbar { gap: 2px; }
  .depth-tools summary > svg:not(.depth-symbol) { display: none; }
  textarea::placeholder { font-size: 14px; }
}

@media (max-width: 640px) {
  #chat:not(.has-thread) { justify-content: flex-start; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .hero { margin: auto 0; padding: 10px 0 16px; }
}

@media (max-height: 390px) {
  .header { min-height: calc(48px + env(safe-area-inset-top)); }
  #chat:not(.has-thread) { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .hero { margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --motion-short: 0ms; --motion-panel: 0ms; }
  .bubble[data-new],.bubble[data-new] img,.reply-progress,
  .composer-tools[open] .tool-menu,
  .depth-tools[data-level="4"] .depth-track,
  .reply-dots > span,.reply-progress[data-kind="image"]::before,
  .voice-indicator,.source-context { animation: none; }
  .send:enabled:active,.history-new:enabled:active,.voice-button:enabled:active { scale: none; }
}
