/* Shared touch affordances; desktop layout remains available. */
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; }
.send-btn, .call-btn, .agent-btn, .attach-btn, .mic-btn, .view-tab, .call-fab, .call-fab-item, .hangup-btn, .composer-more, .dl-btn, .model-dropdown-btn {
  position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}
.send-btn { background: var(--accent); opacity: .38; }
.send-btn.is-ready:not(:disabled) { opacity: 1; }
.send-btn:disabled { opacity: .38; cursor: not-allowed; }
.composer-label { display: none; }
.chat-header .call-btn { width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; flex: 0 0 40px; border-radius: 50%; background: transparent; box-shadow: none; color: var(--text2); font-size: 20px; }
.chat-header .call-btn:hover { transform: none; box-shadow: none; }
.md-ripple { position: absolute; border-radius: 50%; pointer-events: none; z-index: 0; transform: scale(0); opacity: 1; animation: mdRipple 450ms cubic-bezier(0.2, 0, 0, 1) forwards; }
@keyframes mdRipple { to { transform: scale(1); } }
.md-ripple.fade { animation: mdRippleFade 150ms linear forwards; }
@keyframes mdRippleFade { to { opacity: 0; } }
.composer-more, .mobile-scheduled-link { display: none; }
.composer-options { display: contents; }
.mobile-page-context[hidden], [hidden] { display: none !important; }
@media (hover: none) {
  .send-btn:hover, .call-btn:hover { transform: none; box-shadow: none; }
  .call-overlay .hangup-btn:hover, .call-overlay .hangup-btn:active { transform: rotate(135deg); }
}

/* Voice-to-action dialog. Its content scrolls independently of the controls. */
.call-overlay {
  inset: 0; height: var(--app-height, 100dvh); padding: max(20px, env(safe-area-inset-top)) 24px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 32%, rgba(78,57,129,.58), transparent 64%), rgba(8,13,29,.96);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); gap: 0; isolation: isolate;
  animation: callModalIn 240ms ease both;
}
@keyframes callModalIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.call-heading { display: flex; align-items: center; justify-content: space-between; width: min(100%, 480px); flex-shrink: 0; color: #b9c2d9; }
.call-session-label { font-size: 10px; font-weight: 650; letter-spacing: .2em; }
.call-overlay .call-timer { margin: 0; font-size: 14px; color: #b9c2d9; }
.call-stage { width: min(100%, 480px); flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow-y: auto; padding: 20px 0; scrollbar-width: thin; }
.call-overlay .avatar-ring { width: 104px; height: 104px; margin: 12px 0; flex-shrink: 0; animation: none; box-shadow: 0 0 70px #7750be38; }
.call-overlay .avatar-inner { font-size: 3rem; }
.call-overlay .call-name { margin: 12px 0 0; font-size: 28px; letter-spacing: -.03em; }
.call-overlay .call-status { display: flex; align-items: center; gap: 8px; min-height: 24px; margin-top: 8px; color: #cbd6e9; font-size: 14px; }
.call-status::before, .live-indicator { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #55e0c0; box-shadow: 0 0 12px #55e0c066; }
.call-overlay[data-state="processing"] .call-status::before { background: #c2a4ff; animation: dotPulse 1s infinite; }
.call-overlay[data-state="executed"] .call-status { color: #85f1d3; }
.call-overlay .wave-container { width: 100%; height: 48px; margin: 16px 0; flex-shrink: 0; }
.call-action-toast { width: 100%; flex-shrink: 0; max-height: 128px; overflow-y: auto; padding: 16px; border: 1px solid #72edc755; border-radius: 18px; background: linear-gradient(120deg,#64e3bf1a,#ae84ed1a); box-shadow: 0 12px 32px #0003, inset 0 1px #ffffff0d; color: #caffed; font-size: 14px; line-height: 1.6; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); overflow-wrap: anywhere; }
.action-arrived { animation: callModalIn 240ms ease both; }
.transcript-heading { display: flex; align-items: center; gap: 8px; margin-top: 20px; margin-bottom: 8px; color: #94a3bd; font-size: 11px; letter-spacing: .05em; }
.call-overlay .call-transcript { position: static; transform: none; width: 100%; max-width: none; max-height: 130px; min-height: 40px; flex: 0 1 auto; overflow-y: auto; pointer-events: auto; text-align: center; }
.call-overlay .transcript-msg { padding: 8px 10px; margin: 4px 0; font-size: 13px; border-radius: 12px; }
.call-overlay .transcript-msg.ai-msg { background: transparent; border: 0; color: #c2b6dc; }
.call-overlay .call-actions { width: min(100%, 380px); gap: 10px; margin: 0; padding: 12px 0 0; flex-shrink: 0; }
.call-overlay .hangup-btn { width: 72px; height: 72px; min-height: 56px; min-width: 56px; margin-top: 8px; transform: rotate(135deg); background: linear-gradient(145deg,#ff6869,#e9394b); box-shadow: 0 8px 32px #e9394b40; }
.call-overlay .hangup-btn:hover, .call-overlay .hangup-btn:active { transform: rotate(135deg); }
.hangup-label { color: #b6bed1; font-size: 11px; }
#deviceModal button { min-height: 48px; }

@media (max-width:768px) {
  :root { --mobile-nav-height: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .app { height: var(--app-height,100dvh) !important; }
  .main { padding-bottom: var(--mobile-nav-height); transition: padding-bottom 180ms ease; }
  #sectionNav { display: grid !important; position: fixed; inset: auto 0 0; grid-template-columns: repeat(4,minmax(0,1fr)); height: var(--mobile-nav-height); padding: 4px 12px env(safe-area-inset-bottom); border: 0; border-top: 1px solid var(--border); background: var(--bg3); z-index: 110; gap: 4px; overflow: visible; transition: transform 180ms ease, opacity 180ms ease; }
  #sectionNav .view-tab { min-width: 48px; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; border: 0; border-radius: 14px; font-size: 11px; font-weight: 550; color: var(--text3); background: transparent; }
  #sectionNav .nav-icon { font-size: 21px; line-height: 24px; filter: grayscale(1); opacity: .6; }
  #sectionNav .view-tab.active { color: var(--accent2); background: color-mix(in srgb,var(--accent2) 10%,transparent); }
  #sectionNav .view-tab.active .nav-icon { filter: none; opacity: 1; }
  #sectionNav [data-view="cron"] { display: none; }
  .keyboard-active .main { padding-bottom: 0; }
  .keyboard-active #sectionNav { transform: translateY(100%); opacity: 0; visibility: hidden; pointer-events: none; }
  .main-panel > div:first-child > .view-tab { display: none; }
  #panel-calendar > div:first-child > span { display: none; }
  .mobile-scheduled-link { display: block; min-height: 48px; margin: 12px 52px 4px; color: var(--text); background: var(--bg3); border: 1px solid var(--border); border-radius: 12px; }
  .mobile-page-context { padding: 16px 20px 16px 64px; font-size: 17px; font-weight: 650; border-bottom: 1px solid var(--border); }
  .sidebar-toggle { top: max(4px,env(safe-area-inset-top)); left: 8px; width: 48px; height: 48px; min-width: 48px; background: transparent; border: 0; color: var(--text2); font-size: 20px; }
  .chat-header { min-height: 56px; padding: 4px 12px 4px 64px; gap: 8px; }
  .chat-header .title { max-width: none; font-size: 15px; }
  .chat-header .title-edit-btn, #headerFolderBtn, #headerCopyBtn, #headerExportBtn { display: none; }
  .chat-header #headerPinBtn, .chat-header #headerAttachBtn { min-width: 48px; min-height: 48px; padding: 8px; border: 0; background: transparent; }
  .chat-header > div:last-child { gap: 0 !important; }
  .input-resize-handle { display: none; }
  .messages { padding: 16px 12px 24px; }
  .input-area { padding: 10px 12px 12px; background: var(--bg3); border-top: 1px solid var(--border); }
  .keyboard-active .input-area { padding-bottom: 8px; }
  .chat-header .call-btn { width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 0; flex: 0 0 48px; border-radius: 50%; background: transparent; box-shadow: none; color: var(--text); font-size: 22px; }
  .input-row { position: relative; display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 6px; }
  .input-row textarea { order: 2; flex: 1 1 auto; width: auto; min-width: 0; min-height: 48px; max-height: 120px; padding: 12px 14px; border: 2px solid var(--border2); border-radius: 24px; font-size: 16px; line-height: 22px; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
  .input-row textarea::-webkit-scrollbar { width: 3px; height: 3px; }
  .input-row textarea:focus { outline: none; border-color: var(--accent2); }
  .input-row > .attach-wrap { order: 1; }
  .input-row > .composer-more { order: 3; }
  .input-row > .send-btn { order: 4; }
  .input-row > .mic-btn { order: 5; }
  .input-row .attach-wrap, .input-row .attach-btn, .input-row .composer-more, .input-row .mic-btn { width: 48px; height: 48px; min-width: 48px; min-height: 48px; padding: 0; flex: 0 0 48px; border-radius: 50%; }
  .input-row .attach-btn, .input-row .composer-more, .input-row .mic-btn { border: 0; background: transparent; color: var(--text2); font-size: 22px; }
  .input-row .mic-btn.recording { background: var(--accent); color: #fff; }
  .input-row > .send-btn:not(.is-ready) { position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .input-row > .send-btn.is-ready { position: static; width: 96px; min-width: 96px; height: 48px; min-height: 48px; padding: 0 12px; flex: 0 0 96px; border-radius: 24px; font-size: 15px; line-height: 1; white-space: nowrap; }
  .composer-more { display: inline-flex; align-items: center; justify-content: center; }
  .input-row .composer-options { display: none; position: absolute; left: 0; right: 0; bottom: 100%; z-index: 120; flex-direction: column; gap: 4px; padding: 8px; background: var(--bg2); border: 1px solid var(--border); border-bottom: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 32px #0006; }
  .input-row .composer-options.open { display: flex; }
  .input-row .composer-options .composer-label { display: inline; position: relative; z-index: 1; }
  .input-row .composer-options .agent-btn,
  .input-row .composer-options .call-btn,
  .input-row .composer-options .model-dropdown,
  .input-row .composer-options .model-dropdown-btn { width: 100%; max-width: none; min-height: 48px; height: 48px; margin: 0; padding: 0 16px; border: 0; border-radius: 12px; background: transparent; box-shadow: none; color: var(--text); font-size: 15px; display: flex; align-items: center; justify-content: flex-start; gap: 12px; }
  .input-row .composer-options .model-dropdown { padding: 0; height: auto; min-height: 0; }
  .input-row .composer-options .agent-btn.active { background: var(--accent); color: #fff; }
  .call-overlay { padding-left: 20px; padding-right: 20px; }
}
@media (max-height:600px) {
  .call-overlay { padding-top: 8px; padding-bottom: max(8px,env(safe-area-inset-bottom)); }
  .call-stage { padding: 4px 0; justify-content: flex-start; }
  .call-overlay .avatar-ring { width: 56px; height: 56px; margin: 4px; }
  .call-overlay .avatar-inner { font-size: 24px; }
  .call-overlay .call-name { font-size: 20px; margin: 2px 0; }
  .call-overlay .wave-container { margin: 4px 0; height: 32px; }
  .call-overlay .call-actions { gap: 6px; padding-top: 6px; }
  .call-overlay .hangup-btn { width: 56px; height: 56px; margin-top: 0; }
  .call-overlay .call-fab-wrap { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion:reduce) {
  .call-overlay *, .call-overlay, #sectionNav, .main, button, .md-ripple { animation: none !important; transition: none !important; }
  .md-ripple { display: none; }
  .send-btn:active, .hangup-btn:active, .mic-btn.recording:active, .agent-btn.active:active, .call-btn:active { box-shadow: inset 0 0 0 999px rgba(255,255,255,.12); }
  .attach-btn:active, .mic-btn:not(.recording):active, .composer-more:active, .agent-btn:not(.active):active, .view-tab:active, .dl-btn:active, .model-dropdown-btn:active { box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--accent2) 12%, transparent); }
}
@media (prefers-reduced-motion:reduce) and (max-width:768px) {
  .composer-options .call-btn:active { box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--accent2) 12%, transparent); }
}
/* Native dialogs use the top layer above the call overlay and browser keyboard. */
.action-dialog { margin:auto; width:min(560px,calc(100% - 24px)); max-height:calc(var(--app-height,100dvh) - 24px); padding:0; border:1px solid var(--border); border-radius:24px; background:var(--bg2); color:var(--text); box-shadow:0 24px 80px #0008; }
.action-dialog::backdrop { background:#080d1dbd; backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px); }
.action-dialog > header { position:sticky; top:0; z-index:1; padding:12px 16px; display:flex; align-items:center; justify-content:space-between; background:var(--bg2); border-bottom:1px solid var(--border); }
.action-dialog h2 { font-size:18px; }
.action-dialog button { min-width:48px; min-height:48px; padding:10px 14px; border:1px solid var(--border); border-radius:14px; background:var(--bg3); color:var(--text); cursor:pointer; }
.action-dialog button:active { transform:scale(.96); }
.action-dialog button:disabled { opacity:.45; cursor:default; }
.action-dialog-body { padding:16px 20px max(20px,env(safe-area-inset-bottom)); display:flex; flex-direction:column; gap:16px; }
.action-dialog label { display:flex; flex-direction:column; gap:8px; font-size:13px; color:var(--text2); }
.action-dialog input, .action-dialog textarea { width:100%; border:1px solid var(--border); border-radius:12px; min-height:48px; padding:12px; font:inherit; font-size:16px; background:var(--input-bg); color:var(--text); }
.action-dialog textarea { min-height:140px; resize:vertical; }
.action-dialog footer { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.action-dialog footer > button:first-child { grid-column:1/-1; background:var(--accent); border-color:var(--accent); color:white; }
.action-caption { color:var(--text3); font-size:12px; line-height:1.6; }
.action-feedback { font-size:13px; color:var(--accent2); line-height:1.6; }
.action-feedback.error { color:#ff9c99; }
.connection-card { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:16px 0; border-bottom:1px solid var(--border); }
.connection-card > div { min-width:0; }
.call-action-toast, .message.assistant .bubble { white-space:pre-line; }
.call-action-toast a { display:inline-block; color:#caffed; text-underline-offset:4px; min-height:44px; padding-top:8px; }
@keyframes chatReturn { from {opacity:.65;transform:translateY(6px)} to {opacity:1;transform:translateY(0)} }
.call-return { animation:chatReturn 200ms ease; }
@media(prefers-reduced-motion:reduce){.call-return{animation:none}}

@media(max-width:768px){
  .main { padding-top:env(safe-area-inset-top); }
  .sidebar { padding-top:env(safe-area-inset-top); }
}
@media (min-width:769px) {
  .composer-more { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 12px; background: transparent; color: var(--text2); font-size: 22px; }
  .input-row { position: relative; align-items: flex-end; }
  .input-row .composer-options { display: none; position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 120; flex-direction: column; gap: 4px; width: 240px; padding: 8px; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 32px #0006; }
  .input-row .composer-options.open { display: flex; }
  .input-row .composer-options .composer-label { display: inline; position: relative; z-index: 1; }
  .input-row .composer-options .attach-wrap,
  .input-row .composer-options .attach-btn,
  .input-row .composer-options .mic-btn,
  .input-row .composer-options .agent-btn,
  .input-row .composer-options .model-dropdown,
  .input-row .composer-options .model-dropdown-btn { width: 100%; max-width: none; min-height: 44px; height: 44px; margin: 0; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; box-shadow: none; color: var(--text); font-size: 15px; display: flex; align-items: center; justify-content: flex-start; gap: 10px; }
  .input-row .composer-options .model-dropdown { height: auto; min-height: 0; padding: 0; }
  .input-row .composer-options .agent-btn.active,
  .input-row .composer-options .mic-btn.recording { background: var(--accent); color: #fff; }
}
