html,
body,
.app-shell {
  overflow-x: hidden;
}

@media (max-width: 1120px) {
  .workspace {
    height: auto !important;
    min-height: 0;
    grid-template-columns: 1fr !important;
    gap: 12px;
    padding-top: 12px;
  }

  .recharge-panel {
    height: auto !important;
    min-height: 0 !important;
    display: flex;
    flex-direction: column;
  }

  .frame-wrap.large-frame {
    height: min(66vh, 620px) !important;
    min-height: 360px;
  }

  .side-rail {
    grid-template-columns: 1fr !important;
    grid-template-rows: none !important;
    gap: 12px;
    min-height: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 10px;
  }

  h1 {
    font-size: 20px;
  }

  .topbar-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 8px;
  }

  .system-pill {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .panel-header {
    padding: 12px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .panel-header.tight {
    padding-bottom: 8px;
  }

  .segmented {
    width: 100%;
    display: flex !important;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .segmented::-webkit-scrollbar {
    display: none;
  }

  .segmented .segment {
    flex: 0 0 auto;
    min-width: 88px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
  }

  .frame-toolbar {
    padding: 0 12px 10px;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .toolbar-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar-actions .text-button,
  .manual-actions .text-button,
  .checkout-actions .text-button,
  .turkey-action-line .text-button {
    min-height: 36px;
    padding: 0 12px;
  }

  .frame-wrap.large-frame {
    height: 58vh !important;
    min-height: 320px;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-query-box textarea {
    min-height: 110px;
  }

  .manual-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .check-result {
    max-height: 42vh;
    overflow: auto;
  }

  .checkout-page,
  .turkey-page,
  .turkey-shell {
    padding: 10px !important;
  }

  .checkout-head,
  .turkey-head {
    padding: 14px !important;
  }

  .checkout-head h3,
  .turkey-head h3 {
    font-size: 22px !important;
  }

  .checkout-grid,
  .turkey-grid,
  .turkey-workflow,
  .checkout-row,
  .turkey-control-row,
  .turkey-summary {
    grid-template-columns: 1fr !important;
  }

  .checkout-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  #checkoutGenerateBtn {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .segment {
    min-width: 82px;
    font-size: 12px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .manual-actions,
  .checkout-actions {
    grid-template-columns: 1fr;
  }

  .frame-wrap.large-frame {
    height: 54vh !important;
    min-height: 280px;
  }

  .toast-area {
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }
}
