/* Mobile layout: shared spacing, visible navigation and comfortable touch targets. */
#kc-workspace .kc-menu-toggle {
  display: none;
}
#kc-workspace h1,
#kc-workspace h2,
#kc-workspace h3 {
  overflow-wrap: anywhere;
}

@media (max-width: 650px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    min-width: 0;
  }
  #kc-workspace {
    min-height: 100svh;
  }
  #kc-workspace .kc-top {
    min-height: 72px;
    padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px
      max(16px, env(safe-area-inset-left));
    flex-wrap: nowrap;
    gap: 10px;
  }
  #kc-workspace .kc-brand {
    gap: 8px;
    font-size: 10px;
    letter-spacing: 0.7px;
    min-width: 0;
  }
  #kc-workspace .kc-brand small {
    font-size: 8px;
    letter-spacing: 1px;
    margin-top: 3px;
  }
  #kc-workspace .kc-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 13px;
  }
  #kc-workspace .kc-session {
    gap: 6px;
    flex-shrink: 0;
  }
  #kc-workspace .kc-session .kc-button {
    min-height: 44px;
    font-size: 12px;
    padding: 10px 9px;
  }
  #kc-workspace .kc-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
    background: #181719;
    box-shadow: 0 6px 16px #0002;
  }
  #kc-workspace .kc-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 6px 0;
    background: none;
    border: 0;
    color: #f5f2ef;
    text-align: left;
    cursor: pointer;
  }
  #kc-workspace .kc-menu-toggle > span:first-child {
    display: grid;
    gap: 2px;
    min-width: 0;
  }
  #kc-workspace .kc-menu-toggle small {
    font-size: 11px;
    line-height: 1.3;
  }
  #kc-workspace .kc-menu-toggle strong {
    font-size: 15px;
    line-height: 1.4;
    font-weight: 600;
  }
  #kc-workspace .kc-menu-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid #49414b;
    border-radius: 11px;
    background: #302b31;
  }
  #kc-workspace .kc-sidebar .kc-nav {
    display: none;
  }
  #kc-workspace .kc-sidebar.is-menu-open .kc-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 0 8px;
    max-height: 60vh;
    max-height: 60dvh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  #kc-workspace .kc-nav button {
    width: 100%;
    min-height: 52px;
    white-space: normal;
    font-size: 13px;
    line-height: 1.4;
    padding: 10px;
    gap: 8px;
  }
  #kc-workspace .kc-nav button[aria-current='page'] {
    box-shadow: inset 3px 0 0 #ed923d;
  }
  #kc-workspace .kc-main {
    padding: 24px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
  }
  #kc-workspace h1 {
    font-size: 27px;
    line-height: 1.2;
    letter-spacing: -0.6px;
  }
  #kc-workspace h2 {
    font-size: 20px;
    line-height: 1.35;
  }
  #kc-workspace h3 {
    font-size: 16px;
  }
  #kc-workspace p {
    font-size: 15px;
    line-height: 1.6;
  }
  #kc-workspace .kc-heading {
    margin-bottom: 20px;
  }
  #kc-workspace .kc-help {
    font-size: 15px;
    line-height: 1.6;
    margin: 10px 0 14px;
  }
  #kc-workspace .kc-kicker {
    letter-spacing: 1px;
  }
  #kc-workspace .kc-panel {
    padding: 18px;
    border-radius: 16px;
    margin-bottom: 16px;
  }
  #kc-workspace .kc-two,
  #kc-workspace .kc-equal,
  #kc-workspace .kc-cards,
  #kc-workspace .kc-stack {
    gap: 16px;
  }
  #kc-workspace .kc-two > .kc-stack {
    margin-bottom: 16px;
  }
  #kc-workspace .kc-equal > .kc-panel,
  #kc-workspace .kc-two > .kc-panel {
    height: auto;
  }
  #kc-workspace .kc-equal > .kc-panel,
  #kc-workspace .kc-two > .kc-panel,
  #kc-workspace .kc-cards > .kc-panel {
    margin-bottom: 0;
  }
  #kc-workspace .kc-cards h2,
  #kc-workspace .kc-project-card h2 {
    margin-top: 12px;
  }
  #kc-workspace .kc-button {
    min-height: 46px;
    padding: 12px 14px;
    font-size: 14px;
  }
  #kc-workspace .kc-actions {
    gap: 8px;
    margin-top: 16px;
  }
  #kc-workspace .kc-actions .kc-button {
    min-width: 0;
    flex: 1 1 140px;
  }
  #kc-workspace .kc-heading .kc-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin-top: 16px;
  }
  #kc-workspace .kc-metrics {
    gap: 10px;
    margin-bottom: 20px;
  }
  #kc-workspace .kc-metric {
    padding: 14px;
    margin: 0;
    min-height: 0;
    gap: 10px;
    align-content: start;
  }
  #kc-workspace .kc-metric strong {
    font-size: 25px;
    line-height: 1.2;
  }
  #kc-workspace .kc-metric small {
    line-height: 1.5;
  }
  #kc-workspace .kc-facts {
    gap: 14px;
    margin: 18px 0;
  }
  #kc-workspace .kc-facts dd {
    font-size: 15px;
    line-height: 1.55;
  }
  #kc-workspace .kc-tag {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  #kc-workspace .kc-row {
    padding: 18px 0;
  }
  #kc-workspace .kc-tabs {
    gap: 6px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    scroll-padding-inline: 6px;
  }
  #kc-workspace .kc-tabs .kc-button {
    min-height: 44px;
    padding: 10px 12px;
  }
  #kc-workspace .kc-chat {
    gap: 16px;
  }
  #kc-workspace .kc-chat-log {
    height: clamp(220px, 42svh, 480px);
    padding-right: 2px;
    gap: 12px;
  }
  #kc-workspace .kc-message {
    max-width: 92%;
    padding: 12px 14px;
  }
  #kc-workspace .kc-message p {
    font-size: 15px;
    line-height: 1.55;
  }
  #kc-workspace .kc-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  #kc-workspace .kc-grow {
    min-width: 0;
  }
  #kc-workspace .kc-compose textarea {
    min-height: 96px;
  }
  #kc-workspace input:not([type='checkbox']),
  #kc-workspace select,
  #kc-workspace textarea {
    min-width: 0;
    max-width: 100%;
    min-height: 48px;
    font-size: 16px;
  }
  #kc-workspace input[type='file'] {
    font-size: 13px;
    padding: 10px;
  }
  #kc-workspace .kc-modal-backdrop {
    padding: 0;
    align-items: stretch;
    overflow: hidden;
  }
  #kc-workspace #kc-drawer .kc-inline-editor {
    width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
    padding: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-top: 90px;
    scroll-padding-bottom: 100px;
  }
  #kc-workspace .kc-inline-editor > .kc-between {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    margin: 0 0 20px;
    background: #242027;
    border-bottom: 1px solid #49414b;
  }
  #kc-workspace .kc-inline-editor > .kc-between h2 {
    max-width: none;
    font-size: 20px;
  }
  #kc-workspace .kc-inline-editor > :not(.kc-between) {
    margin-left: 16px;
    margin-right: 16px;
  }
  #kc-workspace .kc-inline-editor > :last-child {
    margin-bottom: max(24px, env(safe-area-inset-bottom));
  }
  #kc-workspace .kc-inline-editor form > .kc-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom));
    background: #242027;
    border-top: 1px solid #49414b;
  }
  #kc-workspace .kc-table-wrap {
    overflow: visible;
  }
  #kc-workspace table,
  #kc-workspace tbody {
    display: block;
    width: 100%;
  }
  #kc-workspace thead {
    display: none;
  }
  #kc-workspace tbody tr {
    display: block;
    padding: 4px 0 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #49414b;
  }
  #kc-workspace tbody tr:last-child {
    margin: 0;
    padding-bottom: 0;
    border-bottom: 0;
  }
  #kc-workspace td {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 12px;
    min-width: 0;
    padding: 9px 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  #kc-workspace td::before {
    content: attr(data-label);
    color: #bebbc4;
    font-size: 13px;
  }
  #kc-workspace td:first-child {
    display: block;
    font-size: 18px;
    font-weight: 600;
    padding: 4px 0 14px;
  }
  #kc-workspace td:first-child::before {
    display: none;
  }
  #kc-workspace .kc-foot {
    display: grid;
    gap: 6px;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    font-size: 11px;
  }
  #kc-workspace #kc-toast {
    left: 16px;
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    max-width: none;
    padding: 14px 16px;
  }
  .login {
    min-height: 100svh;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    background: #121214;
  }
  .login-card {
    padding: 28px 22px;
    border-radius: 20px;
  }
  .login-brand {
    margin-bottom: 28px;
  }
  .login input {
    font-size: 16px;
    min-height: 48px;
  }
  .login button {
    min-height: 48px;
  }
}

@media (max-width: 359px) {
  #kc-workspace .kc-top {
    padding-left: 12px;
    padding-right: 12px;
    gap: 6px;
  }
  #kc-workspace .kc-brand {
    font-size: 9px;
    letter-spacing: 0.3px;
    gap: 6px;
  }
  #kc-workspace .kc-brand small {
    font-size: 7px;
    letter-spacing: 0.5px;
  }
  #kc-workspace .kc-session .kc-button {
    padding: 10px 7px;
  }
  #kc-workspace .kc-metrics {
    grid-template-columns: 1fr;
  }
  #kc-workspace .kc-panel {
    padding: 16px;
  }
}
