/* rgba backgrounds so text/chart stay fully opaque (no whole-card opacity) */
:root {
    --page-bg: #0f1114;
    --gap: 10px;
    --pad: 12px;
    --radius: 12px;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--page-bg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.shell {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: var(--gap);
    /* Clear status bar / notch; env() is 0 on most desktop browsers */
    padding-top: max(28px, calc(var(--gap) + env(safe-area-inset-top, 0px)));
    padding-bottom: max(var(--gap), env(safe-area-inset-bottom, 0px));
}

header {
    padding: 8px 4px 14px;
    color: #e8eaed;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

header .sub {
    font-size: 0.75rem;
    font-weight: 400;
    color: #9aa0a6;
    margin-top: 4px;
}

.rowTop {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.rowTop .name {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.quote {
    text-align: right;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    opacity: 0.95;
    white-space: nowrap;
    flex: 0 0 auto;
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.quote > div {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
}

.quote .lbl {
    min-width: 34px;
    text-align: right;
}

.quote .lbl {
    opacity: 0.85;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--gap);
}

.card {
    border-radius: var(--radius);
    padding: var(--pad);
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.card .name {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.card .name .month {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0.9;
    line-height: 1.1;
}

.card .close {
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 6px;
}

/* Keep the number width = content only so flash bg doesn’t span the whole row */
.card .close > [data-close] {
    flex: 0 0 auto;
    width: fit-content;
    max-width: 100%;
    min-width: 0;
}

.card .close > [data-close].vflash {
    display: inline-block;
    vertical-align: baseline;
}

.card .close-trend {
    flex-shrink: 0;
    font-size: 0.92em;
    font-weight: 800;
    line-height: 1;
}

.card .close-trend--up {
    color: #00843d;
}

.card .close-trend--down {
    color: #ff0000;
}

.card .changes {
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.95;
    line-height: 1.35;
}

.chart {
    width: 100%;
    height: 52px;
    margin-top: 4px;
    flex-shrink: 0;
}

.chart svg {
    display: block;
    width: 100%;
    height: 100%;
}

.err {
    color: #f28b82;
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.loading {
    color: #9aa0a6;
    text-align: center;
    padding: 48px 16px;
    font-size: 0.9rem;
}

.bg_green {
    background-color: #b3e0c7;
}

.bg_red {
    background-color: #ffb3b3;
}

.bg_yellow {
    background-color: #fff5d9;
}

.text_green {
    color: #00843d;
}

.text_red {
    color: #ff0000;
}

.text_black {
    color: #000000;
}

.bg_default {
    background-color: #333333;
}

.text_default {
    color: #e8eaed;
}

@keyframes priceFlash {
    0% {
        filter: brightness(1.2);
        box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.2), 0 8px 18px rgba(0, 0, 0, 0.18);
        transform: translateZ(0) scale(1.01);
    }
    100% {
        filter: brightness(1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        transform: translateZ(0) scale(1);
    }
}

.flash {
    animation: priceFlash 420ms ease-out;
}

.vflash {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 6px;
    /* ~1s solid highlight, then quick fade (ease-out was fading almost immediately) */
    animation: valueFlash 1.25s linear forwards;
}

@keyframes valueFlash {
    0%,
    80% {
        background-color: var(--flash-bg);
    }
    100% {
        background-color: transparent;
    }
}

/* Green card: flash lighter (brighten), not darker */
.bg_green .vflash { --flash-bg: rgba(255, 255, 255, 0.72); }
.bg_red .vflash { --flash-bg: rgba(200, 0, 0, 0.42); }
.bg_yellow .vflash { --flash-bg: rgba(180, 135, 0, 0.38); }
.bg_default .vflash { --flash-bg: rgba(255, 255, 255, 0.22); }