@media (max-width: 640px) {
  /* ヘッダーは機能追加前のコンパクトな横並びへ戻す */
  header {
    display: flex;
    padding: 7px 8px;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
  }

  .app-heading {
    display: block;
    flex: 0 0 auto;
    min-width: 0;
  }

  header h1 {
    display: block;
    font-size: 13px;
    line-height: normal;
    white-space: nowrap;
  }

  .build-number {
    display: block;
    margin-top: 2px;
    font-size: 9px;
  }

  .actions {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
  }

  .actions button {
    display: block;
    flex: 0 1 auto;
    min-width: 0;
    min-height: 0;
    padding: 6px 7px;
    border-radius: 6px;
    overflow: hidden;
    font-size: 9px;
    line-height: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* フィルターだけを必要な2段構成にする */
  .filter-bar {
    display: grid;
    grid-template-columns: auto repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 0 8px 6px;
    overflow: visible;
  }

  .hashtag-filter-label {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
  }

  .hashtag-filter {
    grid-column: 2 / 7;
    grid-row: 1;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 32px;
    padding: 0 28px 0 9px;
    border: 1px solid #999;
    border-radius: 7px;
    background: #fff;
    font-size: 12px;
  }

  .filter-bar button {
    grid-row: 2;
    min-width: 0;
    min-height: 32px;
    padding: 5px 3px;
    border-radius: 7px;
    font-size: 10px;
    white-space: nowrap;
  }

  #allFilter { grid-column: 1 / 3; }
  #level0Filter { grid-column: 3; }
  #level1Filter { grid-column: 4; }
  #level2Filter { grid-column: 5; }
  #level3Filter { grid-column: 6 / 7; }

  .filter-bar .small {
    grid-column: 1 / 7;
    grid-row: 3;
    font-size: 9px;
    white-space: nowrap;
  }
}
