:root {
  color-scheme: light;
  --background: #f6f5fa;
  --surface: #ffffff;
  --text: #252334;
  --muted: #767385;
  --soft: #efedf5;
  --border: #e9e7f0;
  --accent: #7154c9;
  --accent-hover: #6041ba;
  --accent-pale: #f0ebfb;
  --accent-text: #6547b2;
  --danger: #a53748;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  --content-inset-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --content-inset-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { width: 100%; }
body { margin: 0; width: 100%; min-width: 0; min-height: 100vh; min-height: 100svh; }
main { width: 100%; min-width: 0; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, input, a { outline-offset: 4px; }
:focus-visible { outline: 3px solid #b9a5e9; }
h1, h2, h3, p { margin: 0; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { touch-action: manipulation; }

.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 15px; color: #fff; background: var(--accent); font-size: 36px; font-weight: 500; line-height: 1; letter-spacing: -3px; padding: 0 4px 7px 0; user-select: none; flex-shrink: 0; }
.brand-name { display: block; font-size: 21px; font-weight: 650; letter-spacing: -.6px; line-height: 1.25; }
.brand-caption { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.35; letter-spacing: .05px; }
.brand { display: flex; gap: 12px; align-items: center; min-width: 0; text-decoration: none; color: var(--text); }
.brand > span:last-child { min-width: 0; }
.eyebrow { display: flex; align-items: center; gap: 7px; color: var(--accent-text); font-size: 12px; font-weight: 600; letter-spacing: .1px; }
.small-dot { display: inline-block; width: 6px; height: 6px; background: currentColor; border-radius: 50%; flex-shrink: 0; }

.loading-view { min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100svh); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; color: var(--muted); padding: 24px; }
.loading-spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
.login-view { min-height: 100vh; min-height: var(--tg-viewport-stable-height, 100svh); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(40px, var(--content-inset-top)) 24px max(32px, var(--content-inset-bottom)); }
.login-brand { display: flex; gap: 13px; align-items: center; margin-bottom: 36px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); padding: 36px; border: 1px solid var(--border); border-radius: 24px; box-shadow: 0 10px 44px #30234405; }
.login-card h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.9px; font-weight: 600; margin-top: 15px; }
.intro { color: var(--muted); font-size: 14px; margin-top: 10px; line-height: 1.55; }
#login-form { margin-top: 28px; }
.form-field + .form-field { margin-top: 19px; }
.form-field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 8px; }
.form-field input { width: 100%; min-width: 0; height: 48px; border: 1px solid #dedbe7; border-radius: 10px; padding: 0 13px; background: #fdfcfe; color: var(--text); font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.form-field input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px #7154c914; }
.form-field input:disabled { opacity: .65; }
.form-error { color: var(--danger); background: #fff4f5; padding: 10px 12px; border-radius: 9px; margin-top: 17px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 9px; min-height: 43px; padding: 10px 16px; border-radius: 10px; font-weight: 550; font-size: 13px; border: 1px solid transparent; transition: color .15s, background .15s, transform .15s, border-color .15s; }
.button svg { width: 18px; height: 18px; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--accent-hover); }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .6; }
.login-submit { width: 100%; min-height: 48px; margin-top: 24px; justify-content: space-between; padding-left: 18px; padding-right: 18px; font-size: 14px; }
.login-footnote { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; margin-top: 26px; }
.login-footnote svg { width: 14px; height: 14px; }
.text-button { color: var(--accent-text); background: transparent; border: 0; padding: 8px 3px; font-size: 13px; text-decoration: underline; text-decoration-color: #7154c94d; text-underline-offset: 4px; }
.text-button:hover { color: var(--accent-hover); }
.session-retry { display: block; margin: 15px auto -8px; }

.app-shell { width: 100%; min-width: 0; max-width: 1200px; margin: 0 auto; padding: var(--content-inset-top) max(40px, env(safe-area-inset-right, 0px)) max(25px, var(--content-inset-bottom)) max(40px, env(safe-area-inset-left, 0px)); }
.app-header { display: flex; align-items: center; justify-content: space-between; min-height: 101px; border-bottom: 1px solid var(--border); gap: 20px; }
.header-actions { display: flex; align-items: center; gap: 20px; min-width: 0; flex-shrink: 0; }
.user-label { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--muted); }
.button-quiet { color: var(--muted); background: transparent; padding: 9px 11px; }
.button-quiet:hover:not(:disabled) { color: var(--text); background: var(--soft); }
.page-intro { display: flex; align-items: center; justify-content: space-between; min-width: 0; gap: 20px; margin-top: 37px; margin-bottom: 25px; }
.page-intro > div { min-width: 0; }
.page-intro .eyebrow { color: var(--muted); font-weight: 400; margin-bottom: 7px; }
.page-intro h1 { font-size: 28px; line-height: 1.25; font-weight: 600; letter-spacing: -.8px; }
.ai-badge { display: inline-flex; gap: 7px; align-items: center; background: var(--accent-pale); color: var(--accent-text); padding: 7px 11px; border-radius: 8px; white-space: nowrap; font-size: 11px; font-weight: 550; }
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 13px 15px; border: 1px solid #e2d9f3; background: #f2eef9; border-radius: 12px; margin-bottom: 18px; color: #5d4c7d; font-size: 13px; overflow-wrap: anywhere; }
.notice svg { width: 18px; height: 18px; margin-top: 1px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
.panel { min-width: 0; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 21px; overflow: hidden; }
.voice-card { display: flex; flex-direction: column; min-height: 541px; }
.voice-card-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 23px 25px 0; }
.section-label { font-size: 12px; font-weight: 550; color: var(--text); }
.session-label { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.voice-content { display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 29px 24px 28px; text-align: center; }
.mic-area { display: grid; place-items: center; width: 208px; height: 208px; margin-bottom: 22px; }
.microphone-button { position: relative; isolation: isolate; display: grid; place-items: center; width: 146px; height: 146px; border: none; border-radius: 50%; color: #fff; background: var(--accent); box-shadow: 0 12px 26px #7154c927; transition: background .2s, transform .2s, box-shadow .2s; }
.microphone-button::before, .microphone-button::after { content: ""; position: absolute; border: 1px solid #7154c91a; border-radius: 50%; pointer-events: none; z-index: -1; }
.microphone-button::before { inset: -16px; }
.microphone-button::after { inset: -31px; border-color: #7154c90d; }
.microphone-button:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 15px 30px #7154c935; }
.microphone-button:active:not(:disabled) { transform: scale(.97); }
.microphone-button:disabled { background: #e8e5ef; color: #aaa3bb; box-shadow: none; }
.microphone-button:disabled::before, .microphone-button:disabled::after { border-color: #eeebf3; }
.microphone-icon { width: 46px; height: 46px; stroke-width: 2.1; }
.mic-busy { display: none; position: absolute; inset: 12px; border: 2px solid #ffffff30; border-top-color: #ffffffb0; border-radius: 50%; animation: spin 1.2s linear infinite; }
.voice-card[data-state="connecting"] .mic-busy { display: block; }
.voice-card[data-state="listening"] .microphone-button::before, .voice-card[data-state="speaking"] .microphone-button::before { animation: pulse-ring 2.7s ease-in-out infinite; }
.voice-copy h2 { font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -.5px; }
.voice-copy { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.voice-status { margin-top: 10px; color: var(--accent-text); font-size: 14px; font-weight: 500; min-height: 21px; }
.voice-hint { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 7px; max-width: 310px; min-height: 19px; }
.voice-levels { display: flex; align-items: center; gap: 4px; height: 24px; margin-top: 16px; color: var(--accent); opacity: 0; transition: opacity .2s; }
.voice-levels i { display: block; width: 3px; height: 7px; background: currentColor; border-radius: 4px; }
.voice-card[data-state="speaking"] .voice-levels { opacity: .65; }
.voice-card[data-state="speaking"] .voice-levels i { animation: sound-wave .8s ease-in-out infinite alternate; }
.voice-card[data-state="speaking"] .voice-levels i:nth-child(2) { animation-delay: -.4s; }
.voice-card[data-state="speaking"] .voice-levels i:nth-child(3) { animation-delay: -.2s; }
.voice-card[data-state="speaking"] .voice-levels i:nth-child(4) { animation-delay: -.5s; }
.voice-card[data-state="speaking"] .voice-levels i:nth-child(5) { animation-delay: -.1s; }
.button-secondary { color: #5e586e; border-color: #e4e0ec; background: var(--surface); }
.button-secondary:hover:not(:disabled) { background: #f8f6fb; border-color: #d7d0e5; }
.stop-button { margin-top: 11px; min-height: 40px; font-size: 12px; }
.stop-square { width: 9px; height: 9px; background: currentColor; border-radius: 2px; }
.play-audio-button { margin-top: 5px; }
.voice-card-footnote { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 16px 20px; border-top: 1px solid #f0edf5; color: var(--muted); font-size: 10px; line-height: 1.5; }
.privacy-dot { display: block; width: 5px; height: 5px; border: 1px solid #aaa3b8; border-radius: 50%; flex-shrink: 0; }
.conversation-card { display: flex; flex-direction: column; }
.conversation-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 24px 18px; border-bottom: 1px solid #f0edf5; gap: 12px; }
.conversation-header h2 { font-size: 15px; font-weight: 600; letter-spacing: -.15px; }
.conversation-header p { font-size: 11px; margin-top: 3px; color: var(--muted); }
.live-label { display: flex; align-items: center; gap: 6px; color: var(--accent-text); font-size: 10px; white-space: nowrap; }
.transcript { flex: 1; min-height: 350px; height: 405px; max-height: 570px; overflow-y: auto; padding: 23px; scrollbar-width: thin; scrollbar-color: #ddd7e8 transparent; overscroll-behavior: contain; }
.transcript-empty { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; min-height: 290px; text-align: center; }
.empty-icon { display: grid; place-items: center; width: 51px; height: 51px; border-radius: 17px; background: #f5f2fa; color: #b5a7cf; margin-bottom: 18px; }
.empty-icon svg { width: 27px; height: 27px; stroke-width: 1.4; }
.transcript-empty h3 { font-size: 14px; font-weight: 500; color: #666073; }
.transcript-empty p { font-size: 12px; line-height: 1.7; margin-top: 7px; color: #9890a4; }
.message { margin-bottom: 22px; }
.message:last-child { margin-bottom: 0; }
.message-label { font-size: 10px; font-weight: 600; margin-bottom: 7px; color: var(--muted); }
.message[data-role="assistant"] .message-label { color: var(--accent-text); }
.message-text { font-size: 13px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.message[data-role="user"] .message-text { display: inline-block; max-width: 100%; padding: 10px 13px; background: #f6f5f9; border-radius: 0 10px 10px 10px; color: #5b5568; }
.message[data-pending="true"] .message-text { color: var(--muted); font-style: italic; font-size: 12px; }
.knowledge-evidence { margin: 0 0 22px; }
.knowledge-evidence-label { color: var(--muted); font-size: 10px; font-weight: 550; margin-bottom: 9px; }
.knowledge-source { padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; margin-top: 7px; }
.knowledge-source h3 { font-size: 12px; line-height: 1.5; font-weight: 550; overflow-wrap: anywhere; }
.knowledge-source-text { font-size: 11px; line-height: 1.65; color: #706779; margin-top: 5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.knowledge-source-meta { font-size: 10px; line-height: 1.6; color: var(--muted); margin-top: 6px; overflow-wrap: anywhere; }
.conversation-footnote { padding: 14px 20px; border-top: 1px solid #f0edf5; color: #968e9f; font-size: 10px; line-height: 1.5; }
.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: #a29bab; font-size: 10px; padding-top: 24px; }
.noscript-notice { padding: 20px; text-align: center; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-ring { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.055); opacity: .45; } }
@keyframes sound-wave { from { height: 5px; } to { height: 19px; } }

@media (min-width: 1500px) {
  .app-shell { padding-top: 16px; }
  .page-intro { margin-top: 47px; margin-bottom: 30px; }
  .voice-card { min-height: 580px; }
}

@media (max-width: 900px) {
  .app-shell { padding-left: 25px; padding-right: 25px; }
  .workspace-grid { gap: 16px; }
  .voice-card-heading { flex-wrap: wrap; padding: 21px 21px 0; gap: 6px; }
  .voice-content { padding-left: 18px; padding-right: 18px; }
  .voice-copy h2 { font-size: 20px; }
  .user-label { max-width: 130px; }
}

@media (max-width: 680px) {
  .app-shell { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-bottom: max(16px, var(--content-inset-bottom)); }
  .app-header { min-height: 64px; gap: 8px; }
  .app-header .brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 29px; padding-bottom: 6px; }
  .app-header .brand { gap: 8px; flex: 1; }
  .app-header .brand-name { font-size: 18px; }
  .app-header .brand-caption { font-size: 10px; overflow-wrap: anywhere; }
  .header-actions { gap: 3px; }
  .user-label { display: none; }
  .button-quiet { min-width: 44px; min-height: 44px; padding-left: 8px; padding-right: 5px; gap: 6px; font-size: 12px; }
  .button-quiet svg { width: 16px; height: 16px; }
  .page-intro { margin-top: 17px; margin-bottom: 14px; gap: 8px; align-items: flex-start; }
  .page-intro .eyebrow { font-size: 10px; margin-bottom: 4px; }
  .page-intro h1 { font-size: clamp(21px, 6.1vw, 24px); letter-spacing: -.6px; overflow-wrap: anywhere; }
  .ai-badge { font-size: 0; width: 28px; height: 28px; padding: 0; justify-content: center; margin-top: 5px; }
  .ai-badge .small-dot { width: 7px; height: 7px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .panel { border-radius: 16px; }
  .voice-card { min-height: 340px; }
  .voice-card-heading { flex-wrap: wrap; padding: 15px 16px 0; gap: 4px 10px; }
  .section-label { font-size: 11px; }
  .session-label { min-width: 0; font-size: 10px; white-space: normal; }
  .voice-content { padding: 14px 16px 16px; }
  .mic-area { width: 156px; height: 156px; max-width: 100%; margin-bottom: 10px; }
  .microphone-button { width: 110px; height: 110px; }
  .microphone-button::before { inset: -12px; }
  .microphone-button::after { inset: -23px; }
  .microphone-icon { width: 37px; height: 37px; }
  .voice-copy h2 { font-size: 19px; }
  .voice-status { font-size: 13px; line-height: 1.5; margin-top: 8px; }
  .voice-hint { max-width: 290px; font-size: 12px; line-height: 1.5; margin-top: 6px; }
  .voice-levels { display: none; margin-top: 8px; height: 18px; }
  .voice-card[data-state="speaking"] .voice-levels { display: flex; }
  .voice-card-footnote { padding: 10px 13px; font-size: 10px; }
  .conversation-header { padding: 15px 16px 13px; }
  .conversation-header h2 { font-size: 14px; }
  .transcript { padding: 16px; height: 250px; height: clamp(180px, 36svh, 290px); min-height: 180px; max-height: 420px; }
  .transcript-empty { min-height: 150px; }
  .transcript-empty p { font-size: 12px; }
  .conversation-footnote { font-size: 10px; padding: 11px 16px; }
  .app-footer { flex-direction: column; align-items: flex-start; gap: 5px; font-size: 10px; padding: 16px 2px 0; overflow-wrap: anywhere; }
}

@media (max-width: 420px) {
  .login-view { padding-left: 18px; padding-right: 18px; }
  .login-brand { margin-bottom: 28px; }
  .login-card { padding: 28px 24px; border-radius: 20px; }
  .login-card h1 { font-size: 26px; }
  .intro { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
