@import url("fonts.css");

/* Dragon Agent — reference layout.
   Theme tokens, shared controls, navigation, chat, dialogs, then breakpoints. */
:root {
    color-scheme: light;
    --bg: #fbfdff;
    --sidebar: #eaf0f8;
    --surface: #ffffff;
    --surface-hover: #edf4ff;
    --border: #e1eaf8;
    --text: #101d3c;
    --muted: #607194;
    --subtle: #8192b3;
    --accent: #245eff;
    --accent-soft: #eaf2ff;
    --shadow: 0 15px 42px #264f9610;
    --sidebar-width: clamp(272px, 20vw, 336px);
    --navigation-width: var(--sidebar-width);
    --font: "IBM Plex Sans Thai", "Noto Sans Thai", Tahoma, system-ui, sans-serif;
}
:root[data-theme=dark] {
    color-scheme: dark;
    --bg: #101a2c;
    --sidebar: #152037;
    --surface: #1b2941;
    --surface-hover: #233754;
    --border: #30425f;
    --text: #eff5ff;
    --muted: #b0c1db;
    --subtle: #90a4c3;
    --accent: #80b1ff;
    --accent-soft: #20395f;
    --shadow: 0 15px 42px #0003;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
button, input, textarea { font: inherit; }
button { border: 0; background: none; color: inherit; cursor: pointer; transition: background .18s, box-shadow .18s, transform .18s; }
button:disabled { cursor: default; opacity: .55; }
a { color: inherit; text-decoration: none; }
button, input, textarea, a { -webkit-tap-highlight-color: transparent; outline-offset: 4px; }
:focus-visible { outline: 2px solid var(--accent); }
[hidden] { display: none !important; }
.icon { width: 21px; height: 21px; flex-shrink: 0; vertical-align: middle; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px; color: var(--muted); }
.icon-button:hover { background: var(--surface-hover); color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 100; background: #245eff; color: #fff; padding: 12px; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.mobile-nav { display: none; }
.history-popover { display: none; }

/* Sidebar: only real session history is shown; no sample identities or records. */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--navigation-width); display: flex; flex-direction: column; padding: 22px 22px 0; border-right: 1px solid var(--border); background: var(--sidebar); transition: width 240ms cubic-bezier(.2,.75,.25,1), padding 240ms cubic-bezier(.2,.75,.25,1), box-shadow 240ms ease; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin: 0 0 30px; }
.brand { display: flex; align-items: center; gap: 7px; min-width: 0; line-height: 1.15; font: 700 clamp(19px, 1.45vw, 24px)/1.15 var(--font); letter-spacing: -.8px; white-space: nowrap; }
.brand img { width: 49px; height: 55px; flex-shrink: 0; }
.brand-light { font-weight: 400; color: var(--muted); }
.brand small { display: block; margin-top: 6px; color: var(--subtle); font-size: 9px; font-weight: 500; letter-spacing: 2.7px; }
.sidebar-toggle { width: 36px; height: 40px; }
.sidebar-toggle .icon { width: 21px; }
.rail-history-toggle { display: none; }
.new-chat { flex-shrink: 0; height: 57px; display: flex; align-items: center; gap: 15px; padding: 0 18px; border: 1px solid #2575ff; border-radius: 16px; background: linear-gradient(110deg, #2455ff, #328cff); color: #fff; font-weight: 600; box-shadow: 0 6px 14px #2462ff20; }
.new-chat:hover { background: linear-gradient(110deg, #1545ed, #227cf5); box-shadow: 0 8px 18px #2462ff30; }
.new-chat kbd { margin-left: auto; padding: 1px 7px; border: 1px solid #ffffff40; border-radius: 6px; background: #ffffff10; color: #e4efff; font: 12px/1.8 var(--font); }
.new-chat { margin-bottom: 26px; }
.history-label { display: flex; justify-content: space-between; padding: 0 10px; margin-bottom: 8px; color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.history-label > span { display: none; }
.history { min-height: 50px; flex: 1; overflow-y: auto; scrollbar-width: thin; }
.history-empty { padding: 8px 8px; margin: 0; color: var(--subtle); font-size: .875rem; white-space: pre-line; line-height: 1.9; }
.history-row { position:relative; margin-bottom:2px; }.history-item { position: relative; display: flex; align-items: center; width: 100%; min-height: 40px; padding: 9px 45px 9px 10px; border-radius: 9px; text-align: left; color: var(--muted); }
.history-item:hover, .history-item.active { background: var(--surface-hover); color: var(--text); }
.history-delete { position:absolute;top:50%;right:7px;min-width:31px;padding:4px 5px;border-radius:6px;color:#b24f58;font-size:.6875rem;font-weight:700;line-height:1;opacity:0;transform:translateY(-50%);transition:opacity .16s ease,background .16s ease; }.history-row:hover .history-delete,.history-row:focus-within .history-delete{opacity:1}.history-delete:hover{background:#fff0f1;color:#a73440}
.history-copy { min-width: 0; flex: 1; }
.history-title { display: block; color: var(--text); font-size: .8125rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-retry { color: var(--accent); font-size: .8125rem; padding: 12px 9px; }
.sidebar-bottom { padding-top: 7px; margin-top: auto; }
.workspace-card { display: flex; align-items: center; gap: 11px; text-align: left; width: 100%; margin: 13px 0 8px; padding: 14px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--accent-soft); box-shadow: 0 3px 12px #254c8910; }
.workspace-card:hover { box-shadow: 0 5px 15px #2563eb24; }
.workspace-card strong { display: block; color: var(--accent); font-size: .875rem; font-weight: 600; }
.workspace-card small { display: block; color: var(--muted); font-size: .75rem; line-height: 1.7; }
.workspace-card > .icon { margin-left: auto; width: 17px; color: var(--accent); }
.module-card-icon { display: grid; place-items: center; width: 40px; height: 44px; flex-shrink: 0; color: var(--accent); background: var(--surface); border-radius: 10px; }
.profile-button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 17px 3px 22px; text-align: left; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: linear-gradient(135deg, #d9eaff, #b8d7ff); color: #1c4fab; border: 2px solid var(--surface); font: 600 15px var(--font); }
.profile-info { min-width: 0; flex: 1; }
.profile-info strong { display: block; font-size: .875rem; font-weight: 600; }
.profile-info small { display: block; color: var(--subtle); font-size: .75rem; }
.profile-button > .icon { width: 18px; color: var(--subtle); }

/* The wave asset is abstract geometry; it never obstructs controls or messages. */
.workspace { position: relative; isolation: isolate; display: flex; flex-direction: column; margin-left: var(--navigation-width); height: 100%; min-width: 0; transition: margin-left 240ms cubic-bezier(.2,.75,.25,1); }
.workspace-waves { position: absolute; z-index: -1; inset: 80px 0 auto; height: 530px; pointer-events: none; background: url('../img/waves.svg') center top / 100% 100% no-repeat; opacity: .85; }
:root[data-theme=dark] .workspace-waves { opacity: .045; }
.has-conversation .workspace-waves { opacity: .22; }
:root[data-theme=dark] .has-conversation .workspace-waves { opacity: .02; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-shrink: 0; min-height: 80px; padding: 15px 28px 15px 22px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 16px; min-width: 0; }
.header-logo { background: var(--accent-soft); border-radius: 12px; flex-shrink: 0; }
.header-brand strong { display: block; font: 650 1.125rem/1.6 var(--font); }
.header-brand > span { display: block; color: var(--subtle); font-size: .75rem; }
.model-select, .composer-model { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; padding: 7px 14px; border: 1px solid var(--border); border-radius: 17px; background: var(--bg); font: .875rem/1.5 var(--font); white-space: nowrap; }
.model-select .icon:first-child, .composer-model .icon:first-child { color: var(--accent); width: 18px; height: 18px; }
.model-select .icon:last-child, .composer-model .icon:last-child { color: var(--muted); width: 15px; height: 15px; }
.model-select:hover, .composer-model:hover { border-color: var(--accent); background: var(--surface-hover); }
.connection-status { display: inline-flex; align-items: center; gap: 9px; padding: 5px 12px; border-radius: 20px; color: var(--muted); background: var(--surface-hover); font-size: .8125rem; white-space: nowrap; }
.connection-dot { width: 8px; height: 8px; background: var(--subtle); border-radius: 50%; }
.connection-status[data-state=ready] { color: #13875d; background: #e4f8f1; }
.connection-status[data-state=ready] .connection-dot { background: #10b981; box-shadow: 0 0 0 4px #10b98113; }
.connection-status[data-state=error] { color: #b64525; background: #fff0e8; }
.connection-status[data-state=error] .connection-dot { background: #e6774d; }
.header-profile { padding: 0; border-radius: 50%; }
.header-profile:hover { box-shadow: 0 0 0 3px var(--accent-soft); }
.header-admin { color: var(--muted); }
.header-admin:hover { color: var(--accent); background: var(--accent-soft); }

/* Welcome and messages share one scrolling region; the composer stays visible. */
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--border) transparent; display: flex; flex-direction: column; }
.welcome { position: relative; flex-shrink: 0; width: 100%; max-width: 1320px; padding: 28px 52px 16px; margin: auto; text-align: center; }
.welcome-emblem { width: 132px; height: 132px; margin: 0 auto 3px; }
.welcome-emblem img { display: block; width: 100%; height: 100%; filter: drop-shadow(0 8px 12px #297dff0a); }
.eyebrow { color: #7898d5; font: 600 .6875rem/1.7 var(--font); letter-spacing: 4px; }
.welcome h1 { margin: 11px 0 13px; font-size: clamp(2.125rem, 3.6vw, 3.75rem); font-weight: 750; line-height: 1.4; letter-spacing: -.045em; }
.welcome h1 > span { color: #245eff; }
:root[data-theme=dark] .welcome h1 > span { color: var(--accent); }
.welcome-description { margin: 0; color: var(--muted); font-size: 1.125rem; line-height: 1.65; }
.welcome-aside { position: absolute; top: 53px; right: 50px; margin: 0; color: #7d9bce; font-size: 1.0625rem; line-height: 1.6; font-style: italic; text-align: left; transform: rotate(-8deg); }
.welcome-aside::after { content: ''; display: block; width: 90%; height: 9px; margin-top: 1px; border-top: 1px solid #91b5ff; border-radius: 50%; }
.suggestions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-top: 24px; text-align: left; }
.suggestion { position: relative; display: flex; flex-direction: column; align-items: flex-start; padding: 20px; min-height: 156px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: 0 3px 5px #28487a03; text-align: left; }
.suggestion:hover { border-color: #a3c5ff; box-shadow: 0 10px 25px #2563eb13; transform: translateY(-3px); }
.suggestion-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 15px; margin-bottom: 10px; }
.suggestion-icon .icon { width: 29px; height: 29px; stroke-width: 1.65; }
.blue { background: #eaf1ff; color: #245eff; }
.cyan { background: #e2f4ff; color: #0091df; }
.indigo { background: #eeedff; color: #5040ff; }
.purple { background: #f1eaff; color: #762fff; }
.suggestion strong { font-weight: 650; font-size: 1.0625rem; line-height: 1.6; }
.suggestion > span:not(.suggestion-icon) { color: var(--muted); font-size: .875rem; line-height: 1.6; margin-top: 1px; }
.suggestion-arrow { position: absolute; right: 21px; top: 26px; color: var(--subtle); width: 18px; height: 18px; }
.messages { flex-shrink: 0; width: 100%; max-width: 1120px; padding: 30px 32px 10px; margin: 0 auto; }
.message { display: flex; gap: 16px; margin-bottom: 32px; animation: appear .18s ease-out; }
.message-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); font: 600 .875rem var(--font); }
.message-avatar img { width: 39px; height: 39px; }
.message-user .message-avatar { border-radius: 50%; }
.message-body { flex: 1; min-width: 0; }
.message-name { display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 8px; font-size: 1rem; font-weight: 600; }
.message-name span { color: var(--accent); background: var(--accent-soft); padding: 2px 5px; border-radius: 4px; font: .625rem var(--font); letter-spacing: 1px; }
.message-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.1875rem; line-height: 1.85; }
.message-user .message-text { background: var(--surface); border: 1px solid var(--border); border-radius: 0 16px 16px; padding: 13px 18px; }
.copy-button { width: 32px; height: 32px; margin-top: 10px; }
.copy-button .icon { width: 16px; height: 16px; }

/* Compact composer expands with text; circular action buttons mirror the reference. */
.composer-area { width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px 32px 14px; flex-shrink: 0; }
.composer { background: var(--surface); border: 1px solid #d4e2f7; border-radius: 25px; padding: 16px 22px 7px; box-shadow: 0 16px 35px #315d9e13, 0 2px 3px #315d9e06; transition: border-color .18s, box-shadow .18s; }
:root[data-theme=dark] .composer { border-color: var(--border); }
.composer:focus-within { border-color: #79aaff; box-shadow: 0 16px 35px #315d9e16, 0 0 0 3px #3b82f60b; }
.composer textarea { display: block; width: 100%; height: 36px; min-height: 36px; max-height: 192px; max-height: clamp(72px, 24dvh, 192px); padding: 2px 0; border: 0; resize: none; background: none; color: var(--text); font-size: 1.0625rem; line-height: 1.65; overflow-y: hidden; scrollbar-width: thin; outline: none; }
.attachment-list{display:flex;flex-wrap:wrap;gap:6px;margin:3px 0 9px}.attachment-chip{display:inline-flex;align-items:center;gap:6px;max-width:220px;padding:4px 7px 4px 9px;border-radius:8px;background:var(--accent-soft);color:var(--accent);font-size:.75rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.attachment-chip button{width:18px;height:18px;border-radius:50%;background:#d7e6ff;color:var(--accent);font-size:15px;line-height:1}
.voice-report-card{width:min(100%,520px);padding:18px;border:1px solid #cfe0fc;border-radius:18px;background:linear-gradient(145deg,#f7fbff,#eaf3ff);box-shadow:0 10px 25px #245eff10}.voice-report-heading{display:flex;align-items:center;gap:10px}.voice-report-heading>span{display:grid;place-items:center;width:38px;height:38px;border-radius:11px;background:#dceaff;color:var(--accent);font-size:20px}.voice-report-heading strong,.voice-report-heading small{display:block}.voice-report-heading strong{font-size:1rem}.voice-report-heading small{margin-top:2px;color:var(--muted);font-size:.72rem}.voice-report-metric{display:flex;align-items:end;justify-content:space-between;margin:17px 0 11px}.voice-report-metric span{color:var(--muted);font-size:.82rem}.voice-report-metric b{color:var(--accent);font-size:2rem;line-height:1}.voice-report-metric b small{font-size:.8rem;color:var(--text)}.voice-report-chart{display:flex;align-items:end;gap:10px;height:82px;padding:10px 13px;border-radius:12px;background:#fff}.voice-report-chart i{display:block;flex:1;min-height:6px;border-radius:5px 5px 2px 2px;background:linear-gradient(#63a2ff,#245eff)}.voice-report-card p{margin:11px 0 0;color:var(--muted);font-size:.72rem}
.composer textarea::placeholder { color: var(--subtle); }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 9px; }
.composer-tools, .send-tools { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tool-button { display: flex; align-items: center; gap: 8px; min-height: 39px; padding: 8px 13px; border-radius: 22px; color: var(--muted); background: var(--sidebar); font-size: .8125rem; }
.tool-button .icon { width: 18px; height: 18px; }
.tool-button:hover { background: var(--surface-hover); color: var(--accent); }
.composer-model { min-height: 38px; border-radius: 24px; font-size: .8125rem; padding: 7px 14px; }
.voice-button, .send-button { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; transition: transform .18s, background .18s, box-shadow .18s; }
.voice-button { background: var(--accent-soft); color: var(--accent); }
.send-button { background: linear-gradient(145deg, #3285ff, #2455ff); color: #fff; box-shadow: 0 5px 12px #245eff26; }
.voice-button .icon, .send-button .icon { width: 24px; height: 24px; }
.send-button:disabled { opacity: .65; box-shadow: none; }
.voice-button:active, .send-button:active:not(:disabled) { transform: scale(.95); }
.voice-button:focus-visible, .send-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
@media (hover: hover) {
    .voice-button:hover { color: #fff; background: #2870ff; transform: translateY(-2px); box-shadow: 0 6px 15px #245eff26; }
    .send-button:hover:not(:disabled) { background: #194adc; transform: translateY(-2px); box-shadow: 0 7px 18px #245eff40; }
}
.keyboard-hint { text-align: right; margin-top: 5px; color: var(--subtle); font-size: .6875rem; }
.composer-note { display: flex; align-items: center; justify-content: center; gap: 48px; flex-wrap: wrap; margin: 20px 0 0; color: var(--subtle); font-size: .6875rem; }
.chat-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); font-size: .875rem; margin-bottom: 8px; }
.chat-heading > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-heading .icon-button { width: 30px; height: 30px; }
.chat-heading .icon { width: 17px; height: 17px; }
.inline-error { padding: 10px 14px; border: 1px solid #f2c8b7; background: #fff3ed; color: #a13e24; border-radius: 12px; margin-bottom: 10px; font-size: .875rem; }
.char-count { font-size: .75rem; color: var(--subtle); white-space: nowrap; }
.is-busy .send-button .icon { display: none; }
.is-busy .send-button::after { content: ''; width: 18px; height: 18px; border: 2px solid #ffffff65; border-top-color: #fff; border-radius: 50%; animation: spin .75s linear infinite; }

/* Dialogs reuse the same palette and retain native keyboard/focus behavior. */
.modal { width: calc(100% - 32px); max-width: 550px; max-height: 85vh; max-height: 85dvh; padding: 28px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: #14233f80; backdrop-filter: blur(4px); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.modal h2 { font-size: 1.5rem; font-weight: 650; margin: 8px 0; }
.modal-header .eyebrow { font-size: .625rem; letter-spacing: 2px; }
.modal-description { font-size: .9375rem; line-height: 1.85; color: var(--muted); margin: 12px 0 22px; }
.module-item { display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; }
.module-icon { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.module-item h3 { font: 600 .9375rem var(--font); margin: 0 0 5px; }
.module-item p { font-size: .8125rem; color: var(--muted); margin: 0; }
.module-status { margin-left: auto; color: var(--subtle); white-space: nowrap; font-size: .75rem; }
.modal-footnote { font-size: .8125rem; color: var(--muted); line-height: 1.85; margin: 20px 0 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 23px 0; border-bottom: 1px solid var(--border); }
.setting-row strong { font-size: .9375rem; font-weight: 600; }
.setting-row p { font-size: .8125rem; color: var(--muted); margin: 5px 0 0; }
.theme-switch { display: flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--sidebar); flex-shrink: 0; }
.theme-switch button { display: flex; align-items: center; gap: 5px; font-size: .8125rem; padding: 8px; border-radius: 7px; color: var(--muted); }
.theme-switch .icon { width: 15px; height: 15px; }
.theme-switch button[aria-pressed=true] { color: var(--accent); background: var(--surface); box-shadow: 0 2px 8px #335b8a12; }
.demo-badge { color: var(--accent); background: var(--accent-soft); border: 1px solid var(--border); padding: 5px 9px; border-radius: 20px; font-size: .75rem; white-space: nowrap; }
.storage-tag { color: var(--muted); font: .8125rem var(--font); }
.compact-modal { max-width: 440px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.secondary-button, .danger-button { padding: 10px 16px; border-radius: 10px; font-size: .875rem; }
.secondary-button { border: 1px solid var(--border); background: var(--sidebar); }
.danger-button { color: white; background: #bd3935; }
.sidebar-logout { margin: 0 0 4px; }
.sidebar-logout .secondary-button { width: 100%; }
.sidebar-collapsed .sidebar-logout { display: none; }
.toast { position: fixed; bottom: 24px; left: calc(50% + var(--navigation-width) / 2); transform: translateX(-50%); max-width: calc(100% - var(--navigation-width) - 32px); z-index: 60; background: #17345d; color: #fff; padding: 11px 20px; border-radius: 12px; box-shadow: var(--shadow); font-size: .875rem; transition: left 240ms cubic-bezier(.2,.75,.25,1), max-width 240ms cubic-bezier(.2,.75,.25,1); }
.noscript { position: fixed; bottom: 10px; margin: 12px; padding: 16px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Collapse keeps the existing actions in a usable icon rail.
   Text is visually removed; aria-labels and native tooltips still name actions. */
.sidebar-collapsed .sidebar { width: var(--navigation-width); padding: 18px 12px 0; }
.sidebar-collapsed .brand-row { flex-direction: column; gap: 12px; margin-bottom: 22px; }
.sidebar-collapsed .sidebar-toggle { width: 44px; height: 44px; }
.sidebar-collapsed .sidebar-toggle { order: -1; }
.sidebar-collapsed .brand img { width: 40px; height: 40px; }
.sidebar-collapsed .brand > span,
.sidebar-collapsed .new-chat > span,
.sidebar-collapsed .new-chat kbd,
.sidebar-collapsed .history-label,
.sidebar-collapsed .history,
.sidebar-collapsed .workspace-card > span:not(.module-card-icon),
.sidebar-collapsed .workspace-card > .icon,
.sidebar-collapsed .profile-info,
.sidebar-collapsed .profile-button > .icon { visibility: hidden; opacity: 0; pointer-events: none; transition: opacity 120ms ease, visibility 0s linear 120ms; }
.sidebar-collapsed .new-chat { justify-content: center; gap:0; width: 44px; height: 44px; margin: 0 auto 12px; padding: 0; border-radius: 13px; }
.sidebar-collapsed .new-chat > span, .sidebar-collapsed .new-chat kbd { display:none; }
.sidebar-collapsed .new-chat .icon { display:block; width:22px; height:22px; color:#fff; stroke-width:2.2; }
.sidebar-collapsed .rail-history-toggle { display: inline-flex; width: 44px; height: 44px; margin-inline: auto; }
.sidebar-collapsed .workspace-card { justify-content: center; width: 44px; height: 44px; padding: 0; margin: 12px auto; background: transparent; border-color: transparent; box-shadow: none; }
.sidebar-collapsed .workspace-card:hover { background: var(--surface-hover); }
.sidebar-collapsed .module-card-icon { background: transparent; }
.sidebar-collapsed .profile-button { justify-content: center; width: 44px; margin: 0 auto; padding: 6px 0 20px; }
.brand > span, .new-chat > span, .new-chat kbd, .history-label, .history, .workspace-card > span:not(.module-card-icon), .workspace-card > .icon, .profile-info, .profile-button > .icon { transition: opacity 120ms ease, visibility 0s; }

@media (min-width: 761px) {
    :root.sidebar-collapsed { --navigation-width: 76px; }
    .sidebar-collapsed .messages, .sidebar-collapsed .composer-area { max-width: 1280px; }
    .history-popover { position:fixed;z-index:45;top:88px;left:calc(var(--navigation-width) + 12px);display:flex;width:286px;max-height:min(520px,calc(100dvh - 112px));flex-direction:column;overflow:hidden;border:1px solid #e2eaf7;border-radius:16px;background:var(--surface);box-shadow:0 18px 45px #1d4e8b26; }
    .history-popover-header { display:flex;align-items:center;justify-content:space-between;padding:13px 12px 10px 16px;border-bottom:1px solid #eef2f8; }.history-popover-header strong { color:var(--text);font-size:.875rem; }.history-popover-header .icon-button { width:32px;height:32px; }.history-popover-header .icon { width:17px;height:17px; }
    .history-popover-list { flex:1;min-height:0;padding:7px; }.history-popover-list .history-item { margin-bottom:1px;padding-left:10px; }.history-popover-all { flex-shrink:0;margin:3px 8px 9px;padding:9px;border-top:1px solid #eef2f8;color:var(--accent);font-size:.8125rem;font-weight:700; }.history-popover-all:hover { background:var(--surface-hover);border-radius:9px; }
}
@media (min-width: 1400px) and (min-height: 880px) {
    .welcome { padding-top: 35px; padding-bottom: 22px; }
    .welcome-emblem { width: 150px; height: 150px; }
    .suggestions { margin-top: 30px; }
    .suggestion { min-height: 163px; }
}
@media (max-width: 1200px) {
    :root { --sidebar-width: 264px; }
    .sidebar { padding-left: 17px; padding-right: 17px; }
    .brand img { width: 41px; }
    .brand { font-size: 19px; }
    .brand small { font-size: 8px; letter-spacing: 2px; }
    .topbar-right { gap: 10px; }
    .connection-status { display: none; }
    .welcome { padding-left: 28px; padding-right: 28px; }
    .welcome-aside { display: none; }
    .suggestions { gap: 12px; }
    .suggestion { padding: 17px 14px; }
    .suggestion strong { font-size: .9375rem; }
    .suggestion > span:not(.suggestion-icon) { font-size: .8125rem; }
}
@media (max-width: 1020px) {
    .suggestions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .suggestion { min-height: 132px; }
    .suggestion-icon { width: 40px; height: 40px; margin-bottom: 8px; border-radius: 12px; }
    .suggestion-icon .icon { width: 24px; height: 24px; }
    .header-logo { display: none; }
    .topbar { padding-right: 20px; }
    .topbar-left, .topbar-right { gap: 9px; }
    .header-brand > span { font-size: .6875rem; }
    .header-modules { display: none; }
    .composer-area { padding-left: 24px; padding-right: 24px; }
    .composer-model { padding: 7px 10px; gap: 6px; }
    .composer-note { gap: 8px 24px; }
}
@media (max-height: 780px) and (min-width: 761px) {
    .welcome { padding-top: 18px; }
    .welcome-emblem { width: 90px; height: 90px; }
    .welcome h1 { font-size: clamp(2rem, 3.25vw, 3.25rem); margin: 7px 0 10px; }
    .suggestions { margin-top: 20px; }
    .suggestion { min-height: 133px; padding-top: 16px; padding-bottom: 16px; }
    .suggestion-icon { width: 44px; height: 44px; }
    .composer-note { margin-top: 14px; }
    .workspace-card { padding-top: 10px; padding-bottom: 10px; }
}
@media (max-width: 760px) {
    :root { --navigation-width: 64px; }
    .sidebar { width: min(310px, calc(100vw - 24px)); padding: 22px 19px 0; transform: translateX(-100%); transition: transform 240ms cubic-bezier(.2,.75,.25,1), box-shadow 240ms ease; }
    .sidebar-collapsed .sidebar { width: min(310px, calc(100vw - 24px)); padding: 22px 19px 0; }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-open .sidebar { box-shadow: 12px 0 35px #11234222; }
    .workspace { margin-left: 0; }
    .sidebar-overlay { position: fixed; inset: 0; z-index: 25; background: #11234266; backdrop-filter: blur(3px); }
    .brand { font-size: 22px; }
    .brand img { width: 48px; }
    .brand small { font-size: 9px; }
    .workspace-waves { inset-block-start: 69px; height: 430px; background-size: auto 100%; }
    .topbar { min-height: 69px; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
    .header-brand strong { font-size: 1rem; }
    .header-brand > span { display: none; }
    .header-profile { display: none; }
    .model-select { min-height: 36px; font-size: .75rem; padding: 7px 10px; gap: 7px; }
    .model-select .icon:first-child { width: 16px; }
    .welcome { padding: 23px 20px 18px; }
    .welcome-emblem { width: 110px; height: 110px; }
    .eyebrow { font-size: .625rem; letter-spacing: 3px; }
    .welcome h1 { font-size: clamp(1.875rem, 5.8vw, 2.75rem); letter-spacing: -.035em; margin-top: 12px; }
    .welcome-description { font-size: 1rem; line-height: 1.8; }
    .suggestions { gap: 12px; margin-top: 23px; }
    .suggestion { min-height: 134px; padding: 16px; border-radius: 16px; }
    .suggestion strong { font-size: .9375rem; }
    .suggestion > span:not(.suggestion-icon) { font-size: .8125rem; }
    .suggestion-arrow { right: 16px; top: 20px; width: 16px; }
    .composer-area { padding: 8px 15px calc(82px + env(safe-area-inset-bottom)); }
    .composer { border-radius: 21px; padding: 12px 14px 10px; }
    .composer textarea { min-height: 34px; font-size: 1rem; }
    .composer-toolbar { gap: 8px; margin-top: 7px; }
    .composer-tools { gap: 8px; }
    .send-tools { gap: 8px; }
    .voice-button, .send-button { width: 44px; height: 44px; }
    .voice-button .icon, .send-button .icon { width: 22px; height: 22px; }
    .tool-button { padding: 8px 10px; min-height: 36px; }
    .composer-model { font-size: .75rem; min-height: 36px; }
    .composer-model .icon:first-child { display: none; }
    .keyboard-hint, .char-count { display: none; }
    .composer-note { margin-top: 12px; font-size: .625rem; gap: 4px; }
    .composer-note > span:first-child { display: none; }
    .messages { padding: 22px 18px 6px; }
    .message { gap: 11px; margin-bottom: 27px; }
    .message-avatar { width: 34px; height: 34px; }
    .message-avatar img { width: 33px; height: 33px; }
    .message-name { min-height: 34px; font-size: .9375rem; }
    .message-text { font-size: 1.125rem; }
    .message-user .message-text { padding: 12px 14px; }
    .modal { padding: 22px; }
    .modal h2 { font-size: 1.25rem; }
    .setting-row { flex-wrap: wrap; }
    .module-item { flex-wrap: wrap; }
    .module-status { margin-left: 50px; }
    .profile-button { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
    .mobile-nav { position:fixed;z-index:22;right:0;bottom:0;left:0;display:grid;grid-template-columns:repeat(4,1fr);min-height:72px;padding:7px 12px max(7px,env(safe-area-inset-bottom));border-top:1px solid #e4ecf8;background:#ffffffed;box-shadow:0 -8px 24px #315d9e0d;backdrop-filter:blur(15px); }
    .mobile-nav-item { display:flex;min-width:0;min-height:57px;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-radius:16px;color:var(--muted);font-size:.66rem;font-weight:700;line-height:1.2; }
    .mobile-nav-item .icon { width:22px;height:22px; }.mobile-nav-item.is-active { color:#fff;background:linear-gradient(135deg,#1688f3,#2761ef);box-shadow:0 7px 14px #2478ec2e; }.mobile-nav-item:not(.is-active):active { background:var(--accent-soft);color:var(--accent); }
}
@media (max-width: 480px) {
    .composer-model, .tool-button > span { display: none; }
    .tool-button { width: 38px; justify-content: center; padding-inline: 0; }
    .welcome { padding-inline: 12px; }
    .suggestions { gap: 8px; }
    .suggestion { padding: 12px; }
    .suggestion-arrow { display: none; }
}
@media (max-width: 390px) {
    .composer-model { display: none; }
    .header-brand strong { font-size: .9375rem; }
    .topbar { padding-inline: 12px; }
    .topbar-left { gap: 5px; }
    .model-select { gap: 4px; }
    .model-select .icon:first-child { display: none; }
    .suggestion { padding: 13px; }
    .welcome { padding-inline: 16px; }
}
/* Voice uses a native modal for focus trapping, Escape and an inert chat behind it. */
.voice-modal { width: min(480px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); text-align: center; padding: 28px; border-radius: 28px; }
.voice-modal::backdrop { background: #101d3c80; backdrop-filter: blur(8px); }
.voice-modal .modal-header { margin-bottom: 26px; }
.voice-modal .eyebrow { letter-spacing: 2px; }
.voice-orb { display: grid; place-items: center; width: 148px; height: 148px; margin: 0 auto 24px; overflow: hidden; border: 1px solid #cfe0ff; border-radius: 50%; color: var(--accent); background: radial-gradient(circle at 30% 25%, var(--surface), var(--accent-soft)); box-shadow: 0 0 0 12px var(--accent-soft), 0 12px 28px #2e63d826; }
.voice-orb img { display: block; width: 148%; height: 148%; max-width: none; object-fit: cover; transform: scale(1.02); }
.voice-modal h2 { margin: 0 0 8px; font-size: 1.65rem; }
#voice-hint { min-height: 3.3em; margin: 0; color: var(--muted); font-size: .9375rem; }
.voice-wave { height: 48px; display: flex; align-items: center; justify-content: center; gap: 4px; margin: 8px 0; }
.voice-wave i { width: 4px; height: 8px; border-radius: 9px; background: var(--accent); opacity: .4; transform: scaleY(.35); }
.voice-wave i:nth-child(2n) { height: 22px; animation-delay: -.7s !important; }
.voice-wave i:nth-child(3n) { height: 32px; animation-delay: -.3s !important; }
.voice-wave i:nth-child(4n) { height: 40px; animation-delay: -.9s !important; }
.voice-modal[data-state=listening] .voice-wave i, .voice-modal[data-state=speaking] .voice-wave i { animation: voice-wave 1.15s ease-in-out infinite alternate; opacity: .8; }
.voice-modal.is-hearing .voice-wave i { animation-duration: .45s; }
.voice-modal[data-state=processing] .voice-orb, .voice-modal[data-state=thinking] .voice-orb { animation: voice-pulse 1s ease-in-out infinite alternate; }
.voice-modal[data-state=speaking] .voice-orb { animation: dragon-speaking .7s ease-in-out infinite; box-shadow: 0 0 0 12px #dce9ff, 0 0 0 22px #3f78ff1c, 0 16px 34px #2e63d84d; }
.voice-modal[data-state=speaking] .voice-orb img { animation: dragon-speaking-image .7s ease-in-out infinite; }
.voice-modal[data-state=error] .voice-orb { color: var(--muted); box-shadow: none; }
.voice-transcript { min-height: 54px; max-height: 130px; overflow-y: auto; overflow-wrap: anywhere; padding: 12px; margin: 0 0 20px; border-radius: 12px; background: var(--accent-soft); font-size: 1.0625rem; }
.voice-transcript:empty::before { content: 'ข้อความที่ได้ยินจะแสดงตรงนี้'; color: var(--muted); font-size: .875rem; }
.voice-response { color: var(--accent); margin: 0 0 20px; overflow-wrap: anywhere; }
.voice-modal[data-state=speaking] .voice-wave i { animation-duration: .8s; }
.voice-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.voice-actions button { min-height: 44px; }
.voice-modal .modal-footnote { margin-bottom: 0; line-height: 1.8; }
.voice-chat-status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 8px 10px; color: var(--muted); font-size: .8125rem; }
.voice-chat-status button { min-height: 32px; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
@keyframes voice-wave { from { transform: scaleY(.35); } to { transform: scaleY(1); } }
@keyframes voice-pulse { to { opacity: .5; transform: scale(.96); } }
@keyframes dragon-speaking { 0%, 100% { transform: translateY(0) rotate(0); } 25% { transform: translate(-2px, -2px) rotate(-1deg) scale(1.025); } 75% { transform: translate(2px, -1px) rotate(1deg) scale(1.025); } }
@keyframes dragon-speaking-image { 0%, 100% { filter: brightness(1) saturate(1); } 50% { filter: brightness(1.13) saturate(1.2); } }
@media (max-width: 480px) { .voice-modal { padding: 20px; } .voice-orb { width: 112px; height: 112px; margin-bottom: 20px; } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .suggestion:hover, .voice-button:hover, .send-button:hover { transform: none; }
}

/* Conversation message layout: user bubbles sit on the right while the
   assistant response remains an open text block on the left. */
.has-conversation .workspace-waves { opacity: 0; }
.messages { max-width: 1120px; padding-top: 34px; }
.message { align-items: flex-start; }
.message-user { justify-content: flex-end; }
.message-user .message-avatar { display: none; }
.message-user .message-body { flex: 0 1 auto; max-width: min(78%, 760px); }
.message-user .message-name { display: none; }
.message-user .message-text { width: fit-content; max-width: 100%; margin-left: auto; padding: 10px 17px; border: 0; border-radius: 20px; background: #edf3fc; line-height: 1.65; }
.message-assistant .message-text { background: transparent; }

@media (max-width: 600px) {
    .message-user .message-body { max-width: 86%; }
}
.chat-generated-image{display:block;width:100%;max-width:640px;height:auto;margin-top:12px;border:1px solid #dbe7ff;border-radius:14px}
