/* ==================================================================
   Kilo Webhook — Responsive Design
   ================================================================== */

/* ── Tablet: 768px ── */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 260px;
  }

  .sidebar {
    position: fixed !important;
    left: 0;
    top: 44px;
    bottom: 0;
    z-index: 50;
    transition: transform .25s ease;
  }

  .sidebar:not(.mobile-open) {
    transform: translateX(-100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main > .resize-handle {
    display: none;
  }

  .chat-wrap {
    width: 100%;
  }

  .msg-body {
    max-width: 90% !important;
  }

  .editor-panel {
    top: 44px;
    left: 0;
    right: 0;
    width: auto !important;
    height: calc(100vh - 66px) !important;
    border-radius: 0;
  }

  .llm-sidebar {
    width: 220px;
  }

  .api-sb {
    width: 200px;
  }

  .modal {
    width: 90vw;
    max-height: 85vh;
  }

  .sch-table {
    font-size: .8rem !important;
    min-width: 750px;
  }

  .llm-table {
    min-width: 800px;
  }
}

/* ── Mobile: 480px ── */
@media (max-width: 480px) {
  html, body {
    font-size: 13px;
  }

  :root {
    --sidebar-w: 100vw;
  }

  .topbar {
    height: 40px;
    padding: 0 8px;
    gap: 4px;
  }

  .topbar-title {
    font-size: .75rem;
  }

  .topbar-badge {
    font-size: .65rem;
    padding: 0 4px;
  }

  .topbar-status {
    display: none;
  }

  .tb-btn {
    padding: 2px 6px;
    font-size: .65rem;
  }

  .sidebar-header {
    padding: 8px;
  }

  .sidebar.mobile-open {
    width: 100vw;
  }

  .chat-header {
    height: 40px;
    padding: 0 10px;
  }

  .msg {
    padding: 0 10px;
  }

  .msg-body {
    max-width: 95% !important;
  }

  .msg-bubble {
    padding: 8px 10px;
    font-size: .8rem;
  }

  .input-area {
    padding: 8px 10px 10px;
  }

  .input-toolbar {
    gap: 4px;
    flex-wrap: wrap;
  }

  .input-select {
    max-width: 120px;
    font-size: .7rem;
  }

  .input-box {
    padding: 6px 8px;
  }

  .input-textarea {
    font-size: .78rem;
  }

  .send-btn,
  .voice-btn,
  .tts-float-btn,
  .attach-btn {
    width: 30px;
    height: 30px;
    font-size: .85rem;
  }

  .editor-panel {
    height: calc(100vh - 40px) !important;
  }

  .editor-tab {
    max-width: 160px;
  }

  .llm-body {
    flex-direction: column;
  }

  .llm-sidebar {
    width: 100%;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .llm-detail {
    min-width: 0;
  }

  .llm-radar-wrap {
    width: 260px;
    height: 260px;
  }

  .api-sb {
    width: 100%;
    max-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .api-main {
    flex-direction: column;
  }

  .modal {
    width: 95vw;
    padding: 14px;
  }

  .statusbar {
    font-size: .65rem;
    gap: 6px;
  }

  .sch-table-wrap {
    overflow-x: auto;
  }

  .llm-table-wrap {
    overflow-x: auto;
  }

  .toast-container {
    right: 8px;
    left: 8px;
  }

  .toast {
    max-width: 100%;
    min-width: 0;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Mobile hamburger menu button ── */
.mobile-menu-btn {
  display: none;
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
  transition: all .15s;
}
.mobile-menu-btn:hover {
  background: var(--surface3);
  border-color: var(--border2);
  color: var(--text);
}

@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(0, 0, 0, .4);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}

@media (max-width: 768px) {
  .sidebar.mobile-open ~ .sidebar-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}
