/* ══════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATION PATCH - 35 items
   Inject before closing </style>
   ══════════════════════════════════════════════════════════════ */

/* ── #2: 100dvh fix for iOS/Android address bar ── */
html, body, .app {
  height: 100vh;
  height: 100dvh;
}

/* ── #19: Safe area insets for notch/home indicator ── */
.topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.input-area { padding-bottom: calc(4px + max(var(--safe-b), env(safe-area-inset-bottom))); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
.sb { padding-bottom: env(safe-area-inset-bottom); }

/* ── #33: Disable double-tap zoom ── */
* { touch-action: manipulation; }

/* ── #18: Smooth momentum scrolling ── */
.msg-wrap, .sb-list, .modal-body, .reason-steps, .chips-row {
  -webkit-overflow-scrolling: touch;
}

/* ══════════════════ MOBILE ONLY (≤768px) ══════════════════ */
@media (max-width: 768px) {

  /* ── #2: dvh body ── */
  .app { height: 100dvh; overflow: hidden; }

  /* ── #3: Prevent iOS auto-zoom on input focus ── */
  #msgIn, .prompt-input, .sb-search input, .ci-input, .ci-field input,
  .field-input, .s-grp textarea, .s-grp select, #imgPrompt,
  #inlineEditTa, .img-gen-dd input {
    font-size: 16px !important;
  }

  /* ── #1: Settings modal sidebar - horizontal tabs on mobile ── */
  /* ── Settings: native full-screen on mobile ── */
  #setModal .modal-bg {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  #setModal .modal {
    flex-direction: column !important;
    height: 95dvh !important;
    max-height: 95dvh !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    animation: sheetUp .25s var(--ease) !important;
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

  /* Hide sidebar nav - use top pills instead */
  #setModal .set-nav {
    width: 100% !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    padding: 4px 16px 8px !important;
    border-right: none !important;
    border-bottom: none !important;
    gap: 6px !important;
    flex-shrink: 0 !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: transparent !important;
  }
  #setModal .set-nav::-webkit-scrollbar { display: none; }
  /* "Settings" label hidden - title in header is enough */
  #setModal .set-nav > div:first-child { display: none !important; }

  #setModal .set-nav-item {
    padding: 8px 16px !important;
    white-space: nowrap !important;
    border-radius: 20px !important;
    flex-shrink: 0 !important;
    font-size: .8rem !important;
    font-weight: 600 !important;
    background: var(--bg-2) !important;
    color: var(--tx-3) !important;
    border: 1px solid var(--brd) !important;
  }
  #setModal .set-nav-item.active {
    background: var(--bg-3) !important;
    color: var(--tx) !important;
    border-color: var(--brd-3) !important;
  }
  /* Hide Close + Admin nav items */
  #setModal .set-nav-item:last-child { display: none !important; }
  #setModal .set-nav-item:nth-last-child(2) { display: none !important; }

  /* Header: compact, prominent X */
  #setModal .modal-head {
    padding: 16px 16px 8px !important;
    border-bottom: none !important;
  }
  #setModal .modal-title {
    font-size: 1.2rem !important;
  }
  #setModal .modal-x {
    width: 34px !important;
    height: 34px !important;
  }

  /* Content area */
  #setModal .modal-head + div {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #setModal .modal-head + div > div:first-child {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 80px !important;
  }

  /* Rows: more spacious */
  #setModal .s-row {
    padding: 14px 0 !important;
  }
  #setModal .s-row-l {
    font-size: .92rem !important;
  }
  #setModal .s-grp label {
    font-size: .75rem !important;
  }

  /* Footer: auto-save style - hide footer, or make sticky minimal */
  #setModal .modal-foot {
    padding: 12px 16px !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: var(--bg-1) !important;
    border-top: 1px solid var(--brd) !important;
    border-radius: 0 !important;
    z-index: 10 !important;
  }

  /* Model cards */
  .model-card {
    padding: 14px !important;
    margin-bottom: 10px !important;
  }
  .model-card .mc-name { font-size: .88rem !important; }
  .model-card .mc-desc { font-size: .78rem !important; line-height: 1.5 !important; }
  .model-card .mc-dot { width: 12px !important; height: 12px !important; }

  /* Toggle bigger on mobile */
  #setModal .tgl {
    width: 44px !important;
    height: 24px !important;
  }
  #setModal .tgl::after {
    width: 18px !important;
    height: 18px !important;
  }
  #setModal .tgl.on::after {
    transform: translateX(20px) !important;
  }

  /* ── #4: Image gen dropdown overflow fix ── */
  .img-gen-dd {
    width: calc(100vw - 40px) !important;
    max-width: 300px !important;
    left: 0 !important;
    right: auto !important;
  }
  /* Reposition if overflows right */
  .img-gen-btn { position: static !important; }
  .input-tools { position: relative; }

  /* ── #5: Share modal footer buttons ── */
  #shareModal .modal-foot {
    flex-direction: column !important;
    gap: 8px !important;
  }
  #shareModal .modal-foot > div {
    display: flex !important;
    width: 100% !important;
  }
  #shareModal .modal-foot .btn {
    flex: 1 !important;
    text-align: center !important;
    justify-content: center !important;
  }

  /* ── #6 & #7: Inline edit + keyboard + retry lite ── */
  #inlineEditTa {
    max-height: 40vh !important;
    font-size: 16px !important;
  }
  .retry-lite-btn {
    position: relative !important;
    z-index: 5;
    margin-bottom: 8px !important;
  }

  /* ── #8: Swipe-to-close sidebar (CSS part - JS handles touch) ── */
  .sb {
    transition: transform .28s cubic-bezier(.4,0,.2,1) !important;
    will-change: transform;
  }

  /* ── #9: Share button icon-only on mobile ── */
  .top-btn span { display: none !important; }
  .top-btn { padding: 0 8px !important; width: 34px; justify-content: center; }

  /* ── #10: Message actions - tap to reveal on mobile ── */
  .m-acts {
    /* opacity controlled by .msg.tapped in chat.html */
    flex-wrap: wrap;
  }
  .m-act {
    padding: 8px !important;
    min-height: 40px;
    min-width: 40px;
  }
  .m-act svg { width: 18px !important; height: 18px !important; }

  /* ── #11: Chat bubble wider on mobile ── */
  .msg.user .m-body {
    max-width: 92% !important;
  }

  /* ── #12: Reasoning steps word-break ── */
  .reason-step, .reason-label, .reason-steps-inner {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* ── #13: Code blocks smooth horizontal scroll ── */
  .m-txt pre code {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  .m-txt pre {
    max-width: calc(100vw - 60px);
  }

  /* ── #14: Lightbox - better mobile sizing ── */
  .lightbox img {
    max-width: 96vw !important;
    max-height: 85vh !important;
    object-fit: contain;
  }

  /* ── #15: Search results dropdown constrain ── */
  .sb-search-results {
    max-height: 50vh !important;
    max-width: calc(100vw - 32px);
  }

  /* ── #16: Model badge + timestamp overlap fix ── */
  .m-head {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }
  .m-time {
    width: 100%;
    margin-left: 0 !important;
  }

  /* ── #17: Active touch feedback ── */
  .sb-item:active, .sug:active, .chip:active, .m-act:active,
  .sb-btn:active, .top-ico:active, .top-btn:active, .in-tool:active,
  .send-btn:active, .btn:active, .cmd-i:active {
    opacity: 0.7 !important;
    transform: scale(0.97) !important;
    transition: transform 0.08s, opacity 0.08s !important;
  }

  /* ── #20: Keyboard push - reserve space (JS sets --vvh) ── */
  .input-area {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    transition: bottom 0.15s ease-out;
  }

  /* ── #21: System font scaling guard ── */
  .topbar, .input-box, .send-btn, .m-acts {
    font-size: initial;
  }

  /* ── #22: Disable drag overlay on mobile (touch) ── */
  .drag-ov { display: none !important; }

  /* ── #24: Tour tooltip overflow guard ── */
  .tour-tip {
    max-width: calc(100vw - 32px) !important;
    left: 16px !important;
    right: 16px !important;
  }

  /* ── #25: PWA splash + apple-touch-icon handled via manifest ── */
  .pwa-banner {
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 24px) !important;
    left: 12px !important;
    transform: none !important;
  }

  /* ── #26: Landscape orientation ── */
  @media (orientation: landscape) {
    .welcome { min-height: 30vh; margin-top: 1vh; }
    .wel-logo { width: 48px; height: 48px; margin-bottom: 12px; }
    .wel-title { font-size: 1.3rem; }
    .sugs { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .sug { padding: 8px 10px; }
    .msg-wrap { padding-top: 48px; }
    .topbar { height: calc(48px + var(--safe-t)); padding-top: var(--safe-t); }
    .input-box { padding: 8px 10px; }
  }

  /* ── #27: Loading skeleton / flash guard ── */
  .msg-inner:empty::before {
    content: '';
    display: block;
    height: 200px;
  }

  /* ── #29: Hidden chips - don't affect layout when hidden ── */
  #chipsArea[style*="display:none"],
  #chipsArea[style*="display: none"] {
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* ── #30: Admin/Status page links accessible ── */
  /* Handled via sidebar - already accessible */

  /* ── #31: Voice indicator bigger ── */
  .voice-indicator {
    font-size: .82rem !important;
    padding: 6px 12px !important;
  }
  .voice-dot {
    width: 8px !important;
    height: 8px !important;
  }
  #voiceBtn.recording {
    width: 40px !important;
    height: 40px !important;
  }

  /* ── #34: Scroll-to-bottom FAB size/position ── */
  .scroll-fab {
    width: 44px !important;
    height: 44px !important;
    right: 12px !important;
    bottom: calc(140px + env(safe-area-inset-bottom)) !important;
  }
  .scroll-fab svg { width: 20px; height: 20px; }

  /* ── #35: Toast above keyboard ── */
  .toast {
    bottom: calc(160px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 40px) !important;
    font-size: .82rem !important;
  }

  /* ── PWA-TUNE-v1 - mobile UX polish ── */

  /* Topbar: tighter, cleaner - height/padding handled by mobile-native.css (safe-area aware) */
  .topbar {
    gap: 8px !important;
  }
  .topbar-title { font-size: .92rem !important; }
  .top-ico, .top-btn {
    width: 36px !important;
    height: 36px !important;
  }
  .top-ico svg, .top-btn svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* Message wrap: adjust for topbar (52px content + safe-area-inset-top) */
  .msg-wrap {
    padding-top: calc(52px + var(--safe-t)) !important;
  }

  /* User bubble: rounder, tighter padding */
  .msg.user .m-body {
    max-width: 88% !important;
    padding: 12px 16px !important;
    border-radius: 20px !important;
    border-bottom-right-radius: 6px !important;
  }

  /* AI message text: slightly tighter */
  .m-txt {
    font-size: .94rem !important;
    line-height: 1.6 !important;
  }
  .m-txt p { margin-bottom: 10px !important; }

  /* Input box: pill shape like PWA */
  .input-box {
    border-radius: 18px !important;
    padding: 7px 12px !important;
  }

  /* Input area: cleaner spacing */
  .input-area {
    padding: 0 12px calc(4px + var(--safe-b)) !important;
  }

  /* Send button: round */
  .send-btn {
    border-radius: 50% !important;
    width: 38px !important;
    height: 38px !important;
  }

  /* Input tools (attach, voice etc): tighter */
  .in-tool {
    width: 36px !important;
    height: 36px !important;
  }
  .in-tool svg {
    width: 20px !important;
    height: 20px !important;
  }

  /* Sidebar: slightly wider, smoother */
  .sb {
    width: 290px !important;
  }

  /* Sidebar items: more touch-friendly */
  .sb-item {
    padding: 11px 14px !important;
    border-radius: 10px !important;
    font-size: .88rem !important;
  }

  /* Welcome screen: compact like PWA */
  .welcome {
    gap: 14px !important;
    padding: 24px 16px !important;
  }
  .wel-logo {
    width: 52px !important;
    height: 52px !important;
    border-radius: 14px !important;
  }
  .wel-title {
    font-size: 1.25rem !important;
  }
  .wel-sub {
    font-size: .88rem !important;
  }

  /* Suggestion chips: rounder like PWA */
  .sug {
    border-radius: 18px !important;
    padding: 10px 16px !important;
    font-size: .82rem !important;
  }

  /* Message actions: compact */
  .m-act {
    width: 34px !important;
    height: 34px !important;
  }

  /* Thinking indicator: cleaner */
  .thinking {
    font-size: .88rem !important;
  }

}

/* ── #28: Pull-to-refresh disable in PWA ── */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: contain; }
  .msg-wrap { overscroll-behavior-y: contain; }
}

/* ── #23: Suppress long-press context menu on interactive elements ── */
.m-act, .chip, .sb-item, .sug, .send-btn, .in-tool, .top-ico, .top-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* But allow text selection in messages */
.m-txt {
  -webkit-user-select: text;
  user-select: text;
}

/* ── SAFARI-FIX-v1 - reduce spacing in Safari browser mode ── */

/* Safari browser (not standalone PWA): tighter bottom spacing */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 768px) {
    /* Only in browser mode - standalone handled separately */
    .msg-wrap {
      padding-bottom: calc(110px + var(--safe-b)) !important;
    }
    .input-area {
      padding: 0 10px calc(4px + var(--safe-b)) !important;
    }
    .input-foot {
      padding: 6px 12px 0 !important;
      font-size: .65rem !important;
    }
  }
}

/* Standalone PWA: restore comfortable spacing */
@media (display-mode: standalone) and (max-width: 768px) {
  .msg-wrap {
    padding-bottom: calc(130px + var(--safe-b)) !important;
  }
  .input-area {
    padding: 0 10px calc(4px + var(--safe-b)) !important;
  }
}

/* SETTINGS-MOBILE-REDESIGN-v1 */
@media (max-width: 768px) {

  /* ===== MODAL SHELL ===== */
  #setModal .modal {
    background: var(--bg-1) !important;
    border-radius: 16px 16px 0 0 !important;
    border: none !important;
    box-shadow: 0 -4px 40px rgba(0,0,0,0.5) !important;
  }

  /* ===== HEADER - compact with drag indicator ===== */
  #setModal .modal-head {
    padding: 10px 16px 0 !important;
    border-bottom: none !important;
    min-height: 44px !important;
    position: relative !important;
  }

  #setModal .modal-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
  }

  #setModal .modal-title {
    font-family: var(--font-d) !important;
    font-size: 1.1rem !important;
    font-weight: 600 !important;
    padding-top: 8px !important;
  }

  #setModal .modal-x {
    width: 30px !important;
    height: 30px !important;
    background: rgba(255,255,255,0.08) !important;
    border-radius: 50% !important;
    margin-top: 8px !important;
  }
  #setModal .modal-x:active {
    background: rgba(255,255,255,0.15) !important;
  }

  /* ===== NAV PILLS - filled accent active ===== */
  #setModal .set-nav {
    border-bottom: 0.5px solid var(--brd) !important;
    padding: 8px 16px 12px !important;
    gap: 6px !important;
  }

  #setModal .set-nav-item {
    padding: 7px 16px !important;
    border-radius: 20px !important;
    font-size: .8rem !important;
    font-weight: 500 !important;
    background: rgba(255,255,255,0.06) !important;
    color: var(--tx-3) !important;
    border: none !important;
    transition: background 0.2s, color 0.2s !important;
  }
  #setModal .set-nav-item:active {
    transform: scale(0.97) !important;
  }
  #setModal .set-nav-item.active {
    background: var(--ac) !important;
    color: #fff !important;
    border: none !important;
  }

  /* Hide keyboard shortcuts + close nav items */
  #navShortcuts { display: none !important; }

  /* ===== CONTENT AREA ===== */
  #setModal .modal-head + div > div:first-child {
    padding: 8px 0 24px !important;
    scrollbar-width: none !important;
  }
  #setModal .modal-head + div > div:first-child::-webkit-scrollbar {
    display: none !important;
  }

  /* ===== SECTION GROUPS - iOS style ===== */
  #setModal .s-grp {
    background: rgba(255,255,255,0.03) !important;
    border-radius: 12px !important;
    margin: 0 16px 12px !important;
    overflow: hidden !important;
    border: none !important;
  }

  #setModal .s-grp > label,
  #setModal .s-label {
    display: block !important;
    font-size: .7rem !important;
    font-weight: 600 !important;
    color: var(--tx-4) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding: 12px 16px 6px !important;
    margin: 0 !important;
    background: transparent !important;
  }

  #setModal .s-grp select {
    appearance: none !important;
    -webkit-appearance: none !important;
    background: transparent !important;
    border: none !important;
    color: var(--tx-2) !important;
    font-size: .88rem !important;
    padding: 10px 16px !important;
    width: 100% !important;
    cursor: pointer !important;
    background-image: url("data:image/svg+xml,%3Csvg width='7' height='12' viewBox='0 0 7 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l5 5-5 5' stroke='%2371717a' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 16px center !important;
    background-size: 7px 12px !important;
  }
  #setModal .s-grp select:focus {
    outline: none !important;
    box-shadow: none !important;
  }

  /* ===== SETTINGS ROWS - grouped cells ===== */
  #setModal .s-row {
    padding: 13px 16px !important;
    min-height: 48px !important;
    gap: 12px !important;
    border-bottom: 0.5px solid var(--brd) !important;
    margin: 0 !important;
  }
  #setModal .s-row:last-child {
    border-bottom: none !important;
  }

  #setModal .s-row-l {
    font-size: .9rem !important;
    font-weight: 500 !important;
    color: var(--tx) !important;
  }
  #setModal .s-row-d {
    font-size: .72rem !important;
    color: var(--tx-4) !important;
    margin-top: 2px !important;
  }

  /* ===== TOGGLE - bigger touch target ===== */
  #setModal .tgl {
    width: 46px !important;
    height: 28px !important;
    border-radius: 14px !important;
    background: rgba(255,255,255,0.15) !important;
    border: none !important;
  }
  #setModal .tgl::after {
    width: 22px !important;
    height: 22px !important;
    top: 3px !important;
    left: 3px !important;
  }
  #setModal .tgl.on {
    background: var(--ac) !important;
  }
  #setModal .tgl.on::after {
    transform: translateX(18px) !important;
  }

  /* ===== MODEL CARDS - compact radio rows ===== */
  #setModal .model-card {
    display: flex !important;
    align-items: flex-start !important;
    padding: 12px 16px !important;
    gap: 12px !important;
    cursor: pointer !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    min-height: 48px !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
  #setModal .model-card:active {
    background: rgba(255,255,255,0.04) !important;
  }
  #setModal .model-card + .model-card {
    border-top: 0.5px solid var(--brd) !important;
  }

  /* Selected state - subtle tint */
  #setModal .model-card.selected {
    background: rgba(154,137,104,0.06) !important;
    border: none !important;
    box-shadow: none !important;
  }
  #setModal .model-card.selected[data-model="adaptive"] {
    background: var(--adaptive-dim) !important;
    border: none !important;
  }
  #setModal .model-card.selected[data-model="lyt"] {
    background: var(--lyt-dim) !important;
    border: none !important;
  }
  #setModal .model-card.selected[data-model="omni"] {
    background: var(--omni-dim) !important;
    border: none !important;
  }

  #setModal .mc-dot {
    width: 10px !important;
    height: 10px !important;
    margin-top: 5px !important;
  }
  #setModal .mc-name {
    font-size: .88rem !important;
    font-weight: 600 !important;
  }
  #setModal .mc-desc {
    font-size: .72rem !important;
    color: var(--tx-3) !important;
    line-height: 1.4 !important;
    margin-top: 2px !important;
  }

  /* ===== TEXTAREAS - clean, borderless in group ===== */
  #setModal textarea,
  #setModal .s-grp textarea,
  #setModal .field-input {
    background: rgba(255,255,255,0.03) !important;
    border: none !important;
    border-radius: 10px !important;
    color: var(--tx-2) !important;
    font-size: .88rem !important;
    line-height: 1.5 !important;
    padding: 12px 14px !important;
    box-shadow: none !important;
  }
  #setModal textarea:focus,
  #setModal .field-input:focus {
    outline: none !important;
    color: var(--tx) !important;
    border: none !important;
    box-shadow: none !important;
  }

  /* ===== ACCOUNT PROFILE CARD ===== */
  #setTab_account > div:first-child {
    border-radius: 12px !important;
    padding: 14px !important;
    margin-bottom: 14px !important;
  }

  /* ===== FOOTER - slim, safe area ===== */
  #setModal .modal-foot {
    padding: 10px 16px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
    border-top: 0.5px solid var(--brd) !important;
    background: var(--bg-1) !important;
    gap: 10px !important;
  }
  #setModal .modal-foot .btn {
    flex: 1 !important;
    padding: 11px 0 !important;
    border-radius: 10px !important;
    font-size: .9rem !important;
    font-weight: 500 !important;
    text-align: center !important;
    justify-content: center !important;
  }
  #setModal .modal-foot .btn-ghost {
    background: rgba(255,255,255,0.08) !important;
    color: var(--tx-2) !important;
  }
  #setModal .modal-foot .btn-primary {
    background: var(--ac) !important;
    color: #fff !important;
  }
  #setModal .modal-foot .btn-primary:active {
    background: var(--ac-3) !important;
  }

  /* Saved msg */
  #setModal #setSavedMsg {
    display: none !important;
  }

  /* ===== TAB CONTENT TRANSITION ===== */
  #setModal .set-tab-content {
    animation: settingsFadeIn 0.2s ease !important;
  }
  @keyframes settingsFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ===== DANGER BUTTON - full width ===== */
  #setModal .btn-danger,
  #setModal .btn.btn-danger {
    width: 100% !important;
    padding: 12px !important;
    border-radius: 10px !important;
    font-size: .88rem !important;
  }
}
/* END SETTINGS-MOBILE-REDESIGN-v1 */


/* SETTINGS-SIZE-TUNE-v2 */
@media (max-width: 768px) {

  /* Nav pills: bigger, more tappable */
  #setModal .set-nav {
    padding: 10px 16px 14px !important;
    gap: 8px !important;
  }
  #setModal .set-nav-item {
    padding: 10px 20px !important;
    font-size: .9rem !important;
    font-weight: 600 !important;
  }

  /* Header title */
  #setModal .modal-title {
    font-size: 1.25rem !important;
  }

  /* Section labels */
  #setModal .s-grp > label,
  #setModal .s-label {
    font-size: .78rem !important;
    padding: 16px 16px 8px !important;
  }

  /* Select dropdowns */
  #setModal .s-grp select {
    font-size: .95rem !important;
    padding: 14px 16px !important;
  }

  /* Settings rows */
  #setModal .s-row {
    padding: 16px 16px !important;
    min-height: 56px !important;
  }
  #setModal .s-row-l {
    font-size: .95rem !important;
    font-weight: 500 !important;
  }
  #setModal .s-row-d {
    font-size: .8rem !important;
    margin-top: 3px !important;
  }

  /* Model cards */
  #setModal .model-card {
    padding: 16px 16px !important;
    min-height: 58px !important;
    gap: 14px !important;
  }
  #setModal .mc-name {
    font-size: .95rem !important;
    font-weight: 700 !important;
  }
  #setModal .mc-desc {
    font-size: .8rem !important;
    margin-top: 3px !important;
    line-height: 1.45 !important;
  }
  #setModal .mc-dot {
    width: 12px !important;
    height: 12px !important;
  }

  /* Toggle: bigger */
  #setModal .tgl {
    width: 50px !important;
    height: 30px !important;
    border-radius: 15px !important;
  }
  #setModal .tgl::after {
    width: 24px !important;
    height: 24px !important;
  }
  #setModal .tgl.on::after {
    transform: translateX(20px) !important;
  }

  /* Textareas */
  #setModal textarea,
  #setModal .field-input {
    font-size: .92rem !important;
    padding: 14px 16px !important;
  }

  /* CI section labels */
  #setModal #setTab_ci div[style*="font-size"] {
    font-size: .8rem !important;
  }

  /* Account profile */
  #setTab_account > div:first-child {
    padding: 16px !important;
  }
  #setTab_account #accName {
    font-size: 1rem !important;
  }
  #setTab_account #accEmail {
    font-size: .82rem !important;
  }

  /* Footer buttons */
  #setModal .modal-foot .btn {
    padding: 14px 0 !important;
    font-size: .95rem !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
  }

  /* KB grid items (if visible) */
  #setModal .kb-item {
    padding: 14px !important;
    font-size: .88rem !important;
  }
}
/* END SETTINGS-SIZE-TUNE-v2 */

/* TEXT-SIZE-TUNE-v1 */
@media (max-width: 768px) {

  /* Chat message text: slightly bigger */
  .m-txt {
    font-size: 1.10rem !important;
    line-height: 1.65 !important;
  }

  /* Welcome screen */
  .wel-title {
    font-size: 1.5rem !important;
    font-weight: 700 !important;
  }
  .wel-sub {
    font-size: .95rem !important;
    color: var(--tx-2) !important;
  }

  /* Suggestion cards text */
  .sug-title, .sug strong, .sug b {
    font-size: .95rem !important;
  }
  .sug-desc, .sug span, .sug p {
    font-size: .85rem !important;
  }
  .sug {
    padding: 16px !important;
  }

  /* Settings sign-in required / locked content */
  #setModal [style*="Sign in"],
  #setModal .auth-required,
  #setModal .lock-msg {
    font-size: .95rem !important;
  }
  /* Generic bold text inside settings tabs */
  #setModal .set-tab-content b,
  #setModal .set-tab-content strong {
    font-size: .95rem !important;
  }
  /* Description text in settings locked state */
  #setModal .set-tab-content p,
  #setModal .set-tab-content div[style*="color:var(--tx-3)"],
  #setModal .set-tab-content div[style*="color:var(--tx-4)"] {
    font-size: .88rem !important;
    line-height: 1.5 !important;
  }
  /* Login/Signup buttons in settings */
  #setModal .btn {
    font-size: .9rem !important;
    padding: 10px 20px !important;
  }

  /* Sidebar text */
  .sb-item {
    font-size: .92rem !important;
    padding: 12px 16px !important;
  }
  .sb .sign-up-link,
  .sb a[href*="register"],
  .sb a[href*="sign"] {
    font-size: .92rem !important;
  }
  /* Sidebar "Chat history is saved..." text */
  .sb-empty, .sb-placeholder {
    font-size: .88rem !important;
    line-height: 1.5 !important;
  }
  /* Sidebar footer login/register buttons */
  .sb-foot .btn,
  .sb-foot a {
    font-size: .88rem !important;
    padding: 10px 18px !important;
  }
}
/* END TEXT-SIZE-TUNE-v1 */
