.agent-preset-bar, .agent-mobile-menu, .agent-mobile-new { display: none; }

@media (max-width: 1000px) {
  body:has(.agent-layout), body:has(.agent-layout) .container,
  body:has(.agent-layout) .main-content, .agent-layout {
    height: var(--agent-mobile-height, 100dvh) !important;
    min-height: 0;
  }
  .agent-main { height: calc(var(--agent-mobile-height, 100dvh) / var(--agent-mobile-zoom, 1)); }
  body:has(.agent-layout) .container { margin-left: 52px !important; width: calc(100% - 52px) !important; }
  .agent-topbar { padding: 6px 12px; gap: 4px; min-height: 52px; }
  .topbar-title { min-width: 0; font-size: 15px; }
  .topbar-icon-btn { width: 40px; height: 40px; flex-shrink: 0; }
  .agent-mobile-new { display: flex; }
  .agent-preset-bar { display: flex; justify-content: center; flex-shrink: 0; padding: 0 12px 8px; }
  #agentPresetSelect {
    width: 100%; max-width: 640px; min-width: 0; height: 42px;
    padding: 0 12px; border: 1px solid #dedede; border-radius: 12px;
    background: #fff; color: #444; font: inherit; font-size: 14px;
    text-overflow: ellipsis; cursor: pointer;
  }
  body.dark-theme #agentPresetSelect { background: #171717; border-color: #333; color: #ddd; color-scheme: dark; }
  #agentPresetSelect:focus-visible { outline: 2px solid var(--agent-accent); outline-offset: 2px; }
  .landing-center { padding: 0 12px max(12px, env(safe-area-inset-bottom)); }
  .quick-actions { overflow: hidden; justify-content: center; }
  .qmap { display: block; padding: 16px 0; animation: none; }
  .qmap-side, .qmap-links { display: none; }
  .qmap-hub { padding: 0; border: 0; box-shadow: none; background: transparent; }
  .qmap-hub .landing-greeting { max-width: none; margin: 0; font-size: clamp(20px, 4vw, 28px); overflow-wrap: anywhere; }
  .landing-input-card { margin-top: 0; }
  .landing-input-card, .chat-input-card { border-radius: 24px; }
  .landing-input-card .chat-input, .chat-input { padding: 14px 16px 4px; font-size: 16px; min-height: 52px; max-height: min(150px, 25dvh); }
  .input-bottom-row { min-width: 0; gap: 4px; flex-wrap: wrap; padding: 6px 8px 8px; }
  .input-spacer { display: none; }
  .agent-model-trigger { flex: 1; max-width: none; margin: 0; padding-inline: 8px; min-height: 40px; }
  .agent-mode-switch { margin-right: 0; }
  .agent-mode-switch[hidden] { display: none; }
  .input-send-btn { width: 40px; height: 40px; border-radius: 50%; margin-left: auto; }
  .chat-area { min-height: 0; padding: 8px 0; overscroll-behavior-y: contain; }
  .chat-msg { padding: 12px 16px; }
  .chat-bubble-wrap { min-width: 0; }
  .chat-msg.user .chat-bubble { max-width: 90%; padding: 10px 14px; }
  .chat-bubble { font-size: 16px; overflow-wrap: anywhere; }
  .chat-bubble pre { max-width: 100%; overflow-x: auto; }
  .chat-input-area { padding: 6px 12px max(10px, env(safe-area-inset-bottom)); }
  .input-disclaimer { margin-top: 6px; font-size: 10px; }
  .history-item-menu { display: flex; }
  .msg-actions { opacity: 1; }
}

@media (max-width: 700px) {
  body:has(.agent-layout) .container { margin-left: 0 !important; width: 100% !important; }
  .agent-layout .cs-sidebar.collapsed { visibility: hidden; pointer-events: none; transform: translateX(-100%); }
  .agent-layout .cs-sidebar { height: var(--agent-mobile-height, 100dvh); max-width: 85vw; }
  .agent-mobile-menu { display: flex; }
  .agent-topbar { padding-inline: 6px; }
  .chat-msg { padding-inline: 14px; }
  .rc-grid { grid-template-columns: minmax(0, 1fr); }
  .rc-vcard { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 4px 10px; align-items: start; }
  .rc-vcard .rc-thumb { grid-row: 1 / 3; }
  .rc-vcard .rc-title { font-size: 14px; }
  .rc-vcard .rc-meta { white-space: normal; overflow-wrap: anywhere; }
  .input-bottom-row:has(.agent-mode-switch:not([hidden])) .agent-mode-switch { order: 1; }
  .input-bottom-row:has(.agent-mode-switch:not([hidden])) .agent-model-trigger { flex-basis: calc(100% - 48px); }
  .input-bottom-row:has(.agent-mode-switch:not([hidden])) .input-send-btn { order: 2; }
  .input-bottom-row:has(.agent-mode-switch:not([hidden])) .agent-model-trigger { order: 0; }
}

@media (max-width: 1000px) and (max-height: 500px) {
  .agent-topbar { min-height: 44px; padding-block: 2px; }
  .agent-preset-bar { padding-bottom: 4px; }
  #agentPresetSelect { height: 36px; }
  .qmap { padding-block: 4px; }
  .qmap-hub .landing-greeting { font-size: 18px; }
  .input-disclaimer { display: none; }
}
