:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --bg: #F5F8FC;
    --surface: #FFFFFF;
    --text: #1A1A1A;
    --muted: #666666;
    --border: #E0E0E0;
    --sidebar-width: 240px;
    --bp-mobile: 768px;
    --bp-tablet: 900px;
    --bp-side-ads: 1100px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
    text-decoration: none;
}

.brand:hover,
.brand:focus-visible {
    color: inherit;
    text-decoration: none;
    opacity: 0.92;
}

.brand-mark {
    display: block;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
    outline: 1px solid rgba(255, 255, 255, 0.35);
    outline-offset: -1px;
}

.topbar-brand .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    outline: none;
}

.brand-name {
    min-width: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.language-form label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.language-form select {
    width: 100%;
    padding: 0.4rem;
    border-radius: 6px;
    border: none;
}

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 3.25rem;
}

.topbar-start {
    display: none;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1.2;
    text-decoration: none;
}

.topbar-brand:hover,
.topbar-brand:focus-visible {
    color: var(--primary-dark);
    text-decoration: none;
    opacity: 0.88;
}

.nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
}

.nav-toggle-bar {
    display: block;
    width: 1.25rem;
    height: 2px;
    margin: 0 auto;
    background: var(--text);
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.sidebar-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.nav-open {
    overflow: hidden;
}

.breadcrumbs {
    flex: 1;
    min-width: 0;
}
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.breadcrumbs a {
    color: var(--primary);
    text-decoration: none;
}

.breadcrumbs .sep { color: var(--muted); }
.breadcrumbs .current { color: var(--muted); }

.content {
    flex: 1;
    padding: 1.5rem 2rem 3rem;
    width: 100%;
}

.content--centered {
    max-width: 960px;
    margin: 0 auto;
}

.content--full {
    max-width: none;
}

.page-with-side-ads {
    display: grid;
    grid-template-columns: minmax(120px, 160px) minmax(0, 960px) minmax(120px, 160px);
    gap: 1.5rem;
    justify-content: center;
    align-items: start;
    max-width: 1320px;
    margin: 0 auto;
}

.page-main {
    width: 100%;
    min-width: 0;
}

.side-ad {
    position: sticky;
    top: 1.5rem;
}

.side-ad-label {
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
}

.side-ad .adsbygoogle,
.side-ad .ad-placeholder {
    width: 100%;
    min-height: 250px;
}

.mobile-ad {
    display: none;
    margin-top: 9.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.mobile-ad-label {
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
}

.mobile-ad .adsbygoogle,
.mobile-ad .ad-placeholder {
    max-width: 728px;
    margin: 0 auto;
    min-height: 90px;
}

.app-download-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--primary);
    background: var(--surface);
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.app-download-link:hover {
    background: var(--primary);
    color: #fff;
}

.site-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem 1.25rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem 1.25rem;
    max-width: 100%;
}

.site-footer-legal {
    font-size: 0.8125rem;
    color: var(--muted);
    text-decoration: none;
    line-height: 1.4;
}

.site-footer-legal:hover {
    color: var(--primary);
    text-decoration: underline;
}

.site-footer-legal:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.ad-placeholder {
    background: #EEEEEE;
    color: #999;
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.privacy-page .privacy-body {
    white-space: pre-line;
}

.privacy-page section {
    margin-bottom: 1.75rem;
}

.privacy-page section + section {
    padding-top: 0.25rem;
}

.privacy-page ul {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
}

.privacy-page li + li {
    margin-top: 0.5rem;
}

.page-header h1 {
    margin: 0 0 0.25rem;
    color: var(--primary-dark);
}

.subtitle { color: var(--muted); margin: 0 0 1.5rem; }

.crop-group { margin-bottom: 1.5rem; }
.crop-group-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    color: var(--primary-dark);
}

.domain-section-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
    color: var(--primary-dark);
}

.domain-section + .domain-section {
    margin-top: 1.75rem;
}

.domain-section--calculator .domain-tile-grid {
    max-width: 220px;
}

.crop-grid, .domain-tile-grid, .domain-item-grid {
    display: grid;
    gap: 1rem;
    justify-content: start;
}

.crop-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 172px)); }
.domain-tile-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 176px)); }
.domain-item-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 188px)); }

.crop-card, .domain-tile, .domain-item-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: transform 0.15s, box-shadow 0.15s;
}

.crop-card:hover, .domain-tile:hover, .domain-item-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.crop-card img, .domain-tile img, .domain-item-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.crop-placeholder {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    background: #E3F2FD;
}

.crop-placeholder.large { min-height: 280px; aspect-ratio: auto; }

.crop-card .crop-placeholder {
    font-size: 3.1rem;
}

.crop-card .crop-name {
    font-size: 1rem;
    padding: 0.75rem 0.875rem;
}

.crop-name, .domain-tile span, .domain-item-card span {
    display: block;
    padding: 0.6rem 0.75rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

.detail-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.detail-header {
    text-align: center;
}

.detail-header h1 {
    margin: 0 0 0.35rem;
    color: var(--primary);
}

.detail-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detail-hero-row {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 2rem;
    align-items: center;
}

.detail-hero-row--no-symptoms {
    grid-template-columns: 1fr;
}

.detail-below {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.detail-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.detail-image {
    display: flex;
    align-items: center;
    justify-content: center;
}

.detail-main .detail-hero-image {
    margin-bottom: 0;
}

.detail-recommendations {
    text-align: start;
}

.detail-recommendations h2 {
    color: #D32F2F;
}

.detail-recommendations .recommendation-list {
    width: 100%;
    text-align: start;
}

.detail-image img {
    width: 100%;
    border-radius: 8px;
    object-fit: cover;
}

.detail-symptoms .paragraph-text,
.detail-body .paragraph-text {
    text-align: start;
}

.paragraph-text {
    white-space: pre-wrap;
    line-height: 1.6;
    margin: 0;
}

.recommendation-list { display: flex; flex-direction: column; gap: 0.75rem; }
.recommendation-card {
    background: #FAFAFA;
    border-left: 4px solid var(--primary);
    padding: 0.75rem 1rem;
    border-radius: 0 8px 8px 0;
}

.recommendation-chemical {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
}

.recommendation-card .formulation {
    font-size: 0.85rem;
    color: var(--muted);
}

.recommendation-card .quantity {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.recommendation-card .paragraph-text {
    margin-top: 0.5rem;
}

.nutrient-results section ul li.paragraph-text {
    margin-bottom: 0.5rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.blog-list { display: flex; flex-direction: column; gap: 1rem; }

.blog-card {
    display: block;
    background: var(--surface);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.blog-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.25rem;
}

.blog-card-body h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1.45;
}

.blog-list .blog-card:nth-child(odd) .blog-card-body h2 {
    color: var(--primary);
}

.blog-list .blog-card:nth-child(even) .blog-card-body h2 {
    color: #2E7D32;
}

.blog-card-body time { font-size: 0.85rem; color: var(--muted); }

.blog-article {
    background: var(--surface);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.blog-hero {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: min(70vh, 520px);
    object-fit: contain;
    object-position: center;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.detail-hero-image {
    width: 100%;
    max-height: 360px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.blog-body { line-height: 1.7; white-space: pre-wrap; }

.nutrient-layout {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
}

.nutrient-form, .nutrient-results {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.nutrient-form label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 500; }
.nutrient-form select, .nutrient-form input[type=number] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.nutrient-form button[type="submit"] {
    margin-top: 1rem;
}

.toggle-group {
    display: flex;
    gap: 0.5rem;
    border: none;
    padding: 0;
    margin: 1rem 0;
}

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.toggle-group label.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.toggle-group input { display: none; }

.stage-choice-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border: none;
    padding: 0;
    margin: 1rem 0;
}

.stage-choice-legend {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0 0 0.25rem;
    font-weight: 600;
    color: var(--primary);
}

.stage-choice-hint {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.stage-choice {
    display: block;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-weight: 400;
    margin: 0;
}

.stage-choice.active {
    border: 2px solid var(--primary);
}

.stage-choice input { display: none; }

.fertilizer-package {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.soil-note { font-size: 0.85rem; color: var(--muted); font-style: italic; }

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.pagination a { color: var(--primary); }

.empty-state { color: var(--muted); text-align: center; padding: 2rem; }

img {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
}

.protected-content {
    user-select: none;
    -webkit-user-select: none;
}

@media (min-width: 1200px) {
    .crop-grid {
        grid-template-columns: repeat(auto-fill, minmax(142px, 168px));
    }

    .domain-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(142px, 172px));
    }

    .domain-item-grid {
        grid-template-columns: repeat(auto-fill, minmax(152px, 184px));
    }
}

@media (max-width: 1100px) {
    .page-with-side-ads {
        grid-template-columns: 1fr;
        max-width: 960px;
    }

    .side-ad {
        display: none;
    }

    .mobile-ad {
        display: block;
    }
}

@media (max-width: 900px) {
    .detail-hero-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .nutrient-layout {
        grid-template-columns: 1fr;
    }

    .blog-article {
        padding: 1.25rem;
    }

    .content {
        padding: 1.25rem 1.25rem 2.5rem;
    }
}

@media (max-width: 768px) {
    .app-shell {
        min-height: 100vh;
        min-height: 100dvh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 200;
        width: min(280px, 85vw);
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .topbar-start {
        display: flex;
    }

    .topbar {
        padding: 0.65rem 1rem;
        gap: 0.75rem;
    }

    .site-footer {
        padding: 1rem 1rem 1.25rem;
    }

    .site-footer .app-download-link {
        padding: 0.4rem 0.65rem;
        font-size: 0.8rem;
    }

    .breadcrumbs {
        font-size: 0.82rem;
    }

    .content {
        padding: 1rem 1rem 2rem;
    }

    .page-header h1 {
        font-size: 1.45rem;
    }

    .crop-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.875rem;
    }

    .domain-tile-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .domain-item-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .detail-layout {
        padding: 1rem;
        gap: 1.25rem;
    }

    .crop-placeholder.large {
        min-height: 200px;
    }

    .nutrient-form,
    .nutrient-results {
        padding: 1rem;
    }

    .toggle-group {
        flex-direction: column;
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }

    .nav-link {
        min-height: 2.75rem;
        display: flex;
        align-items: center;
    }

    .language-form select {
        min-height: 2.75rem;
    }
}

@media (max-width: 480px) {
    .crop-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .domain-tile-grid,
    .domain-item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .crop-card .crop-name,
    .domain-tile span,
    .domain-item-card span {
        font-size: 0.82rem;
        padding: 0.5rem 0.4rem;
    }

    .topbar-brand .brand-name {
        font-size: 1rem;
    }
}
