/* Mobile and compact tablet interaction model. Loaded after styles.css. */
.mobile-nav,
.mobile-back,
.mobile-context-button,
.mobile-context-header { display: none; }

@media (max-width: 820px) {
  #view-inbox[hidden], .other-view[hidden] { display: none !important; }
  html, body { width: 100%; height: 100%; overflow: hidden; }
  body { min-width: 320px; }
  .app-shell { width: 100%; height: 100dvh; min-height: 0; }
  .sidebar { display: none; }
  .main-area { width: 100%; height: 100dvh; min-height: 0; overflow: hidden; }
  .topbar { height: 54px; min-height: 54px; padding: 0 16px; }
  .view-pane { width: 100%; max-width: none; height: calc(100dvh - 54px); min-height: 0; margin: 0; padding: 13px 14px calc(13px + 66px + env(safe-area-inset-bottom)); overflow: hidden; }
  #view-inbox { display: flex; flex-direction: column; }
  #view-inbox .page-heading { flex: none; margin-bottom: 12px; }
  #view-inbox.mobile-detail .page-heading { display: none; }
  #view-inbox .inbox-layout { position: relative; display: block; flex: 1; width: 100%; height: auto; min-height: 0; overflow: hidden; border-radius: 10px; }
  .conversation-column, .thread-column, .context-column { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; border: 0; }
  .conversation-column { display: flex; }
  .thread-column, .context-column { display: none; }
  .inbox-layout.mobile-thread .conversation-column { display: none; }
  .inbox-layout.mobile-thread .thread-column { display: flex; }
  .inbox-layout.mobile-context .conversation-column,
  .inbox-layout.mobile-context .thread-column { display: none; }
  .inbox-layout.mobile-context .context-column { display: flex; overflow: auto; }
  .inbox-toolbar { padding: 12px 13px 10px; }
  .searchbox { height: 44px; padding: 0 11px; }
  .searchbox input { min-width: 0; font-size: 16px; }
  .searchbox kbd { display: none; }
  .filter-row { padding-top: 9px; }
  .filter-chips { gap: 7px; padding: 1px 0 8px; scrollbar-width: none; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .filter-chip { min-height: 36px; padding: 0 11px; font-size: 12px; }
  .filter-row select { min-height: 40px; margin-top: 2px; font-size: 14px; }
  .list-summary { min-height: 34px; padding-top: 5px; font-size: 12px; }
  .link-button { min-height: 36px; padding: 0 8px; font-size: 12px; }
  .conversation-list { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .conversation-card { min-height: 88px; gap: 11px; padding: 13px 12px; }
  .conversation-card > .avatar { width: 38px; height: 38px; font-size: 12px; }
  .card-top { gap: 7px; }
  .card-name { font-size: 14px; }
  .card-time { font-size: 11px; }
  .channel-mark { height: 21px; min-width: 24px; font-size: 9px; }
  .card-subject { margin: 5px 0 3px; font-size: 12px; }
  .card-preview { font-size: 11px; }
  .card-foot { gap: 5px; margin-top: 7px; overflow: hidden; }
  .status-pill, .priority-pill, .tag, .mini-pill { padding: 4px 7px; font-size: 9px; }
  .thread-content { display: flex; flex: 1; flex-direction: column; min-height: 0; }
  .thread-header { min-height: 58px; height: auto; padding: 6px 9px; gap: 7px; }
  .mobile-back { display: grid; place-items: center; flex: none; width: 42px; height: 44px; border: 0; border-radius: 8px; background: #f5f6fa; color: #526176; font-size: 23px; }
  .thread-title strong { font-size: 14px; }
  .thread-title span { font-size: 10px; line-height: 1.3; }
  .thread-actions { flex: none; gap: 3px; }
  .square-btn { width: 42px; height: 44px; border-radius: 8px; font-size: 16px; }
  .square-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
  .mobile-context-button { display: grid; }
  .thread-messages { padding: 15px 13px 12px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .day-divider { font-size: 11px; margin-bottom: 16px; }
  .message { max-width: 94%; gap: 7px; margin-bottom: 13px; }
  .msg-avatar { width: 30px; height: 30px; font-size: 10px; }
  .msg-meta { font-size: 10px; flex-wrap: wrap; }
  .msg-bubble { padding: 10px 12px; font-size: 14px; line-height: 1.48; }
  .copilot-card { padding: 12px; }
  .copilot-top { font-size: 12px; }
  .copilot-body { font-size: 12px; line-height: 1.5; }
  .citation-chip { padding: 5px 7px; font-size: 10px; }
  .risk-banner { font-size: 10px; }
  .reply-box { padding: 7px 10px calc(9px + env(safe-area-inset-bottom)); }
  .composer-toolbar { min-height: 40px; margin-bottom: 3px; }
  .composer-label { font-size: 10px; }
  .composer-tool { width: 40px; height: 40px; font-size: 17px; }
  .reply-box textarea { display: block; min-height: 76px; max-height: 25dvh; padding: 9px 2px; resize: vertical; font-size: 16px; line-height: 1.4; }
  .reply-footer { align-items: flex-end; gap: 8px; }
  .reply-hint { max-width: 33%; font-size: 9px; line-height: 1.35; }
  .reply-buttons { gap: 6px; }
  .reply-buttons .button { min-height: 44px; height: auto; padding: 0 11px; font-size: 11px; white-space: nowrap; }
  .mobile-context-header { position: sticky; top: 0; z-index: 1; display: flex; min-height: 52px; align-items: center; gap: 12px; padding: 4px 12px; border-bottom: 1px solid var(--line); background: #fff; }
  .mobile-context-header button { min-height: 42px; border: 0; background: transparent; color: #5d6bd4; font-size: 13px; }
  .mobile-context-header strong { font-size: 14px; }
  .context-header { padding: 20px 16px 16px; }
  .context-header strong { font-size: 15px; }
  .contact-avatar { width: 52px; height: 52px; font-size: 15px; }
  .context-section { padding: 15px; }
  .context-section h3 { margin-bottom: 12px; font-size: 12px; }
  .context-section h3 .context-action { margin-left: auto; }
  .context-kv { grid-template-columns: minmax(90px, .8fr) minmax(0, 1.2fr); gap: 11px 8px; font-size: 12px; }
  .context-kv b { max-width: none; }
  .context-note { font-size: 12px; }
  .order-card { padding: 11px; }
  .order-card b { font-size: 11px; }
  .order-card span { font-size: 10px; }
  .context-action { min-height: 38px; font-size: 12px; }
  .mobile-nav { position: fixed; z-index: 15; right: 0; bottom: 0; left: 0; display: flex; height: calc(64px + env(safe-area-inset-bottom)); align-items: stretch; padding: 5px 7px calc(5px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); box-shadow: 0 -5px 18px rgba(24,38,64,.06); backdrop-filter: blur(12px); }
  .mobile-nav-item { position: relative; display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 9px; background: transparent; color: #8490a0; }
  .mobile-nav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; }
  .mobile-nav-item span { font-size: 10px; line-height: 1.1; white-space: nowrap; }
  .mobile-nav-item.active { color: #5367e8; font-weight: 700; }
  .mobile-nav-item.active::before { position: absolute; top: -5px; width: 25px; height: 2px; border-radius: 2px; background: currentColor; content: ""; }
  .mobile-count { position: absolute; top: 3px; left: calc(50% + 11px); min-width: 17px; padding: 2px 4px; border-radius: 12px; background: #ffefdc; color: #a76a1d; font-size: 9px; line-height: 1.1; text-align: center; }
  .other-view { height: calc(100dvh - 54px); padding: 16px 14px calc(18px + 66px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .other-heading { align-items: flex-start; gap: 10px; margin-bottom: 15px; }
  .other-heading h1 { font-size: 21px; }
  .other-heading p { font-size: 12px; line-height: 1.4; }
  .other-heading > .mini-pill { max-width: 42%; white-space: normal; text-align: center; }
  .panel { padding: 13px; margin-bottom: 11px; }
  .panel-title { align-items: flex-start; gap: 8px; }
  .panel-title h2 { font-size: 13px; }
  .panel-title span { text-align: right; }
  .approval-card { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 13px; }
  .approval-card h3 { font-size: 14px; line-height: 1.35; }
  .approval-card p { font-size: 12px; }
  .approval-meta { font-size: 10px; line-height: 1.4; }
  .approval-detail { max-height: 180px; font-size: 12px; }
  .approval-actions { justify-content: stretch; gap: 8px; }
  .approval-actions .button { flex: 1; min-height: 44px; height: auto; justify-content: center; padding: 7px 9px; font-size: 11px; text-align: center; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card span { font-size: 11px; line-height: 1.3; }
  .stat-card b { font-size: 21px; }
  .stat-card em { font-size: 9px; }
  .analytics-grid { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .bar-row { grid-template-columns: minmax(82px, 1fr) minmax(45px, 1.4fr) 25px; gap: 7px; font-size: 10px; }
  .audit-filters select { width: 100%; min-height: 44px; font-size: 13px; }
  .audit-row { grid-template-columns: minmax(88px, .7fr) minmax(0, 1.3fr); gap: 5px 9px; padding: 12px 2px; font-size: 11px; }
  .audit-row time { grid-column: 1; grid-row: 1; font-size: 10px; }
  .audit-row .audit-type { grid-column: 2; grid-row: 1; }
  .audit-row b { grid-column: 1 / -1; grid-row: 2; font-size: 12px; }
  .audit-row span:last-child { display: block; grid-column: 1 / -1; grid-row: 3; }
  .toast-region { right: 12px; bottom: calc(75px + env(safe-area-inset-bottom)); left: 12px; }
  .toast { padding: 12px 14px; font-size: 12px; }
  .app-dialog { width: 100%; max-width: none; max-height: 86dvh; margin: auto 0 0; overflow: auto; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .dialog-inner { padding: 20px 18px 18px; }
  .dialog-top h2 { font-size: 17px; }
  .dialog-close { width: 44px; height: 44px; }
  .dialog-body { font-size: 13px; }
  .dialog-body textarea, .dialog-body input, .dialog-body select { min-height: 44px; font-size: 16px; }
  .dialog-footer .button { min-height: 44px; }
  .action-menu { display: grid; gap: 7px; }
  .action-menu .button { min-height: 46px; justify-content: flex-start; padding: 0 12px; font-size: 13px; }
}

@media (max-width: 650px) {
  .topbar { padding: 0 12px; }
  .breadcrumbs { font-size: 12px; }
  .breadcrumbs > span:first-child, .breadcrumbs .slash { display: none; }
  .topbar-right { gap: 7px; }
  .demo-pill, .top-avatar { display: none; }
  .icon-button { width: auto; min-width: 40px; height: 40px; padding: 0 10px; font-size: 12px; }
  .mobile-reset-label { display: inline; }
  .view-pane { padding: 11px 10px calc(11px + 66px + env(safe-area-inset-bottom)); }
  #view-inbox .page-heading { align-items: center; margin-bottom: 10px; }
  .eyebrow { margin-bottom: 4px; font-size: 8px; }
  .page-heading h1 { font-size: 19px; letter-spacing: -.5px; }
  .page-heading p { max-width: 250px; font-size: 10px; line-height: 1.35; }
  .page-heading > .button { min-width: 40px; width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 16px; }
  .page-heading > .button span { display: none; }
  #refresh-demo { display: none; }
  .inbox-layout { border-radius: 8px !important; }
  .inbox-toolbar { padding: 10px 10px 7px; }
  .searchbox input { font-size: 16px; }
  .conversation-card { min-height: 84px; padding: 11px 10px; }
  .card-foot .tag { display: none; }
  .thread-header { padding: 5px 7px; gap: 5px; }
  .mobile-back, .square-btn { width: 40px; min-width: 40px; height: 42px; }
  .thread-actions [data-action="assign"],
  .thread-actions [data-action="followup"],
  .thread-actions [data-action="close"] { display: none; }
  .thread-title strong { font-size: 13px; }
  .thread-title span { font-size: 9px; }
  .thread-messages { padding: 12px 10px; }
  .message { max-width: 97%; }
  .reply-hint { display: none; }
  .reply-footer { justify-content: flex-end; }
  .reply-buttons { width: 100%; }
  .reply-buttons .button { flex: 1; justify-content: center; padding: 0 7px; font-size: 10px; }
  .composer-label { max-width: calc(100% - 120px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .other-view { padding: 14px 10px calc(16px + 66px + env(safe-area-inset-bottom)); }
  .other-heading { flex-direction: column; gap: 8px; }
  .other-heading > .mini-pill { max-width: 100%; }
  .panel-title { flex-direction: column; gap: 4px; }
  .panel-title span { text-align: left; }
  .approval-actions { flex-direction: column-reverse; }
  .approval-actions .button { width: 100%; flex: none; }
  .audit-row { grid-template-columns: minmax(80px, .75fr) minmax(0, 1.25fr); }
}

@media (min-width: 651px) and (max-width: 820px) {
  .mobile-reset-label { display: none; }
  .icon-button { width: 40px; padding: 0; font-size: 20px; }
}

@media (max-width: 370px) {
  .topbar-right { gap: 3px; }
  .view-pane { padding-right: 8px; padding-left: 8px; }
  .mobile-nav { padding-right: 3px; padding-left: 3px; }
  .mobile-nav-item span { font-size: 9px; }
  .thread-title span { display: none; }
  .reply-buttons .button { font-size: 9px; }
}


/* --- Slack: ajustes móviles del canal --- */
@media (max-width: 1200px) {
  .channel-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .mobile-nav-item span { font-size: 9px; }
  .channel-grid { gap: 2px; }
  .check-grid { grid-template-columns: minmax(0, 1fr); }
  .connector-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .connector-actions .button { min-height: 44px; justify-content: center; }
  .slack-demo-row { min-height: 62px; padding: 11px; }
  .slack-demo-main b { font-size: 12px; }
  .slack-demo-main span { font-size: 11px; }
  .slack-guide li { font-size: 12px; line-height: 1.5; }
  .slack-guide b { font-size: 13px; }
  .security-list { font-size: 12px; }
  .connector-note, .connector-meta { font-size: 11px; }
  .check-row b { font-size: 12px; }
  .check-row span, .check-row em { font-size: 10px; }
  .connector-mode { font-size: 11px; }
}
@media (max-width: 370px) {
  .mobile-nav-item span { font-size: 8px; letter-spacing: -.2px; }
}

/* --- Slack: mensajes D1 en móvil --- */
@media (max-width: 820px) {
  .live-slack-banner { min-height: 54px; padding: 11px 12px; }
  .live-slack-banner b { font-size: 12px; }
  .live-slack-banner span { font-size: 10px; }
  .live-note { font-size: 12px; }
  .live-reply-form { gap: 10px; padding: 12px; }
  .live-reply-form label { font-size: 13px; }
  .live-reply-form textarea { min-height: 100px; padding: 11px; font-size: 14px; }
  .live-reply-form .button { min-height: 44px; font-size: 13px; }
  .live-reply-form > span { font-size: 11px; }
  .live-thread-row { min-height: 64px; padding: 11px; }
  .live-thread-main b { font-size: 12px; }
  .live-thread-main span { font-size: 11px; }
  .live-thread-main em { font-size: 10px; }
  .live-message { padding: 10px; }
  .live-meta, .live-meta b { font-size: 10px; }
  .live-text { font-size: 12px; }
}
