/* Scoped layout corrections. Field visibility and business validation stay in existing scripts. */
.page-auth, .page-chat { font-family: "Segoe UI", Arial, sans-serif; }
.page-auth button, .page-auth input, .page-auth select, .page-chat button, .page-chat textarea, .page-chat select { font-family: inherit; }
.page-auth :focus-visible, .page-chat :focus-visible { outline: 3px solid #218894; outline-offset: 3px; }
.page-auth { display: block; height: auto; min-height: 100dvh; width: 100%; padding: 32px 16px; overflow-y: auto; color: var(--text-color); }
.page-auth .container { position: relative; inset: auto; transform: none; width: min(100%, 520px); max-width: 100%; padding: 28px; margin: 0 auto; background: var(--panel-bg); border: 1px solid var(--line-color); border-radius: 20px; }
.page-auth #singInBox { width: min(100%, 720px); }
.page-auth .imgLogoVLarge { width: min(230px, 80%); height: auto; object-fit: contain; }
.page-auth #loginForm h4 { font-weight: 400; color: var(--muted-color); line-height: 1.5; }
.page-auth .input-group { display: inline-flex !important; flex-direction: column; text-align: left; vertical-align: top; gap: 6px; margin-bottom: 16px; }
.page-auth #loginForm > .input-group, .page-auth #signStep3 > .input-group { width: 100% !important; }
.page-auth .input-group label { position: static; order: -1; transform: none; margin: 0; padding: 0; font-size: .85rem; line-height: 1.4; color: var(--text-color); background: transparent; pointer-events: auto; }
.page-auth .input-group input, .page-auth .input-group select { width: 100%; min-width: 0; height: 48px; padding: 10px 12px; font-size: 16px; color: var(--text-color); background: var(--input-bg); border: 1px solid var(--line-color); border-radius: 10px; }
.page-auth button, .page-auth .spanbutton, .page-auth .spanbutton22, .page-auth .spanbuttonLeft, .page-auth .spanbuttonRight { min-height: 44px; height: auto; padding: 11px 16px; cursor: pointer; line-height: 1.4; }
.page-auth .link-button { display: block; margin: 10px auto; padding: 6px 10px; border: 0; background: transparent; color: var(--accent-color, #218894); box-shadow: none; }
.page-auth .link-button:hover { text-decoration: underline; background: transparent; }
.page-auth #passwordResetBox > .input-group { vertical-align: top; }
.page-auth #passwordResetBox #passwordResetMessage { margin: 14px 0; min-height: 24px; color: var(--text-color) !important; }
.page-auth #passwordResetBox #resetConfirmFields { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: start; margin-top: 8px; }
.page-auth #passwordResetBox #resetConfirmFields .input-group { width: 100% !important; min-width: 0; }
.page-auth #passwordResetBox #resetConfirmFields button { grid-column: 1 / -1; width: 100%; }
.page-auth .spanbutton { display: inline-block; }
.page-auth .crBT { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; }
.page-auth .crBT > * { width: auto; flex: 1; }
.page-auth .addfiaddFilePort { gap: 12px; align-items: stretch; }
.page-auth .addFile { min-width: 0; flex: 1; background: var(--input-bg); color: var(--text-color); border: 2px dashed #8886; }
.page-auth #canvas { background: white; touch-action: none; max-width: 100%; }
.page-auth .message, .page-auth #result, .page-auth #resultSign { overflow-wrap: anywhere; line-height: 1.5; }
.page-auth .field-error { width: 100%; }
.page-auth .signup-progress { font-size: .85rem; color: var(--muted-color); text-align: center; margin-bottom: 12px; }

.page-chat { display: block; width: 100%; height: var(--app-height, 100dvh); padding: 0; overflow: hidden; }
.page-chat #app { width: 100%; height: 100%; min-height: 0; }
.page-chat .chat-container { display: flex; flex-direction: column; position: relative; inset: auto; transform: none; width: 100%; height: 100%; min-height: 0; max-width: 1040px; margin: 0 auto; padding: 0 20px; border-radius: 0; overflow: hidden; }
.page-chat .headerBar { position: relative; inset: auto; display: flex; align-items: center; justify-content: space-between; flex: 0 0 64px; min-height: 64px; width: 100%; padding: 0 4px; gap: 12px; border-bottom: 1px solid var(--line-color); background: var(--page-bg); }
.page-chat .headerBar #menu { display: flex; align-items: center; gap: 8px; margin: 0; }
.page-chat .headerBar .imgLogo { width: 34px; height: 34px; object-fit: contain; }
.page-chat .headerBar #logoHeadMenu { width: 130px; max-width: 35vw; height: auto; object-fit: contain; }
.page-chat #chat-box { flex: 1 1 0; min-height: 0; height: auto; width: 100%; margin: 0; padding: 20px 8px 28px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scroll-padding-block: 20px; }
.page-chat #welcomBox { max-width: 640px; margin: clamp(24px, 10vh, 100px) auto 36px; padding: 12px; text-align: center; line-height: 1.6; animation: none; opacity: 1; }
.page-chat #startmessage { font-weight: 400; color: var(--muted-color) !important; }
.page-chat #welcomBox h2 { text-transform: none; }
.page-chat #welcomBox h2 { text-align: center; font-size: clamp(1.5rem, 4vw, 2.2rem); line-height: 1.25; }
.page-chat #toolNotifications { position: fixed; z-index: 3000; top: 76px; right: 16px; width: min(440px, calc(100vw - 32px)); max-height: 70dvh; overflow: auto; padding: 16px; border: 1px solid var(--border-color, #888); border-radius: 12px; background: var(--panel-bg, white); color: var(--text-color); box-shadow: 0 8px 30px #0003; box-sizing: border-box; }
.page-chat #toolNotifications[hidden] { display: none; }
.page-chat .tool-notification { padding: 10px 0; border-bottom: 1px solid var(--border-color, #888); overflow-wrap: anywhere; }
.page-chat a[href^="/api/documents/"][href$="/download"] { display: inline-block; padding: 7px 12px; margin: 4px 0; border: 1px solid currentColor; border-radius: 8px; text-decoration: none; }
.page-chat .tool-notifications-button { font-size: 12px; max-width: min(160px, 35vw); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-chat #message-container { position: relative; inset: auto; transform: none; flex: 0 0 auto; width: 100%; max-width: 100%; margin: 0 0 max(12px, env(safe-area-inset-bottom)); padding: 10px; background: var(--panel-bg); box-sizing: border-box; }
.page-chat #message-container .message-row { width: 100%; min-width: 0; }
.page-chat .input-wrapper { flex: 1 1 0; min-width: 0; }
.page-chat #message-input { width: 100%; min-width: 0; min-height: 44px; max-height: 35dvh; margin: 0; padding: 10px 6px; font-size: 16px; line-height: 1.5; color: var(--text-color); background: transparent; resize: none; }
.page-chat .input-wrapper.expanded #message-input { max-height: 45dvh; }
.page-chat .controls-row { flex-shrink: 0; padding-bottom: 0; }
.page-chat #attachedBT, .page-chat #submitButton, .page-chat #speetchTtext_legacy, .page-chat #menuToggleBtn, .page-chat #themeToggleBtn, .page-chat #sidebarCloseBtn { min-width: 44px; width: 44px !important; height: 44px !important; padding: 10px; margin: 0 !important; flex: 0 0 auto; }
.page-chat button svg { width: 22px; height: 22px; flex-shrink: 0; }
.page-chat .botChat { width: 100%; max-width: 100%; margin: 18px 0; padding: 0; left: auto; }
.page-chat .myChat { max-width: 90%; margin: 18px 0 18px auto; }
.page-chat .messageElementTextBoxR, .page-chat .messageElementTextBoxL { left: auto; width: fit-content; max-width: 100%; overflow-wrap: anywhere; padding: 14px 16px; }
.page-chat #previewBox { max-height: min(160px, 22dvh); overflow: auto; }
.page-chat .sidebarXov { position: fixed; inset: 0 auto 0 0; width: min(320px, 90vw); max-width: 90vw; height: var(--app-height, 100dvh); padding: 0; color: var(--text-color); background: var(--page-bg); z-index: 1400; overflow-y: auto; overscroll-behavior: contain; }
.page-chat .sidebarXovHead { position: relative; width: 100%; padding: 12px; }
.page-chat:not(.dark-theme) .sidebarXovHead .imgLogoLarge { filter: invert(1); }
.page-chat .sidebarXovContent { padding: 16px; padding-bottom: 100px; height: auto; min-height: 0; }
.page-chat .sidebarXovBottom { position: sticky; bottom: 0; width: 100%; padding: 12px; background: var(--page-bg); }
.page-chat .sidebarXovBottom button { width: 100%; min-height: 44px; }
.page-chat .voice-setting-row { min-width: 0; }
.page-chat .voice-setting-row select { min-width: 0; max-width: 100%; flex: 1; color: var(--text-color); background: var(--input-bg); }
.ui-backdrop { position: fixed; inset: 0; z-index: 1399; background: #0007; margin: 0; padding: 0; width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.ui-backdrop[hidden] { display: none !important; }
.page-chat .memory-dialog { padding: 20px; max-width: 94vw; }
@media (max-width: 600px) {
  .page-auth { padding: 16px 12px; }
  .page-auth .container { padding: 20px 16px; }
  .page-auth #signStep2 .input-group { width: 100% !important; }
  .page-auth .addfiaddFilePort { flex-direction: column; }
  .page-auth .addFile { width: 100%; min-height: 145px !important; }
  .page-auth #passwordResetBox > .input-group { width: 100% !important; }
  .page-auth #passwordResetBox #resetConfirmFields { grid-template-columns: 1fr; gap: 0; }
  .page-auth #passwordResetBox #resetConfirmFields button { grid-column: auto; }
  .page-chat .chat-container { padding: 0 10px; }
  .page-chat .headerBar { flex-basis: 58px; min-height: 58px; }
  .page-chat #chat-box { padding: 12px 2px 20px; }
  .page-chat #message-container { padding: 7px; border-radius: 16px; }
  .page-chat .myChat { max-width: 94%; }
  .page-chat .messageElementTextBoxR, .page-chat .messageElementTextBoxL { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .page-auth *, .page-chat * { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
#pushSetup {position:fixed;bottom:90px;right:16px;max-width:360px;max-height:70vh;overflow:auto;padding:18px;background:var(--panel-bg,#222);color:var(--text-color,#fff);border:1px solid #777;border-radius:12px;z-index:2005;box-shadow:0 6px 25px #0006}
#pushSetup button {display:block;margin-top:10px;padding:10px;max-width:100%;white-space:normal}
.page-chat .message-actions { display:flex; gap:4px; min-height:28px; margin:3px 4px 0; opacity:.72; }
.page-chat .message-copy { width:30px; height:28px; padding:5px; border:0; border-radius:8px; background:transparent; color:var(--muted-color); cursor:pointer; }
.page-chat .message-copy:hover, .page-chat .message-copy.copied { color:var(--workspace-accent,#167c80); background:var(--workspace-soft,#8881); }
.page-chat .message-copy i { font-size:14px; }
.page-chat .message-copy.copied { animation: copyConfirmed .42s ease-out; }
.page-chat .message-copy.copy-failed { color: #c45b64; background: rgba(196, 91, 100, .12); animation: copyFailed .42s ease-out; }
@keyframes copyConfirmed { 0% { transform: scale(.78); opacity:.5; } 65% { transform: scale(1.18); opacity:1; } 100% { transform: scale(1); } }
@keyframes copyFailed { 0% { transform: translateX(-2px); } 35% { transform: translateX(2px); } 70% { transform: translateX(-1px); } 100% { transform: translateX(0); } }
.page-chat .message-meta { display:flex; align-items:center; gap:8px; margin:3px 5px 0; color:var(--muted-color); font-size:10px; line-height:1.2; font-variant-numeric:tabular-nums; opacity:.72; }
.page-chat .message-meta-date { white-space:nowrap; }
.page-chat .message-meta-duration { padding-left:8px; border-left:1px solid color-mix(in srgb,var(--muted-color) 45%,transparent); white-space:nowrap; }
.page-chat .message-meta-duration::before { content:'◷ '; opacity:.8; }
@media (prefers-reduced-motion: reduce) {
  .page-chat .message-copy.copied, .page-chat .message-copy.copy-failed { animation:none; }
}
.page-chat .message-send-state { display:flex; align-items:center; justify-content:center; width:20px; height:18px; margin:4px 4px 0 auto; color:var(--muted-color); opacity:.75; }
.page-chat .message-send-state svg { width:20px; height:18px; }
.page-chat .message-send-spinner { width:11px; height:11px; border:1.5px solid currentColor; border-right-color:transparent; border-radius:50%; animation:messageSendSpin .85s linear infinite; }
.page-chat .message-send-state[data-state="error"] { color:#c77939; font-size:12px; }
@keyframes messageSendSpin { to { transform:rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .page-chat .message-send-spinner { animation:none; } }
.page-chat .chat-voice-player { width:min(300px,70vw); height:38px; display:block; accent-color:var(--workspace-accent,#167c80); }
.page-chat { --recording-wave-color: #62676d; }
.page-chat #audioRecordingPanel { border:1px solid var(--workspace-line,#8884); border-radius:20px; padding:12px 16px; background:var(--page-bg); box-shadow:0 8px 30px #0002; }
.page-chat .recording-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.page-chat .recording-title { font-weight:650; font-size:13px; }
.page-chat .recording-timer { font-variant-numeric:tabular-nums; color:#db5360; font-weight:700; }
.page-chat .recording-controls { display:flex; justify-content:flex-end; gap:8px; margin-top:10px; }
.page-chat .recording-controls button { width:42px; height:42px; padding:0; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; }
.page-chat .recording-visual { height:72px; margin:8px 0; padding:0 4px; border-radius:14px; background:color-mix(in srgb,var(--workspace-accent,#167c80) 9%,transparent); overflow:hidden; }
.page-chat .recording-waveform { display:block; width:100%; height:72px; }
.page-chat #cancelRecordingBtn { color:#db5360; }
.page-chat #sendRecordingBtn { color:#fff; background:var(--workspace-accent,#167c80); }

/* WhatsApp-style voice composer: duration + live bars on top, actions below. */
.page-chat #audioRecordingPanel {
  position: fixed;
  left: 50%;
  bottom: max(84px, calc(env(safe-area-inset-bottom) + 76px));
  transform: translateX(-50%);
  z-index: 2200;
  width: min(1120px, calc(100vw - 28px));
  min-width: 0;
  margin: 0;
  padding: 24px 30px 22px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 34px;
  background: var(--panel-bg, #fff);
  color: var(--text-color, #111827);
  box-shadow: 0 18px 55px rgba(15, 23, 42, .22);
  box-sizing: border-box;
  animation: recordingComposerIn 180ms ease-out both;
}
.dark-theme #audioRecordingPanel {
  border-color: rgba(255,255,255,.12);
  background: #1a1d21;
  box-shadow: 0 18px 55px rgba(0,0,0,.48);
}
.dark-theme.page-chat { --recording-wave-color: #d5d9df; }
.page-chat .recording-topline {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) 66px;
  align-items: center;
  gap: 14px;
  min-height: 88px;
}
.page-chat .recording-timer {
  color: var(--text-color, #111827);
  font-size: clamp(27px, 4vw, 42px);
  font-weight: 400;
  letter-spacing: -.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.dark-theme .recording-timer { color: #f8fafc; }
.page-chat .recording-visual {
  height: 88px;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  overflow: hidden;
}
.page-chat .recording-waveform {
  display: block;
  width: 100%;
  height: 88px;
}
.page-chat .recording-speed {
  width: 62px;
  height: 62px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-color, #111827);
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font-weight: 650;
  cursor: default;
}
.page-chat .recording-speed span { font-size: 31px; line-height: .8; }
.page-chat .recording-speed b { font-size: 15px; font-weight: 700; align-self: flex-start; margin-top: 5px; }
.dark-theme .recording-speed { color: #f8fafc; }
.page-chat .recording-controls {
  display: grid;
  grid-template-columns: clamp(64px, 12vw, 164px) minmax(0, 1fr) clamp(64px, 12vw, 164px);
  align-items: center;
  gap: clamp(12px, 2.4vw, 30px);
  margin-top: 18px;
}
.page-chat .recording-action,
.page-chat .recording-pause {
  height: clamp(64px, 10vw, 164px) !important;
  min-height: 64px;
  margin: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.page-chat .recording-action:hover,
.page-chat .recording-pause:hover { transform: translateY(-1px); }
.page-chat .recording-action:active,
.page-chat .recording-pause:active { transform: scale(.97); }
.page-chat .recording-delete {
  width: clamp(64px, 10vw, 164px) !important;
  min-width: 64px;
  justify-self: start;
  border-radius: 50%;
  color: #df1438;
  background: #ffe7ed;
  font-size: clamp(25px, 3vw, 58px);
}
.page-chat .recording-pause {
  width: min(100%, 760px) !important;
  justify-self: center;
  border-radius: 18px;
  gap: clamp(12px, 2.5vw, 36px);
  color: #111827;
  background: #f2f1f0;
  font-size: clamp(25px, 3vw, 52px);
}
.page-chat .recording-pause span {
  font-size: clamp(20px, 2.5vw, 34px);
  font-weight: 650;
  letter-spacing: -.02em;
}
.dark-theme .recording-pause { color: #f8fafc; background: #2a2e33; }
.page-chat .recording-send {
  width: clamp(64px, 10vw, 164px) !important;
  min-width: 64px;
  justify-self: end;
  border-radius: 50%;
  color: #fff;
  background: #101113;
  font-size: clamp(27px, 3.2vw, 58px);
  box-shadow: 0 8px 18px rgba(0,0,0,.16);
}
.page-chat #audioRecordingPanel.is-paused .recording-waveform { opacity: .62; }
@keyframes recordingComposerIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@media (max-width: 600px) {
  .page-chat #audioRecordingPanel {
    width: calc(100vw - 16px);
    padding: 15px 14px 14px;
    border-radius: 26px;
  }
  .page-chat .recording-topline { grid-template-columns: 68px minmax(0, 1fr) 40px; gap: 8px; min-height: 58px; }
  .page-chat .recording-visual, .page-chat .recording-waveform { height: 58px; }
  .page-chat .recording-timer { font-size: 25px; }
  .page-chat .recording-speed { width: 38px; height: 38px; font-size: 12px; }
  .page-chat .recording-speed span { font-size: 20px; }
  .page-chat .recording-speed b { font-size: 10px; margin-top: 2px; }
  .page-chat .recording-controls { grid-template-columns: 52px minmax(0, 1fr) 52px; gap: 11px; margin-top: 10px; }
  .page-chat .recording-action, .page-chat .recording-pause { height: 52px !important; min-height: 52px; }
  .page-chat .recording-delete, .page-chat .recording-send { width: 52px !important; min-width: 52px; font-size: 21px; }
  .page-chat .recording-pause { width: 100% !important; gap: 12px; border-radius: 14px; font-size: 19px; }
  .page-chat .recording-pause span { font-size: 18px; }
}

.page-chat #newMessagesBtn { align-items:center; justify-content:center; width:36px; height:36px; min-width:36px; padding:0; border-radius:50%; color:var(--text-color); background:var(--input-bg); border:1px solid var(--workspace-line,#8884); box-shadow:0 3px 12px #0002; }
.page-chat #newMessagesBtn svg { flex-shrink:0; }

.page-chat .message-meta { flex-wrap:nowrap; gap:clamp(3px,1vw,8px); min-height:28px; max-width:100%; }
.page-chat .message-meta .message-actions { flex:0 0 auto; margin:0; opacity:1; min-height:28px; }
.page-chat .message-meta .message-send-state { flex:0 0 20px; margin:0; opacity:1; }
.page-chat .myChat .message-meta { justify-content:flex-end; }
@media (max-width:480px) {
  .page-chat .message-meta { font-size:9px; margin-inline:0; }
  .page-chat .message-meta-duration { padding-left:4px; }
  .page-chat .message-meta .message-copy { width:28px; }
}

.page-chat .message-meta .message-copy { display:inline-flex; align-items:center; justify-content:center; width:16px; height:16px; padding:0; border:0; border-radius:0; background:none; line-height:1; vertical-align:middle; }
.page-chat .message-copy svg { width:14px; height:14px; flex-shrink:0; }
.page-chat .message-meta .message-copy:hover, .page-chat .message-meta .message-copy.copied, .page-chat .message-meta .message-copy.copy-failed { background:none; }
.page-chat .message-copy:focus-visible { outline:1px solid currentColor; outline-offset:3px; }

/* Let the status area blend into the chat background. */
.page-chat .headerBar,
.page-chat .assistant-state { background:transparent; border:0; box-shadow:none; }
.page-chat .assistant-state::before,
.page-chat .assistant-state::after { background:none; box-shadow:none; }
@media (max-width:900px) {
  .page-chat .headerBar { width:calc(100% + 40px); max-width:none; margin-inline:-20px; padding-inline:8px; border-radius:0; box-sizing:border-box; }
}
@media (max-width:600px) {
  .page-chat .headerBar { width:calc(100% + 20px); margin-inline:-10px; }
}
