:root,
[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #111;
    --bg-table-border: #222;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #aaa;
    --text-dim: #888;
    --border: #333;
    --border-hover: #555;
    --accent: #646cff;
    --green-bg: #0d4a2f;
    --green-fg: #4ade80;
    --yellow-bg: #5c4b00;
    --yellow-fg: #facc15;
    --orange-bg: #6b3a00;
    --orange-fg: #fb923c;
    --red-bg: #5c1a1a;
    --red-fg: #f87171;
    --purple-bg: #3b1a5c;
    --purple-fg: #c084fc;
    --legend-bg: #1a1a1a;
    --scrollbar-track: #1a1a1a;
    --scrollbar-thumb: #444;
}

[data-theme="light"] {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --bg-table-border: #d0d0d0;
    --text-primary: #111111;
    --text-secondary: #333333;
    --text-muted: #555;
    --text-dim: #777;
    --border: #ccc;
    --border-hover: #999;
    --accent: #4a5af0;
    --green-bg: #d4edda;
    --green-fg: #155724;
    --yellow-bg: #fff3cd;
    --yellow-fg: #856404;
    --orange-bg: #ffe0b2;
    --orange-fg: #e65100;
    --red-bg: #f8d7da;
    --red-fg: #721c24;
    --purple-bg: #e8daef;
    --purple-fg: #6c3483;
    --legend-bg: #ffffff;
    --scrollbar-track: #e0e0e0;
    --scrollbar-thumb: #aaa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.top-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-tertiary);
}

h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.8rem;
    color: var(--text-primary);
}

.subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 30px;
    font-size: 0.9rem;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

select, input[type="number"] {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    min-width: 180px;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover, input[type="number"]:hover {
    border-color: var(--border-hover);
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="number"] {
    min-width: 150px;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.category-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.category-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.category-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--bg-table-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

th, td {
    padding: 8px 5px;
    text-align: center;
    border: 1px solid var(--bg-table-border);
}

th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

th.corner {
    background: var(--bg-tertiary);
}

th.charset-header {
    font-size: 0.68rem;
    min-width: 90px;
}

.length-cell {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
    position: sticky;
    left: 0;
    z-index: 5;
    min-width: 45px;
}

.time-cell {
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s;
    font-size: 0.72rem;
}

.color-green { background: var(--green-bg); color: var(--green-fg); }
.color-yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.color-orange { background: var(--orange-bg); color: var(--orange-fg); }
.color-red { background: var(--red-bg); color: var(--red-fg); }
.color-purple { background: var(--purple-bg); color: var(--purple-fg); }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    padding: 15px;
    background: var(--legend-bg);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

#custom-gpu-container {
    display: none;
}

.methodology {
    margin-top: 40px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--bg-table-border);
}

.methodology h2 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.methodology p {
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-secondary);
    text-align: justify;
}

.assumptions {
    margin-top: 20px;
}

.assumptions h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.assumptions ul {
    list-style: disc;
    padding-left: 20px;
}

.assumptions li {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.references {
    margin-top: 20px;
}

.references h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.references-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.references-links a {
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    line-height: 1.5;
}

.references-links a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .container { padding: 10px; }
    h1 { font-size: 1.3rem; }
    .controls { flex-direction: column; align-items: stretch; }
    select, input[type="number"] { min-width: 100%; }
    table { font-size: 0.68rem; }
    th, td { padding: 5px 3px; }
    .methodology { padding: 16px; }
}

.site-footer {
    margin-top: 34px;
    padding: 22px 16px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    text-align: center;
    font-size: 0.86rem;
    line-height: 1.7;
}

.footer-brand {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: 0.03em;
}

.footer-links {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.site-footer a {
    color: var(--accent);
    text-decoration: none;
}

.site-footer a:hover {
    text-decoration: underline;
}
