@media (max-width: 1023px) {
  .dialog-backdrop {
    align-items: end;
    padding: 0;
  }

  .dialog,
  .dialog-wide {
    width: 100%;
    max-height: calc(100dvh - var(--s-44));
    border-radius: var(--card-radius) var(--card-radius) 0 0;
  }

  button,
  .btn,
  .icon-button,
  .input,
  .select,
  .review-remark,
  .tracking-entry,
  .seg-control button,
  .segmented button,
  .mobile-nav-item,
  .mobile-workspace-switch select {
    min-width: var(--touch-height);
    min-height: var(--touch-height);
  }

  .icon-button {
    width: var(--touch-height);
  }

  .membership-lock {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    padding-left: 0;
    padding-bottom: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
  }

  .sidebar,
  .statusbar,
  .desktop-only,
  .market-details {
    display: none;
  }

  .topbar {
    gap: var(--s-8);
    padding: 0 var(--s-10);
  }

  .topbar-title {
    font-size: var(--font-13);
  }

  .identity-cluster .tag,
  .account-name {
    display: none;
  }

  .mobile-account-label {
    display: inline;
  }

  .market-strip-row {
    gap: var(--s-12);
    overflow-x: auto;
    padding-right: var(--s-10);
    padding-left: var(--s-10);
    white-space: nowrap;
  }

  .market-toggle {
    display: none;
  }

  .page-frame {
    min-height: calc(100dvh - var(--shell-topbar-height) - var(--shell-summary-height) - var(--shell-mobile-nav-height));
    padding: var(--s-12) var(--s-10);
  }

  .entity-detail-heading,
  .entity-detail-heading > div:first-child,
  .entity-detail-price,
  .entity-detail-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .entity-detail-actions {
    margin-left: 0;
  }

  .entity-detail-grid,
  .entity-stock-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .entity-metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .market-hover-popover {
    display: none;
  }

  .mobile-context-bar {
    display: grid;
    gap: var(--s-10);
    padding: var(--s-6) var(--s-10);
    border-bottom: var(--s-1) solid var(--color-border);
    background: var(--color-surface);
  }

  .mobile-workspace-switch {
    min-height: var(--touch-height);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--s-10);
    color: var(--color-text-secondary);
    font-size: var(--font-12);
    font-weight: var(--weight-600);
  }

  .mobile-workspace-switch select {
    min-width: 0;
    padding: 0 var(--s-10);
    border: var(--s-1) solid var(--color-border);
    border-radius: var(--control-radius);
    color: var(--color-text);
    background: var(--color-surface-muted);
  }

  .mobile-date-control {
    display: grid;
    grid-template-columns: var(--touch-height) minmax(0, 1fr) var(--touch-height);
  }

  .mobile-date-control .date-input {
    width: 100%;
    height: var(--touch-height);
    text-align: center;
  }

  .mobile-only {
    display: inline-flex;
  }

  .page-header {
    align-items: flex-start;
    gap: var(--s-4);
    flex-direction: column;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-mobile-nav);
    min-height: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    border-top: var(--s-1) solid var(--color-border);
    background: var(--color-surface);
  }

  .mobile-nav-item {
    min-width: 0;
    display: grid;
    place-items: center;
    color: var(--color-text-secondary);
    font-size: var(--font-11);
  }

  .mobile-nav-item.router-link-active,
  .mobile-nav-item.active {
    color: var(--color-primary);
    font-weight: var(--weight-600);
  }

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

  .comparison-row {
    grid-template-columns: minmax(0, 1fr) var(--s-64) var(--s-64);
  }

  .search-layout {
    grid-template-columns: 1fr;
  }

  .search-results {
    max-height: none;
    border-right: 0;
    padding-right: 0;
  }

  .search-preview {
    display: none;
  }

  .auth-view {
    align-items: start;
    padding-top: var(--s-34);
  }

  .auth-panel {
    box-shadow: none;
  }

  .system-header,
  .system-header > div:first-child {
    align-items: flex-start;
    flex-direction: column;
  }

  .system-tabs {
    width: 100%;
    margin-left: 0;
    overflow-x: auto;
  }

  .system-grid,
  .model-grid {
    grid-template-columns: 1fr;
  }

  .credential-row,
  .selection-grid,
  .operation-form,
  .event-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .event-reason,
  .event-actions {
    grid-column: auto;
  }

  .member-editor {
    position: static;
  }

  .emotion-overview,
  .pool-layout,
  .performance-layout {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .pool-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .pool-filters {
    width: 100%;
    overflow-x: auto;
  }

  .pool-search {
    width: 100%;
    margin-left: 0;
  }

  .pool-summary-grid,
  .performance-levels {
    grid-template-columns: minmax(0, 1fr);
  }

  .performance-conclusion {
    position: static;
  }

  .market-page-header .page-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .market-page-header .page-actions .seg-control {
    width: 100%;
  }

  .market-page-header .page-actions .seg-control button {
    flex: 1;
  }

  .ladder-layout,
  .ladder-level {
    grid-template-columns: minmax(0, 1fr);
  }

  .ladder-level > header {
    border-right: 0;
    border-bottom: var(--s-1) solid var(--color-divider);
  }

  .ladder-stocks {
    grid-template-columns: minmax(0, 1fr);
  }

  .rotation-legend {
    align-items: flex-start;
    flex-direction: column;
  }

  .rotation-tracker {
    align-items: stretch;
    flex-direction: column;
  }

  .rotation-days {
    grid-template-columns: minmax(0, 1fr);
  }

  .rotation-day {
    border-right: 0;
    border-bottom: var(--s-1) solid var(--color-divider);
  }
}

@media (max-width: 430px) {
  .data-table-wrap {
    overflow: visible;
  }

  .data-table {
    display: block;
  }

  .data-table thead {
    position: absolute;
    width: var(--s-1);
    height: var(--s-1);
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .data-table tbody {
    display: grid;
    gap: var(--s-8);
    padding: var(--s-8);
  }

  .data-table tbody tr {
    display: grid;
    padding: var(--s-8) var(--s-10);
    border: var(--s-1) solid var(--color-border);
    border-radius: var(--control-radius);
    background: var(--color-surface-muted);
  }

  .data-table tbody td,
  .data-table tbody td.numeric,
  .data-table tbody td.code-column,
  .data-table tbody td.wide-column {
    width: auto;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(var(--s-96), 1fr) minmax(0, 2fr);
    gap: var(--s-8);
    padding: var(--s-6) 0;
    border-bottom: var(--s-1) solid var(--color-divider);
    text-align: right;
    white-space: normal;
  }

  .data-table tbody td:last-child {
    border-bottom: 0;
  }

  .data-table tbody td::before {
    content: attr(data-label);
    color: var(--color-text-secondary);
    font-size: var(--font-11);
    font-weight: var(--weight-600);
    text-align: left;
  }

  .data-table tbody td.index-column {
    display: none;
  }
}

@media (max-width: 1023px) and (orientation: landscape) and (max-height: 430px) {
  .page-header {
    align-items: baseline;
    flex-direction: row;
  }

  .pool-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    flex-wrap: nowrap;
  }

  .pool-filters {
    width: auto;
  }

  .pool-search {
    width: 100%;
  }
}

@media (max-width: 1023px) {
  .review-main-grid { grid-template-columns: minmax(0, 1fr); }
  .review-heading-actions { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-left: 0; }
  .trade-card, .daily-review-card { min-height: auto; }
  .review-watch-table { max-height: var(--s-320); }
  .trade-scroll { max-height: var(--s-320); }
  .trade-form-grid, .alert-create-grid { grid-template-columns: minmax(0, 1fr); }
  .review-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-summary > div:last-child { grid-column: 1 / -1; }
  .review-history-list article, .stock-note-history article { grid-template-columns: minmax(0, 1fr); }
  .review-history-list p, .review-history-list small,
  .stock-note-history p, .stock-note-history small { grid-column: 1; }
  .assistant-messages article { max-width: 94%; }
}

@media (max-width: 1399px) {
  .auction-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .auction-side {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .auction-dataset-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .auction-datasets {
    align-self: stretch;
    overflow-x: auto;
    margin: var(--s-7) var(--s-10);
  }

  .auction-inline-summary {
    width: 100%;
    min-width: 0;
    margin-left: 0;
    border-top: var(--s-1) solid var(--color-divider);
    border-left: 0;
  }
}

@media (max-width: 1023px) {
  .auction-side,
  .themes-layout,
  .popularity-summary-strip,
  .dragon-summary-grid,
  .dragon-daily-layout,
  .dragon-profiles {
    grid-template-columns: minmax(0, 1fr);
  }

  .auction-toolbar,
  .popularity-toolbar,
  .dragon-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .auction-toolbar .seg-control,
  .popularity-toolbar .seg-control,
  .dragon-toolbar .seg-control {
    width: 100%;
    overflow-x: auto;
  }

  .auction-toolbar .search-control,
  .popularity-toolbar .search-control,
  .dragon-toolbar .search-control {
    width: 100%;
    margin-left: 0;
  }

  .auction-inline-summary,
  .theme-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .theme-rank-list {
    max-height: var(--s-320);
  }

  .theme-preview-popover {
    display: none;
  }

  .popularity-summary-strip article,
  .dragon-profiles > aside {
    border-right: 0;
    border-bottom: var(--s-1) solid var(--color-divider);
  }

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

  .dragon-table-scroll {
    height: auto;
    overflow: visible;
  }

  .mentor-page {
    height: auto;
    display: block;
    overflow: visible;
  }

  .mentor-page-header {
    flex-direction: row;
    align-items: center;
  }

  .mentor-mobile-directory {
    display: inline-flex;
    margin-left: auto;
  }

  .mentor-workspace {
    min-height: calc(100vh - var(--shell-topbar-height) - var(--shell-summary-height) - var(--shell-mobile-nav-height) - var(--s-200));
    display: block;
  }

  .mentor-library {
    display: none;
    margin-bottom: var(--layout-gap);
  }

  .mentor-workspace.show-library .mentor-library {
    max-height: var(--s-400);
    display: grid;
  }

  .mentor-chat {
    min-height: var(--s-400);
    max-height: none;
  }

  .mentor-messages {
    max-height: var(--s-400);
  }

  .mentor-prompts {
    grid-template-columns: minmax(0, 1fr);
  }

  .mentor-message {
    max-width: 96%;
  }

  .mentor-composer-actions .muted {
    display: none;
  }
}
