/* Mobile layout — card feed matching desktop data (graphs, scores, metrics) */

.mobile-brand-row,
.mobile-cards,
.mobile-user-trigger,
.mobile-sort-wrap {
  display: none;
}

@media (max-width: 760px) {
  body {
    padding: 0;
    background: #f7f7f8;
  }

  .sidebar {
    display: none !important;
  }

  .main-content,
  .main-content.collapsed {
    margin-left: 0;
    width: 100%;
    padding: 16px 16px calc(100px + env(safe-area-inset-bottom, 0px));
    min-height: 100vh;
  }

  /* ── Header: brand + timeframe ── */
  .mobile-brand-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    min-width: 0;
  }

  .mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .mobile-brand-logo {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
  }

  .mobile-brand-text {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-black);
    letter-spacing: -0.02em;
  }

  .mobile-brand-text span {
    color: var(--accent-color);
  }

  .mobile-user-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    left: auto;
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: 11;
    width: 48px;
    height: 48px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    padding: 0;
    cursor: pointer;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }

  .mobile-user-trigger .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
  }

  .controls-container {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand timeframe"
      "search search"
      "meta refresh"
      "sort sort"
      "actions actions";
    gap: 14px 12px;
    align-items: center;
    margin-bottom: 18px;
  }

  .mobile-brand-row {
    grid-area: brand;
  }

  .left-controls {
    display: contents;
  }

  .dashboard-title,
  .divider,
  .command-shortcut,
  .scroll-indicator,
  .pagination,
  .pagination.collapsed {
    display: none !important;
  }

  .search-row {
    display: contents;
  }

  .search-container {
    grid-area: search;
    min-width: 0;
    width: 100%;
  }

  .total-container {
    display: flex !important;
    align-items: center;
    grid-area: meta;
    font-size: 15px;
    color: var(--color-gray);
    padding: 0 4px;
    font-weight: 500;
    min-width: 0;
  }

  .controls-right {
    display: contents;
  }

  .controls-right-top {
    display: contents;
  }

  .controls-right-bottom {
    display: block !important;
    grid-area: actions;
  }

  .mobile-sort-wrap {
    display: block;
    grid-area: sort;
    width: 100%;
  }

  .mobile-sort-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-white);
    color: var(--color-black);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
  }

  .mobile-sort-button svg {
    width: 18px;
    height: 18px;
    color: var(--color-gray);
    flex-shrink: 0;
  }

  .mobile-sort-label {
    flex: 1;
    text-align: left;
    color: var(--color-gray);
  }

  .mobile-sort-label strong {
    color: var(--color-black);
    font-weight: 650;
  }

  .mobile-sort-chevron {
    margin-left: auto;
  }

  .selected-controls {
    display: flex;
    gap: 10px;
    width: 100%;
  }

  .show-selected-button,
  .clear-button {
    flex: 1;
    justify-content: center;
    height: 48px;
    font-size: 15px;
    padding: 0 14px;
    border-radius: 12px;
    gap: 0.5rem;
  }

  .show-selected-button i,
  .clear-button i {
    width: 18px;
    height: 18px;
  }

  .search-input {
    height: 52px;
    border-radius: 16px;
    padding-left: 44px;
    padding-right: 44px;
    font-size: 16px; /* avoids iOS zoom on focus */
    background: var(--color-white);
  }

  .search-icon {
    left: 16px;
    font-size: 16px;
  }

  .search-clear-btn {
    right: 12px;
    width: 28px;
    height: 28px;
  }

  .search-clear-btn i {
    width: 15px;
    height: 15px;
  }

  .refresh-button {
    display: inline-flex !important;
    grid-area: refresh;
    width: auto;
    max-width: 100%;
    height: 40px;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    border-radius: 999px;
    padding: 0 14px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .refresh-button svg {
    width: 16px;
    height: 16px;
  }

  .refresh-button .refresh-button-lock {
    width: 13px;
    height: 13px;
  }

  .timeframe-selector {
    grid-area: timeframe;
    height: 44px;
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
    flex-shrink: 0;
  }

  .timeframe-option {
    padding: 8px 14px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 999px;
  }

  /* ── Hide desktop table, show cards ── */
  .table-container {
    display: none !important;
  }

  .mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mobile-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 16px 16px 14px;
    transition: box-shadow 0.15s ease;
  }

  .mobile-card.expanded {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }

  .mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    cursor: pointer;
  }

  .mobile-card-tag-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  .mobile-card-tag-row .custom-checkbox {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
  }

  .mobile-card-tag-row .custom-checkbox::after {
    width: 7px;
    height: 12px;
    top: 2px;
  }

  .mobile-card-hashtag {
    color: var(--accent-color);
    font-weight: 650;
    font-size: 17px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-card-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--color-gray-light);
    color: var(--color-gray);
    font-size: 13px;
    font-weight: 650;
    flex-shrink: 0;
  }

  .mobile-card-spam {
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    color: #b45309;
    background: #fef3c7;
    border-radius: 6px;
    padding: 3px 7px;
  }

  .mobile-card-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-gray-light);
    color: var(--color-gray);
    cursor: pointer;
    border-radius: 12px;
    flex-shrink: 0;
    padding: 0;
  }

  .mobile-card-toggle svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
  }

  .mobile-card.expanded .mobile-card-toggle svg {
    transform: rotate(180deg);
  }

  .mobile-card-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 12px 14px;
    align-items: end;
  }

  .mobile-card-score {
    min-width: 0;
    width: 100%;
  }

  .mobile-card-score-label {
    font-size: 13px;
    color: var(--color-gray);
    margin-bottom: 8px;
    font-weight: 550;
  }

  .mobile-card-score .score-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 80%;
  }

  .mobile-card-score .score-bar {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    height: 10px;
    border-radius: 5px;
  }

  .mobile-card-score .score-value {
    font-size: 15px;
    font-weight: 600;
    min-width: 32px;
    flex-shrink: 0;
    text-align: right;
  }

  .mobile-card-change {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 6px;
    width: 100px;
    min-width: 100px;
  }

  .mobile-card-change-value {
    position: relative;
    width: 100%;
    text-align: right;
  }

  .mobile-card-change .percent-change {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
  }

  .mobile-card-posts {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    color: var(--color-gray);
    font-size: 14px;
    font-weight: 500;
  }

  .mobile-card-posts svg {
    width: 15px;
    height: 15px;
  }

  .mobile-card-change-value .pro-lock-overlay {
    position: absolute;
    inset: -4px -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(3px);
    border-radius: 8px;
    cursor: pointer;
  }

  .mobile-card-change-value .pro-lock-overlay svg {
    width: 16px;
    height: 16px;
    color: var(--color-gray);
  }

  /* ── Expanded metrics grid (match reference: centered cells, floating dividers) ── */
  .mobile-card-details {
    display: none;
    margin-top: 12px;
    padding: 4px 0 2px;
    border-top: 1px solid #e8e8ea;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    gap: 0;
    position: relative;
  }

  .mobile-card.expanded .mobile-card-details {
    display: grid;
  }

  .mobile-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 8px;
    position: relative;
    min-width: 0;
    text-align: center;
  }

  /* Horizontal rule between the two metric rows (not across the graph) */
  .mobile-metric:nth-child(-n + 3) {
    border-bottom: 1px solid #e8e8ea;
  }

  /* Short floating vertical dividers */
  .mobile-metric:not(:nth-child(3n))::after {
    content: '';
    position: absolute;
    top: 14px;
    bottom: 14px;
    right: 0;
    width: 1px;
    background: #e8e8ea;
    pointer-events: none;
  }

  .mobile-metric-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-size: 13px;
    color: #757575;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
  }

  .mobile-metric-label i,
  .mobile-metric-label svg {
    width: 14px;
    height: 14px;
    font-size: 13px;
    color: #757575;
    stroke-width: 1.75;
    flex-shrink: 0;
  }

  .mobile-metric-label span {
    color: #757575;
    font-weight: 500;
  }

  .mobile-metric-value {
    font-size: 22px;
    font-weight: 700;
    color: #000000;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-align: center;
    letter-spacing: -0.02em;
  }

  /* Full-width trend graph at bottom of expanded details */
  .mobile-card-details .mobile-card-graph {
    grid-column: 1 / -1;
    display: flex;
    align-items: flex-end;
    justify-content: stretch;
    position: relative;
    width: 100%;
    min-height: 96px;
    margin-top: 8px;
    padding: 16px 20px 0;
    border-top: 1px solid #e8e8ea;
    overflow: visible;
  }
  
  .mobile-card-details .mini-graph-full {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    width: 100%;
    height: 48px; /* keep original base height */
    position: relative;
    gap: 6px;
    transform: scaleY(1.8);
    transform-origin: bottom;
  }
  
  .mobile-card-details .mini-graph-full .mini-graph-bar {
    position: relative;
    left: auto !important;
    flex: 1 1 0;
    min-width: 0;
    max-width: 13px;
    border-radius: 3px 3px 0 0;
    background: var(--accent-color);
    opacity: 0.85;
  }

  .mobile-card-details .mobile-card-graph .pro-lock-overlay {
    position: absolute;
    inset: 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(3px);
    border-radius: 8px;
    cursor: pointer;
  }

  .mobile-card-details .mobile-card-graph .pro-lock-overlay svg {
    width: 18px;
    height: 18px;
    color: var(--color-gray);
  }

  .mobile-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 56px 16px;
    color: var(--color-gray);
    gap: 10px;
    font-size: 16px;
  }

  .mobile-empty svg {
    width: 44px;
    height: 44px;
    opacity: 0.5;
  }

  .mobile-pro-gate {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    margin-top: 4px;
    margin-bottom: 8px;
    padding: 18px 16px;
    border: 1px dashed #bfdbfe;
    border-radius: 16px;
    background: #eff6ff;
    color: var(--color-black);
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
  }

  .mobile-pro-gate.in-view {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    transform: translateY(-2px);
  }

  .mobile-pro-gate-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #dbeafe;
    color: var(--accent-color);
    flex-shrink: 0;
  }

  .mobile-pro-gate-icon svg {
    width: 20px;
    height: 20px;
  }

  .mobile-pro-gate-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
  }

  .mobile-pro-gate-text strong {
    font-size: 15px;
    font-weight: 650;
  }

  .mobile-pro-gate-text span {
    font-size: 13px;
    color: var(--color-gray);
  }

  .mobile-pro-gate-cta {
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 650;
    color: var(--accent-color);
    background: var(--color-white);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 10px 14px;
  }

  /* ── Copy / account (no pagination bar) ── */
  .copy-button-container,
  .copy-button-container.collapsed {
    left: 0;
    width: 100%;
    bottom: 18px;
    display: flex;
    justify-content: center;
    text-align: center;
  }

  .copy-button {
    max-width: calc(100% - 32px);
    width: auto;
    min-width: 220px;
    padding: 16px 18px;
    font-size: 16px;
    margin: 0 auto;
    border-radius: 12px;
  }

  .copy-button svg {
    width: 20px;
    height: 20px;
  }

  /* Desktop user-button hidden; mobile trigger opens same dropdown */
  .user-menu {
    position: fixed;
    bottom: auto;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    margin: 0;
    overflow: visible;
    background: transparent;
    z-index: 30;
    pointer-events: none;
  }

  .user-menu .user-button {
    display: none !important;
  }

  .user-menu .dropdown-menu {
    pointer-events: auto;
    position: fixed;
    top: auto;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    left: auto;
    right: 12px;
    width: min(300px, calc(100vw - 24px));
  }

  .user-menu .dropdown-item {
    padding: 14px 16px;
    font-size: 15px;
    min-height: 48px;
  }

  /* Modals full-bleed friendly */
  .pro-promo-modal,
  .help-center-modal {
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
  }

  .search-menu {
    width: calc(100vw - 24px);
    max-width: none;
    left: 12px;
    right: 12px;
    transform: none;
  }
}

/* Mobile sort sheet (outside media so it can animate; only used on mobile) */
.mobile-sort-overlay {
  display: none;
}

@media (max-width: 760px) {
  .mobile-sort-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .mobile-sort-overlay.active {
    display: flex;
  }

  .mobile-sort-sheet {
    width: 100%;
    max-height: min(78vh, 640px);
    overflow: auto;
    background: var(--color-white);
    border-radius: 20px 20px 0 0;
    padding: 8px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  }

  .mobile-sort-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 10px;
  }

  .mobile-sort-sheet-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-black);
    margin: 0;
  }

  .mobile-sort-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--color-gray-light);
    color: var(--color-gray);
    cursor: pointer;
    padding: 0;
  }

  .mobile-sort-sheet-close svg {
    width: 20px;
    height: 20px;
  }

  .mobile-sort-options {
    display: flex;
    flex-direction: column;
    padding: 4px 10px 8px;
  }

  .mobile-sort-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--color-black);
    font-size: 16px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
  }

  .mobile-sort-option:active {
    background: var(--color-gray-light);
  }

  .mobile-sort-option.active {
    background: #eff6ff;
    color: var(--accent-color);
  }

  .mobile-sort-option i,
  .mobile-sort-option svg:not(.mobile-sort-check):not(.mobile-sort-pro-lock) {
    width: 18px;
    height: 18px;
    font-size: 15px;
    color: var(--color-gray);
    flex-shrink: 0;
  }

  .mobile-sort-option.active i,
  .mobile-sort-option.active svg:not(.mobile-sort-check) {
    color: var(--accent-color);
  }

  .mobile-sort-at {
    width: 18px;
    text-align: center;
    font-weight: 700;
    color: var(--color-gray);
    flex-shrink: 0;
  }

  .mobile-sort-option.active .mobile-sort-at {
    color: var(--accent-color);
  }

  .mobile-sort-option span:not(.mobile-sort-at) {
    flex: 1;
  }

  .mobile-sort-check {
    width: 18px !important;
    height: 18px !important;
    color: var(--accent-color) !important;
    opacity: 0;
    flex-shrink: 0;
  }

  .mobile-sort-option.active .mobile-sort-check {
    opacity: 1;
  }

  .mobile-sort-pro-lock {
    width: 16px !important;
    height: 16px !important;
    color: var(--color-gray) !important;
    flex-shrink: 0;
  }

  .mobile-sort-option.active .mobile-sort-pro-lock {
    display: none;
  }

  .mobile-sort-direction {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 8px 16px 4px;
    border-top: 1px solid var(--color-border);
    margin-top: 4px;
  }

  .mobile-sort-dir-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 48px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background: var(--color-white);
    color: var(--color-gray);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-sort-dir-btn svg {
    width: 18px;
    height: 18px;
  }

  .mobile-sort-dir-btn.active {
    background: var(--color-black);
    border-color: var(--color-black);
    color: var(--color-white);
  }
}
