/* Ultra Lightweight CSS - Optimized for Speed */
:root {
    --primary: #1e3a8a;
    --primary-dark: #1e3a8a;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --bg: #f8fafc;
    --text: #0f172a;
    --card: #ffffff;
    --gray: #64748b;
    --gray-light: #e2e8f0;
    --border: #e2e8f0;
    --menu-bg: #ffffff;
    --menu-text: #0f172a;
    --menu-hover: #f1f5f9;
    --header-bg: #ffffff;
    --header-text: #0f172a;
    --header-muted: #64748b;
    --footer-bg: #0f172a;
    --footer-text: #f1f5f9;
    --footer-muted: #94a3b8;
    --footer-border: #334155;
    --breadcrumb-bg: #f1f5f9;
}

[data-theme="dark"] {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --bg: #0f172a;
    --text: #f1f5f9;
    --card: #1e293b;
    --gray: #94a3b8;
    --gray-light: #334155;
    --border: #334155;
    --menu-bg: #1e293b;
    --menu-text: #f1f5f9;
    --menu-hover: #334155;
    --header-bg: #1e293b;
    --header-text: #f1f5f9;
    --header-muted: #94a3b8;
    --footer-bg: #0a0f1a;
    --footer-text: #e2e8f0;
    --footer-muted: #94a3b8;
    --footer-border: #2d3a4f;
    --breadcrumb-bg: #1e293b;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background .3s, color .3s;
    min-height: 100vh;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

/* Header */
header {
    background: var(--header-bg);
    color: var(--header-text);
    position: relative;
    z-index: 1001;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    border-bottom: 1px solid var(--border);
}

.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
}

.logo img { height: 2.6rem; width: auto; }

/* Dropdown Menu */
.dropdown { position: relative; }

.dropdown summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--gray-light);
    color: var(--header-text);
    padding: .65rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    user-select: none;
    list-style: none;
    border: 1px solid var(--border);
    transition: background 0.2s;
}

.dropdown summary:hover { background: var(--border); }
.dropdown summary::-webkit-details-marker { display: none; }

.dropdown summary::after {
    content: "▼";
    font-size: 0.7rem;
    margin-left: 0.3rem;
    opacity: 0.8;
    transition: transform 0.2s;
    color: var(--header-text);
}

.dropdown[open] summary::after { transform: rotate(180deg); }

.dropdown-menu {
    position: fixed;
    top: 70px;
    left: 1rem;
    width: 280px;
    max-width: 85vw;
    background: var(--menu-bg);
    color: var(--menu-text);
    padding: 0.75rem 0;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.2s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.dropdown[open] .dropdown-menu { display: flex; opacity: 1; }

.menu-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--menu-text);
    background: transparent;
    border: none;
    padding: 0.25rem 0.5rem;
    display: block;
    z-index: 2001;
    border-radius: 4px;
}

.menu-close:hover { background: var(--menu-hover); }

.dropdown-menu a {
    padding: 0.85rem 1.4rem;
    font-size: 1rem;
    color: var(--menu-text);
    text-decoration: none;
    transition: background 0.2s;
    display: block;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.dropdown-menu a:last-child { border-bottom: none; }

.dropdown-menu a:hover,
.dropdown-menu a.active {
    background: var(--menu-hover);
    color: var(--primary);
}

.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 1999;
}

.dropdown[open] + .menu-overlay { display: block; }

/* Theme Switch */
.theme-switch {
    background: var(--gray-light);
    border: 1px solid var(--border);
    color: var(--header-text);
    padding: .65rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1rem;
    transition: background 0.2s;
}

.theme-switch:hover { background: var(--border); }

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0;
    opacity: 0.5;
}

/* Breadcrumb */
.breadcrumb {
    padding: 1rem 0;
    background: transparent;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--gray);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--primary); }

.breadcrumb span { color: var(--gray); }
.breadcrumb .separator { color: var(--gray); font-size: 0.8rem; }
.breadcrumb .current { color: var(--primary); font-weight: 500; }

/* Main Layout */
.main-content {
    display: flex;
    gap: 2rem;
    margin: 1.5rem 0 2rem;
}

.tool-section { flex: 1; min-width: 0; }
.ad-section-desktop { width: 300px; flex-shrink: 0; }

/* Vertical Ad */
.vertical-ad {
    width: 250px;
    height: 300px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 100px;
    margin: 0 auto;
}

.ad-label {
    font-size: 0.7rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-placeholder-vertical {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--gray-light) 0%, var(--border) 100%);
    color: var(--gray);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Mobile Ad */
.ad-section-mobile { display: none; margin: 1.5rem 0; width: 100%; }

.mobile-ad {
    width: 100%;
    min-height: 100px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

/* Tool Container */
.tool-container {
    background: var(--card);
    border-radius: 24px;
    padding: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.tool-title {
    font-size: 1.0rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

.converter-box { display: flex; flex-direction: column; gap: 1.5rem; }
.input-group { width: 100%; }

.input-label {
    font-size: 1rem;
    color: var(--gray);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Input and button row */
.input-button-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within { border-color: var(--primary); }

.input-wrapper input {
    width: 100%;
    padding: 0.75rem 0;
    font-size: 1.5rem;
    background: transparent;
    border: none;
    color: var(--text);
    outline: none;
}

.input-wrapper input[type="number"] { -moz-appearance: textfield; }
.input-wrapper input[type="number"]::-webkit-outer-spin-button,
.input-wrapper input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.unit-badge {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    background: var(--gray-light);
    border-radius: 6px;
}

/* Convert Button */
.convert-button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
    min-width: 120px;
}

.convert-button:hover { background: var(--accent-hover); }
.convert-button:active { transform: scale(0.98); }

/* Results Adjacent */
.results-adjacent {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 0.5rem;
    padding: 1.5rem;
    background: var(--bg);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.result-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 1.2rem;
    line-height: 1.6;
}

.result-number {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.3rem;
}

.result-text { color: var(--text); }
.result-unit { color: var(--gray); font-weight: 500; }
.result-bold { font-weight: 700; color: var(--primary); }

/* Quick Table */
.quick-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.quick-table th {
    background: var(--primary);
    color: white;
    padding: 1rem;
    text-align: center;
}

.quick-table td {
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border);
}

.quick-table tr:hover { background: var(--gray-light); }

/* Related Converters */
.related-converters {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.related-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.related-link {
    background: var(--gray-light);
    color: var(--text);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
    border: 1px solid transparent;
}

.related-link:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-2px);
}

/* Article Section */
.article-section {
    background: var(--card);
    border-radius: 24px;
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid var(--border);
}

.article-section h2 {
    color: var(--primary);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

.article-section h3 {
    color: var(--primary);
    font-size: 1.3rem;
    margin: 1.5rem 0 1rem;
}

.article-section p { margin-bottom: 1rem; color: var(--text); }
.article-section ul, .article-section ol { margin: 1rem 0 1rem 2rem; }
.article-section li { margin: 0.5rem 0; }

/* Footer */
footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 2.5rem 1rem;
    margin-top: 4rem;
    font-size: 0.95rem;
    border-top: 1px solid var(--footer-border);
}

footer a {
    color: var(--footer-muted);
    text-decoration: none;
    transition: color 0.2s;
    margin: 0 0.5rem;
}

footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.footer-copyright {
    color: var(--footer-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

/* Responsive */
@media (min-width: 768px) {
    .dropdown-menu {
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 0;
        width: 280px;
        max-width: 280px;
    }
    .menu-close { display: none; }
}

@media (max-width: 900px) {
    .main-content { flex-direction: column; }
    .ad-section-desktop { display: none; }
    .ad-section-mobile { display: block; }
    .vertical-ad { position: static; width: 100%; height: auto; margin: 0; }
    .ad-placeholder-vertical { height: 100px; }
}

@media (max-width: 600px) {
    .footer-links { flex-direction: column; gap: 0.5rem; }
    .tool-container { padding: 1.5rem; }
    .input-button-row { flex-wrap: nowrap; }
    .convert-button { padding: 0.75rem 1rem; font-size: 1rem; min-width: 100px; }
    .result-row { font-size: 1rem; flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .input-button-row { gap: 0.5rem; }
    .input-wrapper { padding: 0.25rem 0.75rem; }
    .input-wrapper input { font-size: 1.2rem; padding: 0.5rem 0; }
    .unit-badge { font-size: 1rem; }
    .convert-button { padding: 0.6rem 0.8rem; font-size: 0.95rem; min-width: 85px; }
}