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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
nav {
    background: #4CAF50;
    padding: 10px 16px;
    display: flex;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
}

nav a {
    color: rgba(255,255,255,0.88);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

nav a:hover {
    background: rgba(0,0,0,0.12);
    color: white;
}

nav a.active {
    background: rgba(0,0,0,0.18);
    color: white;
}

/* Layout */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
}

/* Ad units */
.ad-unit {
    width: 100%;
    max-width: 728px;
    min-height: 60px;
    margin: 8px 0;
    text-align: center;
}

/* Calculator card */
.container {
    background: white;
    padding: 28px 24px;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.09);
    width: 100%;
    max-width: 500px;
}

h1 {
    font-size: 1.55rem;
    color: #222;
    text-align: center;
    margin-bottom: 22px;
}

/* Form */
.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

input[type="number"],
select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    background: #fafafa;
    color: #333;
    transition: border-color 0.15s;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #4CAF50;
    background: white;
}

button {
    width: 100%;
    background: #4CAF50;
    color: white;
    padding: 11px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
    transition: background 0.15s;
}

button:hover {
    background: #43a047;
}

/* Result */
#result {
    display: none;
    margin-top: 18px;
    padding: 14px 16px;
    background: #f1f8f1;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    line-height: 1.8;
    font-size: 15px;
}

/* Affiliate section */
.affiliate-section {
    display: none;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #eee;
}

.affiliate-section h3 {
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
}

.affiliate-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.affiliate-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 7px;
    text-decoration: none;
    color: #333;
    transition: border-color 0.15s, background 0.15s;
}

.affiliate-link:hover {
    background: #f1f8f1;
    border-color: #4CAF50;
}

.affiliate-link .icon {
    font-size: 20px;
    margin-right: 11px;
    flex-shrink: 0;
}

.affiliate-link .text {
    flex: 1;
    min-width: 0;
}

.affiliate-link .text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.affiliate-link .text span {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 1px;
}

.affiliate-link .arrow {
    color: #bbb;
    font-size: 16px;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Related calculators */
.calculator-links {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #eee;
}

.calculator-links p {
    font-size: 11px;
    color: #aaa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 10px;
}

.calc-link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

.calc-link {
    display: block;
    padding: 10px 8px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    color: #444;
    transition: all 0.15s;
}

.calc-link:hover {
    background: #e8f5e9;
    border-color: #a5d6a7;
    color: #2e7d32;
}

.hint-text {
    font-size: 12px;
    color: #aaa;
    text-align: center;
    margin-top: 10px;
}

.hint-text a {
    color: #4CAF50;
    text-decoration: none;
}

/* Embed snippet */
.embed-section {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #eee;
}

.embed-label {
    font-size: 11px;
    color: #aaa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 8px;
}

.embed-code {
    width: 100%;
    padding: 10px;
    font-size: 12px;
    font-family: monospace;
    color: #555;
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    resize: none;
    cursor: text;
    line-height: 1.5;
    height: 72px;
}

/* Footer */
footer {
    background: #2d2d2d;
    color: #888;
    text-align: center;
    padding: 18px 16px;
    font-size: 13px;
    line-height: 1.6;
}

footer a {
    color: #aaa;
    text-decoration: none;
    margin: 0 6px;
}

footer a:hover {
    color: white;
}

.footer-disclaimer {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

/* Mobile */
@media (max-width: 480px) {
    .container {
        padding: 22px 16px;
    }

    h1 {
        font-size: 1.3rem;
    }

    nav a {
        font-size: 13px;
        padding: 5px 9px;
    }
}

/* Dark mode toggle button */
.dark-toggle {
    width: auto;
    background: rgba(0,0,0,0.15);
    color: white;
    padding: 6px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    font-weight: normal;
    margin-top: 0;
    margin-left: auto;
    transition: background 0.15s;
    line-height: 1;
}

.dark-toggle:hover {
    background: rgba(0,0,0,0.28);
}

/* Dark theme — applied by html.dark (manual toggle or system preference via JS) */
:root { color-scheme: light; }
html.dark { color-scheme: dark; }

html.dark body {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

html.dark .container {
    background: #242424;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

html.dark h1 {
    color: #f0f0f0;
}

html.dark label {
    color: #bbb;
}

html.dark input[type="number"],
html.dark select {
    background: #2c2c2c;
    border-color: #444;
    color: #e0e0e0;
}

html.dark input[type="number"]:focus,
html.dark select:focus {
    background: #333;
    border-color: #4CAF50;
}

html.dark #result {
    background: #1e2e1e;
    border-color: #2d5a2d;
}

html.dark .affiliate-section {
    border-top-color: #333;
}

html.dark .affiliate-link {
    background: #2c2c2c;
    border-color: #3a3a3a;
    color: #e0e0e0;
}

html.dark .affiliate-link:hover {
    background: #1e2e1e;
    border-color: #4CAF50;
}

html.dark .affiliate-link .text span {
    color: #888;
}

html.dark .affiliate-link .arrow {
    color: #555;
}

html.dark .calculator-links {
    border-top-color: #333;
}

html.dark .calc-link {
    background: #2c2c2c;
    border-color: #3a3a3a;
    color: #ccc;
}

html.dark .calc-link:hover {
    background: #1e2e1e;
    border-color: #4CAF50;
    color: #81c784;
}

html.dark .embed-section {
    border-top-color: #333;
}

html.dark .embed-code {
    background: #2c2c2c;
    border-color: #3a3a3a;
    color: #bbb;
}
