/* A denser working surface on desktop; single-pane conversations on phones. */
.mobile-navigation { display: none; }
.workspace-heading { margin-bottom: 18px; }
.workspace-heading .eyebrow { margin-bottom: 5px; }
.workspace-heading h1 { font-size: 30px; }
.tabs { gap: 8px 20px; flex-wrap: wrap; margin-bottom: 16px; overflow: visible; }
.tabs .tab-button { min-height: 44px; }
.connection-bar { margin-bottom: 18px; font-size: 14px; }
.section-help { line-height: 1.6; }
input, select, textarea { font-size: 16px; }
.check-label, .quiet { font-size: 14px; }
.rich-composer:focus-within { border-color: #44886b; box-shadow: 0 0 0 2px #21674914; }
.editor-body .ql-editor { font-size: 16px; line-height: 1.65; }
.compact-composer { display: flex; flex-direction: column; }
.compact-composer .editor-toolbar { order: 0; }
.compact-composer .editor-body { order: 1; }
.compact-composer .composer-options { order: 2; gap: 8px; padding: 4px 10px; border-top: 1px solid #e8eee9; }
.compact-composer .upload-area { order: 3; padding: 0 10px 7px; border-top: 0; gap: 5px; }
.compact-composer .composer-options .upload-label { margin-left: auto; }
.compact-composer .send-key-hint { font-size: 12px; }
.compact-composer .upload-label { display: inline-flex; align-items: center; cursor: pointer; margin-bottom: 0; }
.compact-composer .upload-label:focus-within { outline: 2px solid #216749; outline-offset: 2px; }
.compact-composer .upload-label input { width: 1px; height: 1px; min-height: 0; padding: 0; position: absolute; opacity: 0; }
.compact-composer .upload-area > small { font-size: 12px; }
.compact-composer .upload-list { max-height: 140px; overflow: auto; }
.message-composer { padding: 12px; gap: 10px; }
.message-composer > .primary { min-width: 72px; min-height: 48px; margin-bottom: 1px; }
.message-composer .ql-editor { min-height: 66px; max-height: 180px; }
.new-message-button { bottom: calc(var(--composer-height, 180px) + 12px); }
.inquiry-conversation { position: relative; }
.chat-layout { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); gap: 16px; }
.chat-sidebar { padding: 18px; }
.chat-sidebar .room-list { max-height: 55dvh; overflow: auto; }
.chat-main .message-stream, .inquiry-stream { height: clamp(260px, 47dvh, 650px); }
.message-footer button { min-height: 32px; padding-inline: 6px; }
.upload-chip { max-width: 100%; }
.upload-chip > span { min-width: 0; overflow-wrap: anywhere; }
.survey-submit { position: sticky; bottom: 8px; z-index: 4; background: #fff; border: 1px solid #cadbd3; border-radius: 12px; padding: 10px 14px; box-shadow: 0 3px 20px #102a2010; }
.survey-submit .hint { margin: 0; padding: 0; background: none; }
.survey-submit .primary { min-height: 48px; }
.survey-sticky { scroll-margin-top: 12px; }
.survey-question, .survey-section { scroll-margin-top: 110px; }
.survey-options input { min-height: 20px; }

@media (min-width: 761px) {
  #chat-active:not([hidden]), .inquiry-conversation {
    display: flex; flex-direction: column; height: var(--conversation-height, 560px); min-height: 0;
  }
  .inquiry-conversation { width: 100%; }
  .chat-main .message-stream, .inquiry-stream { flex: 1 1 0; height: auto; min-height: 0; }
  .message-composer, .conversation-heading, .chat-tools-bar, .history-button { flex-shrink: 0; }
  .conversation-heading { max-height: 25%; overflow: auto; }
  #chat-pinned { max-height: 20%; overflow: auto; flex-shrink: 0; }
  .compact-composer .editor-toolbar { max-height: 180px; overflow-y: auto; }
}

@media (min-width: 761px) and (max-width: 1040px) {
  .chat-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .compact-composer .send-key-hint { display: none; }
}

@media (max-width: 760px) {
  :root { --mobile-preview-height: 0px; }
  body { font-size: 16px; }
  main { padding: 16px 14px 36px; }
  .topbar { min-height: 0; padding: 14px; gap: 12px; flex-wrap: wrap; }
  .brand { font-size: 16px; }
  .brand-mark { width: 38px; height: 38px; font-size: 16px; }
  .brand small { font-size: 12px; }
  .account { width: 100%; max-width: none; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
  #account-name { flex: 1 1 100%; font-size: 14px; text-align: left; }
  .account button { min-height: 40px; padding: 7px 12px; }
  .workspace-heading { margin: 4px 0 14px; }
  .workspace-heading h1 { font-size: 26px; line-height: 1.35; }
  .workspace-heading .eyebrow, .workspace-heading .class-pill { display: none; }
  #workspace-description { font-size: 14px; margin-top: 6px; }
  .mobile-navigation { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 8; padding: 8px 0; margin-bottom: 12px; background: var(--bg, #f5f7f2); }
  .mobile-navigation label { flex: none; font-size: 14px; margin: 0; }
  .mobile-navigation select { flex: 1; min-width: 0; font-weight: 700; background-color: #fff; }
  .mobile-navigation .new-content-badge { margin-left: 0; }
  #tabs { display: none; }
  .connection-bar { margin-bottom: 14px; font-size: 12px; }
  .connection-bar > .muted { display: none; }
  .panel { padding: 20px 16px; border-radius: 14px; }
  .panel h2, .toolbar h2 { font-size: 21px; }
  .toolbar, .section-heading { gap: 12px; flex-wrap: wrap; }
  .toolbar { margin-bottom: 16px; }
  .toolbar > .search-label { width: 100%; flex: 1 1 100%; }
  .toolbar .muted { font-size: 14px; }
  .form-grid, .survey-settings { grid-template-columns: minmax(0, 1fr); }
  form { gap: 16px; }
  label, .check-label { font-size: 14px; }
  input, select, textarea { font-size: 16px; min-width: 0; }
  .check-label { min-height: 40px; }
  .primary, .secondary { min-height: 44px; }
  .actions { gap: 8px; }
  .hint { font-size: 14px; padding: 12px; }
  .notice-view-bar { gap: 10px; }
  .notice-view-switch { display: flex; width: 100%; }
  .notice-view-switch button { flex: 1; min-height: 44px; padding: 9px 5px; font-size: 13px; white-space: nowrap; }
  .category-chips { gap: 7px; }
  .category-chip { min-height: 40px; }
  .announcement-summary h3 { font-size: 18px; }
  .resource-list, .survey-list { grid-template-columns: minmax(0, 1fr); }
  .filters { width: 100%; gap: 8px; flex-wrap: wrap; }
  .filters > label:not(.check-label) { flex: 1 1 120px; }
  .chat-layout { display: block; }
  .chat-sidebar { position: static; max-height: none; padding: 16px; }
  .chat-sidebar .room-list { max-height: none; }
  #chats-view:not(.room-open) .chat-main { display: none; }
  .room-button { min-height: 68px; }
  .editor-toolbar { gap: 5px; padding: 8px; }
  .editor-toolbar button, .editor-toolbar select { min-height: 40px; font-size: 14px; }
  .editor-toolbar .editor-point-size input { font-size: 16px; }
  .compact-composer .send-key-hint { display: none; }
  .compact-composer .composer-options { padding: 2px 8px; gap: 6px; }
  .compact-composer .format-toggle, .compact-composer .upload-label { min-height: 38px; font-size: 13px; padding: 4px 7px; }
  .compact-composer .upload-area { padding: 0 8px 5px; }
  .compact-composer .upload-list { max-height: 16dvh; }
  .compact-composer .upload-chip button { min-height: 36px; }
  .compact-composer .editor-toolbar { max-height: min(190px, 25dvh); overflow-y: auto; }
  .message-composer { padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); gap: 7px; flex-shrink: 0; }
  .message-composer > .primary { min-width: 56px; padding: 9px; font-size: 14px; }
  .message-composer .ql-editor { min-height: 50px; max-height: min(120px, 20dvh); padding: 10px; }
  .message-footer button { min-height: 36px; }
  .chat-message { max-width: 92%; }

  /* The conversation itself owns scrolling; the composer is never below a long page. */
  body.conversation-open { overflow: hidden; }
  .conversation-open #chats-view.room-open:not([hidden]),
  .conversation-open #post-detail:not([hidden]) {
    position: fixed; z-index: 30; left: 0; right: 0;
    top: calc(var(--visible-top, 0px) + var(--mobile-preview-height));
    height: calc(var(--visible-height, 100dvh) - var(--mobile-preview-height));
    margin: 0; padding: 0; background: #fff;
    display: flex; flex-direction: column; min-height: 0;
  }
  .conversation-open .chat-layout { height: 100%; min-height: 0; }
  .conversation-open .chat-main { height: 100%; border: 0; border-radius: 0; padding: 0; }
  .conversation-open #chat-active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .conversation-open .conversation-heading { flex: none; padding: 8px 12px; gap: 4px 10px; border-bottom: 1px solid #e4ece6; }
  .conversation-open .conversation-heading h2 { font-size: 18px; margin: 0; }
  .conversation-open .chat-back { min-height: 36px; padding: 4px 0 !important; }
  .conversation-open #chat-members { font-size: 12px; }
  .conversation-open .chat-tools-bar { flex-shrink: 0; gap: 6px; padding: 5px 10px; }
  .conversation-open .chat-tools-bar button { min-height: 36px; }
  .conversation-open #chat-pinned { max-height: 18%; overflow: auto; flex-shrink: 0; }
  .conversation-open .message-stream { flex: 1 1 0; height: auto !important; min-height: 0; max-height: none; padding: 14px 10px; overflow-y: auto; overscroll-behavior: contain; }
  .conversation-open .history-button { min-height: 36px; flex-shrink: 0; }
  .conversation-open #post-detail > .toolbar { flex: none; margin: 0; padding: 6px 10px; border-bottom: 1px solid #e4ece6; }
  .conversation-open #post-detail > .toolbar > .muted { display: none; }
  .conversation-open .inquiry-conversation { flex: 1; display: flex; flex-direction: column; width: 100%; min-height: 0; border: 0; border-radius: 0; padding: 0; }
  .conversation-open .inquiry-conversation .conversation-heading { max-height: 25%; overflow: auto; }
  .conversation-open .new-message-button { right: 12px; bottom: calc(var(--composer-height, 160px) + 8px); }
  .conversation-open .live-toasts { z-index: 35; top: 8px; bottom: auto; }
  .conversation-open #global-status:not([hidden]) { position: fixed; z-index: 50; top: calc(var(--visible-top, 0px) + 8px); left: 10px; right: 10px; max-height: 28dvh; overflow: auto; box-shadow: 0 6px 24px #20352e20; }

  /* A file can remain visible above the conversation while a reply is typed. */
  body.conversation-open:has(.reading-layout.has-preview) { --mobile-preview-height: calc(var(--visible-height, 100dvh) * .36); }
  .conversation-open .has-preview .file-dock {
    position: fixed; z-index: 40; top: var(--visible-top, 0px); left: 0; right: 0;
    height: var(--mobile-preview-height); max-height: none; margin: 0; border-radius: 0;
    display: flex; flex-direction: column; overflow: hidden;
  }
  .conversation-open .file-dock .dock-header { flex: none; padding: 4px 10px; align-items: center; }
  .conversation-open .file-dock .dock-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  .conversation-open .file-dock .dock-header button { min-height: 40px; }
  .conversation-open .file-dock > .file-preview { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  .conversation-open .file-dock .preview-tools { flex: none; flex-wrap: nowrap; overflow-x: auto; }
  .conversation-open .file-dock .preview-action { flex: none; min-height: 36px; }
  .conversation-open .file-dock .preview-surface { flex: 1; min-height: 0; max-height: none; padding: 6px; }
  .conversation-open .file-dock > .file-download { display: none; }
  .survey-sticky { top: var(--mobile-nav-height, 64px); padding: 10px; gap: 8px; }
  .survey-sticky > strong { flex: 1 1 50%; overflow-wrap: anywhere; }
  .survey-sticky > .actions { width: 100%; display: flex; }
  .survey-sticky > .actions > button { flex: 1; }
  .survey-submit { bottom: max(0px, calc(100dvh - var(--visible-height, 100dvh) - var(--visible-top, 0px))); padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px; }
  .survey-question, .survey-section { scroll-margin-top: calc(var(--mobile-nav-height, 64px) + 140px); }
  .survey-submit .hint { font-size: 12px; flex: 1; }
  .survey-submit .primary { flex: none; }
  .survey-question { padding: 18px 14px; }
  .survey-option { padding: 12px; }
  .survey-q-actions button { min-height: 40px; }
  .notification-settings .actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .notification-settings .actions .primary { grid-column: 1 / -1; }
  dialog { max-height: calc(var(--visible-height, 100dvh) - 24px); overflow: auto; padding: 20px 16px; }
  .dialog-header { position: sticky; top: -20px; z-index: 6; background: #fff; padding-block: 8px; }
  .floating-color-panel { max-height: calc(var(--visible-height, 100dvh) - 20px); overflow: auto; }
  footer { font-size: 12px; padding: 20px 14px; }
}

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

/* Keep the familiar native picker, with a clear themed face and touch target. */
@media(max-width:760px){
 .mobile-navigation{position:sticky;display:flex;gap:10px;padding:5px 13px 5px 8px;margin-bottom:17px;min-height:60px;border:1px solid color-mix(in srgb,var(--green) 28%,var(--line));border-radius:16px;background:linear-gradient(120deg,var(--light),color-mix(in srgb,var(--light) 65%,var(--paper)));box-shadow:0 3px 12px #163a2510;color:var(--green)}
 .mobile-navigation:focus-within{outline:3px solid color-mix(in srgb,var(--green) 35%,transparent);outline-offset:2px}
 .mobile-navigation>label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
 .mobile-menu-icon{display:grid;place-items:center;flex:none;width:39px;height:39px;border-radius:11px;background:var(--paper);color:var(--green);pointer-events:none}
 .mobile-menu-icon svg{display:block;width:23px;height:23px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
 .mobile-navigation select{appearance:none;-webkit-appearance:none;position:relative;flex:1;min-width:0;min-height:48px;padding:10px 28px 10px 2px;background:transparent;border:0;box-shadow:none;font-size:16px;font-weight:750;letter-spacing:-.25px;color:var(--green);cursor:pointer;outline:0}
 .mobile-navigation select option{color:var(--ink);background:var(--paper);font-weight:500}
 .mobile-navigation::after{content:'';position:absolute;right:18px;top:24px;width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg);pointer-events:none}
 .mobile-navigation:has(.new-content-badge:not([hidden]))::after{right:46px}
 .mobile-navigation .new-content-badge{margin:0 0 0 -4px;flex:none}
}
