:root {
    color-scheme: dark;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #0d1117;
    color: #e6edf3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    border-radius: 0.55rem;
    background: #9147ff;
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    padding: 0.72rem 1rem;
}

button:hover {
    background: #a970ff;
}
button:focus-visible,
input:focus-visible {
    outline: 3px solid #bf94ff;
    outline-offset: 2px;
}
button:disabled {
    cursor: wait;
    opacity: 0.7;
}

.page-shell {
    margin: 0 auto;
    max-width: 1120px;
    padding: 1.25rem 1.25rem 4rem;
}
h2,
h3,
p {
    margin-top: 0;
}
h2 {
    font-size: 1.5rem;
    margin-bottom: 0.6rem;
}
h3 {
    font-size: 1.05rem;
}
.muted {
    color: #9ba8b5;
}
.small {
    font-size: 0.86rem;
}
.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.search-panel,
.metrics-card,
.player-card,
.chart-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 0.8rem;
}

.search-panel {
    margin: 0 auto;
    max-width: 640px;
    padding: 0.7rem;
}
.search-row {
    display: flex;
    gap: 0.6rem;
}
label {
    display: block;
    font-weight: 700;
}
input {
    background: #0d1117;
    border: 1px solid #57606a;
    border-radius: 0.55rem;
    color: inherit;
    flex: 1;
    min-width: 0;
    padding: 0.72rem 0.8rem;
}
.status-message {
    color: #ffb4ab;
    min-height: 1.4rem;
    padding-top: 0.75rem;
}

.dashboard {
    margin-top: 1.25rem;
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
}
.player-card {
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
#twitchPlayer {
    border: 0;
    height: 100%;
    width: 100%;
}
.metrics-card,
.chart-card {
    padding: 1.15rem;
}
.metrics-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}
.metrics-grid div {
    border-bottom: 1px solid #30363d;
    padding-bottom: 0.65rem;
}
dt {
    color: #9ba8b5;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
}
dd {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    font-weight: 750;
    margin: 0;
}
#viewerSampleMeta {
    margin: 1rem 0 0;
}
.chart-card {
    margin-top: 1rem;
}
.chart-heading {
    align-items: start;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}
.legend {
    display: flex;
    font-size: 0.82rem;
    gap: 0.8rem;
    white-space: nowrap;
}
.legend span::before {
    border-radius: 99px;
    content: "";
    display: inline-block;
    height: 0.55rem;
    margin-right: 0.3rem;
    width: 0.55rem;
}
.messages-key::before {
    background: #a970ff;
}
.engagement-key::before {
    background: #f0883e;
}
.viewers-key::before {
    background: #3fb950;
}
.chart {
    min-height: 210px;
    overflow-x: auto;
    position: relative;
}
.chart svg {
    display: block;
    min-width: 480px;
    width: 100%;
}
.chart-hit-area {
    cursor: crosshair;
}
.chart-tooltip {
    background: #0d1117;
    border: 1px solid #57606a;
    border-radius: 0.45rem;
    box-shadow: 0 0.35rem 1rem #01040999;
    color: #e6edf3;
    font-size: 0.78rem;
    line-height: 1.45;
    max-width: calc(100% - 1rem);
    padding: 0.45rem 0.55rem;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}
.chart-tooltip strong {
    color: #c9a8ff;
    margin-bottom: 0.15rem;
}
.chart-tooltip-values {
    display: grid;
    gap: 0.08rem;
    list-style: none;
    margin: 0;
    padding: 0;
}
.chart-tooltip-values li {
    display: flex;
    gap: 1.25rem;
    justify-content: space-between;
    white-space: nowrap;
}
.chart-tooltip-values li span:last-child {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.empty-chart {
    color: #9ba8b5;
    padding: 3rem 0;
    text-align: center;
}
.session-controls {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.75rem;
}
.session-refresh,
.session-delete {
    background: transparent;
    border: 1px solid #57606a;
    color: #b7c1cc;
    font-size: 0.78rem;
    font-weight: 650;
    padding: 0.35rem 0.55rem;
}
.session-refresh:hover {
    background: #9147ff26;
    border-color: #a970ff;
    color: #e6edf3;
}
.session-refresh.near-expiry {
    border-color: #d29922;
    color: #f0d69a;
}
.session-delete:hover {
    background: #f8514926;
    border-color: #f85149;
    color: #ffb4ab;
}
.details-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 1rem;
}
.detail-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 0.8rem;
    min-width: 0;
    padding: 1rem 1.15rem;
}
.detail-card summary {
    cursor: pointer;
    font-weight: 750;
}
.detail-card[open] summary {
    margin-bottom: 1rem;
}
.chat-messages {
    display: grid;
    gap: 0.5rem;
    max-height: 28rem;
    overflow-y: auto;
}
.chat-line {
    background: #0d1117;
    border-radius: 0.4rem;
    line-height: 1.4;
    padding: 0.55rem 0.65rem;
    word-break: break-word;
}
.chat-line time {
    color: #9ba8b5;
    font-size: 0.78rem;
    margin-right: 0.3rem;
}
.chat-line strong {
    color: #c9a8ff;
    margin-right: 0.35rem;
}
.chat-content {
    vertical-align: middle;
}
.chat-emote {
    height: 1.5em;
    margin: -0.2em 0.1em;
    max-width: 4em;
    object-fit: contain;
    vertical-align: middle;
}
.user-filter-label {
    font-size: 0.86rem;
    margin: 0.65rem 0 0.3rem;
}
.user-table-wrap {
    max-height: 28rem;
    overflow: auto;
}
table {
    border-collapse: collapse;
    font-size: 0.88rem;
    margin-top: 0.8rem;
    width: 100%;
}
th,
td {
    border-bottom: 1px solid #30363d;
    padding: 0.5rem 0.3rem;
    text-align: left;
    white-space: nowrap;
}
th {
    color: #9ba8b5;
    font-size: 0.76rem;
}

@media (max-width: 720px) {
    .page-shell {
        padding-top: 2rem;
    }
    .search-row {
        align-items: stretch;
        flex-direction: column;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .details-grid {
        grid-template-columns: 1fr;
    }
    .chart-heading {
        flex-direction: column;
        gap: 0.1rem;
    }
}
