body {
    margin: 0;
    padding: 12px 14px 24px;
}

.world-graphs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-links a.submit {
    display: inline-block;
    padding: 2px 8px;
    border: solid 1px #444;
    text-decoration: none;
}

.world-graphs-layout {
    width: 100%;
    max-width: 1920px;
    margin: 16px auto 0;
}

.graph-picker {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    margin-bottom: 14px;
}

.graph-picker-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: start;
}

.graph-picker label {
    display: block;
    font-weight: bold;
}

.era-picker-label .submit {
    margin-left: 8px;
}

.era-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.era-option {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border: 1px solid #555;
    background: #252525;
    color: #ddd;
    cursor: pointer;
    font-weight: normal !important;
    line-height: 1.2;
    border-radius: 3px;
}

.era-option:hover {
    background: #303030;
}

.era-option input {
    margin: 0;
}

.featured-graph-presets {
    display: none;
    margin-top: 10px;
}

.featured-graph-presets.has-items {
    display: block;
}

.featured-graph-title {
    margin-bottom: 6px;
    font-weight: bold;
}

.featured-graph-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.featured-graph-button {
    cursor: pointer;
}

.ema-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-top: 10px;
}

.ema-toggle,
.ema-alpha-wrap {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    font-weight: normal !important;
}

.ema-alpha-wrap input {
    width: 72px;
    box-sizing: border-box;
    padding: 3px 5px;
    border: 1px solid #555;
    background: #1f1f1f;
    color: #ddd;
}

.share-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.share-controls button.submit {
    cursor: pointer;
}

.share-controls input {
    width: min(560px, 100%);
    box-sizing: border-box;
    padding: 4px 6px;
    border: 1px solid #555;
    background: #1f1f1f;
    color: #ddd;
}

.selected-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0;
}

.selected-metric-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #666;
    background: #2c2c2c;
    color: #f0b43c;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}

.selected-metric-tag:hover {
    background: #383838;
}

.selected-metric-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex: 0 0 auto;
}

.metric-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 8px;
}

.metric-group {
    border: 1px solid #444;
    background: #252525;
    padding: 6px;
}

.metric-group summary {
    cursor: pointer;
    color: #f0b43c;
    font-weight: bold;
    user-select: none;
}

.metric-list {
    display: grid;
    gap: 4px;
    margin-top: 7px;
}

.metric-subgroup {
    border-left: 1px solid #555;
    margin-top: 3px;
    padding-left: 7px;
}

.metric-subgroup-title {
    color: #aaa;
    font-size: 11px;
    letter-spacing: 0;
    margin: 2px 0 4px;
}

.metric-subgroup-list {
    display: grid;
    gap: 4px;
}

.metric-option {
    display: flex !important;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal !important;
    line-height: 1.25;
}

.metric-option input[type="checkbox"] {
    margin: 0;
}

.metric-option-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1px solid #777;
    border-radius: 2px;
    padding: 0;
    cursor: pointer;
    flex: 0 0 auto;
}

.metric-color-picker {
    position: fixed;
    left: 0;
    top: 0;
    width: 24px;
    height: 24px;
    border: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}

.muted {
    opacity: 0.65;
}

.legendColor {
    display: inline-block;
    width: 20px;
    height: 15px;
    margin-right: 3px;
    vertical-align: middle;
}

.colorPicker,
.columnColorPicker {
    display: none;
}

.chart-shell {
    width: 100%;
    margin-top: 14px;
    background-color: #fff;
}

.chart-cell {
    width: auto;
    min-height: 520px;
    background-color: #252525;
}

#worldGraphsChart {
    min-height: 520px;
    background-color: #ffffff;
}

#chartLegendPanel {
    width: 265px;
    min-width: 265px;
    max-width: 360px;
    vertical-align: top;
    background: #252525;
    color: white;
    font-size: 12px;
    line-height: 1.25;
}

#chartLegendPanel .legendTitle {
    font-weight: bold;
    margin-bottom: 6px;
}

#chartLegendPanel .legendTime {
    margin-bottom: 8px;
    color: #b3b3b3;
}

#chartLegendItems {
    max-height: 650px;
    overflow: auto;
}

#chartLegendItems .legendGroup {
    margin-bottom: 10px;
}

#chartLegendItems .legendGroupTitle {
    margin: 8px 0 4px;
    padding: 3px 0;
    border-bottom: 2px solid #3b3b3b;
    color: #f0b43c;
    font-weight: bold;
}

#chartLegendItems .legendGroup:first-child .legendGroupTitle {
    margin-top: 0;
}

#chartLegendItems .legendRow {
    display: grid;
    grid-template-columns: 14px 22px 22px minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid #3b3b3b;
}

#chartLegendItems .legendRow--active {
    background: #4c4c4c;
}

#chartLegendItems .legendRow--active .legendName,
#chartLegendItems .legendRow--active .legendValue {
    font-weight: 800;
}

#chartLegendItems .legendSwatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 0;
    padding: 0;
    cursor: pointer;
}

#chartLegendItems .legendWidth {
    width: 18px;
    height: 16px;
    border: 1px solid #5d5d5d;
    border-radius: 2px;
    padding: 0;
    background: #202020;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

#chartLegendItems .legendWidth span {
    display: block;
    width: 14px;
    min-height: 1px;
    margin: 0 auto;
    border-radius: 999px;
}

#chartLegendItems .legendWidth--zero span {
    min-height: 0;
    background: transparent !important;
}

#chartLegendItems .legendName {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

#chartLegendItems .legendMetricControl:hover {
    color: #8c5d00;
}

#chartLegendItems .legendWidthControl:hover {
    border-color: #8c5d00;
}

#chartLegendItems .legendCumulative {
    width: 18px;
    height: 16px;
    border: 1px solid #5d5d5d;
    border-radius: 2px;
    padding: 0;
    background: #202020;
    color: #d6d6d6;
    cursor: pointer;
    font: inherit;
    line-height: 1;
}

#chartLegendItems .legendCumulative--active {
    background: #3b3320;
    border-color: #f0b43c;
    color: #f0b43c;
}

#chartLegendItems .legendCumulative--w2 {
    font-weight: 700;
}

#chartLegendItems .legendCumulative--w3 {
    font-weight: 900;
}

#chartLegendItems .legendCumulativeControl:hover {
    border-color: #8c5d00;
}

#chartLegendItems .legendValue {
    font-variant-numeric: tabular-nums;
    font-weight: bold;
    padding-left: 8px;
}

#chartLegendItems .legendCumulativeValue {
    color: #f0b43c;
}

@media (max-width: 900px) {
    body {
        padding: 8px;
    }

    .metric-picker {
        grid-template-columns: 1fr;
    }

    .chart-shell,
    .chart-shell tbody,
    .chart-shell tr,
    .chart-shell td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    #chartLegendPanel {
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    #chartLegendItems .legendRow {
        grid-template-columns: 18px 26px 26px minmax(0, 1fr) auto auto;
        gap: 8px;
        padding: 5px 0;
    }

    #chartLegendItems .legendSwatch {
        width: 14px;
        height: 14px;
    }

    #chartLegendItems .legendWidth {
        width: 22px;
        height: 20px;
    }

    #chartLegendItems .legendWidth span {
        width: 18px;
    }

    #chartLegendItems .legendCumulative {
        width: 22px;
        height: 20px;
    }

    .chart-cell,
    #worldGraphsChart {
        min-height: 360px;
    }

}
