/* ── Reset ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11', 'ss01';
    background: #0c0c0e;
    color: #f2f2f3;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app { height: 100%; }

/* ── Loading ───────────────────────────────────────────────────────────────── */

.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1rem;
    color: #78788c;
    font-size: 0.875rem;
    background: #0c0c0e;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #1e1e22;
    border-top-color: #f97316;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App layout ────────────────────────────────────────────────────────────── */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Navigation ────────────────────────────────────────────────────────────── */

.nav-sidebar {
    width: 220px;
    flex-shrink: 0;
    height: 100vh;
    background: #0f0f12;
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.nav-header {
    padding: 1.75rem 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}

.nav-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 500;
    color: #78788c;
    text-decoration: none;
    margin-bottom: 0.875rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: color 0.15s;
}
.nav-back:hover { color: #f97316; }

.nav-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #f2f2f3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.nav-items {
    padding: 0.75rem 0;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.6rem 1.5rem;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: #78788c;
    text-align: left;
    font-family: inherit;
    letter-spacing: -0.005em;
    transition: color 0.12s, background 0.12s;
}
.nav-item:hover {
    color: #a8a8b3;
    background: rgba(255,255,255,0.03);
}
.nav-item.active {
    color: #f97316;
    background: rgba(249,115,22,0.08);
    border-left-color: #f97316;
    font-weight: 600;
}

/* ── Main ──────────────────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.main-header {
    flex-shrink: 0;
    padding: 1.75rem 2.5rem 1.5rem;
    background: #0c0c0e;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.main-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem 3rem;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #1e1e22 transparent;
}
.main-body::-webkit-scrollbar { width: 5px; }
.main-body::-webkit-scrollbar-track { background: transparent; }
.main-body::-webkit-scrollbar-thumb { background: #1e1e22; border-radius: 99px; }

.main-body.chat-active {
    overflow: hidden;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
}

/* ── Sections ──────────────────────────────────────────────────────────────── */

.section-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.section-chat .chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.section-chat .chat-container {
    flex: 1;
    height: 0;
}

.hidden { display: none !important; }

/* ── Page header ───────────────────────────────────────────────────────────── */

.dash-header {}

.back-link {
    display: inline-block;
    font-size: 0.72rem;
    color: #78788c;
    text-decoration: none;
    margin-bottom: 0.75rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: color 0.15s;
}
.back-link:hover { color: #f97316; }

.convo-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: #f2f2f3;
    margin-bottom: 0.625rem;
    line-height: 1.2;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #a8a8b3;
    letter-spacing: 0.01em;
}

.dash-sub {
    font-size: 0.78rem;
    color: #78788c;
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* ── Stat grid ─────────────────────────────────────────────────────────────── */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 1px;
    margin-bottom: 1.5rem;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}

.stat-card {
    background: #141416;
    padding: 1.25rem 1.4rem 1.1rem;
    position: relative;
}
.stat-card:first-child { border-radius: 13px 0 0 13px; }
.stat-card:last-child  { border-radius: 0 13px 13px 0; }

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    color: #f2f2f3;
    line-height: 1;
    letter-spacing: -0.04em;
    margin-bottom: 0.45rem;
}

.stat-label {
    font-size: 0.67rem;
    font-weight: 600;
    color: #78788c;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
    background: #141416;
    border-radius: 12px;
    padding: 1.4rem 1.5rem;
    border: 1px solid rgba(255,255,255,0.07);
    margin-bottom: 1px;
}

.card-full { width: 100%; }

.card-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #78788c;
    margin-bottom: 1.1rem;
}

/* ── Grid system ───────────────────────────────────────────────────────────── */

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    align-items: start;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(255,255,255,0.06);
}

.two-col > .card {
    border-radius: 0;
    border: none;
    margin-bottom: 0;
}

.col-stack {
    display: flex;
    flex-direction: column;
}

.col-stack > .card {
    border-radius: 0;
    border: none;
    margin-bottom: 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.col-stack > .card:last-child { border-bottom: none; }

/* Cards outside two-col need their own spacing */
.section > .card,
.section > .stat-grid {
    margin-bottom: 1.25rem;
}
.section > .card:last-child { margin-bottom: 0; }

@media (max-width: 800px) {
    .two-col { grid-template-columns: 1fr; }
    .convo-title { font-size: 1.3rem; }
    .stat-value { font-size: 1.5rem; }
}

/* ── Per person ────────────────────────────────────────────────────────────── */

.person-block {
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.person-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.person-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.person-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.person-name {
    font-size: 0.875rem;
    font-weight: 700;
    color: #f2f2f3;
    flex: 1;
    letter-spacing: -0.02em;
}

.person-count {
    font-size: 0.85rem;
    font-weight: 700;
    color: #8e8e99;
}

.person-pct {
    font-size: 0.78rem;
    color: #78788c;
    min-width: 40px;
    text-align: right;
    font-weight: 500;
}

.person-bar-wrap {
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.65rem;
}

.person-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}

.person-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.875rem;
    font-size: 0.75rem;
    color: #78788c;
}
.person-meta strong { color: #8e8e99; font-weight: 600; }

/* ── Charts ────────────────────────────────────────────────────────────────── */

.chart-wrap { width: 100%; }

.chart-labels {
    display: flex;
    margin-top: 6px;
}

.chart-labels span {
    flex: 1;
    text-align: center;
    font-size: 0.65rem;
    color: #64646f;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Bar rows ──────────────────────────────────────────────────────────────── */

.type-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}
.type-row:last-child { margin-bottom: 0; }

.type-label {
    font-size: 0.78rem;
    color: #78788c;
    min-width: 50px;
    font-weight: 500;
}

.type-bar-wrap {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 99px;
    overflow: hidden;
}

.type-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}

.type-count {
    font-size: 0.78rem;
    font-weight: 700;
    color: #8e8e99;
    min-width: 52px;
    text-align: right;
}

.types-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
}
.types-col-label { min-width: 50px; }
.types-person {
    flex: 1;
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
}

.type-row-split {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}
.type-row-split:last-child { margin-bottom: 0; }

.type-split-bars { flex: 1; display: flex; gap: 3px; }

.split-bar-wrap {
    flex: 1;
    height: 5px;
    background: rgba(255,255,255,0.06);
    border-radius: 99px;
    overflow: hidden;
}

.split-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
    float: left;
}
.split-bar-right { float: right; }

.type-counts {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 88px;
    text-align: right;
    display: flex;
    gap: 0.2rem;
    justify-content: flex-end;
    align-items: center;
}
.type-sep { color: #525260; }

/* ── Reactions ─────────────────────────────────────────────────────────────── */

.reaction-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.reaction-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    min-width: 52px;
    border: 1px solid rgba(255,255,255,0.07);
    transition: background 0.15s;
}
.reaction-item:hover { background: rgba(255,255,255,0.07); }

.reaction-emoji { font-size: 1.4rem; line-height: 1; }
.reaction-count { font-size: 0.66rem; font-weight: 700; color: #78788c; }

/* ── Word cloud ────────────────────────────────────────────────────────────── */

.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.75rem;
    align-items: baseline;
    line-height: 1.7;
}

.word-tag {
    color: #f97316;
    font-weight: 700;
    cursor: default;
    transition: opacity 0.15s;
    letter-spacing: -0.01em;
}
.word-tag:hover { opacity: 1 !important; }

/* ── Yearly chart ──────────────────────────────────────────────────────────── */

.yearly-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 168px;
    padding-bottom: 30px;
    position: relative;
}

.yearly-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    position: relative;
}

.yearly-bars {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 2px;
}

.yearly-bar {
    flex: 1;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: opacity 0.15s;
}
.yearly-bar:hover { opacity: 0.7; }

.yearly-label {
    font-size: 0.66rem;
    color: #64646f;
    font-weight: 600;
    margin-top: 5px;
    white-space: nowrap;
}

.yearly-total {
    font-size: 0.64rem;
    color: #78788c;
    font-weight: 700;
}

.yearly-legend {
    display: flex;
    gap: 1.25rem;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: #78788c;
}

.yearly-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.yearly-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Emoji stats ───────────────────────────────────────────────────────────── */

.emoji-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
}

.emoji-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.emoji-char { font-size: 1.1rem; width: 1.6rem; text-align: center; }
.emoji-count { font-size: 0.75rem; font-weight: 700; color: #8e8e99; min-width: 36px; text-align: right; }

.person-emoji-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}
.person-emoji-name { font-size: 0.75rem; font-weight: 700; min-width: 90px; }
.person-emoji-list { font-size: 1.1rem; letter-spacing: 3px; }

/* ── Milestones ────────────────────────────────────────────────────────────── */

.milestone-row {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.milestone-row:last-child { border-bottom: none; }

.milestone-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    background: rgba(249,115,22,0.1);
    border-radius: 8px;
    margin-top: 1px;
}
.ms-svg { width: 15px; height: 15px; color: #f97316; }
.milestone-label { font-size: 0.67rem; color: #78788c; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.milestone-value { font-size: 0.85rem; color: #d4d4da; font-weight: 600; margin-top: 2px; letter-spacing: -0.01em; }

/* ── Heatmap ───────────────────────────────────────────────────────────────── */

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 0.75rem;
    font-size: 0.68rem;
    color: #64646f;
    font-weight: 500;
}

.hm-swatch {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Calls ─────────────────────────────────────────────────────────────────── */

.call-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-bottom: 1rem;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
}

.call-stat {
    background: rgba(255,255,255,0.03);
    padding: 0.875rem 0.5rem;
    text-align: center;
}

.call-stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #f2f2f3;
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.call-stat-label {
    font-size: 0.63rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #78788c;
}

.call-durations {
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 0.875rem;
    margin-bottom: 0.875rem;
}

.call-dur-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.825rem;
}

.call-dur-label { color: #78788c; }
.call-dur-value { font-weight: 700; color: #d4d4da; letter-spacing: -0.01em; }

.call-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64646f;
    margin-bottom: 0.65rem;
    margin-top: 0.625rem;
}

/* ── Response time ─────────────────────────────────────────────────────────── */

.rt-avg {
    font-size: 0.8rem;
    color: #78788c;
    margin-top: 0.875rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    padding-top: 0.875rem;
}
.rt-avg strong { color: #d4d4da; font-weight: 700; }

.rt-note {
    font-size: 0.75rem;
    color: #64646f;
    margin-bottom: 0.875rem;
    line-height: 1.6;
}

/* ── Chat ──────────────────────────────────────────────────────────────────── */

.chat-view { gap: 0; }

.chat-who-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    font-weight: 600;
    color: #64646f;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.625rem;
    padding: 0 0.25rem;
}

.chat-container {
    overflow-y: scroll;
    background: #0f0f12;
    border-radius: 12px;
    padding: 1rem 1rem 2.5rem;
    border: 1px solid rgba(255,255,255,0.06);
    scrollbar-width: thin;
    scrollbar-color: #1e1e22 transparent;
}
.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: #1e1e22; border-radius: 99px; }

.chat-sentinel { height: 1px; }

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 24px;
}

.chat-date-div {
    text-align: center;
    font-size: 0.67rem;
    color: #64646f;
    font-weight: 600;
    margin: 1rem 0 0.625rem;
    position: relative;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.chat-date-div::before,
.chat-date-div::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 28%;
    height: 1px;
    background: rgba(255,255,255,0.06);
}
.chat-date-div::before { left: 0; }
.chat-date-div::after  { right: 0; }

.bw {
    display: flex;
    flex-direction: column;
    max-width: 68%;
    margin-bottom: 2px;
}

.bw-self  { align-self: flex-end;  align-items: flex-end; }
.bw-other { align-self: flex-start; align-items: flex-start; }

.bubble-sender {
    font-size: 0.65rem;
    font-weight: 600;
    color: #64646f;
    margin-bottom: 3px;
    padding-left: 4px;
}

.bubble {
    border-radius: 18px;
    padding: 0.5rem 0.9rem;
    max-width: 100%;
    word-break: break-word;
}

.bw-self .bubble {
    background: #f97316;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.bw-other .bubble {
    background: #1a1a1e;
    color: #e8e8ed;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
}

.bubble-text {
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.bubble-media {
    font-size: 0.78rem;
    opacity: 0.5;
    padding: 0.15rem 0;
}

.bubble-share {
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-left: 2px solid rgba(255,255,255,0.3);
    padding-left: 8px;
    margin-top: 4px;
    font-size: 0.8rem;
}
.bw-other .bubble-share { border-color: #f97316; }
.bubble-share-link { opacity: 0.45; font-size: 0.72rem; }

.bubble-unsent {
    font-size: 0.78rem;
    font-style: italic;
    opacity: 0.35;
}

.bubble-time {
    font-size: 0.63rem;
    color: #64646f;
    margin-top: 2px;
    padding: 0 4px;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.bw:hover .bubble-time { opacity: 1; }

.bubble-reactions {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: 3px;
}

.bubble-reaction {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #1a1a1e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 99px;
    padding: 2px 7px;
    font-size: 0.78rem;
    cursor: default;
}

.rn {
    font-size: 0.63rem;
    font-weight: 700;
    color: #78788c;
}

/* ── Reciprocity ───────────────────────────────────────────────────────────── */

.recip-score-wrap {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.recip-score-num {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.recip-score-label {
    font-size: 0.8rem;
    color: #525260;
}

.recip-dim {
    margin-bottom: 0.75rem;
}

.recip-dim-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.3rem;
}

.recip-dim-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #8e8e99;
}

.recip-dim-score {
    font-size: 0.8rem;
    font-weight: 700;
}

.recip-dim-desc {
    font-size: 0.72rem;
    color: #525260;
    margin-top: 0.25rem;
}

/* ── Snapshot ──────────────────────────────────────────────────────────────── */

.snapshot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1px;
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.06);
}

.snapshot-card {
    background: #141416;
    padding: 1.1rem 1.1rem;
}

.snapshot-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
}

.snapshot-name {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.snapshot-traits {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.snapshot-trait {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: #8e8e99;
    line-height: 1.4;
}

.snapshot-trait { align-items: center; }

.snapshot-trait-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.trait-svg { width: 13px; height: 13px; color: #525260; }

/* ── Filler tags ───────────────────────────────────────────────────────────── */

.filler-person-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.filler-person-name {
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 80px;
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.filler-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.filler-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 99px;
    padding: 0.18em 0.6em;
    font-size: 0.73rem;
    color: #8e8e99;
}

.filler-tag-count {
    color: #525260;
    font-size: 0.68rem;
}

/* ── Drift Detector ────────────────────────────────────────────────────────── */

.drift-legend {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.drift-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.72rem;
    color: #525260;
}

.drift-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.drift-period {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.drift-period:last-child { border-bottom: none; }

.drift-period-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.drift-period-dates {
    font-size: 0.85rem;
    font-weight: 600;
    color: #d4d4da;
    letter-spacing: -0.01em;
}

.drift-badge {
    font-size: 0.72rem;
    font-weight: 700;
    border: 1px solid;
    border-radius: 99px;
    padding: 0.15em 0.55em;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.drift-period-meta {
    font-size: 0.75rem;
    color: #525260;
}

/* ── Time-of-day drift ─────────────────────────────────────────────────────── */

.drift-legend-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.drift-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.drift-legend-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: #8e8e99;
    letter-spacing: -0.01em;
}

.drift-legend-range {
    font-weight: 400;
    color: #525260;
}

.tod-drift-row {
    padding: 0.7rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.tod-drift-row:last-child { border-bottom: none; }

.tod-drift-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.tod-drift-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #d4d4da;
    letter-spacing: -0.01em;
}

.tod-drift-hours {
    font-size: 0.72rem;
    color: #525260;
    flex: 1;
}

.tod-drift-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tod-drift-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tod-drift-period {
    font-size: 0.68rem;
    font-weight: 600;
    color: #525260;
    width: 48px;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tod-drift-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: #8e8e99;
    width: 54px;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.tod-drift-unit {
    font-size: 0.65rem;
    color: #525260;
    font-weight: 400;
    margin-left: 1px;
}

/* ── Modal backdrop (shared) ───────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1.5rem;
}

.modal {
    background: #141416;
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 18px;
    width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

/* ── Day modal ─────────────────────────────────────────────────────────────── */

.day-modal-inner {
    max-width: 480px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.day-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.day-modal-date {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f2f2f3;
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
}

.day-modal-count {
    font-size: 0.78rem;
    color: #525260;
}

.day-modal-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: #8e8e99;
    cursor: pointer;
    padding: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.day-modal-close:hover { background: rgba(255,255,255,0.1); color: #f2f2f3; }

.day-modal-messages {
    overflow-y: auto;
    padding: 0.75rem 0;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #1e1e22 transparent;
}

.day-msg-row {
    display: grid;
    grid-template-columns: 40px 90px 1fr;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.3rem 1.5rem;
    font-size: 0.8rem;
    line-height: 1.45;
}
.day-msg-row:hover { background: rgba(255,255,255,0.03); }
.day-msg-cont { padding-top: 0.1rem; }
.day-msg-cont:hover { background: rgba(255,255,255,0.03); }

.day-msg-time {
    color: #525260;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.day-msg-sender {
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-msg-content {
    color: #8e8e99;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Message types stacked counts ──────────────────────────────────────────── */

.type-counts-v {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 52px;
    gap: 3px;
}

.type-counts-v span {
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
}

/* ── Energy legend ───────────────────────────────────────────────────── */
.energy-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 1rem;
}
.energy-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: #a0a0b0;
    letter-spacing: 0.01em;
}
.energy-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    opacity: 0.9;
    flex-shrink: 0;
}

/* ── Topics ──────────────────────────────────────────────────────────── */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}
.topic-card {
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(255,255,255,0.07);
}
.topic-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.topic-label {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.topic-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e8e8f0;
    font-variant-numeric: tabular-nums;
}
.topic-bar-wrap {
    height: 4px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    margin-bottom: 0.6rem;
    overflow: hidden;
}
.topic-bar {
    height: 100%;
    border-radius: 2px;
    opacity: 0.75;
    transition: width 0.4s ease;
}
.topic-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topic-pct {
    font-size: 0.7rem;
    color: #666;
}
.topic-spark {
    opacity: 0.85;
}

/* ── Vocabulary / Caps ───────────────────────────────────────────────── */
.vocab-row, .caps-row {
    padding: 0.65rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.vocab-row:last-child, .caps-row:last-child { border-bottom: none; }
.vocab-header, .caps-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.vocab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.vocab-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #c8c8d8;
}
.vocab-grade, .caps-label {
    font-size: 0.72rem;
    font-weight: 500;
    margin-left: auto;
}
.vocab-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.72rem;
    color: #888;
}
.vocab-stats strong { color: #c8c8d8; }
.vocab-fancy {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.vocab-chip {
    font-size: 0.68rem;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(255,255,255,0.07);
    color: #a0a0b0;
    border: 1px solid rgba(255,255,255,0.1);
}

/* ── Wacky messages ──────────────────────────────────────────────────── */
.wacky-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}
.wacky-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.wacky-msg {
    font-size: 0.95rem;
    color: #e8e8f0;
    line-height: 1.4;
    font-style: italic;
}
.wacky-msg::before { content: '\201C'; opacity: 0.4; }
.wacky-msg::after  { content: '\201D'; opacity: 0.4; }
.wacky-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
}
.wacky-sender { font-weight: 600; }
.wacky-date { color: #555; }

/* ── Phrase detection ────────────────────────────────────────────────────────── */
.phrase-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: baseline;
}
.phrase-chip {
    padding: 4px 10px;
    border-radius: 99px;
    background: rgba(255,255,255,0.07);
    color: #c8c8d8;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: default;
    transition: background 0.15s;
}
.phrase-chip:hover { background: rgba(255,255,255,0.13); }

/* ── Book stats ──────────────────────────────────────────────────────────────── */
.book-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
@media (max-width: 480px) { .book-stats-grid { grid-template-columns: repeat(2, 1fr); } }
.book-stat {
    background: rgba(255,255,255,0.04);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.07);
}
.book-stat-val {
    font-size: 1.15rem;
    font-weight: 700;
    color: #e8e8f0;
    font-variant-numeric: tabular-nums;
}
.book-stat-label {
    font-size: 0.68rem;
    color: #666;
    margin-top: 2px;
}
.book-comparison {
    background: rgba(249,115,22,0.08);
    border: 1px solid rgba(249,115,22,0.2);
    border-radius: 8px;
    padding: 0.65rem 0.9rem;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.book-comparison-ratio { color: #888; }
.book-comparison-title { color: #f97316; font-weight: 600; }

/* ── Monthly winners ─────────────────────────────────────────────────────────── */
.winner-tally {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-bottom: 1rem;
}
.winner-tally-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #a0a0b0;
}
.winner-tally-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.winner-tally-name { color: #c8c8d8; font-weight: 500; }
.winner-tally-count { font-weight: 700; font-variant-numeric: tabular-nums; }
.winner-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.winner-dot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    cursor: default;
}
.winner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.15s;
}
.winner-dot-wrap:hover .winner-dot { opacity: 1; transform: scale(1.3); }
.winner-dot-label {
    font-size: 0.55rem;
    color: #444;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    height: 28px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
}
.winner-dot-wrap:hover .winner-dot-label { opacity: 1; }
