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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #faf8f4;
    color: #3d3529;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 1.05rem;
}

header {
    padding: 2rem 1.5rem 1rem;
    text-align: center;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: #1a1510;
}

.subtitle {
    font-size: 1rem;
    color: #8a7e6e;
    margin-top: 0.25rem;
}

.subtitle a {
    color: #7a6e5e;
    text-decoration: none;
    transition: color 0.15s;
}

.subtitle a:hover {
    color: #5a4e3e;
    text-decoration: underline;
}

.last-updated {
    font-size: 0.75rem;
    color: #a89e8e;
    margin-top: 0.15rem;
}

main {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

/* Table */
.table-wrap {
    overflow-x: auto;
    border: 1px solid #e8e2d8;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(60,40,10,0.05);
}

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

th {
    text-align: left;
    padding: 0.6rem 0.65rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a7e6e;
    border-bottom: 1px solid #e8e2d8;
    white-space: nowrap;
    background: #faf8f4;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: #5a4e3e;
}

th.sortable::after {
    content: "";
    margin-left: 0.3rem;
}

th.sortable.active.desc::after {
    content: "▼";
}

th.sortable.active.asc::after {
    content: "▲";
}

th.sortable.active {
    color: #3d3529;
}

td {
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid #f0ece4;
    white-space: nowrap;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #f8f4ee;
}

/* Provider colors */
.provider-anthropic { color: #a06020; }
.provider-openai { color: #186898; }
.provider-google { color: #187830; }
.provider-xai { color: #6030a0; }

.score {
    font-variant-numeric: tabular-nums;
}

.price {
    font-variant-numeric: tabular-nums;
    font-family: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.95rem;
}

.context {
    color: #8a7e6e;
    font-size: 0.95rem;
}

/* Calculator */
.calculator {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    background: #ffffff;
    border: 1px solid #e8e2d8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(60,40,10,0.05);
}

.calc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.calc-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1510;
}

.calc-toggle {
    background: #faf8f4;
    border: 1px solid #d8d0c4;
    color: #8a7e6e;
    padding: 0.35rem 0.75rem;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.calc-toggle:hover {
    color: #5a4e3e;
    border-color: #b0a490;
}

.calc-toggle.active {
    color: #3d3529;
    border-color: #b0a490;
}

.calc-fields {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.calc-field {
    flex: 1;
    min-width: 120px;
}

.calc-field label {
    display: block;
    font-size: 0.8rem;
    color: #8a7e6e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.calc-hint {
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.7;
}

.calc-field input {
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: #faf8f4;
    border: 1px solid #d8d0c4;
    border-radius: 5px;
    color: #3d3529;
    font-size: 1rem;
    font-family: "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.calc-field input:focus {
    outline: none;
    border-color: #b0a490;
}

.calc-field input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.calc-tokens {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #8a7e6e;
}

.calc-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #5a4e3e;
    cursor: pointer;
    user-select: none;
}

.calc-checkbox input[type="checkbox"] {
    accent-color: #9a6a10;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.calc-checkbox .calc-hint {
    color: #a09480;
    font-size: 0.8rem;
}

.calc-note {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #a09480;
    font-style: italic;
}

/* Est. Cost column highlight */
td.est-cost {
    color: #9a6a10;
    font-weight: 600;
}

/* Search column */
.search-cell {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.search-free {
    font-size: 0.72rem;
    color: #187830;
    white-space: nowrap;
}

/* Deprecated models */
tr.deprecated td {
    opacity: 0.5;
}

tr.deprecated:hover td {
    opacity: 0.7;
}

.dep-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 500;
    color: #8a7e6e;
    border: 1px solid #d8d0c4;
    border-radius: 3px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Meta */
.meta {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: #a09480;
}

/* Footer / API Section */
footer {
    padding: 2rem 1.5rem;
    border-top: 1px solid #e8e2d8;
    text-align: center;
    color: #8a7f72;
    font-size: 0.85rem;
}

footer a {
    color: #6b6159;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}

footer a:hover {
    border-bottom-color: #6b6159;
}

.api-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 0.6rem 1rem;
    background: #ffffff;
    border: 1px solid #e8e2d8;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(60,40,10,0.05);
    font-size: 0.85rem;
}

.api-bar-label {
    font-weight: 600;
    color: #1a1510;
}

.api-bar code {
    background: #f5f0e8;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #6a6050;
}

.api-bar code a {
    color: #6a6050;
    text-decoration: none;
}

.api-bar code a:hover {
    color: #3d3529;
    text-decoration: underline;
}

.api-bar .method {
    color: #187830;
    font-weight: 600;
}


/* Mobile */
@media (max-width: 600px) {
    header {
        padding: 1.25rem 1rem 0.75rem;
    }

    h1 {
        font-size: 1.35rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    main {
        padding: 0 0.75rem 1.5rem;
    }

    .api-bar {
        flex-wrap: wrap;
        gap: 0.4rem 0.6rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .api-bar code {
        font-size: 0.75rem;
    }

    .calculator {
        padding: 1rem;
    }

    .calc-fields {
        gap: 0.6rem;
    }

    .calc-field {
        min-width: 0;
        flex: 1 1 calc(50% - 0.3rem);
    }

    .calc-field input {
        padding: 0.55rem 0.5rem;
        font-size: 0.95rem;
    }

    .calc-tokens {
        font-size: 0.78rem;
    }

    .table-wrap {
        border-radius: 6px;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.85rem;
    }

    .price {
        font-size: 0.8rem;
    }

    .context {
        font-size: 0.8rem;
    }

    .meta {
        font-size: 0.78rem;
    }

    footer {
        padding: 1rem 0.75rem;
    }
}
