/* ===========================================
   Mobile Layout
   =========================================== */

/* Tablet and smaller: collapse the left nav into a horizontal rail. */
@media (max-width: 1100px) {
  .shell,
  .shell--nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--shell-topbar-height) auto minmax(0, 1fr);
    grid-template-areas:
      "topbar"
      "nav"
      "content";
  }

  .shell--chat-focus {
    grid-template-rows: var(--shell-topbar-height) 0 minmax(0, 1fr);
  }

  .shell-nav,
  .shell--nav-collapsed .shell-nav {
    width: auto;
    min-width: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar,
  .sidebar--collapsed {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: row;
    align-items: center;
    border-right: none;
  }

  .sidebar-header,
  .sidebar--collapsed .sidebar-header {
    justify-content: flex-start;
    padding: 8px 10px;
    flex: 0 0 auto;
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav,
  .sidebar--collapsed .sidebar-nav {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 8px 10px 8px 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar,
  .sidebar--collapsed .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-group,
  .nav-group__items,
  .sidebar--collapsed .nav-group,
  .sidebar--collapsed .nav-group__items {
    display: contents;
  }

  .nav-group {
    margin-bottom: 0;
  }

  .sidebar-nav .nav-group__label {
    display: none;
  }

  .nav-item,
  .sidebar--collapsed .nav-item {
    margin: 0;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .sidebar--collapsed .nav-item--active::before,
  .sidebar--collapsed .nav-item.active::before {
    content: none;
  }

  .sidebar-footer,
  .sidebar--collapsed .sidebar-footer {
    display: none;
  }
}

/* Mobile-specific styles */
@media (max-width: 600px) {
  .shell {
    --shell-pad: 8px;
    --shell-gap: 8px;
  }

  /* Topbar */
  .topbar {
    padding: 10px 12px;
    gap: 8px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-sub {
    display: none;
  }

  .topbar-status {
    gap: 6px;
    width: auto;
    flex-wrap: nowrap;
  }

  .topbar-status .pill {
    padding: 4px 8px;
    font-size: 11px;
    gap: 4px;
  }

  .topbar-status .pill .mono {
    display: none;
  }

  .topbar-status .pill span:nth-child(2) {
    display: none;
  }

  .shell-nav {
    border-bottom-width: 0;
  }

  .sidebar-header {
    padding: 6px 8px;
  }

  .sidebar-nav {
    gap: 6px;
    padding: 6px 8px 6px 0;
  }

  .nav-item {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: var(--radius-md);
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Content */
  .content-header {
    display: none;
  }

  .content {
    padding: 4px 4px 16px;
    gap: 12px;
  }

  /* Cards */
  .card {
    padding: 12px;
    border-radius: var(--radius-md);
  }

  .card-title {
    font-size: 13px;
  }

  /* Stats */
  .stat-grid {
    gap: 8px;
    grid-template-columns: repeat(2, 1fr);
  }

  .stat {
    padding: 10px;
    border-radius: var(--radius-md);
  }

  .stat-label {
    font-size: 11px;
  }

  .stat-value {
    font-size: 18px;
  }

  /* Notes */
  .note-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  /* Forms */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .field input,
  .field textarea,
  .field select {
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 14px;
  }

  /* Buttons */
  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* Pills */
  .pill {
    padding: 4px 10px;
    font-size: 12px;
  }

  /* Chat */
  .chat-header {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .chat-header__left {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-header__right {
    justify-content: space-between;
  }

  .chat-session {
    min-width: unset;
    width: 100%;
  }

  .chat-thread {
    margin-top: 8px;
    padding: 12px 8px;
  }

  .chat-msg {
    max-width: 90%;
  }

  .chat-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
  }

  .chat-compose {
    gap: 8px;
  }

  .chat-compose__field textarea {
    min-height: 60px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    font-size: 14px;
  }

  .agent-chat__input {
    margin: 0 8px 10px;
  }

  .agent-chat__toolbar {
    padding: 4px 8px;
  }

  .agent-chat__input-btn,
  .agent-chat__toolbar .btn-ghost {
    width: 28px;
    height: 28px;
  }

  .agent-chat__input-btn svg,
  .agent-chat__toolbar .btn-ghost svg {
    width: 14px;
    height: 14px;
  }

  /* Log stream */
  .log-stream {
    border-radius: var(--radius-md);
    max-height: 380px;
  }

  .log-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 8px;
  }

  .log-time {
    font-size: 10px;
  }

  .log-level {
    font-size: 9px;
  }

  .log-subsystem {
    font-size: 11px;
  }

  .log-message {
    font-size: 12px;
  }

  /* Lists */
  .list-item {
    padding: 10px;
    border-radius: var(--radius-md);
  }

  .list-title {
    font-size: 13px;
  }

  .list-sub {
    font-size: 11px;
  }

  /* Code blocks */
  .code-block {
    padding: 8px;
    border-radius: var(--radius-md);
    font-size: 11px;
  }

  .theme-orb__trigger {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }
}

/* Small mobile */
@media (max-width: 400px) {
  .shell {
    --shell-pad: 4px;
  }

  .topbar {
    padding: 8px 10px;
  }

  .brand-title {
    font-size: 13px;
  }

  .nav-item {
    padding: 6px 8px;
    font-size: 11px;
  }

  .content {
    padding: 4px 4px 12px;
    gap: 10px;
  }

  .card {
    padding: 10px;
  }

  .stat {
    padding: 8px;
  }

  .stat-value {
    font-size: 16px;
  }

  .chat-bubble {
    padding: 8px 10px;
  }

  .chat-compose__field textarea {
    min-height: 52px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .btn {
    padding: 6px 10px;
    font-size: 11px;
  }

  .topbar-status .pill {
    padding: 3px 6px;
    font-size: 10px;
  }

  .theme-orb__trigger {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
}
