@media (max-width: 1280px) {
  .summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  html,
  body {
    max-width: 100%;
    overflow: auto;
    overflow-x: hidden;
  }

  header {
    height: 48px;
    padding: 0 16px;
  }

  .app-subtitle {
    display: none;
  }

  main {
    height: auto;
    grid-template-columns: 1fr;
    padding: 10px;
    overflow: visible;
  }

  .control-panel,
  .result-panel,
  #result {
    overflow: visible;
  }

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

  .market-line {
    display: block;
  }

  .market-line span {
    display: block;
  }

  .progress-top {
    grid-template-columns: 1fr auto;
  }

  .progress-count {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .result-layout {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .result-layout > *,
  #result,
  .table-wrap,
  table,
  tbody,
  tr.stock-row,
  tr.reason-row,
  tr.inline-daily-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .watch-panel {
    max-height: none;
  }

  .table-wrap {
    overflow-x: visible;
    border: 0;
    background: transparent;
  }

  table,
  colgroup,
  tbody {
    display: block;
    width: 100%;
  }

  colgroup,
  thead {
    display: none;
  }

  tr.stock-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 10px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 9px 9px 0 0;
    padding: 8px 10px;
    background: var(--field);
  }

  tr.stock-row.active {
    background: var(--active-row);
  }

  tr.stock-row.passed {
    border-color: color-mix(in srgb, var(--down) 28%, var(--line));
    background: color-mix(in srgb, var(--down) 6%, var(--field));
  }

  tr.stock-row td {
    height: auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 0;
    padding: 5px 0;
    text-align: right;
    white-space: normal;
  }

  tr.stock-row td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
  }

  tr.stock-row td:first-child {
    grid-column: 1 / -1;
    justify-content: flex-start;
    border-bottom: 1px solid var(--line);
    margin-bottom: 2px;
    padding-bottom: 7px;
    font-size: 15px;
    font-weight: 750;
    text-align: left;
  }

  tr.stock-row td:first-child::before {
    display: none;
    content: "";
  }

  .name-cell {
    justify-content: flex-start;
    align-items: flex-start;
  }

  .hot-result-tags {
    max-width: 100%;
    padding-left: 24px;
    justify-content: flex-start;
  }

  .reason-row,
  .inline-daily-row {
    display: block;
  }

  .reason-row td,
  .inline-daily-row td {
    height: auto !important;
    min-height: 0;
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    border-top: 0;
  }

  .reason-row td {
    border-radius: 0;
    padding: 8px 10px !important;
  }

  .reason-content {
    display: block;
  }

  .reason-label {
    display: block;
    margin: 0 0 3px;
  }

  .reason-tags {
    display: grid;
    gap: 5px;
  }

  .reason-item {
    width: 100%;
    justify-content: flex-start;
    border-radius: 7px;
    white-space: normal;
  }

  .inline-daily-row td {
    border-radius: 0 0 9px 9px;
    margin-bottom: 10px;
    max-width: 100%;
    overflow: visible;
  }

  .inline-daily {
    max-width: 100%;
    min-width: 0;
    padding: 8px 4px 10px;
    overflow: hidden;
  }

  .inline-daily-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 4px;
  }

  .daily-title {
    width: 100%;
    justify-content: space-between;
  }

  .inline-daily-head h3 {
    font-size: 15px;
    line-height: 21px;
  }

  .inline-daily-meta {
    text-align: left;
    font-size: 10.5px;
    line-height: 1.28;
  }

  .chart-settings {
    grid-template-columns: 1fr;
  }

  .chart-shell {
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    padding-bottom: 0;
  }

  .kline-chart {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 340px;
  }

  .chart-legend {
    margin-bottom: 3px;
    gap: 4px 9px;
    font-size: 10.5px;
  }

  .chart-axis-mid {
    display: none;
  }

  .chart-tooltip {
    max-width: 240px;
    font-size: 11px;
    padding: 7px 8px;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 12px;
  }

  header {
    height: auto;
    min-height: 0;
    padding: 8px 10px 7px;
    gap: 8px;
  }

  .hot-header-main {
    gap: 6px;
  }

  .hot-header-head {
    align-items: flex-start;
    gap: 8px;
  }

  .hot-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
  }

  h1 {
    font-size: 16px;
  }

  h2,
  .control-panel h2,
  .result-head h2,
  .watch-head h2,
  #result h2 {
    font-size: 14px;
  }

  .hot-sector-meta {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    text-align: right;
  }

  .hot-sector-meta span:not(:first-child) {
    display: none;
  }

  .hot-sector-list {
    gap: 6px;
    padding-bottom: 1px;
  }

  .hot-sector-item {
    flex-basis: 218px;
    padding: 6px 7px;
  }

  .hot-sector-top {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 5px;
  }

  .hot-sector-rank {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .hot-sector-type {
    display: none;
  }

  .hot-sector-top strong {
    font-size: 12px;
  }

  .hot-sector-change {
    font-size: 11px;
  }

  .hot-sector-reason {
    font-size: 10px;
  }

  .hot-sector-badges {
    margin-top: 4px;
  }

  .hot-sector-badges span {
    padding: 1px 5px;
    font-size: 9px;
  }

  .hot-sector-merged {
    font-size: 9.5px;
  }

  button.theme-toggle {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }

  main {
    display: block;
    padding: 8px;
  }

  .control-panel,
  .result-panel {
    gap: 8px;
  }

  .control-panel {
    margin-bottom: 8px;
  }

  .control-block,
  .result-panel,
  .watch-panel {
    border-radius: 9px;
  }

  .control-block,
  .result-panel {
    padding: 8px;
  }

  textarea {
    min-height: 58px;
  }

  input,
  select,
  select.action-mode {
    height: 34px;
    font-size: 12px;
  }

  button:not(.strategy-toggle):not(.theme-toggle):not(.watch-toggle):not(.chart-settings-toggle):not(.hot-sector-item):not(.hot-popover-close) {
    min-height: 34px;
    font-size: 12px;
  }

  .actions {
    grid-template-columns: 1fr;
    gap: 7px;
  }

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

  .rule {
    min-height: 42px;
    padding: 7px 8px;
  }

  .rule-title {
    font-size: 12px;
  }

  input[type="checkbox"] {
    width: 17px;
    height: 17px;
  }

  .result-head,
  .section-head,
  .watch-head {
    gap: 8px;
  }

  .result-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .result-tools label {
    grid-column: 1 / -1;
    margin: 0;
    justify-content: space-between;
  }

  .result-tools select {
    width: min(180px, 58vw);
  }

  .result-tools button {
    width: 100%;
    padding: 0 6px !important;
  }

  .status-row {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    padding: 7px 8px;
  }

  .hot-group-summary {
    padding: 7px 8px;
    align-items: flex-start;
    font-size: 11px;
  }

  .hot-group-summary span {
    padding: 2px 6px;
  }

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

  tr.stock-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  tr.stock-row td {
    padding: 6px 0;
  }

  .watch-panel {
    padding: 8px;
  }

  .watch-item-main {
    align-items: flex-start;
  }

  .watch-hot {
    max-width: 100%;
    font-size: 10px;
  }

  .watch-alert {
    max-width: 100%;
    font-size: 10px;
  }

  .hot-popover-backdrop {
    background: rgba(15, 23, 42, .28);
  }

  .hot-popover {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 78dvh;
    padding: 10px;
    transform: none;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -18px 40px rgba(20, 30, 50, .22);
  }

  .hot-popover.dragging,
  .hot-popover[data-moved="1"] {
    transform: none;
  }

  .hot-stocks-head {
    cursor: default;
    padding-bottom: 8px;
  }

  .hot-stocks-head strong {
    font-size: 15px;
  }

  .hot-stocks-head span {
    font-size: 11px;
    text-align: right;
  }

  .hot-strength {
    gap: 5px;
    font-size: 10px;
  }

  .hot-strength span {
    padding: 2px 6px;
  }

  .hot-popover-close {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .hot-stock-list {
    gap: 6px;
  }

  .hot-stock-row {
    grid-template-columns: 52px minmax(0, 1fr) 108px 52px;
    gap: 7px;
    min-height: 46px;
    padding: 6px 7px;
    font-size: 11px;
  }

  .hot-stock-row strong {
    min-width: 0;
    flex-wrap: wrap;
    gap: 3px;
  }

  .core-badge {
    padding: 1px 4px;
    font-size: 9px;
  }

  .hot-stock-row > :nth-child(5),
  .hot-stock-row > :nth-child(6) {
    display: none;
  }

  .mini-chart,
  .mini-chart svg {
    width: 108px;
    height: 30px;
  }

  .kline-chart {
    height: 300px;
  }
}
