/* Wivrix AI: builds on /assets/app.css tokens (colors, radius, shadows, fonts). */
.ai-body { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
.ai-body.ai-doc { height: auto; min-height: 100vh; overflow: auto; }
.ai-ic { flex: none; }

.ai-topbar-inner { display: flex; align-items: center; gap: 0.7rem; height: 60px; padding: 0 1rem; }
.ai-topbar .brand { font-size: 1.05rem; }
.ai-beta {
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 0.2rem 0.6rem;
}
.ai-topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.ai-account { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-3); font-size: 0.85rem; max-width: 40vw; }
.ai-account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-icon-btn {
  display: none; place-items: center; width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer;
}

.ai-shell { display: flex; height: calc(100% - 61px); min-height: 0; }

/* Sidebar */
.ai-side {
  width: 272px; flex: none; display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem 0.85rem;
  background: color-mix(in srgb, var(--surface) 70%, var(--bg)); border-right: 1px solid var(--border); min-height: 0;
}
.ai-new { width: 100%; justify-content: flex-start; border-radius: 14px; }
.ai-side-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); padding: 0.6rem 0.4rem 0; }
.ai-convs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -0.3rem; padding: 0 0.3rem; }
.ai-conv {
  display: flex; align-items: center; gap: 0.4rem; width: 100%; text-align: left; border: 0; background: none; color: var(--text-2);
  font: inherit; font-size: 0.9rem; padding: 0.55rem 0.65rem; border-radius: 10px; cursor: pointer;
}
.ai-conv:hover { background: var(--surface-2); color: var(--text); }
.ai-conv.is-on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.ai-conv-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conv-del { opacity: 0; font-size: 1.1rem; line-height: 1; color: var(--text-3); padding: 0 0.2rem; border-radius: 6px; }
.ai-conv:hover .ai-conv-del, .ai-conv.is-on .ai-conv-del { opacity: 1; }
.ai-conv-del:hover { color: var(--danger); }
.ai-empty { color: var(--text-3); font-size: 0.85rem; padding: 0.4rem; }
.ai-side-foot { display: grid; gap: 0.55rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.ai-side-note { font-size: 0.76rem; color: var(--text-3); line-height: 1.45; }
.ai-clear { justify-content: flex-start; }
.ai-terms-link { font-size: 0.8rem; }
.ai-scrim { display: none; }

/* Main */
.ai-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.ai-thread { flex: 1; overflow-y: auto; padding: 1.5rem 1.25rem 1rem; scroll-behavior: smooth; }
.ai-thread > * { max-width: 780px; margin-inline: auto; }

.ai-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.ai-state { display: grid; justify-items: center; text-align: center; gap: 0.7rem; padding: 2.5rem 1.5rem; margin-top: 12vh; max-width: 460px !important; }
.ai-state .ai-ic { width: 34px; height: 34px; color: var(--accent); background: var(--accent-soft); padding: 8px; border-radius: 14px; box-sizing: content-box; }
.ai-state h2 { font-family: var(--font-display); font-size: 1.25rem; }
.ai-state p { color: var(--text-3); }

.ai-welcome { text-align: center; padding: 10vh 0 1rem; display: grid; justify-items: center; gap: 0.6rem; }
.ai-welcome-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; color: #fff; background: linear-gradient(135deg, var(--grad-a), var(--accent-2)); box-shadow: 0 12px 30px -14px var(--accent); }
.ai-welcome-mark .ai-ic { width: 26px; height: 26px; }
.ai-welcome h1 { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2rem); }
.ai-welcome p { color: var(--text-3); }
.ai-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin-top: 1rem; max-width: 620px; }
.ai-chip {
  font: inherit; font-size: 0.86rem; color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.5rem 0.9rem; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s, color .15s;
}
.ai-chip:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.ai-chip-sm { font-size: 0.78rem; padding: 0.25rem 0.6rem; }

/* Messages */
.ai-msg { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; animation: ai-in .22s ease-out; }
@keyframes ai-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ai-msg.ai-user { justify-content: flex-end; }
.ai-bubble {
  max-width: min(85%, 620px); background: var(--accent); color: var(--on-accent); padding: 0.7rem 1rem; border-radius: 18px 18px 6px 18px;
  box-shadow: 0 8px 22px -16px var(--accent); white-space: normal; overflow-wrap: anywhere; line-height: 1.5;
}
.ai-tag { font-size: 0.7rem; font-weight: 700; background: color-mix(in srgb, var(--on-accent) 22%, transparent); padding: 0.1rem 0.45rem; border-radius: 6px; }
.ai-avatar { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--grad-a), var(--accent-2)); margin-top: 2px; }
.ai-content { flex: 1; min-width: 0; }
.ai-md { line-height: 1.65; overflow-wrap: anywhere; color: var(--text); }
.ai-md > * + * { margin-top: 0.75rem; }
.ai-md h3, .ai-md h4, .ai-md h5, .ai-md h6, .ai-md h7, .ai-md h8 { font-family: var(--font-display); font-size: 1.05rem; margin-top: 1.1rem; }
.ai-md ul, .ai-md ol { padding-left: 1.35rem; margin-bottom: 0; }
.ai-md li + li { margin-top: 0.25rem; }
.ai-md blockquote { margin-left: 0; padding: 0.2rem 0 0.2rem 0.9rem; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.ai-md hr { border: 0; border-top: 1px solid var(--border); }
.ai-md :not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 0.08rem 0.35rem; font-size: 0.88em; }
.ai-code { border-radius: 14px; overflow: hidden; background: var(--code-bg); border: 1px solid color-mix(in srgb, var(--code-bg) 70%, var(--border)); box-shadow: var(--shadow-sm); }
.ai-code-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.35rem 0.5rem 0.35rem 0.9rem; background: color-mix(in srgb, var(--code-bg) 85%, #fff); color: #aab3c9; font: 600 0.75rem/1 var(--mono); }
.ai-copy { font: 600 0.75rem/1 var(--font); color: #d6dcec; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 0.35rem 0.6rem; cursor: pointer; }
.ai-copy:hover { background: rgba(255,255,255,.16); }
.ai-copy.is-done { color: #86efac; }
.ai-code pre { margin: 0; padding: 0.9rem 1rem; overflow-x: auto; color: var(--code-text); font-size: 0.85rem; line-height: 1.55; }
.ai-table { overflow-x: auto; }
.ai-table table { border-collapse: collapse; font-size: 0.9rem; min-width: 60%; }
.ai-table th, .ai-table td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.ai-table th { background: var(--surface-2); }
.ai-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.55rem; }
.ai-badge { font-size: 0.7rem; font-weight: 600; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0.12rem 0.55rem; }
.ai-act { font: inherit; font-size: 0.75rem; color: var(--text-3); background: none; border: 0; padding: 0.2rem 0.45rem; border-radius: 8px; cursor: pointer; }
.ai-act:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.ai-act:disabled { opacity: .6; cursor: default; }
.ai-report { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; width: 100%; font-size: 0.78rem; color: var(--text-3); margin-top: 0.2rem; }
.ai-note { padding: 0.75rem 0.95rem; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 0.92rem; }
.is-blocked .ai-note { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, var(--border)); }
.is-error .ai-note { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, var(--border)); }
.ai-figure { margin: 0; position: relative; max-width: 512px; }
.ai-figure img { display: block; width: 100%; height: auto; border-radius: 18px; box-shadow: var(--shadow); background: var(--surface-2); }
.ai-figure figcaption { position: absolute; left: 0.6rem; bottom: 0.6rem; }
.ai-figure .ai-badge { background: rgba(9, 13, 22, .62); color: #fff; border-color: transparent; backdrop-filter: blur(6px); }
.ai-skel { width: min(100%, 360px); aspect-ratio: 1; border-radius: 18px; background: linear-gradient(110deg, var(--surface-2) 30%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: ai-shine 1.4s linear infinite; }
@keyframes ai-shine { to { background-position: -200% 0; } }
.ai-typing { display: inline-flex; gap: 4px; align-items: center; color: var(--text-3); font-size: 0.85rem; padding: 0.4rem 0; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: ai-dot 1s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; } .ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-caret { display: inline-block; width: 7px; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; background: var(--accent); border-radius: 2px; animation: ai-blink 1s steps(2) infinite; }
@keyframes ai-blink { 50% { opacity: 0; } }

/* Composer */
.ai-composer { padding: 0.5rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom)); }
.ai-composer-card {
  max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 16px 40px -22px rgba(15,23,42,.28); padding: 0.6rem 0.6rem 0.5rem 0.9rem; transition: border-color .15s, box-shadow .15s;
}
.ai-composer-card:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), 0 16px 40px -22px rgba(15,23,42,.3); }
.ai-composer .ai-composer-card textarea {
  width: 100%; border: 0; outline: 0; box-shadow: none; border-radius: 0; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 1rem;
  line-height: 1.5; padding: 0.35rem 0.1rem; max-height: 220px; min-height: 28px;
}
.ai-composer .ai-composer-card textarea:focus, .ai-composer .ai-composer-card textarea:focus-visible { outline: 0; box-shadow: none; border: 0; }
.ai-composer-bar { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.25rem; }
.ai-seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 2px; }
.ai-seg-btn { display: inline-flex; align-items: center; gap: 0.35rem; font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-3); background: none; border: 0; border-radius: 9px; padding: 0.35rem 0.65rem; cursor: pointer; }
.ai-seg-btn .ai-ic { width: 15px; height: 15px; }
.ai-seg-btn.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ai-seg-btn:disabled { opacity: .45; cursor: not-allowed; }
.ai-composer .ai-select select {
  font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.38rem 1.7rem 0.38rem 0.6rem; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%; background-size: 4px 4px; background-repeat: no-repeat;
}
.ai-send {
  margin-left: auto; display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 14px; cursor: pointer;
  color: var(--on-accent); background: var(--accent); box-shadow: 0 8px 18px -10px var(--accent); transition: transform .1s, background .15s;
}
.ai-send:hover:not(:disabled) { background: var(--accent-hover); }
.ai-send:active { transform: scale(.96); }
.ai-send:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.ai-stop { background: var(--text); color: var(--surface); }
.ai-fine { text-align: center; font-size: 0.72rem; color: var(--text-3); margin-top: 0.45rem; }
.ai-composer.is-disabled .ai-composer-card { opacity: .7; }

/* Modal + toast */
.ai-modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 1rem; background: rgba(9, 13, 22, .45); backdrop-filter: blur(4px); }
.ai-modal-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 30px 80px -30px rgba(0,0,0,.5); padding: 1.5rem; display: grid; gap: 0.9rem; animation: ai-in .2s ease-out; }
.ai-modal-card h2 { font-family: var(--font-display); font-size: 1.2rem; }
.ai-modal-card p { color: var(--text-2); font-size: 0.93rem; }
.ai-check { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; cursor: pointer; }
.ai-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.ai-modal-actions { display: flex; justify-content: flex-end; }
.ai-toast { position: fixed; left: 50%; bottom: 6.5rem; transform: translate(-50%, 8px); z-index: 95; background: var(--text); color: var(--surface); font-size: 0.88rem; font-weight: 600; padding: 0.6rem 1rem; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; max-width: calc(100% - 2rem); text-align: center; }
.ai-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Terms page */
.ai-doc-main { padding: 2rem 1rem 4rem; }
.ai-doc-card { max-width: 760px; margin: 0 auto; padding: 2rem; display: grid; gap: 0.8rem; }
.ai-doc-card h1 { font-family: var(--font-display); font-size: 1.6rem; }
.ai-doc-card h2 { font-size: 1.05rem; margin-top: 0.8rem; }
.ai-doc-card ul { margin: 0; padding-left: 1.3rem; }
.ai-muted { color: var(--text-3); }

/* Mobile */
@media (max-width: 860px) {
  .ai-icon-btn { display: grid; }
  .ai-side { position: fixed; z-index: 80; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); transform: translateX(-102%); transition: transform .22s ease; background: var(--surface); box-shadow: 0 20px 60px -20px rgba(0,0,0,.45); padding-top: calc(1rem + env(safe-area-inset-top)); }
  .ai-side.is-open { transform: none; }
  .ai-scrim { display: block; position: fixed; inset: 0; z-index: 75; background: rgba(9, 13, 22, .4); }
  .ai-account span, .ai-beta { display: none; }
  .ai-topbar-inner { padding: 0 0.75rem; gap: 0.5rem; }
  .ai-thread { padding: 1rem 0.85rem 0.5rem; }
  .ai-composer { padding: 0.4rem 0.6rem calc(0.6rem + env(safe-area-inset-bottom)); }
  .ai-seg-btn span { display: none; }
  .ai-bubble { max-width: 88%; }
  .ai-avatar { display: none; }
  .ai-welcome { padding-top: 6vh; }
  .ai-composer textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { .ai-msg, .ai-modal-card { animation: none; } .ai-thread { scroll-behavior: auto; } }

/* app.css styles every textarea with !important borders; the composer field stays borderless. */
.ai-composer .ai-composer-card textarea,
.ai-composer .ai-composer-card textarea:focus {
  border: 0 !important; box-shadow: none !important; background: transparent !important; border-radius: 0 !important; min-height: 28px;
}
:root[data-theme="dark"] .ai-composer .ai-composer-card textarea { background: transparent !important; }
.ai-composer .ai-select select { border-radius: 10px !important; min-height: 32px; font-size: 0.82rem; }
:root[data-theme="dark"] .ai-composer .ai-select select { background-color: var(--surface) !important; }

/* ---------- credits pill (navbar) ---------- */
.ai-credits { display: inline-flex; align-items: center; gap: 0.35rem; height: 34px; padding: 0 0.75rem 0 0.6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 0.84rem; font-weight: 600; text-decoration: none; white-space: nowrap; transition: border-color .15s, background .15s; }
.ai-credits:hover { border-color: var(--accent); text-decoration: none; }
.ai-credits .ai-ic { width: 16px; height: 16px; color: var(--accent); flex: none; }
.ai-credits b { font-weight: 700; font-variant-numeric: tabular-nums; }
.ai-credits-word { color: var(--text-3); font-weight: 500; }
.ai-credits.is-low { border-color: #e0a400; }
.ai-credits.is-low .ai-ic { color: #e0a400; }
.ai-credits.is-bump b { animation: ai-bump .45s ease-out; }
@keyframes ai-bump { 40% { opacity: .35; } }

/* ---------- model picker ---------- */
.ai-model-btn { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; max-width: 100%; height: 34px; padding: 0 0.55rem 0 0.7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; flex: 0 1 auto; }
.ai-model-btn:hover:not(:disabled) { border-color: var(--accent); }
.ai-model-btn:disabled { opacity: .5; cursor: not-allowed; }
.ai-model-btn .ai-ic { width: 15px; height: 15px; color: var(--text-3); flex: none; }
.ai-model-btn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ai-price { display: inline-flex; align-items: baseline; gap: 1px; flex: none; padding: 0.18rem 0.5rem; border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ai-price small { font-size: 0.7rem; font-weight: 600; opacity: .8; margin-left: 3px; }
.ai-price-sm { font-size: 0.72rem; padding: 0.1rem 0.4rem; }
.ai-composer-bar .ai-send { margin-left: auto; }

.ai-sheet { position: fixed; inset: 0; z-index: 92; display: flex; align-items: flex-end; justify-content: center; background: rgba(9, 13, 22, 0); transition: background .18s; }
.ai-sheet.is-open { background: rgba(9, 13, 22, .45); }
.ai-sheet-card { width: min(520px, 100%); max-height: min(78vh, 640px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0; box-shadow: 0 -20px 60px -30px rgba(0,0,0,.5); transform: translateY(100%); transition: transform .18s ease-out; padding-bottom: env(safe-area-inset-bottom); }
.ai-sheet.is-open .ai-sheet-card { transform: none; }
.ai-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 0.9rem 0 1.1rem; }
.ai-sheet-head h2 { font-family: var(--font-display); font-size: 1.08rem; }
.ai-sheet-sub { padding: 0.2rem 1.1rem 0.6rem; color: var(--text-3); font-size: 0.8rem; }
.ai-sheet-body { overflow-y: auto; padding: 0 0.5rem 0.75rem; overscroll-behavior: contain; }
.ai-model-list { display: grid; gap: 2px; }
.ai-model { display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; font: inherit; color: var(--text); background: none; border: 1px solid transparent; border-radius: 12px; padding: 0.6rem 0.65rem; cursor: pointer; }
.ai-model:hover { background: var(--surface-2); }
.ai-model[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 8%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.ai-model-main { display: grid; gap: 1px; min-width: 0; flex: 1; }
.ai-model-name { font-size: 0.9rem; font-weight: 600; line-height: 1.3; }
.ai-model-desc { font-size: 0.78rem; color: var(--text-3); line-height: 1.3; }
.ai-rec { display: inline-block; margin-left: 0.25rem; padding: 0.05rem 0.4rem; border-radius: 6px; background: #16a34a1f; color: #15803d; font-size: 0.66rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; vertical-align: 1px; }
:root[data-theme="dark"] .ai-rec { color: #4ade80; }
.ai-model-tick { width: 18px; flex: none; color: var(--accent); visibility: hidden; }
.ai-model-tick .ai-ic { width: 18px; height: 18px; }
.ai-model[aria-selected="true"] .ai-model-tick { visibility: visible; }
.ai-topup { margin-left: 0.4rem; vertical-align: middle; }
@media (min-width: 861px) {
  .ai-sheet { align-items: center; }
  .ai-sheet-card { border-radius: 18px; border-bottom: 1px solid var(--border); transform: translateY(12px); opacity: 0; transition: transform .18s, opacity .18s; }
  .ai-sheet.is-open .ai-sheet-card { opacity: 1; }
}
@media (max-width: 860px) {
  .ai-credits { height: 32px; padding: 0 0.6rem 0 0.5rem; font-size: 0.8rem; }
  .ai-model-btn { height: 32px; }
}
@media (max-width: 359px) { .ai-credits-word { display: none; } }
@media (prefers-reduced-motion: reduce) { .ai-sheet, .ai-sheet-card { transition: none; } }
.ai-sheet-head #ai-sheet-close { display: grid !important; }

/* ---------- v5: top bar, menu, composer polish ---------- */
.ai-topbar-inner { gap: 0.6rem; }
.ai-topbar .ai-brand { flex: none; min-width: max-content; white-space: nowrap; overflow: visible; }
.ai-topbar .ai-brand-name { overflow: visible !important; text-overflow: clip !important; white-space: nowrap !important; max-width: none !important; }
.ai-topbar .ai-icon-btn { width: 40px; height: 40px; border-radius: 12px; }
.ai-credits { height: 36px; }

/* Sidebar / drawer */
.ai-side { overflow-y: auto; overscroll-behavior: contain; }
.ai-convs { min-height: 96px; }
.ai-side-foot { border-top: 1px solid var(--border); padding-top: 0.75rem; gap: 0; }
.ai-menu { display: grid; gap: 0.6rem; }
.ai-acct { display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.7rem; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; box-shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 20px -16px rgba(15,23,42,.35); transition: border-color .15s, background .15s; }
.ai-acct:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); text-decoration: none; }
.ai-acct > .ai-ic { width: 16px; height: 16px; color: var(--text-3); }
.ai-acct-av { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #a855f7)); color: #fff; font-weight: 700; font-size: 0.95rem; }
.ai-acct-av .ai-ic { width: 18px; height: 18px; }
.ai-acct-txt { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.ai-acct-txt b { font-size: 0.86rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-acct-txt small { font-size: 0.74rem; color: var(--text-3); }
.ai-menu-links { display: grid; gap: 1px; }
.ai-menu-item { display: flex; align-items: center; gap: 0.7rem; width: 100%; min-height: 42px; padding: 0 0.7rem; border: 0; border-radius: 11px; background: none; color: var(--text-2); font: inherit; font-size: 0.9rem; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer; transition: background .12s, color .12s; }
.ai-menu-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.ai-menu-item > .ai-ic { width: 18px; height: 18px; color: var(--text-3); }
.ai-menu-item > span:not(.ai-switch) { flex: 1; min-width: 0; }
.ai-menu-item > .ai-ic:last-child:not(:first-child) { width: 14px; height: 14px; opacity: .7; }
.ai-menu-item.ai-clear:hover, .ai-menu-item.ai-clear:hover .ai-ic { color: var(--danger); }
.ai-switch { flex: none; position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong, #cbd5e1); transition: background .18s; }
.ai-switch i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s; }
.ai-theme-row[aria-checked="true"] .ai-switch { background: var(--accent); }
.ai-theme-row[aria-checked="true"] .ai-switch i { transform: translateX(16px); }
.ai-menu-note { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0; padding: 0.6rem 0.7rem; border-radius: 12px; background: var(--surface-2); color: var(--text-3); font-size: 0.75rem; line-height: 1.45; }
.ai-menu-note .ai-ic { width: 15px; height: 15px; margin-top: 1px; }

/* Composer row: one line, 40px controls, 12px radii */
.ai-composer-card { padding: 0.55rem 0.55rem 0.55rem 0.85rem; border-radius: 22px; }
.ai-composer-bar { gap: 0.5rem; margin-top: 0.35rem; min-height: 40px; }
.ai-seg { height: 40px; padding: 0; gap: 0; border-radius: 12px; flex: none; align-items: stretch; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.ai-seg-btn { min-width: 40px; height: 38px; padding: 0 0.7rem; justify-content: center; border-radius: 11px; }
.ai-seg-btn .ai-ic { width: 18px; height: 18px; }
.ai-seg-btn.is-on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.ai-model-btn { height: 40px; border-radius: 12px; padding: 0 0.5rem 0 0.75rem; flex: 0 1 auto; min-width: 0; gap: 0.45rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.ai-model-btn-name { flex: 0 1 auto; }
.ai-model-btn .ai-price-sm { flex: none; }
.ai-send { width: 40px; height: 40px; border-radius: 12px; flex: none; margin-left: auto; }
.ai-send .ai-ic { width: 18px; height: 18px; }
.ai-fine { margin-top: 0.4rem; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-fine a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
:root[data-theme="dark"] .ai-seg-btn.is-on { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
:root[data-theme="dark"] .ai-acct { box-shadow: none; }
@media (max-width: 860px) {
  .ai-topbar-inner { gap: 0.55rem; }
  .ai-credits { height: 36px; margin-left: auto; }
  .ai-model-btn { height: 40px; }
  .ai-seg-btn { padding: 0; width: 40px; }
  .ai-side { gap: 0.55rem; }
}
@media (max-width: 380px) {
  .ai-composer-bar { gap: 0.4rem; }
  .ai-topbar .brand-mark { width: 28px; height: 28px; }
}

/* ---------- v6: photo editing ---------- */
.ai-attach { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.ai-attach:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ai-attach[hidden] { display: none; }
.ai-attach .ai-ic { width: 19px; height: 19px; }
.ai-attach-tray { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.15rem 0 0.5rem; }
.ai-attach-tray[hidden] { display: none; }
.ai-thumb { position: relative; flex: none; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.ai-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-thumb.is-base { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ai-thumb-tag { position: absolute; left: 4px; bottom: 4px; font-size: 0.62rem; font-weight: 700; line-height: 1; padding: 0.15rem 0.3rem; border-radius: 5px; background: rgba(9, 13, 22, .62); color: #fff; }
.ai-thumb-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(9, 13, 22, .62); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; padding: 0; }
.ai-thumb-x:hover { background: rgba(9, 13, 22, .85); }
.ai-thumb.is-loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent), transparent); animation: ai-shimmer 1.1s infinite; }
@keyframes ai-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.ai-composer-card.is-drop { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.ai-bubble-imgs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.4rem; }
.ai-bubble-imgs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; display: block; background: color-mix(in srgb, var(--on-accent) 20%, transparent); }
.ai-act .ai-ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
@media (max-width: 860px) {
  .ai-thumb { width: 56px; height: 56px; }
}
@media (prefers-reduced-motion: reduce) { .ai-thumb.is-loading::after { animation: none; } }
@media (max-width: 440px) { .ai-composer.is-edit .ai-model-btn-name { display: none; } }

/* Composer v3: quiet icon tabs, ghost model pill, round send - one aligned 36px row */
.ai-composer-card { padding: 0.6rem 0.6rem 0.5rem 0.9rem; }
.ai-composer-bar { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.3rem; min-height: 36px; flex-wrap: nowrap; }
.ai-seg { height: 36px; padding: 2px; gap: 2px; border: 0; border-radius: 999px; background: var(--surface-2); align-items: center; }
.ai-seg-btn { height: 32px; min-width: 32px; padding: 0 0.7rem; border-radius: 999px; color: var(--text-3); }
.ai-seg-btn:hover:not(:disabled):not(.is-on) { color: var(--text); }
.ai-seg-btn .ai-ic { width: 17px; height: 17px; }
.ai-seg-btn.is-on { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(15,23,42,.12); }
.ai-attach { width: 36px; height: 36px; border-radius: 999px; border: 0; background: transparent; }
.ai-attach:hover:not(:disabled) { background: var(--surface-2); }
.ai-model-btn { height: 36px; margin-left: auto; border: 0; border-radius: 999px; background: transparent; box-shadow: none; padding: 0 0.45rem 0 0.7rem; color: var(--text-2); }
.ai-model-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.ai-model-btn .ai-price-sm { font-size: 0.72rem; }
.ai-send, .ai-composer-bar .ai-send { width: 36px; height: 36px; border-radius: 999px; margin-left: 0; box-shadow: none; flex: none; }
.ai-send .ai-ic { width: 17px; height: 17px; }
@media (max-width: 860px) {
  .ai-seg-btn { width: 32px; padding: 0; }
  .ai-model-btn { height: 36px; max-width: 52%; }
}

/* ---------- v8: model picker looks like a dropdown ---------- */
.ai-model-btn { height: 38px; margin-left: auto; padding: 0 0.45rem 0 0.7rem; gap: 0.4rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15,23,42,.06); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; max-width: 60%; }
.ai-model-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); color: var(--text); }
.ai-model-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ai-model-btn:active:not(:disabled), .ai-model-btn[aria-expanded="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.ai-model-btn .ai-ic { width: 16px; height: 16px; color: var(--text-2); flex: none; transition: transform .15s; }
.ai-model-btn[aria-expanded="true"] .ai-ic { transform: rotate(180deg); }
.ai-model-btn-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-model-btn .ai-price-sm { flex: none; font-size: 0.72rem; }
.ai-composer.is-edit .ai-model-btn-name { display: inline; }
@media (max-width: 440px) { .ai-model-btn { max-width: 55%; font-size: 0.78rem; } }
:root[data-theme="dark"] .ai-model-btn { background: var(--surface-2); box-shadow: none; }
:root[data-theme="dark"] .ai-model-btn:hover:not(:disabled) { background: var(--surface); }
