/* === MOBILE (≤768px) === */
:root {
    --c-brand: #4A90E2; --c-brand-dark: #2E5BA8;
    --c-surface-0: #FFFFFF; --c-surface-1: #F0F2F5; --c-surface-2: #E8EBF0;
    --c-text-primary: #1C2833; --c-text-secondary: #5D6D7E; --c-text-muted: #8A9BAD;
    --c-separator: rgba(0,0,0,0.08); --c-overlay: rgba(0,0,0,0.45);
    --c-tab-bar-bg: rgba(255,255,255,0.96);
    --r-card: 12px; --r-pill: 20px; --r-input: 10px;
    /* [STRATA] sheet tokens */
    --grip: #D4DADE; --r-sheet: 18px;
}
.mobile-tabbar { display: none; }
.filter-drawer { display: none; }
#mobile-detail { display: none; }

@media (max-width: 768px) {
    /* Hide desktop elements */
    .tabs, .filter-bar, .exec-summary { display: none !important; }
    .chat-toggle-btn, .chat-panel { display: none !important; }
    .sticky-footer, .settings-btn { display: none !important; }
    body { padding-bottom: 0; }

    /* Show mobile elements */
    .mobile-tabbar { display: flex !important; }
    .filter-drawer { display: block; }
    #mobile-detail { display: block; }

    /* Header — sized consistent with the sibling apps (was compacted to 56px) */
    .header { padding: 1.5rem 1.5rem 2.2rem; }
    .header-logo { height: 86px; }
    .header .subtitle { font-size: 0.95rem; }
    .header .question { display: none; }

    /* Layout adjustments */
    body { background: var(--c-surface-1); }
    .container { padding: 0; max-width: 100%; }
    .tab-content.active { display: block; }
    #tab-table { padding-bottom: 0; }
    .landscape-grid { grid-template-columns: 1fr !important; padding: 0 12px 100px; gap: 10px; }
    .landscape-panel { border-radius: var(--r-card); }
    .methodology-grid { padding: 0 12px 100px; }
    #tab-landscape, #tab-methodology { padding-bottom: 0; }
}

/* --- Mobile tab bar --- */
.mobile-tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 1200;
    background: var(--c-tab-bar-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--c-separator);
    padding-bottom: env(safe-area-inset-bottom, 8px);
    height: auto; align-items: stretch;
}
.m-tab {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; background: none; border: none; cursor: pointer;
    color: var(--c-text-muted); font-size: 0.62rem; padding: 8px 0; position: relative;
    min-height: 44px;
}
.m-tab.sel { color: var(--c-brand); }
.m-tab-bar {
    position: absolute; top: 0; left: 20%; right: 20%; height: 2.5px;
    background: var(--c-brand); border-radius: 0 0 2px 2px;
    opacity: 0; transition: opacity 0.15s;
}
.m-tab.sel .m-tab-bar { opacity: 1; }

/* --- Mobile search bar --- */
.search-bar-m {
    display: flex; align-items: center; gap: 8px;
    background: var(--c-surface-2); border-radius: var(--r-input);
    padding: 9px 12px; margin: 12px 12px 0;
}
.search-bar-m input {
    flex: 1; border: none; background: none; outline: none;
    font-size: 0.9rem; color: var(--c-text-primary);
}
.search-bar-m input::placeholder { color: var(--c-text-muted); }
.m-filter-icon-btn {
    background: none; border: none; cursor: pointer;
    color: var(--c-text-secondary); padding: 0; line-height: 1;
    display: flex; align-items: center;
}

/* --- Stat strip --- */
.stat-strip-m {
    display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px 6px;
    scrollbar-width: none;
}
.stat-strip-m::-webkit-scrollbar { display: none; }
.stat-card-m {
    flex-shrink: 0; background: var(--c-surface-0); border-radius: 10px;
    padding: 9px 13px; min-width: 88px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}
.stat-card-m .sn { font-family: 'Instrument Serif', serif; font-size: 1.6rem; font-weight: 400; color: var(--c-text-primary); line-height: 1; }
.stat-card-m .sl { font-size: 0.6rem; font-weight: 600; color: var(--c-text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.07em; }

/* --- Card grid --- */
.mobile-card-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
    padding: 6px 12px 100px;
    /* Force equal columns in Safari — grid children need min-width:0 */
    overflow: hidden;
}
.card-m {
    background: var(--c-surface-0); border-radius: var(--r-card);
    padding: 11px; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: transform 0.1s;
    min-width: 0; /* prevents content from blowing out grid column */
    overflow: hidden;
}
.card-m:active { transform: scale(0.97); }
.card-m .cn { font-size: 0.85rem; font-weight: 600; color: var(--c-text-primary); margin-bottom: 3px; line-height: 1.3; word-break: break-word; }
.card-m .ct { font-size: 0.65rem; color: var(--c-text-secondary); margin-bottom: 5px; }
.card-m .ctags { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 8px; }
.card-m .ctags .badge { font-size: 0.62rem; padding: 0.15rem 0.45rem; }
.card-m .cscore-row { display: flex; align-items: center; justify-content: space-between; }
.card-m .cscore { font-size: 1.05rem; font-weight: 700; color: var(--c-text-primary); }
.card-m .cbar-wrap { flex: 1; height: 3px; background: var(--c-surface-2); border-radius: 2px; margin-left: 7px; }
.card-m .cbar-fill { height: 100%; border-radius: 2px; background: var(--c-brand); }

/* --- Filter drawer --- */
.filter-drawer {
    position: fixed; inset: 0; z-index: 2000;
    background: var(--c-overlay);
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.filter-drawer.open { opacity: 1; pointer-events: all; }
.filter-drawer-sheet {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--c-surface-0); border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    max-height: 80vh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.28s cubic-bezier(.32,.72,0,1);
}
.filter-drawer.open .filter-drawer-sheet { transform: translateY(0); }
.drawer-handle {
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--c-surface-2); margin: 10px auto 14px;
}
.drawer-section-title {
    font-size: 0.68rem; font-weight: 600; color: var(--c-text-secondary);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 0 16px 6px;
}
.drawer-pill-row {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px;
}
.drawer-pill {
    padding: 5px 12px; border-radius: var(--r-pill);
    border: 1.5px solid var(--c-surface-2); background: var(--c-surface-0);
    font-size: 0.75rem; font-weight: 500; color: var(--c-text-secondary);
    cursor: pointer; white-space: nowrap; line-height: 1.4;
}
.drawer-pill.sel {
    background: var(--c-brand); border-color: var(--c-brand); color: #fff;
}
.apply-btn-m {
    display: block; width: calc(100% - 32px); margin: 8px 16px 6px;
    background: var(--c-brand); color: #fff; border: none; border-radius: 10px;
    padding: 14px; font-size: 0.9rem; font-weight: 600; cursor: pointer;
}
.clear-link-m {
    display: block; width: 100%; text-align: center;
    background: none; border: none; color: var(--c-text-secondary);
    font-size: 0.85rem; padding: 10px 0 14px; cursor: pointer;
}

/* --- Mobile detail — [STRATA] bottom sheet (was full-screen translateX push) --- */
#mobile-detail {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
    background: var(--c-surface-1);
    border-radius: var(--r-sheet) var(--r-sheet) 0 0;
    max-height: 94vh; display: flex; flex-direction: column; overflow: hidden;
    transform: translateY(101%); transition: transform .34s cubic-bezier(.22,1,.36,1);
    box-shadow: 0 -12px 44px rgba(15,20,26,.24); touch-action: none;
}
#mobile-detail.open { transform: translateY(0); }
#mobile-detail.dragging { transition: none; }
#mobile-detail-hero { flex: 0 0 auto; }                          /* dark header — fixed, part of the drag zone */
#mobile-detail-inner { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }   /* seg + content scroll */
/* grip sits on the dark header so the top reads as one hero */
#mobile-detail .strata-grip { background: #0D1B2A; border-radius: var(--r-sheet) var(--r-sheet) 0 0; }
#mobile-detail .strata-grip i { background: rgba(255,255,255,0.4); }
#mobile-detail .detail-dh { padding-top: 8px; }
.detail-dh {
    background: linear-gradient(150deg, #0D1B2A 0%, #1C3550 100%);
    padding: 16px 16px 20px; color: #fff;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
}
.detail-dh .back-btn {
    background: none; border: none; color: rgba(255,255,255,0.75);
    font-size: 0.9rem; cursor: pointer; padding: 0; margin-bottom: 12px;
    display: flex; align-items: center; gap: 5px;
}
.detail-dh .dh-name { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.detail-dh .dh-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.detail-dh .dh-tag {
    font-size: 0.67rem; padding: 3px 8px; border-radius: 6px;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9);
}
.detail-dh .dh-score-row { display: flex; align-items: baseline; gap: 4px; }
.detail-dh .dh-score { font-family: 'Instrument Serif', serif; font-size: 2rem; font-weight: 400; }
.detail-dh .dh-score-max { font-size: 0.8rem; color: rgba(255,255,255,0.55); }
.detail-dh .dh-website-btn {
    display: inline-flex; align-items: center; gap: 5px; margin-top: 10px;
    background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9);
    border: none; border-radius: 8px; padding: 7px 12px;
    font-size: 0.78rem; cursor: pointer; text-decoration: none;
}

/* Floating tab bar (matches desktop .tabs-inner style) */
.detail-seg-wrap {
    position: sticky; top: 0; z-index: 10;
    background: var(--c-surface-1); padding: 8px 12px;
    box-shadow: 0 1px 0 var(--c-separator);
}
.detail-seg {
    display: flex; overflow-x: auto; scrollbar-width: none;
    background: #E4E8EB; border-radius: 10px; padding: 4px; gap: 2px;
}
.detail-seg::-webkit-scrollbar { display: none; }
.seg-btn {
    flex-shrink: 0; padding: 8px 14px; border: none; border-radius: 8px;
    background: transparent; cursor: pointer;
    font-size: 0.78rem; font-weight: 500; color: #85929E;
    white-space: nowrap; transition: all 0.2s;
}
.seg-btn:hover { background: rgba(255,255,255,0.5); color: #1C2833; }
.seg-btn.active {
    background: #ffffff; color: #1C2833; font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Detail content block */
.detail-block-m {
    background: var(--c-surface-0); border-radius: var(--r-card);
    margin: 10px 12px 0; padding: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.detail-block-m:last-child { margin-bottom: 100px; }
.detail-block-m .db-title {
    font-size: 0.68rem; font-weight: 600; color: var(--c-text-secondary);
    text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px;
}
.detail-tab-pane { display: none; }
.detail-tab-pane.active { display: block; }

/* Score dim row */
.score-dim-row-m {
    display: flex; align-items: center; gap: 8px; padding: 6px 0;
    border-bottom: 1px solid var(--c-separator);
}
.score-dim-row-m:last-child { border-bottom: none; }
.sdm-label { font-size: 0.75rem; color: var(--c-text-secondary); width: 68px; flex-shrink: 0; }
.sdm-bar-wrap { flex: 1; height: 5px; background: var(--c-surface-2); border-radius: 3px; }
.sdm-bar-fill { height: 100%; border-radius: 3px; background: var(--c-brand); }
.sdm-pts { font-size: 0.75rem; font-weight: 600; color: var(--c-text-primary); width: 32px; text-align: right; flex-shrink: 0; }

/* DMI signal row */
.dmi-signal-row-m {
    display: flex; align-items: center; gap: 6px; padding: 5px 0;
    border-bottom: 1px solid var(--c-separator);
}
.dmi-signal-row-m:last-child { border-bottom: none; }
.dsm-label { font-size: 0.72rem; color: var(--c-text-secondary); flex: 1; }
.dsm-obs { font-size: 0.7rem; color: var(--c-text-muted); flex: 1; text-align: center; }
.dsm-pts { font-size: 0.72rem; font-weight: 600; color: var(--c-brand); width: 26px; text-align: right; flex-shrink: 0; }
.dsm-pts.zero { color: var(--c-text-muted); font-weight: 400; }

/* Mobile chat tab */
.chat-full-m {
    display: flex; flex-direction: column;
    background: var(--c-surface-1);
}
.chat-header-m {
    background: #1C2833; color: #fff; padding: 14px 16px;
    flex-shrink: 0;
}
.chat-header-m .cht { font-size: 0.95rem; font-weight: 600; }
.chat-header-m .chs { font-size: 0.72rem; color: rgba(255,255,255,0.6); margin-top: 2px; }
.chat-messages-m {
    flex: 1; overflow-y: auto; padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.bubble-m {
    max-width: 86%; padding: 9px 13px; border-radius: 12px;
    font-size: 0.85rem; line-height: 1.5; word-break: break-word;
}
.bubble-m.user { background: var(--c-brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.bubble-m.ai { background: var(--c-surface-0); color: var(--c-text-primary); align-self: flex-start; border-bottom-left-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.bubble-meta-m { font-size: 0.64rem; color: var(--c-text-muted); padding: 0 4px 4px; align-self: flex-start; }
.chat-input-row-m {
    display: flex; gap: 8px; padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--c-surface-0); border-top: 1px solid var(--c-separator); flex-shrink: 0;
}
.chat-input-m {
    flex: 1; border: 1.5px solid var(--c-surface-2); border-radius: 20px;
    padding: 8px 14px; font-size: 0.85rem; outline: none; resize: none;
    max-height: 80px; line-height: 1.4; font-family: inherit;
}
.chat-input-m:focus { border-color: var(--c-brand); }
.chat-send-m {
    background: var(--c-brand); color: #fff; border: none; border-radius: 50%;
    width: 36px; height: 36px; cursor: pointer; flex-shrink: 0; align-self: flex-end;
    display: flex; align-items: center; justify-content: center;
}
.chat-send-m:disabled { background: var(--c-surface-2); }

/* === [STRATA] shared sheet chrome — grip, scrim, KPI snapshot sheet, drawer drag === */
.strata-grip { padding: 9px 0 5px; display: flex; justify-content: center; flex: 0 0 auto; cursor: grab; }
.strata-grip i { width: 38px; height: 5px; border-radius: 999px; background: var(--grip); display: block; }
.strata-scrim { position: fixed; inset: 0; background: var(--c-overlay); opacity: 0; visibility: hidden;
    transition: opacity .26s; z-index: 1490; }
.strata-scrim.open { opacity: 1; visibility: visible; }
.strata-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; background: var(--c-surface-0);
    border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 80vh; display: flex; flex-direction: column;
    transform: translateY(101%); transition: transform .34s cubic-bezier(.22,1,.36,1);
    box-shadow: 0 -12px 44px rgba(15,20,26,.24); touch-action: none; }
.strata-sheet.open { transform: translateY(0); }
.strata-sheet.dragging { transition: none; }
.strata-sheet-head { padding: 2px 18px 12px; flex: 0 0 auto; }
.strata-sheet-head h3 { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 1.3rem; margin: 0; color: var(--c-text-primary); }
.strata-sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 24px; flex: 1; }
.kpi-grid-m { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi-cell-m { background: var(--c-surface-1); border-radius: var(--r-card); padding: 14px; }
.kpi-cell-m.wide { grid-column: 1 / -1; }
.kpi-cell-m .kn { font-family: 'Instrument Serif', serif; font-size: 1.7rem; line-height: 1; color: var(--c-text-primary); }
.kpi-cell-m .kl { font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--c-text-secondary); margin-top: 6px; }
/* drag-to-dismiss on the existing filter drawer (Concept C had no gesture) */
.filter-drawer-sheet.dragging { transition: none; }

