:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: rgba(11, 14, 20, .9);
  --panel-2: rgba(15, 19, 27, .92);
  --line: rgba(255,255,255,.085);
  --line-strong: rgba(255,255,255,.14);
  --text: #f7f8fb;
  --muted: #9299a7;
  --red: #e31b2f;
  --red-soft: rgba(227,27,47,.14);
  --green: #41e884;
  --shadow: 0 24px 80px rgba(0,0,0,.42);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.012) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.45), transparent 70%);
}

.ambient { position: fixed; border-radius: 50%; filter: blur(80px); opacity: .2; pointer-events: none; }
.ambient-one { width: 520px; height: 520px; right: -180px; top: -220px; background: #a20f22; }
.ambient-two { width: 400px; height: 400px; left: 22%; bottom: -280px; background: #4c0610; }

.config-warning {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100;
  width: min(760px, calc(100% - 32px)); padding: 14px 18px; border: 1px solid rgba(255,188,5,.35);
  border-radius: 14px; color: #ffe49a; background: rgba(56,41,5,.95); box-shadow: var(--shadow); font-size: 14px;
}

.app-shell { position: relative; z-index: 2; display: grid; grid-template-columns: 272px minmax(0, 1fr) 292px; height: 100vh; }
.sidebar, .intel-panel, .main-panel { min-height: 0; }
.sidebar {
  padding: 22px 16px 14px; border-right: 1px solid var(--line); background: rgba(5,7,10,.88); backdrop-filter: blur(18px);
  display: flex; flex-direction: column; gap: 18px;
}
.brand-block { padding: 2px 4px 4px; }
.brand-row { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 0;
  border-radius: 11px;
  background: url('/kitgpt-logo.png') center / cover no-repeat;
  box-shadow: 0 0 18px rgba(227,27,47,.16);
  overflow: hidden;
}
.brand-mark::before, .brand-mark::after,
.brand-mark > span { display: none !important; }
.brand-mark.large { width: 46px; height: 46px; border-radius: 14px; }
.brand-name { font-size: 25px; font-weight: 900; letter-spacing: -1.6px; font-style: italic; }
.brand-name span { color: #fff; }
.brand-name b { color: var(--red); }
.brand-name.big { font-size: 34px; }
.brand-subtitle { color: #a7adba; font-size: 9px; letter-spacing: 2.2px; margin-top: 1px; }
.powered-pill { margin-top: 14px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; color: #bac0cc; font-size: 11px; letter-spacing: .35px; background: rgba(255,255,255,.025); }
.southland-s { color: var(--red); font-weight: 900; margin-right: 4px; }

.new-chat-btn { width: 100%; border: 1px solid rgba(227,27,47,.32); background: linear-gradient(180deg, rgba(227,27,47,.15), rgba(227,27,47,.07)); border-radius: 12px; padding: 11px 13px; text-align: left; cursor: pointer; transition: .2s ease; }
.new-chat-btn:hover { border-color: rgba(227,27,47,.65); transform: translateY(-1px); }
.new-chat-btn span { color: var(--red); margin-right: 5px; }

.primary-nav { display: grid; gap: 5px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 11px; border: 0; border-radius: 10px; background: transparent; color: #b2b8c4; text-align: left; }
.nav-item span { width: 18px; text-align: center; color: #7e8796; }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(227,27,47,.19), transparent); }
.nav-item.active span { color: var(--red); }
.nav-item small { margin-left: auto; color: #5d6572; font-size: 9px; }
.nav-item.disabled { cursor: default; }

.history-section { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.section-kicker, .intel-heading, .eyebrow { color: #6f7785; font-size: 10px; font-weight: 800; letter-spacing: 1.5px; }
.conversation-list { margin-top: 10px; min-height: 0; overflow-y: auto; display: grid; gap: 3px; padding-right: 3px; }
.conversation-item { width: 100%; display: flex; gap: 8px; align-items: center; border: 0; background: transparent; color: #aeb5c1; border-radius: 9px; padding: 9px 9px; cursor: pointer; text-align: left; }
.conversation-item:hover, .conversation-item.active { color: #fff; background: rgba(255,255,255,.055); }
.conversation-item .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conversation-item .delete-conv { opacity: 0; color: #727b89; padding: 0 2px; }
.conversation-item:hover .delete-conv { opacity: 1; }
.conversation-empty { color: #59616e; padding: 8px 5px; font-size: 12px; }

.sidebar-footer { display: grid; gap: 10px; }
.status-mini { display: flex; align-items: center; gap: 9px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.02); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(65,232,132,.7); }
.status-mini strong, .status-mini small { display: block; }
.status-mini strong { font-size: 11px; }
.status-mini small { color: #6e7684; font-size: 9px; margin-top: 2px; }
.profile-card { display: flex; align-items: center; width: 100%; gap: 9px; border: 0; border-radius: 11px; background: transparent; padding: 7px; cursor: pointer; text-align: left; }
.profile-card:hover { background: rgba(255,255,255,.045); }
.avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(145deg, #222833, #10131a); border: 1px solid var(--line); font-weight: 800; }
.profile-copy { min-width: 0; flex: 1; }
.profile-copy strong, .profile-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy strong { font-size: 11px; }
.profile-copy small { color: #727a88; font-size: 9px; margin-top: 2px; }
.profile-menu { position: fixed; z-index: 80; left: 18px; bottom: 74px; width: 210px; padding: 7px; border-radius: 12px; background: #11151d; border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.profile-menu button { width: 100%; border: 0; border-radius: 8px; background: transparent; text-align: left; padding: 10px; cursor: pointer; }
.profile-menu button:hover { background: rgba(227,27,47,.12); color: #ff8c99; }

.main-panel { display: flex; flex-direction: column; min-width: 0; background: linear-gradient(180deg, rgba(12,15,21,.78), rgba(5,7,10,.72)); }
.topbar { height: 76px; flex: 0 0 76px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.topbar-copy { min-width: 0; flex: 1; }
.topbar h1 { font-size: 17px; margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.online-badge { display: flex; align-items: center; gap: 7px; border: 1px solid rgba(65,232,132,.15); color: #8ff6b7; background: rgba(65,232,132,.055); padding: 7px 10px; border-radius: 999px; font-size: 9px; font-weight: 800; letter-spacing: 1px; }
.online-badge span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02); cursor: pointer; }
.icon-btn:hover { border-color: var(--line-strong); background: rgba(255,255,255,.045); }
.mobile-only { display: none; margin-right: 10px; }

.chat-viewport { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.empty-state { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 8%; text-align: center; }
.welcome-logo { width: 92px; height: 92px; object-fit: contain; display: block; margin: 0 auto 18px; filter: drop-shadow(0 0 18px rgba(227,27,47,.16)); }
.scanner-orb { position: relative; width: 72px; height: 72px; border-radius: 50%; border: 1px solid rgba(227,27,47,.45); background: radial-gradient(circle at 50% 45%, #3b1118 0, #12151c 48%, #090b0f 72%); box-shadow: 0 0 40px rgba(227,27,47,.12), inset 0 0 25px rgba(227,27,47,.15); overflow: hidden; margin-bottom: 22px; }
.scanner-orb::before, .scanner-orb::after { content: ""; position: absolute; inset: 9px; border: 1px solid rgba(227,27,47,.2); border-radius: 50%; }
.scanner-orb::after { inset: 20px; }
.scanner-line { position: absolute; top: 34px; left: 9px; right: 9px; height: 2px; background: #ff3147; box-shadow: 0 0 11px #ff3147; animation: scan 2.4s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateX(-9px); opacity: .45; } 50% { transform: translateX(9px); opacity: 1; } }
.welcome-kicker { color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: 2px; }
.empty-state h2 { font-size: clamp(32px, 4vw, 54px); line-height: 1.05; letter-spacing: -2.3px; margin: 10px 0 14px; max-width: 760px; }
.empty-state h2 em { color: var(--red); font-style: normal; }
.empty-state > p { color: var(--muted); max-width: 590px; margin: 0; line-height: 1.65; font-size: 14px; }
.suggestion-grid { width: min(760px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 32px; }
.suggestion { position: relative; border: 1px solid var(--line); border-radius: 15px; padding: 15px 16px; background: rgba(255,255,255,.025); text-align: left; cursor: pointer; transition: .2s ease; }
.suggestion:hover { transform: translateY(-2px); border-color: rgba(227,27,47,.35); background: rgba(227,27,47,.045); }
.suggestion > span { position: absolute; right: 14px; top: 13px; color: var(--red); }
.suggestion strong, .suggestion small { display: block; }
.suggestion strong { font-size: 13px; }
.suggestion small { color: #777f8d; font-size: 11px; margin-top: 5px; }

.messages { width: min(860px, calc(100% - 42px)); margin: 0 auto; padding: 28px 0 36px; display: grid; gap: 28px; }
.message { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; }
.message.user { grid-template-columns: minmax(0,1fr) 34px; }
.message.user .message-avatar { order: 2; }
.message.user .message-body { justify-self: end; width: min(78%, 680px); }
.message-avatar { width: 34px; height: 34px; border-radius: 11px; border: 1px solid var(--line); display: grid; place-items: center; background: #11151c; font-size: 11px; font-weight: 800; color: #aeb5c1; }
.message.assistant .message-avatar { border-color: rgba(227,27,47,.28); background: radial-gradient(circle at center, rgba(227,27,47,.22), #10131a 66%); color: #ff5263; }
.message-meta { color: #69717e; font-size: 9px; margin: 0 0 7px; }
.message.user .message-meta { text-align: right; }
.message-content { line-height: 1.7; font-size: 14px; color: #e6e9ef; }
.message.user .message-content { padding: 11px 14px; border-radius: 15px 15px 4px 15px; background: linear-gradient(135deg, rgba(174,20,38,.88), rgba(112,13,26,.9)); border: 1px solid rgba(255,76,96,.2); color: #fff; }
.message.assistant .message-content { padding-top: 2px; }
.message-content pre { overflow-x: auto; padding: 14px; border: 1px solid var(--line); background: #080b10; border-radius: 12px; line-height: 1.5; }
.message-content code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .92em; }
.message-content :not(pre) > code { background: rgba(255,255,255,.065); padding: 2px 5px; border-radius: 5px; }
.cursor { display: inline-block; width: 7px; height: 15px; margin-left: 3px; vertical-align: -2px; background: var(--red); animation: blink .85s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.composer-wrap { flex: 0 0 auto; padding: 10px 22px 12px; background: linear-gradient(to top, rgba(5,7,10,1) 70%, rgba(5,7,10,.7)); }
.composer { width: min(880px, 100%); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line-strong); background: rgba(16,20,28,.9); border-radius: 17px; padding: 9px 10px; box-shadow: 0 12px 34px rgba(0,0,0,.24); }
.composer:focus-within { border-color: rgba(227,27,47,.35); box-shadow: 0 0 0 3px rgba(227,27,47,.055), 0 12px 34px rgba(0,0,0,.24); }
.composer textarea { flex: 1; max-height: 170px; min-height: 38px; resize: none; border: 0; outline: 0; background: transparent; color: white; padding: 9px 4px 7px; line-height: 1.45; }
.composer textarea::placeholder { color: #626b78; }
.composer-icon, .send-btn { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; border: 0; cursor: pointer; }
.response-mode-picker { position: relative; flex: 0 0 auto; align-self: flex-end; }
.response-mode-btn { height: 38px; min-width: 108px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid rgba(255,255,255,.085); border-radius: 11px; outline: 0; background: rgba(255,255,255,.035); color: #dfe3ea; padding: 0 10px; font: inherit; font-size: 11px; font-weight: 760; letter-spacing: -.1px; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease; -webkit-tap-highlight-color: transparent; }
.response-mode-btn:hover { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.06); }
.response-mode-btn:active { transform: translateY(1px); }
.response-mode-btn:focus-visible { border-color: rgba(227,27,47,.48); box-shadow: 0 0 0 3px rgba(227,27,47,.09); }
.response-mode-picker.open .response-mode-btn { border-color: rgba(227,27,47,.34); background: rgba(227,27,47,.07); }
.response-mode-btn-icon { width: 16px; height: 16px; display: grid; place-items: center; color: #ff4d61; font-size: 12px; line-height: 1; }
.response-mode-picker.thinking-active .response-mode-btn-icon { color: #f1b65c; }
.response-mode-chevron { margin-left: 1px; color: #7d8591; font-size: 13px; transform: translateY(-1px); transition: transform .16s ease; }
.response-mode-picker.open .response-mode-chevron { transform: translateY(1px) rotate(180deg); }
.response-mode-menu { position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 80; width: min(310px, calc(100vw - 28px)); padding: 7px; border: 1px solid rgba(255,255,255,.10); border-radius: 16px; background: rgba(17,20,27,.98); box-shadow: 0 20px 60px rgba(0,0,0,.48), 0 2px 8px rgba(0,0,0,.25); backdrop-filter: blur(20px); transform-origin: left bottom; animation: responseModeIn .14s ease-out; }
@keyframes responseModeIn { from { opacity: 0; transform: translateY(7px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.response-mode-menu-head { display: grid; gap: 2px; padding: 8px 10px 7px; }
.response-mode-menu-head > span { color: #eef1f6; font-size: 11px; font-weight: 780; }
.response-mode-menu-head small { color: #737c89; font-size: 9px; font-weight: 550; }
.response-mode-option { width: 100%; min-height: 58px; display: grid; grid-template-columns: 34px minmax(0,1fr) 22px; align-items: center; gap: 10px; border: 0; border-radius: 11px; background: transparent; color: #e8ebf0; padding: 8px 9px; text-align: left; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent; transition: background .14s ease, transform .14s ease; }
.response-mode-option:hover, .response-mode-option:focus-visible { outline: 0; background: rgba(255,255,255,.055); }
.response-mode-option:active { transform: scale(.992); }
.response-mode-option.selected { background: rgba(227,27,47,.075); }
.response-mode-option-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; border: 1px solid rgba(255,255,255,.075); background: rgba(255,255,255,.035); font-size: 14px; }
.response-mode-option-icon.instant { color: #ff5064; background: rgba(227,27,47,.09); border-color: rgba(227,27,47,.17); }
.response-mode-option-icon.thinking { color: #f0b35b; background: rgba(240,179,91,.08); border-color: rgba(240,179,91,.16); }
.response-mode-option-copy { min-width: 0; display: grid; gap: 3px; }
.response-mode-option-copy strong { font-size: 11px; font-weight: 780; color: #eff2f6; }
.response-mode-option-copy small { color: #818a97; font-size: 9.5px; line-height: 1.3; white-space: normal; }
.response-mode-check { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: #ff5064; font-size: 11px; font-weight: 900; opacity: 0; transform: scale(.78); transition: opacity .14s ease, transform .14s ease; }
.response-mode-option.selected .response-mode-check { opacity: 1; transform: scale(1); }
.composer-icon { background: transparent; color: #838c99; font-size: 22px; }
.composer-icon:hover { background: rgba(255,255,255,.05); }
.send-btn { background: linear-gradient(145deg, #f0273d, #a60f22); box-shadow: 0 0 20px rgba(227,27,47,.18); }
.send-btn:disabled { opacity: .42; cursor: not-allowed; }
.composer-note { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; text-align: center; color: #555d69; font-size: 9px; margin-top: 8px; }
.footer-powered { display: inline-flex; align-items: center; gap: 5px; color: #848c98; font-weight: 600; }
.footer-powered .southland-s { color: var(--red); font-weight: 900; font-size: 11px; }
.typing-status { width: min(880px,100%); margin: 0 auto 7px; color: #7a8390; font-size: 9px; letter-spacing: .4px; }
.typing-status span { display: inline-block; width: 4px; height: 4px; border-radius: 50%; background: var(--red); margin-right: 3px; animation: pulse 1.1s infinite ease-in-out; }
.typing-status span:nth-child(2) { animation-delay: .13s; }
.typing-status span:nth-child(3) { animation-delay: .26s; margin-right: 7px; }
@keyframes pulse { 0%,100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.intel-panel { padding: 18px 14px; border-left: 1px solid var(--line); background: rgba(5,7,10,.79); backdrop-filter: blur(18px); overflow-y: auto; }
.intel-card { border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(150deg, rgba(18,22,30,.75), rgba(8,10,15,.75)); padding: 15px; margin-bottom: 12px; }
.intel-heading { margin-bottom: 15px; color: #b7bdc8; }
.intel-heading.red { color: #ff4357; }
.orb-row { display: flex; align-items: center; gap: 12px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.mini-orb { width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(227,27,47,.45); background: radial-gradient(circle at center, #371018, #0b0e13 64%); position: relative; }
.mini-orb span { position: absolute; left: 8px; right: 8px; top: 23px; height: 2px; background: #ff3248; box-shadow: 0 0 10px #ff3248; }
.green { color: var(--green); font-size: 12px; }
.orb-row p, .mission-card p { color: #a1a8b4; font-size: 11px; margin: 4px 0 0; line-height: 1.55; }
.metric-row { display: flex; justify-content: space-between; gap: 10px; color: #7b8390; font-size: 10px; padding-top: 11px; }
.metric-row b { color: #b9c0cb; font-size: 9px; }
.capability-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; color: #a6aebb; font-size: 11px; }
.capability-list li { display: flex; align-items: center; gap: 9px; }
.capability-list span { color: var(--red); width: 18px; text-align: center; }
.mission-card .muted { color: #696f7b; }
.waveform { display: flex; align-items: center; justify-content: center; gap: 4px; height: 50px; margin-top: 16px; }
.waveform i { width: 3px; height: 12px; border-radius: 4px; background: var(--red); box-shadow: 0 0 10px rgba(227,27,47,.3); animation: wave 1.2s ease-in-out infinite; }
.waveform i:nth-child(2), .waveform i:nth-child(10) { height: 20px; animation-delay: .1s; }
.waveform i:nth-child(3), .waveform i:nth-child(9) { height: 30px; animation-delay: .2s; }
.waveform i:nth-child(4), .waveform i:nth-child(8) { height: 17px; animation-delay: .3s; }
.waveform i:nth-child(5), .waveform i:nth-child(7) { height: 38px; animation-delay: .4s; }
.waveform i:nth-child(6) { height: 25px; animation-delay: .5s; }
@keyframes wave { 50% { transform: scaleY(.45); opacity: .45; } }

.auth-screen { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 70% 10%, rgba(156,15,33,.18), transparent 36%), rgba(4,6,9,.96); }
.auth-card { width: min(430px,100%); padding: 30px; border: 1px solid var(--line-strong); border-radius: 22px; background: rgba(12,15,21,.94); box-shadow: var(--shadow); backdrop-filter: blur(22px); }
.auth-brand { display: flex; justify-content: center; align-items: center; gap: 11px; }
.auth-tagline { text-align: center; color: #7d8592; font-size: 12px; margin: 10px 0 25px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; background: rgba(255,255,255,.035); border: 1px solid var(--line); padding: 4px; border-radius: 12px; margin-bottom: 20px; }
.auth-tab { border: 0; border-radius: 9px; padding: 9px; background: transparent; color: #777f8d; cursor: pointer; font-size: 12px; }
.auth-tab.active { color: white; background: rgba(227,27,47,.12); }
.auth-card label { display: block; color: #a7aebb; font-size: 10px; font-weight: 700; margin: 12px 0 6px; }
.auth-card input { width: 100%; border: 1px solid var(--line); background: #080b10; color: white; border-radius: 11px; padding: 12px 13px; outline: 0; }
.auth-card input:focus { border-color: rgba(227,27,47,.45); box-shadow: 0 0 0 3px rgba(227,27,47,.06); }
.primary-auth-btn, .google-btn, .magic-btn { width: 100%; border-radius: 11px; padding: 12px; cursor: pointer; }
.primary-auth-btn { margin-top: 18px; border: 1px solid rgba(255,70,89,.25); background: linear-gradient(145deg, #d91b30, #8f0c1c); }
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.google-btn svg { width: 18px; height: 18px; }
.magic-btn { margin-top: 10px; border: 0; background: transparent; color: #858e9b; font-size: 11px; }
.magic-btn:hover { color: #c5cbd4; }
.divider { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; color: #575f6b; font-size: 10px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.auth-message { min-height: 20px; margin-top: 13px; color: #ff8d99; font-size: 11px; text-align: center; line-height: 1.45; }
.auth-message.success { color: #8ff6b7; }
.auth-foot { text-align: center; color: #525a66; font-size: 9px; margin-top: 10px; }
.sidebar-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  background: rgba(0,0,0,.38);
  pointer-events: auto;
  touch-action: manipulation;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.14); border: 2px solid transparent; background-clip: padding-box; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 250px minmax(0,1fr); }
  .intel-panel { display: none; }
}

@media (max-width: 780px) {
  body { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: 18px 0 60px rgba(0,0,0,.4); }
  .sidebar.open { transform: translateX(0); }
  .main-panel { height: 100vh; }
  .mobile-only { display: grid; }
  .topbar { padding: 0 13px; height: 68px; flex-basis: 68px; }
  .topbar h1 { font-size: 14px; }
  .online-badge { display: none; }
  .messages { width: calc(100% - 24px); padding-top: 20px; }
  .message.user .message-body { width: min(90%, 680px); }
  .composer-wrap { padding: 8px 10px 10px; }
  .empty-state { padding: 34px 18px; justify-content: center; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .empty-state h2 { letter-spacing: -1.5px; }
}

/* Guest-first flow + responsive refinements */
body.modal-open { overflow: hidden; }
.guest-limit-pill {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 10px;
  border: 1px solid rgba(255,255,255,.09); border-radius: 999px; background: rgba(255,255,255,.035);
  color: #aab2bf; font-size: 9px; font-weight: 750; letter-spacing: .35px; white-space: nowrap;
}
.guest-limit-pill.limit-low { color: #ff9aa6; border-color: rgba(227,27,47,.25); background: rgba(227,27,47,.075); }
.top-signin-btn {
  min-height: 34px; padding: 0 13px; border-radius: 10px; border: 1px solid rgba(227,27,47,.35);
  background: linear-gradient(180deg, rgba(227,27,47,.14), rgba(227,27,47,.07)); color: #fff;
  font-size: 10px; font-weight: 750; cursor: pointer;
}
.top-signin-btn:hover { border-color: rgba(227,27,47,.62); background: rgba(227,27,47,.14); }

.auth-screen {
  z-index: 90;
  background: radial-gradient(circle at 70% 10%, rgba(156,15,33,.16), transparent 38%), rgba(3,5,8,.72);
  backdrop-filter: blur(14px);
  overflow-y: auto;
}
.auth-card { position: relative; max-height: calc(100dvh - 28px); overflow-y: auto; }
.auth-close {
  position: absolute; top: 13px; right: 13px; width: 32px; height: 32px; border: 1px solid var(--line);
  border-radius: 10px; background: rgba(255,255,255,.025); color: #8c94a0; cursor: pointer; font-size: 20px;
  line-height: 1;
}
.auth-close:hover { color: #fff; background: rgba(255,255,255,.06); }
.auth-tagline { margin-bottom: 8px; }
.auth-reason {
  margin: 0 auto 22px; max-width: 340px; color: #9aa2af; font-size: 11px; line-height: 1.55; text-align: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025);
}

@media (max-width: 960px) {
  .guest-limit-pill { font-size: 8px; padding-inline: 8px; }
  .top-signin-btn { padding-inline: 10px; }
}

@media (max-width: 780px) {
  .main-panel { height: 100dvh; min-height: 100dvh; }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); flex-basis: calc(64px + env(safe-area-inset-top)); }
  .topbar-copy .eyebrow { display: none; }
  .topbar-actions { gap: 6px; }
  .guest-limit-pill { min-height: 30px; max-width: 112px; overflow: hidden; text-overflow: ellipsis; }
  .top-signin-btn { min-height: 32px; }
  .topbar-actions .icon-btn { display: none; }
  .chat-viewport { overscroll-behavior: contain; }
  .messages { width: calc(100% - 20px); gap: 23px; padding-bottom: 22px; }
  .message { grid-template-columns: 30px minmax(0,1fr); gap: 9px; }
  .message.user { grid-template-columns: minmax(0,1fr) 30px; }
  .message-avatar { width: 30px; height: 30px; border-radius: 9px; }
  .message.user .message-body { width: min(94%, 680px); }
  .message-content { font-size: 14px; line-height: 1.65; }
  .composer-wrap { padding: 7px 9px calc(8px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 15px; padding: 7px 8px; gap: 5px; }
  .composer textarea { min-height: 36px; font-size: 16px; }
  .composer-icon, .send-btn { width: 36px; height: 36px; flex-basis: 36px; }
  .response-mode-btn { height: 36px; min-width: 101px; padding-inline: 9px; font-size: 10px; }
  .response-mode-menu { left: -42px; bottom: calc(100% + 9px); width: min(300px, calc(100vw - 18px)); }
  .composer-note { font-size: 8px; margin-top: 6px; gap: 6px; }
  .footer-powered { width: 100%; justify-content: center; }
  .empty-state { min-height: auto; padding: 32px 16px 22px; justify-content: flex-start; }
  .welcome-logo { width: 76px; height: 76px; margin-bottom: 14px; }
  .empty-state h2 { font-size: clamp(28px, 9vw, 40px); }
  .empty-state > p { font-size: 12px; max-width: 520px; }
  .suggestion-grid { width: 100%; max-width: 520px; gap: 8px; }
  .suggestion { min-height: 67px; }
  .auth-screen { padding: 10px; align-items: end; }
  .auth-card { width: 100%; max-height: 92dvh; padding: 24px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 22px 22px 16px 16px; }
  .brand-name.big { font-size: 30px; }
}

@media (max-width: 480px) {
  .topbar { padding-left: 9px; padding-right: 9px; }
  .mobile-only { margin-right: 6px; }
  .topbar h1 { font-size: 12px; max-width: 112px; }
  .guest-limit-pill { max-width: 94px; padding-inline: 7px; }
  .top-signin-btn { padding-inline: 9px; font-size: 9px; }
  .empty-state { padding-left: 12px; padding-right: 12px; }
  .suggestion-grid { grid-template-columns: 1fr 1fr; }
  .suggestion { min-height: 78px; padding: 12px; }
  .suggestion small { line-height: 1.3; }
}

/* Mobile drawer + phone usability pass */
.sidebar-close { margin-left: auto; }

@media (max-width: 780px) {
  html, body { width: 100%; height: 100%; min-height: 100%; }
  body.sidebar-open { overflow: hidden; }

  .app-shell { width: 100%; height: 100dvh; min-height: 100dvh; overflow: hidden; }
  .main-panel { width: 100%; height: 100dvh; min-height: 100dvh; }

  .sidebar {
    z-index: 60;
    inset: 0 auto 0 0;
    width: min(86vw, 320px);
    max-width: calc(100vw - 46px);
    height: 100dvh;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom));
    gap: 14px;
    overflow: hidden;
    transform: translate3d(-104%,0,0);
    transition: transform .24s cubic-bezier(.2,.75,.25,1);
    box-shadow: 22px 0 70px rgba(0,0,0,.58);
    will-change: transform;
    touch-action: pan-y;
  }
  .sidebar.open { transform: translate3d(0,0,0); }
  .sidebar .brand-row { min-height: 44px; }
  .sidebar-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
    color: #aeb5c1;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }
  .sidebar-close:active { transform: scale(.96); background: rgba(227,27,47,.11); }
  .sidebar .new-chat-btn,
  .sidebar .nav-item,
  .sidebar .profile-card { min-height: 46px; }
  .history-section { min-height: 88px; }
  .conversation-list { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .conversation-item { min-height: 42px; }
  .conversation-item .delete-conv { opacity: .75; min-width: 28px; min-height: 28px; display: grid; place-items: center; }

  .sidebar-backdrop {
    display: block;
    z-index: 50;
    background: rgba(0,0,0,.34);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  /* Keep the drawer above the dimmer on iOS/Safari. The backdrop now lives
     inside .app-shell so these z-index values share the same stacking context. */
  .sidebar.open {
    z-index: 70;
    pointer-events: auto;
    visibility: visible;
  }
  .sidebar.open * { pointer-events: auto; }
  body.sidebar-open .main-panel { pointer-events: none; }
  body.sidebar-open .sidebar,
  body.sidebar-open .sidebar * { pointer-events: auto; }

  .topbar {
    width: 100%;
    gap: 7px;
    padding-left: max(9px, env(safe-area-inset-left));
    padding-right: max(9px, env(safe-area-inset-right));
  }
  .topbar > .mobile-only { flex: 0 0 40px; width: 40px; height: 40px; margin-right: 0; }
  .topbar-copy { flex: 1 1 auto; min-width: 0; }
  .topbar h1 { max-width: none; font-size: 13px; }
  .topbar-actions { flex: 0 0 auto; min-width: 0; }
  .guest-limit-pill { max-width: 104px; min-height: 30px; padding-inline: 8px; }
  .top-signin-btn { min-height: 34px; padding-inline: 10px; white-space: nowrap; }

  .chat-viewport { width: 100%; -webkit-overflow-scrolling: touch; }
  .empty-state { width: 100%; padding-top: clamp(22px, 6vh, 46px); }
  .empty-state h2 { max-width: 520px; overflow-wrap: anywhere; }
  .suggestion-grid { grid-template-columns: 1fr; max-width: 560px; }
  .suggestion { min-height: 64px; padding: 13px 14px; }

  .messages { width: min(100% - 18px, 860px); }
  .message-body { min-width: 0; }
  .message-content { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
  .message-content pre { max-width: 100%; -webkit-overflow-scrolling: touch; }
  .message.user .message-body { width: min(92%, 680px); }

  .composer-wrap {
    width: 100%;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .composer { width: 100%; max-width: 880px; }
  .composer textarea { width: 100%; min-width: 0; max-height: min(150px, 24dvh); }
  .composer-note { line-height: 1.35; padding-inline: 4px; }

  .auth-screen { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .auth-card input, .primary-auth-btn, .google-btn { min-height: 46px; }
  .auth-close { width: 40px; height: 40px; }
}

@media (max-width: 540px) {
  .welcome-logo { width: 68px; height: 68px; margin-bottom: 12px; }
  .empty-state h2 { font-size: clamp(27px, 9.6vw, 38px); margin-top: 8px; }
  .empty-state > p { line-height: 1.55; }
  .suggestion-grid { margin-top: 22px; }
  .suggestion { display: grid; grid-template-columns: 28px minmax(0,1fr); grid-template-rows: auto auto; column-gap: 9px; align-items: center; }
  .suggestion > span { grid-row: 1 / 3; margin: 0; }
  .suggestion strong { grid-column: 2; }
  .suggestion small { grid-column: 2; margin-top: 2px; }
}

@media (max-width: 430px) {
  .topbar-copy { display: none; }
  .topbar-actions { margin-left: auto; }
  .guest-limit-pill { max-width: 92px; font-size: 8px; }
  .top-signin-btn { padding-inline: 9px; font-size: 9px; }
  .empty-state { padding-left: 11px; padding-right: 11px; }
  .empty-state h2 { letter-spacing: -1.2px; }
  .messages { width: calc(100% - 14px); gap: 20px; }
  .message { grid-template-columns: 28px minmax(0,1fr); gap: 8px; }
  .message.user { grid-template-columns: minmax(0,1fr) 28px; }
  .message-avatar { width: 28px; height: 28px; border-radius: 8px; }
  .message.user .message-body { width: 94%; }
  .message-content { font-size: 13.5px; }
  .message.user .message-content { padding: 10px 12px; }
  .composer-icon { display: none; }
  .composer { padding-left: 8px; }
  .response-mode-btn { min-width: 94px; gap: 5px; padding-inline: 8px; font-size: 9.5px; }
  .response-mode-btn-icon { width: 14px; }
  .response-mode-menu { position: fixed; left: 10px; right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); width: auto; max-width: none; border-radius: 18px; padding: 8px; transform-origin: center bottom; }
  .response-mode-option { min-height: 62px; grid-template-columns: 38px minmax(0,1fr) 24px; gap: 11px; padding: 9px 10px; }
  .response-mode-option-icon { width: 38px; height: 38px; border-radius: 11px; }
  .response-mode-option-copy strong { font-size: 12px; }
  .response-mode-option-copy small { font-size: 10px; }
  .composer-note { font-size: 7.5px; }
}

@media (max-width: 360px) {
  .guest-limit-pill { display: none; }
  .top-signin-btn { min-width: 58px; }
  .empty-state h2 { font-size: 28px; }
  .suggestion small { font-size: 10px; }
  .response-mode-btn { min-width: 86px; padding-inline: 7px; }
  .response-mode-chevron { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Auth interaction hardening */
.auth-card { isolation: isolate; }
.auth-card button { position: relative; z-index: 2; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.google-btn { min-height: 46px; user-select: none; }
.google-btn:hover { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.055); }
.google-btn:active { transform: translateY(1px); }
.google-btn:disabled, .primary-auth-btn:disabled, .magic-btn:disabled { opacity: .62; cursor: wait; }

/* KITGPT v3 — Functions, Knowledge, Workspace & Settings */
.nav-item { cursor: pointer; transition: background .16s ease, color .16s ease, transform .16s ease; }
.nav-item:hover { background: rgba(255,255,255,.04); color: #eef1f5; }
.nav-item:active { transform: translateY(1px); }

.feature-view { flex: 1; min-height: 0; overflow-y: auto; }
.feature-shell { width: min(1080px, calc(100% - 42px)); margin: 0 auto; padding: 30px 0 48px; }
.feature-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 6px 2px 24px; }
.feature-hero h2 { margin: 7px 0 8px; font-size: clamp(26px, 3vw, 39px); letter-spacing: -1.6px; line-height: 1.08; }
.feature-hero p { margin: 0; max-width: 670px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.feature-hero-actions { display: flex; gap: 8px; }
.feature-kicker { color: var(--red); font-size: 9px; line-height: 1; font-weight: 850; letter-spacing: 1.65px; }
.feature-primary, .secondary-btn, .danger-btn, .ghost-icon-btn { border-radius: 10px; cursor: pointer; transition: .17s ease; }
.feature-primary { border: 1px solid rgba(255,72,91,.32); padding: 10px 14px; background: linear-gradient(145deg, #d81b31, #921020); color: #fff; font-size: 11px; font-weight: 750; box-shadow: 0 8px 22px rgba(146,16,32,.16); }
.feature-primary:hover { transform: translateY(-1px); border-color: rgba(255,91,108,.58); box-shadow: 0 10px 26px rgba(146,16,32,.24); }
.feature-primary:disabled { opacity: .55; cursor: wait; transform: none; }
.secondary-btn { border: 1px solid var(--line-strong); padding: 8px 11px; background: rgba(255,255,255,.035); color: #c8ced7; font-size: 10px; }
.secondary-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.danger-btn { border: 1px solid rgba(227,27,47,.26); padding: 8px 11px; background: rgba(227,27,47,.07); color: #ff7c8b; font-size: 10px; }
.danger-btn:hover { background: rgba(227,27,47,.13); }
.ghost-icon-btn { width: 31px; height: 31px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; color: #7e8794; font-size: 17px; }
.ghost-icon-btn:hover { color: #fff; background: rgba(255,255,255,.05); }

.function-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 11px; margin-bottom: 18px; }
.function-card { min-height: 158px; position: relative; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 16px; padding: 17px; background: linear-gradient(145deg, rgba(19,23,31,.76), rgba(8,10,15,.72)); text-align: left; cursor: pointer; transition: .18s ease; }
.function-card:hover { transform: translateY(-2px); border-color: rgba(227,27,47,.34); background: linear-gradient(145deg, rgba(30,24,31,.83), rgba(11,12,17,.8)); }
.function-card > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; border: 1px solid rgba(227,27,47,.22); background: rgba(227,27,47,.08); color: #ff465a; font-size: 16px; margin-bottom: 20px; }
.function-card strong { font-size: 13px; }
.function-card small { color: #747d8a; font-size: 10px; margin-top: 6px; line-height: 1.5; }

.feature-card { border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, rgba(16,20,27,.76), rgba(8,10,14,.72)); padding: 18px; }
.feature-card-heading, .feature-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.feature-card-heading h3, .feature-section-heading h3 { margin: 5px 0 0; font-size: 15px; }
.feature-section-heading { margin: 24px 2px 12px; }
.mini-badge { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; background: rgba(255,255,255,.025); color: #7d8693; font-size: 8px; font-weight: 750; letter-spacing: .35px; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 11px; margin-top: 16px; }
.form-grid label, .workspace-create label, .settings-field { color: #9ba3af; font-size: 10px; font-weight: 700; }
.form-grid input, .form-grid textarea, .workspace-create input, .workspace-create textarea, .settings-field input, .settings-field textarea, .search-box input { width: 100%; margin-top: 7px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: rgba(5,7,10,.72); color: #fff; padding: 11px 12px; resize: vertical; }
.form-grid input:focus, .form-grid textarea:focus, .workspace-create input:focus, .workspace-create textarea:focus, .settings-field input:focus, .settings-field textarea:focus, .search-box:focus-within { border-color: rgba(227,27,47,.4); box-shadow: 0 0 0 3px rgba(227,27,47,.055); }
.feature-actions { display: flex; align-items: center; justify-content: flex-end; gap: 11px; margin-top: 13px; }
.inline-status { flex: 1; color: #7f8996; font-size: 10px; min-height: 15px; }
.saved-card-grid { display: grid; gap: 8px; }
.saved-empty { border: 1px dashed var(--line); border-radius: 14px; padding: 22px; color: #68717e; font-size: 11px; text-align: center; }
.saved-tool-card { display: grid; grid-template-columns: 38px minmax(0,1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; background: rgba(255,255,255,.018); }
.saved-tool-icon, .knowledge-file-icon, .workspace-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid rgba(227,27,47,.2); background: rgba(227,27,47,.07); color: #f04355; }
.saved-tool-copy { min-width: 0; }
.saved-tool-copy strong { font-size: 11px; }
.saved-tool-copy p { margin: 4px 0 0; color: #737c89; font-size: 9px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.saved-tool-actions { display: flex; gap: 7px; }

.knowledge-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.search-box { min-width: min(430px, 100%); display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 11px; padding: 0 11px; background: rgba(5,7,10,.62); }
.search-box > span { color: #69727e; }
.search-box input { margin: 0; padding: 10px 0; border: 0; background: transparent; box-shadow: none !important; }
.muted-note { color: #69727e; font-size: 9px; }
.empty-feature-state { display: grid; justify-items: center; text-align: center; padding: 54px 20px; border: 1px dashed var(--line); border-radius: 16px; background: rgba(255,255,255,.012); }
.empty-feature-state.compact { padding: 34px 20px; }
.empty-feature-icon { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 14px; color: #e93c50; background: rgba(227,27,47,.055); font-size: 18px; }
.empty-feature-state h3 { margin: 13px 0 5px; font-size: 14px; }
.empty-feature-state p { margin: 0; color: #717a87; font-size: 10px; }
.knowledge-list { display: grid; gap: 8px; }
.knowledge-row { display: grid; grid-template-columns: 39px minmax(0,1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; background: rgba(255,255,255,.018); }
.knowledge-file-copy { min-width: 0; }
.knowledge-file-copy strong, .knowledge-file-copy small { display: block; }
.knowledge-file-copy strong { font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.knowledge-file-copy small { color: #666f7d; font-size: 8px; margin-top: 3px; }
.knowledge-file-copy p { margin: 5px 0 0; color: #7c8591; font-size: 9px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.knowledge-row-actions { display: flex; gap: 7px; }
.knowledge-preview { margin-top: 13px; }
.knowledge-preview pre { max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--line); border-radius: 11px; padding: 14px; background: #07090d; color: #aeb6c2; font: 10px/1.6 "SFMono-Regular", Consolas, monospace; }

.workspace-layout { display: grid; grid-template-columns: minmax(280px, .78fr) minmax(0,1.22fr); gap: 17px; align-items: start; }
.workspace-create { position: sticky; top: 18px; }
.workspace-create label { display: block; margin-top: 13px; }
.workspace-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.workspace-card { min-height: 226px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 15px; padding: 15px; background: linear-gradient(145deg, rgba(18,22,29,.7), rgba(8,10,14,.72)); }
.workspace-card-top, .workspace-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 9px; }
.workspace-card h3 { margin: 13px 0 6px; font-size: 13px; }
.workspace-card > p { margin: 0; color: #848c99; font-size: 10px; line-height: 1.5; }
.workspace-notes { flex: 1; margin-top: 12px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.022); color: #69727f; font-size: 9px; line-height: 1.5; max-height: 76px; overflow: hidden; white-space: pre-wrap; }
.workspace-card-footer { margin-top: 12px; }
.workspace-card-footer small { color: #5d6673; font-size: 8px; }
.workspace-card-footer > div { display: flex; align-items: center; gap: 6px; }

.profile-menu { width: 225px; }
.profile-menu button { display: flex; align-items: center; gap: 9px; color: #aeb6c2; }
.profile-menu button span { width: 16px; color: #6f7885; }
.profile-menu button:hover { background: rgba(255,255,255,.05); color: #fff; }
.profile-menu #logoutBtn:hover { background: rgba(227,27,47,.1); color: #ff8492; }

.settings-screen { position: fixed; z-index: 120; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(4,6,9,.7); backdrop-filter: blur(13px); }
.settings-modal { width: min(950px, 100%); height: min(680px, calc(100dvh - 44px)); display: grid; grid-template-columns: 230px minmax(0,1fr); overflow: hidden; border: 1px solid var(--line-strong); border-radius: 20px; background: rgba(11,14,19,.985); box-shadow: 0 30px 100px rgba(0,0,0,.55); }
.settings-sidebar { min-height: 0; padding: 16px 12px; border-right: 1px solid var(--line); background: rgba(7,9,13,.76); }
.settings-sidebar-head { display: flex; align-items: center; gap: 12px; padding: 0 5px 16px; }
.settings-sidebar-head strong { display: block; margin-top: 4px; font-size: 14px; }
.settings-close { width: 35px; height: 35px; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: #cad0d8; font-size: 22px; cursor: pointer; }
.settings-close:hover { background: rgba(255,255,255,.055); }
.settings-nav { display: grid; gap: 3px; }
.settings-nav-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; border-radius: 10px; padding: 10px; background: transparent; color: #959eab; text-align: left; cursor: pointer; font-size: 11px; }
.settings-nav-item span { width: 18px; color: #707987; text-align: center; }
.settings-nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.settings-nav-item.active { background: rgba(227,27,47,.1); color: #fff; }
.settings-nav-item.active span { color: #f03a4e; }
.settings-content { min-height: 0; overflow-y: auto; padding: 26px 31px 34px; }
.settings-section { display: none; }
.settings-section.active { display: block; }
.settings-page-title { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.settings-page-title h2 { margin: 0; font-size: 22px; letter-spacing: -.7px; }
.settings-page-title p { margin: 6px 0 0; color: #78818e; font-size: 10px; }
.setting-row { min-height: 71px; display: flex; align-items: center; justify-content: space-between; gap: 22px; border-bottom: 1px solid var(--line); }
.setting-row > div { min-width: 0; }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { font-size: 11px; }
.setting-row small { margin-top: 5px; color: #737c89; font-size: 9px; line-height: 1.45; }
.setting-row select { min-width: 132px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 28px 8px 10px; background: #0b0e14; color: #c8ced7; outline: 0; font-size: 10px; }
.switch { position: relative; flex: 0 0 auto; width: 38px; height: 22px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #282e38; border: 1px solid var(--line); cursor: pointer; transition: .17s ease; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: #9da5b1; transition: .17s ease; }
.switch input:checked + span { background: #c8182b; border-color: #e92f43; }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.settings-group { padding-top: 17px; }
.settings-field { display: block; margin-bottom: 16px; }
.settings-field small { display: block; color: #68717e; font-size: 9px; margin-top: 6px; line-height: 1.45; }
.settings-save-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.account-panel { display: grid; grid-template-columns: 50px minmax(0,1fr) auto; gap: 13px; align-items: center; margin: 18px 0 4px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.settings-avatar { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(145deg, #292f3a, #13171e); border: 1px solid var(--line-strong); font-size: 16px; font-weight: 850; }
.account-panel strong, .account-panel small { display: block; }
.account-panel strong { font-size: 12px; }
.account-panel small { color: #717a87; font-size: 9px; margin-top: 5px; }
.settings-inline-message { padding-top: 12px; }
.about-card { display: flex; align-items: center; gap: 15px; margin: 18px 0 4px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.about-card p { margin: 4px 0; color: #858e9b; font-size: 10px; }
.about-card small { color: #606977; font-size: 9px; }
.status-text-online { color: #75eea4; font-size: 9px; font-weight: 750; }

body.compact-ui .sidebar { gap: 12px; }
body.compact-ui .nav-item { padding-block: 7px; }
body.compact-ui .feature-shell { padding-top: 20px; }
body.compact-ui .function-card { min-height: 135px; }

/* Optional light appearance */
html[data-theme="light"] { color-scheme: light; --bg: #f4f5f7; --panel: rgba(255,255,255,.92); --panel-2: rgba(248,249,251,.96); --line: rgba(20,28,38,.11); --line-strong: rgba(20,28,38,.18); --text: #15181e; --muted: #667080; --shadow: 0 24px 70px rgba(15,22,30,.14); }
html[data-theme="light"] body { background: #f4f5f7; }
html[data-theme="light"] body::before { opacity: .28; }
html[data-theme="light"] .ambient { opacity: .08; }
html[data-theme="light"] .sidebar, html[data-theme="light"] .intel-panel { background: rgba(247,248,250,.92); }
html[data-theme="light"] .main-panel { background: linear-gradient(180deg, rgba(255,255,255,.91), rgba(246,247,249,.92)); }
html[data-theme="light"] .feature-card, html[data-theme="light"] .function-card, html[data-theme="light"] .workspace-card { background: rgba(255,255,255,.72); }
html[data-theme="light"] .profile-card:hover, html[data-theme="light"] .nav-item:hover { background: rgba(20,28,38,.045); }
html[data-theme="light"] .nav-item { color: #5f6875; }
html[data-theme="light"] .nav-item.active { color: #171a20; background: linear-gradient(90deg, rgba(227,27,47,.10), transparent); }
html[data-theme="light"] .status-mini, html[data-theme="light"] .powered-pill, html[data-theme="light"] .intel-card { background: rgba(255,255,255,.62); }
html[data-theme="light"] .message-content { color: #2d333c; }
html[data-theme="light"] .message.assistant .message-avatar, html[data-theme="light"] .message-avatar { background: #fff; }
html[data-theme="light"] .composer-wrap { background: linear-gradient(to top, #f5f6f8 70%, rgba(245,246,248,.7)); }
html[data-theme="light"] .composer { background: rgba(255,255,255,.92); }
html[data-theme="light"] .response-mode-btn { background: rgba(0,0,0,.035); border-color: rgba(20,28,38,.10); color: #343a45; }
html[data-theme="light"] .response-mode-btn:hover { background: rgba(20,28,38,.055); border-color: rgba(20,28,38,.16); }
html[data-theme="light"] .response-mode-menu { background: rgba(255,255,255,.98); border-color: rgba(20,28,38,.11); box-shadow: 0 20px 60px rgba(15,22,30,.16), 0 2px 8px rgba(15,22,30,.08); }
html[data-theme="light"] .response-mode-menu-head > span, html[data-theme="light"] .response-mode-option, html[data-theme="light"] .response-mode-option-copy strong { color: #171a20; }
html[data-theme="light"] .response-mode-menu-head small, html[data-theme="light"] .response-mode-option-copy small { color: #707986; }
html[data-theme="light"] .response-mode-option:hover, html[data-theme="light"] .response-mode-option:focus-visible { background: rgba(20,28,38,.05); }
html[data-theme="light"] .response-mode-option.selected { background: rgba(227,27,47,.07); }
html[data-theme="light"] .composer textarea, html[data-theme="light"] .form-grid input, html[data-theme="light"] .form-grid textarea, html[data-theme="light"] .workspace-create input, html[data-theme="light"] .workspace-create textarea, html[data-theme="light"] .settings-field input, html[data-theme="light"] .settings-field textarea { color: #171a20; background: #fff; }
html[data-theme="light"] .knowledge-preview pre { background: #f7f8fa; color: #3c4550; }
html[data-theme="light"] .profile-menu, html[data-theme="light"] .settings-modal { background: #fbfbfc; }
html[data-theme="light"] .settings-sidebar { background: #f3f4f6; }
html[data-theme="light"] .setting-row select { background: #fff; color: #343b45; }
html[data-theme="light"] .auth-screen { background: rgba(235,237,241,.72); }
html[data-theme="light"] .auth-card { background: rgba(255,255,255,.96); }
html[data-theme="light"] .auth-card input { background: #fff; color: #171a20; }
html[data-theme="light"] .google-btn { background: #fff; }

@media (max-width: 920px) {
  .function-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace-layout { grid-template-columns: 1fr; }
  .workspace-create { position: static; }
  .workspace-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .settings-modal { grid-template-columns: 190px minmax(0,1fr); }
}

@media (max-width: 780px) {
  .feature-shell { width: calc(100% - 22px); padding: 19px 0 calc(30px + env(safe-area-inset-bottom)); }
  .feature-hero { flex-direction: column; gap: 14px; padding-bottom: 17px; }
  .feature-hero h2 { font-size: 27px; }
  .feature-hero .feature-primary { width: 100%; }
  .function-grid { grid-template-columns: 1fr; }
  .function-card { min-height: 125px; }
  .function-card > span { margin-bottom: 14px; }
  .knowledge-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .knowledge-row { grid-template-columns: 38px minmax(0,1fr); }
  .knowledge-row-actions { grid-column: 2; justify-content: flex-end; }
  .workspace-list { grid-template-columns: 1fr; }
  .settings-screen { padding: 0; align-items: stretch; }
  .settings-modal { width: 100%; height: 100dvh; border: 0; border-radius: 0; grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); }
  .settings-sidebar { padding: calc(10px + env(safe-area-inset-top)) 10px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-sidebar-head { padding-bottom: 9px; }
  .settings-nav { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
  .settings-nav-item { width: auto; flex: 0 0 auto; padding: 8px 10px; }
  .settings-nav-item span { display: none; }
  .settings-content { padding: 20px 16px calc(30px + env(safe-area-inset-bottom)); }
  .setting-row { min-height: 76px; }
  .account-panel { grid-template-columns: 46px minmax(0,1fr); }
  .account-panel .mini-badge { grid-column: 2; justify-self: start; }
}

@media (max-width: 480px) {
  .feature-hero h2 { font-size: 24px; }
  .feature-card { padding: 14px; }
  .saved-tool-card { grid-template-columns: 34px minmax(0,1fr); }
  .saved-tool-actions { grid-column: 2; justify-content: flex-end; }
  .setting-row { align-items: flex-start; flex-direction: column; gap: 10px; padding: 14px 0; }
  .setting-row select { width: 100%; }
  .switch { align-self: flex-end; margin-top: -34px; }
  .settings-save-row { flex-direction: column; align-items: stretch; }
  .settings-save-row .feature-primary { width: 100%; }
}
html[data-theme="light"] .brand-name span { color: #15181e; }

.about-value { color: #d8dde6; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
.about-link { color: #d8dde6; font-size: 10px; font-weight: 700; text-decoration: none; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.025); transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.about-link:hover { border-color: rgba(255,255,255,.2); background: rgba(255,255,255,.055); transform: translateY(-1px); }


/* KITGPT v3.3 — streamlined sidebar + larger Recent Chats area */
.sidebar {
  gap: 13px;
}
.primary-nav {
  gap: 3px;
}
.history-section {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-top: 2px;
}
.conversation-list {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 7px;
  gap: 2px;
  padding-right: 2px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.conversation-item {
  min-height: 34px;
  padding: 6px 7px;
  border-radius: 8px;
  font-size: 11px;
}
.conversation-item > span:first-child {
  flex: 0 0 auto;
  opacity: .7;
}
.conversation-item .delete-conv {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 6px;
}
.conversation-item:hover .delete-conv,
.conversation-item:focus-visible .delete-conv {
  opacity: 1;
  background: rgba(255,255,255,.035);
}
.sidebar-footer {
  flex: 0 0 auto;
  gap: 0;
  padding-top: 3px;
  border-top: 1px solid rgba(255,255,255,.055);
}
.profile-card {
  min-height: 48px;
}

@media (min-width: 781px) {
  .sidebar { padding-top: 18px; padding-bottom: 10px; }
  .brand-block { padding-bottom: 0; }
  .powered-pill { margin-top: 10px; padding-block: 8px; }
  .new-chat-btn { padding-block: 10px; }
  .nav-item { padding-block: 8px; }
  .section-kicker { padding-left: 4px; }
}

@media (max-width: 780px) {
  .sidebar {
    gap: 11px;
    width: min(88vw, 328px);
    max-width: calc(100vw - 34px);
  }
  .sidebar .new-chat-btn,
  .sidebar .nav-item,
  .sidebar .profile-card { min-height: 44px; }
  .history-section {
    flex: 1 1 auto;
    min-height: 0;
  }
  .conversation-list {
    margin-top: 6px;
    padding-right: 1px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }
  .conversation-item {
    min-height: 40px;
    padding: 7px 8px;
    font-size: 12px;
  }
  .conversation-item .delete-conv {
    opacity: .72;
    min-width: 30px;
    width: 30px;
    height: 30px;
    line-height: 30px;
  }
  .sidebar-footer {
    padding-bottom: max(2px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .sidebar {
    width: min(91vw, 320px);
    padding-left: 12px;
    padding-right: 12px;
  }
  .brand-name { font-size: 23px; }
  .powered-pill { margin-top: 9px; }
  .conversation-item { min-height: 39px; }
}


/* KITGPT v3.5 — ChatGPT-style collapsible desktop sidebar + chat search */
.app-shell {
  transition: grid-template-columns .22s cubic-bezier(.2,.75,.25,1);
}
.sidebar {
  min-width: 0;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.2,.75,.25,1), opacity .18s ease, padding .22s ease, border-color .22s ease;
}
.app-shell.sidebar-collapsed {
  grid-template-columns: 58px minmax(0, 1fr) 292px;
}
.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-102%);
  opacity: 0;
  pointer-events: none;
  padding-left: 0;
  padding-right: 0;
  border-right-color: transparent;
}
.topbar-nav-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  margin-right: 12px;
}
.topbar-nav-controls .icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}
.topbar-nav-controls svg,
.chat-search-input-wrap svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.desktop-nav-btn { display: grid; }
.chat-search-btn { display: grid; }

/* KITGPT v3.7 — compact desktop rail shown while the full sidebar is collapsed */
.sidebar-rail {
  position: fixed;
  z-index: 18;
  inset: 0 auto 0 0;
  width: 58px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 8px 12px;
  border-right: 1px solid var(--line);
  background: rgba(5,7,10,.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-shell.sidebar-collapsed .sidebar-rail { display: flex; }
.rail-top { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.rail-btn, .rail-profile-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: #c1c7d0;
  background: transparent;
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.rail-btn:hover, .rail-profile-btn:hover { background: rgba(255,255,255,.055); color: #fff; }
.rail-btn:active, .rail-profile-btn:active { transform: scale(.96); }
.rail-btn.active { color: #fff; background: rgba(227,27,47,.11); }
.rail-btn svg {
  width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.65;
  stroke-linecap: round; stroke-linejoin: round;
}
.rail-brand-btn { margin-bottom: 7px; }
.rail-brand-mark {
  position: relative;
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 10px;
  background: url('/kitgpt-logo.png') center / cover no-repeat;
  box-shadow: 0 0 15px rgba(227,27,47,.18);
  overflow: hidden;
}
.rail-brand-mark::before, .rail-brand-mark::after,
.rail-brand-mark > span { display: none !important; }
.rail-profile-btn { margin-top: auto; }
.rail-avatar {
  width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px;
  background: linear-gradient(145deg,#222833,#10131a); border: 1px solid var(--line);
  color: #fff; font-size: 11px; font-weight: 800;
}
.app-shell.sidebar-collapsed .topbar-nav-controls .desktop-nav-btn,
.app-shell.sidebar-collapsed .topbar-nav-controls .chat-search-btn { display: none; }
html[data-theme="light"] .sidebar-rail { background: rgba(247,248,250,.96); }
html[data-theme="light"] .rail-btn, html[data-theme="light"] .rail-profile-btn { color: #444b55; }
html[data-theme="light"] .rail-btn:hover, html[data-theme="light"] .rail-profile-btn:hover { background: rgba(0,0,0,.055); color: #11151a; }

.chat-search-screen {
  position: fixed;
  z-index: 95;
  inset: 0;
  display: grid;
  place-items: start center;
  padding: min(12vh, 110px) 18px 24px;
  background: rgba(0,0,0,.44);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}
.chat-search-modal {
  width: min(650px, 100%);
  max-height: min(680px, 76dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(13,16,22,.98);
  box-shadow: 0 34px 100px rgba(0,0,0,.58);
}
.chat-search-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border-bottom: 1px solid var(--line);
}
.chat-search-input-wrap {
  flex: 1;
  min-width: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.025);
  color: #858e9b;
}
.chat-search-input-wrap:focus-within {
  border-color: rgba(227,27,47,.44);
  box-shadow: 0 0 0 3px rgba(227,27,47,.06);
}
.chat-search-input-wrap input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.chat-search-input-wrap input::placeholder { color: #69727f; }
.search-close-btn {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
  color: #9ba3ae;
  cursor: pointer;
  font-size: 23px;
}
.search-close-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.chat-search-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
}
.chat-search-meta strong { font-size: 12px; }
.chat-search-meta span { color: var(--muted); font-size: 10px; }
.chat-search-results {
  min-height: 90px;
  overflow-y: auto;
  padding: 4px 9px 12px;
  overscroll-behavior: contain;
}
.chat-search-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 54px;
  padding: 8px 10px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #b9c0cb;
  text-align: left;
  cursor: pointer;
}
.chat-search-result:hover,
.chat-search-result.active {
  background: rgba(255,255,255,.055);
  color: #fff;
}
.chat-search-result-icon { color: var(--red); font-size: 18px; }
.chat-search-result-copy { flex: 1; min-width: 0; }
.chat-search-result-copy strong,
.chat-search-result-copy small { display: block; }
.chat-search-result-copy strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.chat-search-result-copy small { margin-top: 3px; color: #656e7b; font-size: 9px; }
.chat-search-result-arrow { opacity: .5; }
.chat-search-empty { padding: 28px 16px 34px; color: #737c89; text-align: center; font-size: 12px; }

@media (max-width: 1180px) and (min-width: 781px) {
  .app-shell.sidebar-collapsed { grid-template-columns: 58px minmax(0,1fr); }
}

@media (max-width: 780px) {
  .sidebar-rail { display: none !important; }
  .desktop-nav-btn { display: none !important; }
  .app-shell.sidebar-collapsed .sidebar {
    opacity: 1;
    pointer-events: auto;
    padding-left: 14px;
    padding-right: 14px;
    border-right-color: var(--line);
  }
  .topbar-nav-controls { gap: 5px; margin-right: 7px; }
  .topbar-nav-controls .icon-btn { width: 38px; height: 38px; flex-basis: 38px; margin-right: 0; }
  .topbar-nav-controls .mobile-only { display: grid; }
  .chat-search-screen {
    place-items: end center;
    padding: 10px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .chat-search-modal {
    width: 100%;
    max-height: 86dvh;
    border-radius: 20px 20px 14px 14px;
  }
  .chat-search-head { padding: 10px; }
  .chat-search-input-wrap { height: 48px; }
  .chat-search-result { min-height: 58px; }
}

@media (max-width: 520px) {
  .topbar-nav-controls { margin-right: 5px; gap: 4px; }
  .topbar-nav-controls .icon-btn { width: 36px; height: 36px; flex-basis: 36px; border-radius: 10px; }
  .topbar-copy h1 { max-width: clamp(90px, 28vw, 150px); }
  .chat-search-modal { max-height: 88dvh; }
}

html[data-theme="light"] .chat-search-modal { background: rgba(251,251,252,.99); }
html[data-theme="light"] .chat-search-input-wrap { background: rgba(0,0,0,.025); }

/* KITGPT v3.6 — compact Recent Chats spacing on desktop + mobile */
.history-section {
  justify-content: flex-start;
}
.conversation-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 5px;
  gap: 1px;
  overflow-y: auto;
  overflow-x: hidden;
}
.conversation-item {
  flex: 0 0 auto;
  margin: 0;
  min-height: 34px;
  padding: 6px 7px;
  line-height: 1.2;
}
.conversation-empty {
  flex: 0 0 auto;
}

@media (max-width: 780px) {
  .conversation-list {
    margin-top: 4px;
    gap: 1px;
  }
  .conversation-item {
    min-height: 38px;
    padding: 7px 8px;
  }
}

@media (max-width: 430px) {
  .conversation-list { gap: 0; }
  .conversation-item {
    min-height: 37px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

/* KITGPT v3.8 — mobile sidebar open/close specificity hotfix */
@media (max-width: 780px) {
  /* The desktop collapsed selector has higher specificity than .sidebar.open.
     Explicit mobile states ensure the drawer always follows the menu button. */
  .app-shell.sidebar-collapsed .sidebar,
  .app-shell:not(.sidebar-collapsed) .sidebar {
    transform: translate3d(-102%, 0, 0);
    visibility: hidden;
    opacity: 1;
    pointer-events: none;
  }

  .app-shell.sidebar-collapsed .sidebar.open,
  .app-shell:not(.sidebar-collapsed) .sidebar.open,
  .sidebar.open {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  #mobileMenuBtn,
  #mobileMenuClose {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

/* KITGPT v3.9 — cleaner mobile header + Search Chats inside drawer */
.mobile-sidebar-search { display: none; }

@media (max-width: 780px) {
  /* Keep the mobile header minimal: one clean drawer control only. */
  #chatSearchBtn { display: none !important; }
  .topbar-nav-controls {
    gap: 0;
    margin-right: 8px;
  }
  #mobileMenuBtn {
    width: 42px !important;
    height: 42px !important;
    flex-basis: 42px !important;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #e8ebf0;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
  }
  #mobileMenuBtn:hover,
  #mobileMenuBtn:focus-visible {
    border: 0;
    background: rgba(255,255,255,.055);
    outline: none;
  }
  #mobileMenuBtn:active {
    transform: scale(.96);
    background: rgba(255,255,255,.075);
  }
  #mobileMenuBtn svg {
    width: 23px;
    height: 23px;
    stroke-width: 1.7;
  }

  /* Search lives in the opened drawer on phones instead of the top bar. */
  .mobile-sidebar-search {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 13px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #aeb6c2;
    font: inherit;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-sidebar-search:hover,
  .mobile-sidebar-search:focus-visible {
    color: #fff;
    background: rgba(255,255,255,.045);
    outline: none;
  }
  .mobile-sidebar-search:active { background: rgba(227,27,47,.10); }
  .mobile-sidebar-search svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  /* Slightly calmer spacing around the drawer's primary actions. */
  .sidebar .new-chat-btn { margin-bottom: 2px; }
  .sidebar .mobile-sidebar-search { margin-bottom: 2px; }
}

@media (max-width: 430px) {
  .topbar-nav-controls { margin-right: 6px; }
  #mobileMenuBtn {
    width: 40px !important;
    height: 40px !important;
    flex-basis: 40px !important;
  }
}

html[data-theme="light"] #mobileMenuBtn { color: #242a31; }
html[data-theme="light"] #mobileMenuBtn:hover,
html[data-theme="light"] #mobileMenuBtn:focus-visible { background: rgba(0,0,0,.055); }
html[data-theme="light"] .mobile-sidebar-search { color: #59616c; }
html[data-theme="light"] .mobile-sidebar-search:hover,
html[data-theme="light"] .mobile-sidebar-search:focus-visible { color: #11151a; background: rgba(0,0,0,.05); }


/* KITGPT v4.0 — uploaded brand icon + ChatGPT-style mobile New Chat control */
@media (max-width: 780px) {
  #chatSearchBtn { display: none !important; }
  .topbar-nav-controls { gap: 3px; margin-right: 8px; }

  #mobileMenuBtn,
  #mobileNewChatBtn {
    width: 40px !important;
    height: 40px !important;
    flex: 0 0 40px !important;
    margin: 0 !important;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #edf0f4;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #mobileMenuBtn:hover,
  #mobileMenuBtn:focus-visible,
  #mobileNewChatBtn:hover,
  #mobileNewChatBtn:focus-visible {
    border: 0;
    background: rgba(255,255,255,.055);
    outline: none;
  }

  #mobileMenuBtn:active,
  #mobileNewChatBtn:active {
    transform: scale(.95);
    background: rgba(255,255,255,.075);
  }

  #mobileMenuBtn svg,
  #mobileNewChatBtn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #mobileNewChatBtn { display: grid !important; }
}

@media (max-width: 430px) {
  .topbar-nav-controls { gap: 2px; margin-right: 6px; }
  #mobileMenuBtn,
  #mobileNewChatBtn {
    width: 38px !important;
    height: 38px !important;
    flex-basis: 38px !important;
  }
}

html[data-theme="light"] #mobileNewChatBtn { color: #242a31; }
html[data-theme="light"] #mobileNewChatBtn:hover,
html[data-theme="light"] #mobileNewChatBtn:focus-visible { background: rgba(0,0,0,.055); }

/* KITGPT v4.5 — ChatGPT-inspired response experience + theme hardening */

/* Keep the legacy live region for accessibility, but remove the old visual status
   line from above the composer. The visible working state now lives in-thread. */
.typing-status {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ChatGPT-like in-thread "Thinking / Responding" state */
.message.assistant:has(.assistant-working) .message-meta { margin-bottom: 5px; }
.assistant-working {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #b7bec8;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.08px;
  user-select: none;
}
.assistant-working-orb {
  position: relative;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(255,255,255,.035);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.018);
}
.assistant-working-orb::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: #ee3a4d;
  border-right-color: rgba(238,58,77,.28);
  animation: kitgptThinkingSpin .9s linear infinite;
}
.assistant-working-orb i {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #ee3a4d;
  box-shadow: 0 0 9px rgba(238,58,77,.55);
  animation: kitgptThinkingGlow 1.3s ease-in-out infinite;
}
.assistant-working-label {
  display: inline-flex;
  align-items: baseline;
  background: linear-gradient(90deg, #858d98 0%, #e9edf2 45%, #858d98 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: kitgptThinkingShimmer 1.9s ease-in-out infinite;
}
.assistant-working-dots { display: inline-flex; width: 17px; margin-left: 1px; }
.assistant-working-dots b { font: inherit; opacity: .3; animation: kitgptThinkingDot 1.15s ease-in-out infinite; }
.assistant-working-dots b:nth-child(2) { animation-delay: .14s; }
.assistant-working-dots b:nth-child(3) { animation-delay: .28s; }
@keyframes kitgptThinkingSpin { to { transform: rotate(360deg); } }
@keyframes kitgptThinkingGlow { 0%,100% { opacity: .45; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@keyframes kitgptThinkingShimmer { 0% { background-position: 100% 50%; } 100% { background-position: -100% 50%; } }
@keyframes kitgptThinkingDot { 0%, 65%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-1px); } }

/* Cleaner, neutral response mode control. */
.response-mode-btn {
  min-width: 104px;
  border-radius: 12px;
  background: rgba(255,255,255,.045);
  border-color: rgba(255,255,255,.10);
  color: #e8ebef;
  font-weight: 670;
  letter-spacing: 0;
  box-shadow: none;
}
.response-mode-btn:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.15); }
.response-mode-picker.open .response-mode-btn { background: rgba(255,255,255,.075); border-color: rgba(255,255,255,.17); }
.response-mode-btn-icon,
.response-mode-picker.thinking-active .response-mode-btn-icon { color: currentColor; opacity: .9; }
.response-mode-chevron { font-size: 12px; color: #8c949f; }

.response-mode-menu {
  left: 0;
  width: 260px;
  padding: 10px;
  border-radius: 18px;
  border-color: rgba(255,255,255,.11);
  background: rgba(24,26,31,.985);
  box-shadow: 0 18px 55px rgba(0,0,0,.44), 0 2px 8px rgba(0,0,0,.22);
}
.response-mode-menu-head { padding: 4px 4px 10px; gap: 4px; }
.response-mode-menu-head > span { font-size: 12px; font-weight: 690; letter-spacing: -.08px; }
.response-mode-menu-head small { font-size: 10px; line-height: 1.35; color: #939aa4; }
.response-mode-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.055);
}
.response-mode-option {
  min-height: 42px;
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 10px;
  color: #b9c0c9;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.response-mode-option:hover,
.response-mode-option:focus-visible { background: rgba(255,255,255,.055); color: #f0f2f5; }
.response-mode-option.selected {
  background: #f5f5f5;
  color: #111318;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.response-mode-option-icon {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  color: currentColor !important;
  font-size: 12px;
}
.response-mode-option-copy { display: block; }
.response-mode-option-copy strong { font-size: 11px; color: inherit; font-weight: 690; }
.response-mode-check { display: none; }

/* Better composer proportions on both desktop and phones. */
@media (min-width: 781px) {
  .composer { padding: 8px 9px; gap: 7px; }
  .response-mode-btn { height: 40px; }
  .composer-icon, .send-btn { width: 40px; height: 40px; flex-basis: 40px; }
  .composer textarea { min-height: 40px; padding-top: 10px; }
}
@media (max-width: 780px) {
  .assistant-working { font-size: 12.5px; gap: 9px; }
  .assistant-working-orb { width: 18px; height: 18px; flex-basis: 18px; }
  .response-mode-menu { width: min(260px, calc(100vw - 18px)); }
}
@media (max-width: 430px) {
  .composer {
    display: grid;
    grid-template-columns: auto minmax(0,1fr) auto;
    align-items: end;
    gap: 5px;
  }
  .response-mode-picker { grid-column: 1; grid-row: 1; }
  .composer textarea { grid-column: 2; grid-row: 1; }
  .send-btn { grid-column: 3; grid-row: 1; }
  .response-mode-btn { min-width: 88px; max-width: 98px; height: 36px; padding-inline: 7px; }
  .response-mode-menu {
    position: fixed;
    left: 9px;
    right: 9px;
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: auto;
    border-radius: 18px;
  }
}

/* Theme contrast hardening: every interactive/selected state stays readable. */
::selection { background: rgba(227,27,47,.38); color: #fff; }
.send-btn, .feature-primary, .top-signin-btn, .message.user .message-content { color: #fff; }

html[data-theme="light"] ::selection { background: #c9dcff; color: #0d1117; }
html[data-theme="light"] body,
html[data-theme="light"] button,
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select { color: #171a20; }
html[data-theme="light"] .message-content { color: #20242a; }
html[data-theme="light"] .message-meta { color: #737b86; }
html[data-theme="light"] .message-avatar { color: #525a65; }
html[data-theme="light"] .message.assistant .message-avatar { color: #c21e31; background: #fff; }
html[data-theme="light"] .message-content pre { background: #f3f4f6; color: #20242a; border-color: rgba(20,28,38,.10); }
html[data-theme="light"] .message-content :not(pre) > code { background: rgba(20,28,38,.065); color: #171a20; }
html[data-theme="light"] .composer textarea { background: transparent; color: #15181e; }
html[data-theme="light"] .composer textarea::placeholder { color: #7a838f; }
html[data-theme="light"] .composer-icon { color: #59616c; }
html[data-theme="light"] .send-btn,
html[data-theme="light"] .feature-primary,
html[data-theme="light"] .top-signin-btn,
html[data-theme="light"] .message.user .message-content { color: #fff; }
html[data-theme="light"] .response-mode-btn {
  background: rgba(0,0,0,.035);
  border-color: rgba(20,28,38,.11);
  color: #30363f;
}
html[data-theme="light"] .response-mode-btn:hover,
html[data-theme="light"] .response-mode-picker.open .response-mode-btn { background: rgba(20,28,38,.06); border-color: rgba(20,28,38,.16); }
html[data-theme="light"] .response-mode-menu {
  background: rgba(255,255,255,.99);
  border-color: rgba(20,28,38,.11);
  box-shadow: 0 18px 48px rgba(16,24,32,.16), 0 2px 8px rgba(16,24,32,.06);
}
html[data-theme="light"] .response-mode-menu-head > span { color: #171a20; }
html[data-theme="light"] .response-mode-menu-head small { color: #707985; }
html[data-theme="light"] .response-mode-segment { background: #eceef1; border-color: rgba(20,28,38,.055); }
html[data-theme="light"] .response-mode-option { color: #555d67; }
html[data-theme="light"] .response-mode-option:hover,
html[data-theme="light"] .response-mode-option:focus-visible { background: rgba(255,255,255,.7); color: #171a20; }
html[data-theme="light"] .response-mode-option.selected { background: #fff; color: #111318; box-shadow: 0 1px 4px rgba(20,28,38,.12); }
html[data-theme="light"] .assistant-working { color: #555e69; }
html[data-theme="light"] .assistant-working-orb { border-color: rgba(20,28,38,.13); background: rgba(20,28,38,.025); }
html[data-theme="light"] .assistant-working-label {
  background: linear-gradient(90deg, #68717d 0%, #171a20 45%, #68717d 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
html[data-theme="light"] .conversation-item { color: #5c6570; }
html[data-theme="light"] .conversation-item:hover,
html[data-theme="light"] .conversation-item.active { color: #171a20; background: rgba(20,28,38,.055); }
html[data-theme="light"] .nav-item:hover { color: #171a20; }
html[data-theme="light"] .settings-nav-item { color: #5d6671; }
html[data-theme="light"] .settings-nav-item:hover { background: rgba(20,28,38,.05); color: #171a20; }
html[data-theme="light"] .settings-nav-item.active { background: rgba(227,27,47,.075); color: #171a20; }
html[data-theme="light"] .secondary-btn:hover,
html[data-theme="light"] .ghost-icon-btn:hover,
html[data-theme="light"] .profile-menu button:hover,
html[data-theme="light"] .search-close-btn:hover { color: #171a20; background: rgba(20,28,38,.055); }
html[data-theme="light"] .chat-search-result { color: #515a66; }
html[data-theme="light"] .chat-search-result:hover,
html[data-theme="light"] .chat-search-result.active { color: #171a20; background: rgba(20,28,38,.055); }
html[data-theme="light"] .rail-btn.active { color: #171a20; background: rgba(227,27,47,.075); }
html[data-theme="light"] .about-value,
html[data-theme="light"] .about-link { color: #3e4650; }
html[data-theme="light"] .about-link { background: rgba(20,28,38,.025); }
html[data-theme="light"] .about-link:hover { background: rgba(20,28,38,.055); border-color: rgba(20,28,38,.16); }
html[data-theme="light"] .auth-tab.active { color: #171a20; background: rgba(227,27,47,.09); }
html[data-theme="light"] .form-grid input,
html[data-theme="light"] .form-grid textarea,
html[data-theme="light"] .workspace-create input,
html[data-theme="light"] .workspace-create textarea,
html[data-theme="light"] .settings-field input,
html[data-theme="light"] .settings-field textarea,
html[data-theme="light"] .search-box input { background: #fff; color: #171a20; }

@media (prefers-reduced-motion: reduce) {
  .assistant-working-orb::before,
  .assistant-working-orb i,
  .assistant-working-label,
  .assistant-working-dots b { animation: none !important; }
}

/* ================================================================
   V4.6 — ChatGPT-style + menu and GPT Image generation mode
   ================================================================ */
.composer-plus-wrap { position: relative; flex: 0 0 auto; align-self: flex-end; }
.composer-plus-wrap .composer-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-basis: 40px;
  border-radius: 12px;
  font-size: 23px;
  line-height: 1;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.composer-plus-wrap.open .composer-icon,
.composer-plus-wrap .composer-icon:hover { background: rgba(255,255,255,.065); color: #eef1f5; }
.composer-plus-wrap .composer-icon:active { transform: scale(.96); }
.composer-plus-wrap .composer-icon:focus-visible { outline: 0; box-shadow: 0 0 0 3px rgba(227,27,47,.11); color: #fff; }

.composer-plus-menu {
  position: absolute;
  z-index: 95;
  left: 0;
  bottom: calc(100% + 10px);
  width: 285px;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 17px;
  background: rgba(24,26,31,.985);
  box-shadow: 0 18px 55px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.2);
  backdrop-filter: blur(20px);
  animation: composerPlusIn .14s ease-out;
}
@keyframes composerPlusIn { from { opacity: 0; transform: translateY(7px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
.composer-plus-option {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0,1fr);
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #f0f2f5;
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.composer-plus-option:hover,
.composer-plus-option:focus-visible { outline: 0; background: rgba(255,255,255,.06); }
.composer-plus-option-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(227,27,47,.18), rgba(120,20,150,.16));
  border: 1px solid rgba(255,92,117,.18);
  color: #ff6a7a;
  font-size: 15px;
}
.composer-plus-option-copy { min-width: 0; display: grid; gap: 3px; }
.composer-plus-option-copy strong { font-size: 12px; font-weight: 720; color: inherit; }
.composer-plus-option-copy small { font-size: 9.5px; line-height: 1.35; color: #929aa5; }

.image-mode-banner {
  width: min(880px,100%);
  min-height: 38px;
  margin: 0 auto 7px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 6px 10px;
  border: 1px solid rgba(227,27,47,.17);
  border-radius: 13px;
  background: linear-gradient(90deg, rgba(227,27,47,.085), rgba(122,49,160,.05));
  color: #dfe4eb;
}
.image-mode-banner.hidden { display: none; }
.image-mode-banner-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  border-radius: 8px;
  background: rgba(227,27,47,.12);
  color: #ff6072;
  font-size: 11px;
}
.image-mode-banner > span:nth-child(2) { min-width: 0; display: flex; align-items: baseline; gap: 7px; flex: 1; }
.image-mode-banner strong { font-size: 10.5px; font-weight: 720; }
.image-mode-banner small { color: #89919d; font-size: 9px; }
.image-mode-banner button {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8d95a0;
  cursor: pointer;
  font-size: 17px;
}
.image-mode-banner button:hover { background: rgba(255,255,255,.055); color: #fff; }
.composer.image-generation-mode { border-color: rgba(227,27,47,.27); }
.composer.image-generation-mode .response-mode-picker { display: none; }
.composer.image-generation-mode textarea::placeholder { color: #777f8b; }

.generated-image-card {
  width: min(620px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.095);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  box-shadow: 0 12px 38px rgba(0,0,0,.18);
}
.generated-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
  object-fit: contain;
  background: rgba(0,0,0,.18);
}
.generated-image-actions {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px 7px 12px;
  border-top: 1px solid rgba(255,255,255,.075);
}
.generated-image-actions span { color: #858e9a; font-size: 9.5px; }
.generated-image-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 29px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.105);
  border-radius: 9px;
  background: rgba(255,255,255,.045);
  color: #e8ebef;
  text-decoration: none;
  font-size: 9.5px;
  font-weight: 650;
}
.generated-image-download:hover { background: rgba(255,255,255,.075); }
.generated-image-prompt {
  padding: 0 12px 10px;
  color: #747d89;
  font-size: 9.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.assistant-working.image-working .assistant-working-orb { border-color: rgba(205,80,232,.28); }
.assistant-working.image-working .assistant-working-orb i { background: linear-gradient(90deg, #e31b2f, #a74fd0); }

html[data-theme="light"] .composer-plus-wrap.open .composer-icon,
html[data-theme="light"] .composer-plus-wrap .composer-icon:hover { background: rgba(20,28,38,.06); color: #171a20; }
html[data-theme="light"] .composer-plus-menu {
  background: rgba(255,255,255,.99);
  border-color: rgba(20,28,38,.11);
  box-shadow: 0 18px 48px rgba(16,24,32,.16), 0 2px 8px rgba(16,24,32,.06);
}
html[data-theme="light"] .composer-plus-option { color: #171a20; }
html[data-theme="light"] .composer-plus-option:hover,
html[data-theme="light"] .composer-plus-option:focus-visible { background: rgba(20,28,38,.05); }
html[data-theme="light"] .composer-plus-option-copy small { color: #6f7884; }
html[data-theme="light"] .image-mode-banner { background: linear-gradient(90deg, rgba(227,27,47,.055), rgba(122,49,160,.025)); border-color: rgba(184,31,51,.15); color: #242931; }
html[data-theme="light"] .image-mode-banner small { color: #717a86; }
html[data-theme="light"] .image-mode-banner button:hover { background: rgba(20,28,38,.05); color: #171a20; }
html[data-theme="light"] .generated-image-card { background: #fff; border-color: rgba(20,28,38,.10); box-shadow: 0 10px 30px rgba(20,28,38,.08); }
html[data-theme="light"] .generated-image { background: #f4f5f7; }
html[data-theme="light"] .generated-image-actions { border-color: rgba(20,28,38,.08); }
html[data-theme="light"] .generated-image-actions span,
html[data-theme="light"] .generated-image-prompt { color: #6e7783; }
html[data-theme="light"] .generated-image-download { border-color: rgba(20,28,38,.11); background: rgba(20,28,38,.035); color: #20252c; }
html[data-theme="light"] .generated-image-download:hover { background: rgba(20,28,38,.065); }

@media (max-width: 780px) {
  .composer-plus-menu {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    border-radius: 18px;
  }
  .image-mode-banner { width: 100%; margin-bottom: 6px; }
  .generated-image-card { width: 100%; max-width: 560px; }
}

@media (max-width: 430px) {
  .composer {
    grid-template-columns: auto auto minmax(0,1fr) auto;
  }
  .composer-plus-wrap { grid-column: 1; grid-row: 1; }
  .response-mode-picker { grid-column: 2; grid-row: 1; }
  .composer textarea { grid-column: 3; grid-row: 1; }
  .send-btn { grid-column: 4; grid-row: 1; }
  .composer.image-generation-mode { grid-template-columns: auto minmax(0,1fr) auto; }
  .composer.image-generation-mode .composer-plus-wrap { grid-column: 1; }
  .composer.image-generation-mode textarea { grid-column: 2; }
  .composer.image-generation-mode .send-btn { grid-column: 3; }
  .composer-plus-wrap .composer-icon { width: 36px; height: 36px; flex-basis: 36px; }
  .image-mode-banner > span:nth-child(2) { display: grid; gap: 0; }
  .image-mode-banner small { font-size: 8px; }
  .generated-image-actions { min-height: 39px; }
}

@media (max-width: 370px) {
  .response-mode-btn { min-width: 36px; width: 36px; padding-inline: 0; }
  .response-mode-btn-label, .response-mode-chevron { display: none; }
}

/* ================================================================
   V4.8 — ChatGPT-style message Edit / Retry actions + KITGPT Image branding
   ================================================================ */
.message-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 29px;
  margin-top: 6px;
  opacity: .72;
  transition: opacity .16s ease;
}
.message:hover .message-actions,
.message:focus-within .message-actions { opacity: 1; }
.message.user .message-actions { justify-content: flex-end; padding-right: 2px; }
.message.assistant .message-actions { justify-content: flex-start; }
.message-actions.hidden { display: none; }
.message-action-btn {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: #8e96a2;
  font: inherit;
  font-size: 10px;
  font-weight: 650;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.message-action-btn:hover,
.message-action-btn:focus-visible {
  outline: 0;
  color: #eef1f5;
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.07);
}
.message-action-btn:active { transform: scale(.97); }
.message-action-btn:disabled { opacity: .38; cursor: default; transform: none; }
.message-action-icon { font-size: 12px; line-height: 1; }

.message.user .message-content.editing {
  width: min(680px, 78vw);
  min-width: min(460px, 70vw);
  padding: 10px;
  border-radius: 15px;
  background: rgba(22,25,31,.98);
  border-color: rgba(255,255,255,.12);
  box-shadow: 0 12px 34px rgba(0,0,0,.22);
}
.message-edit-textarea {
  display: block;
  width: 100%;
  min-height: 70px;
  max-height: 220px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f2f4f7;
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
}
.message-edit-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
}
.message-edit-controls button {
  min-height: 31px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.10);
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.message-edit-cancel { background: rgba(255,255,255,.035); color: #d5dae1; }
.message-edit-cancel:hover { background: rgba(255,255,255,.07); }
.message-edit-submit { background: #f1f3f5; color: #15181d; border-color: transparent !important; }
.message-edit-submit:hover { background: #fff; }
.message-edit-controls button:disabled { opacity: .55; cursor: default; }

html[data-theme="light"] .message-action-btn { color: #747d89; }
html[data-theme="light"] .message-action-btn:hover,
html[data-theme="light"] .message-action-btn:focus-visible {
  color: #1f242b;
  background: rgba(20,28,38,.055);
  border-color: rgba(20,28,38,.07);
}
html[data-theme="light"] .message.user .message-content.editing {
  background: #fff;
  border-color: rgba(20,28,38,.12);
  box-shadow: 0 12px 30px rgba(20,28,38,.10);
}
html[data-theme="light"] .message-edit-textarea { color: #20242a; }
html[data-theme="light"] .message-edit-cancel { background: rgba(20,28,38,.04); color: #4e5661; border-color: rgba(20,28,38,.10); }
html[data-theme="light"] .message-edit-cancel:hover { background: rgba(20,28,38,.075); }
html[data-theme="light"] .message-edit-submit { background: #171a20; color: #fff; }
html[data-theme="light"] .message-edit-submit:hover { background: #000; }

@media (max-width: 780px) {
  .message-actions { opacity: 1; margin-top: 5px; }
  .message-action-btn { min-height: 32px; padding: 0 9px; font-size: 10.5px; }
  .message.user .message-content.editing { width: min(100%, 620px); min-width: 0; }
}

@media (max-width: 430px) {
  .message.user .message-content.editing { width: 100%; }
  .message-edit-textarea { font-size: 13.5px; }
  .message-edit-controls { gap: 6px; }
  .message-edit-controls button { min-height: 34px; padding: 0 10px; }
}
