/* ===== CONVERTER WIDGET ===== */
.converter-widget {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow);
}

#converter-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Select row: [from-col] [swap-btn] [to-col] */
.conv-selects {
    display: grid;
    grid-template-columns: 1fr 56px 1fr;
    gap: 0 0.75rem;
    align-items: end;
}

/* Value row: [input-col] [result-col] — gap matches swap btn width */
.conv-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 calc(56px + 1.5rem);
}

.conv-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conv-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

#from-select, #to-select {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font);
    width: 100%;
    min-height: 52px;
    transition: border-color 0.2s;
    cursor: pointer;
}
#from-select:focus, #to-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}

#swap-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    cursor: pointer;
    transition: background 0.2s, transform 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    flex-shrink: 0;
}
#swap-btn:hover, #swap-btn:focus-visible {
    background: var(--accent-hover);
    transform: rotate(180deg);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

#value-input {
    background: var(--surface);
    border: 1.5px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 1.1rem;
    font-family: var(--font);
    width: 100%;
    min-height: 52px;
    transition: border-color 0.2s;
}
#value-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.2);
}
#value-input::placeholder { color: var(--text-secondary); opacity: 0.5; }

.ops-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding-left: 0.25rem;
}

.result-row {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.6rem 0.65rem 1rem;
    min-height: 52px;
    gap: 0.25rem;
}
#result-output {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.result-actions {
    display: flex;
    gap: 0.1rem;
    flex-shrink: 0;
}
.result-actions button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    line-height: 1;
}
.result-actions button:hover { color: var(--accent); }
.result-actions button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Scientific notation toggle */
.sci-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 50px;
    padding: 0.55rem 0.6rem 0.55rem 1rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-family: var(--font);
    transition: border-color 0.2s, color 0.2s;
    text-align: left;
}
.sci-toggle:hover { border-color: var(--accent); color: var(--text-primary); }
.sci-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--text-primary); }
.toggle-track {
    width: 38px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 0.75rem;
}
.sci-toggle[aria-pressed="true"] .toggle-track { background: var(--accent); }
.toggle-thumb {
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.sci-toggle[aria-pressed="true"] .toggle-thumb { transform: translateX(16px); }

/* ===== HOW TO SECTION ===== */
.how-to {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.how-to h2 {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.formula-box {
    background: var(--card);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
}

.formula {
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    color: var(--accent);
    margin-top: 0.5rem;
}

.explanation { color: var(--text-secondary); line-height: 1.7; }

/* ===== HISTORY SIDEBAR PANEL ===== */
.history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.history-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.history-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 90vw;
    height: 100%;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
.history-panel.open {
    transform: translateX(0);
}
.history-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.history-panel-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}
.history-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.history-clear-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    min-height: 36px;
    transition: all 0.2s;
}
.history-clear-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.history-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}
.history-close-btn:hover {
    color: var(--text-primary);
}
.history-empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    padding: 2rem 1rem;
}
.history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
}
.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.25rem;
    font-size: 0.88rem;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.history-item:hover {
    background: var(--card);
}
.history-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.history-item-cat {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.history-item-conversion {
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-result {
    font-weight: 600;
    color: var(--accent);
}
.history-delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    min-height: 36px;
    min-width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
    flex-shrink: 0;
    opacity: 0;
}
.history-item:hover .history-delete-btn {
    opacity: 1;
}
.history-delete-btn:hover {
    color: #e74c3c;
}

/* ===== RELATED LINKS ===== */
.related {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}
.related h2 { font-size: 1.3rem; margin-bottom: 1rem; font-weight: 600; }

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

.related-list li a {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: all 0.2s;
}
.related-list li a:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    text-decoration: none;
    transform: translateY(-2px);
}

.banner-ad-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 2rem;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.banner-ad-desktop,
.banner-ad-mobile {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
}

.banner-ad-mobile {
    display: none;
}

/* ===== CATEGORY PAGE GRID ===== */
.converters-grid {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.converters-grid li a {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s;
}
.converters-grid li a:hover {
    border-color: var(--accent);
    background: var(--card);
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(108,99,255,0.15);
}

/* ===== CATEGORY DESCRIPTION ===== */
.cat-description {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    line-height: 1.75;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.cat-description strong { color: var(--text-primary); }

/* ===== LANDING PAGE CONTENT (Priority Categories) ===== */
.landing-content {
    margin-top: 2rem;
}
.landing-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    line-height: 1.75;
    color: var(--text-secondary);
    font-size: 0.95rem;
}
.landing-section h2 {
    color: var(--text-primary);
    font-size: 1.3rem;
    margin-bottom: 1rem;
}
.landing-section h3 {
    color: var(--text-primary);
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
}
.landing-section strong {
    color: var(--text-primary);
}

/* Intro */
.landing-intro-text {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Where used */
.landing-where-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.landing-where-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.landing-where-list li:last-child {
    border-bottom: none;
}

/* Mistakes */
.mistakes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.mistake-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    border-left: 4px solid var(--accent);
}
.mistake-card h3 {
    margin-top: 0;
}

/* Reference table */
.ref-table-wrapper {
    overflow-x: auto;
}
.ref-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.ref-table thead {
    background: var(--accent);
    color: #fff;
}
.ref-table th,
.ref-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.ref-table tbody tr:hover {
    background: var(--card);
}
.ref-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.faq-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.faq-item summary {
    padding: 1rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.faq-item summary::after {
    content: "+";
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--accent);
    transition: transform 0.2s;
}
.faq-item[open] summary::after {
    content: "−";
}
.faq-item summary::-webkit-details-marker {
    display: none;
}
.faq-item p {
    padding: 0 1.2rem 1rem;
    margin: 0;
    line-height: 1.7;
}

/* Sources */
.sources-list {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0;
}
.sources-list li {
    padding: 0.25rem 0;
}

/* Related articles */
.related-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.related-article-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.2rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.related-article-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 12px rgba(108, 99, 255, 0.15);
}
.related-article-card h3 {
    margin-top: 0;
    color: var(--text-primary);
    font-size: 1rem;
}
.related-article-card p {
    font-size: 0.9rem;
    margin: 0.5rem 0;
    line-height: 1.6;
}
.read-more {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Editorial trust signal on landing pages */
.landing-trust-signal {
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Real-world block (category pages without landing content) */
.real-world-block {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.real-world-block h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}
.real-world-list {
    padding-left: 1.4rem;
    margin: 0;
}
.real-world-list li {
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.92rem;
}

/* ===== AI MAGIC BAR ===== */
.ai-search-container {
    max-width: 800px;
    margin: 20px auto 10px;
    padding: 0 20px;
    position: relative;
    z-index: 90;
}

.magic-bar {
    display: flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 16px;
    gap: 12px;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    cursor: text;
}

.magic-bar:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.2), var(--shadow);
    transform: translateY(-2px);
}

.ai-spark {
    color: var(--accent);
    font-size: 1.5rem;
    animation: spark-glow 2s infinite alternate;
}

@keyframes spark-glow {
    from { opacity: 0.6; transform: scale(1); }
    to { opacity: 1; transform: scale(1.1); }
}

#magicInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    padding: 10px 0;
    outline: none;
    font-family: var(--font);
}

#magicInput::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.magic-clear-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
}

.magic-clear-btn:hover {
    color: var(--text-primary);
    background: rgba(var(--accent-rgb), 0.1);
}

.magic-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 20px;
    right: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: magic-slide-down 0.2s ease-out;
    z-index: 1000;
}

.magic-results.hidden {
    display: none;
}

@keyframes magic-slide-down {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.suggestion-item:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.suggestion-icon {
    color: var(--accent);
    font-size: 1.3rem;
    width: 28px;
    text-align: center;
}

.suggestion-text {
    flex: 1;
    color: var(--text-primary);
}

.suggestion-action {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(var(--accent-rgb), 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
}
