:root {
    --primary: #095E3F;
    --primary-light: #e6f3ee;
    --primary-dark: #06402b;
    --secondary: #3D9353;
    --bg-main: #f5f8f6;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-main: #2c3830;
    --text-muted: #64756c;
    --border-color: #e2ebe5;
    --highlight-bg: #ffeb3b;
    --highlight-active-bg: #ff9800;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(9, 94, 63, 0.06);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: Georgia, Garamond, "Times New Roman", serif;
    --sidebar-width: 290px;
    --header-height: 60px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #52b788;
    --primary-light: #1b4332;
    --primary-dark: #74c69d;
    --secondary: #74c69d;
    --bg-main: #141f19;
    --bg-sidebar: #1b2620;
    --bg-card: #223028;
    --text-main: #e8f5e9;
    --text-muted: #a3b899;
    --border-color: #2d3c34;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    background-color: var(--bg-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1005;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
    box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.brand-logo svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.brand-text h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

.brand-text p {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Search Component */
.sidebar-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    padding: 8px 30px 8px 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition);
}

.search-input-wrapper input:focus {
    border-color: var(--primary);
    background-color: var(--bg-sidebar);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.clear-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.clear-btn svg {
    width: 16px;
    height: 16px;
}

/* Tree navigation */
.sidebar-tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 6px;
}

.tree-list {
    list-style: none;
}

.tree-node {
    margin-bottom: 2px;
}

.tree-header {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
}

.tree-header:hover {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.tree-header.active {
    background-color: var(--primary);
    color: #ffffff !important;
}

.tree-header.active .node-arrow,
.tree-header.active .node-count,
.tree-header.active .node-la,
.tree-header.active .future-badge {
    color: rgba(255, 255, 255, 0.8) !important;
}

.node-arrow {
    width: 14px;
    height: 14px;
    fill: currentColor;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.tree-node.expanded > .tree-header > .node-arrow {
    transform: rotate(90deg);
}

.node-cn {
    font-weight: 600;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.node-la {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-left: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.node-count {
    margin-left: auto;
    font-size: 0.7rem;
    background-color: var(--border-color);
    padding: 1px 5px;
    border-radius: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tree-header.active .node-count {
    background-color: rgba(255, 255, 255, 0.2);
}

.tree-children {
    list-style: none;
    padding-left: 12px;
    display: none;
}

.tree-node.expanded > .tree-children {
    display: block;
}

/* Level Specific styling */
.tree-node-family > .tree-header {
    font-weight: 700;
}
.tree-node-genus > .tree-header {
    padding-left: 10px;
}
.tree-node-species > .tree-header {
    padding-left: 18px;
    font-weight: normal;
}

.tree-node-species .node-cn {
    font-size: 0.84rem;
    font-weight: 400;
}

.tree-node-future .tree-header {
    opacity: 0.65;
}
.tree-node-future .tree-header:hover {
    opacity: 1;
    background-color: var(--primary-light);
}
.future-badge {
    font-size: 0.62rem;
    background-color: var(--text-muted);
    color: #ffffff;
    padding: 0px 3px;
    border-radius: 3px;
    font-weight: bold;
    margin-left: 2px;
    flex-shrink: 0;
}
[data-theme="dark"] .future-badge {
    background-color: #4a544f;
    color: #ccc;
}

/* Key landmark styling inside tree */
.tree-node-key .node-cn {
    font-weight: bold;
    color: var(--secondary);
    font-size: 0.84rem;
}
.tree-node-key svg {
    color: var(--secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* Main Header */
.main-header {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s;
}

.menu-toggle {
    background-color: var(--primary-light);
    border: 1px solid var(--border-color);
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    gap: 6px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.menu-toggle:hover {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
}

.menu-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.header-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
    flex: 1;
    margin-left: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    border-left: 1px solid var(--border-color);
    padding-left: 8px;
    margin-left: 8px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-search-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.header-search-btn:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

.header-search-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
}

/* Floating Full-Text Search Drawer */
.floating-search-bar {
    position: fixed;
    top: -80px;
    left: var(--sidebar-width);
    right: 0;
    height: 64px;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    z-index: 1008;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
    transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1), left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.sidebar-collapsed .floating-search-bar {
    left: 0;
}

.floating-search-bar.show {
    top: 0;
    box-shadow: var(--shadow-md);
}

.floating-search-inner {
    max-width: 600px;
    width: 100%;
    display: flex;
    align-items: center;
    position: relative;
    gap: 12px;
}

.floating-search-inner input {
    flex: 1;
    padding: 10px 40px 10px 38px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.floating-search-inner input:focus {
    border-color: var(--primary);
    background-color: var(--bg-sidebar);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.floating-search-inner .search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-action-btn {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.search-action-btn:hover {
    background-color: var(--primary-dark);
}

.floating-search-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.floating-search-close:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

.floating-search-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Content Panel */
.content-body {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 30px 20px 80px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Cards and Sections */
.intro-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.intro-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.section-tag {
    display: inline-block;
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 12px;
    text-transform: uppercase;
}

.intro-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.intro-card h2 .la-name {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: normal;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.intro-p {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 12px;
    text-align: justify;
    text-indent: 2em;
}

.intro-p:last-of-type {
    margin-bottom: 0;
}

.subfamily-header {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px dashed var(--border-color);
    text-align: center;
}

/* Dichotomous Key */
.key-wrapper {
    background-color: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-top: 20px;
}

.key-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 8px;
    scroll-margin-top: 80px;
}

.key-table-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background-color: var(--bg-main);
    padding: 16px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
    overflow-x: auto;
}

.key-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: 2px 0;
    font-size: 0.9rem;
    width: 100%;
    transition: var(--transition);
}

.key-line:hover {
    background-color: var(--primary-light);
    border-radius: 4px;
}

.key-desc {
    flex-grow: 0;
    text-align: left;
    padding-right: 8px;
}

.key-index {
    font-weight: 700;
    color: var(--primary);
    margin-right: 4px;
}

.key-dots {
    flex-grow: 1;
    border-bottom: 1px dotted var(--text-muted);
    margin: 0 8px;
    min-width: 15px;
    align-self: stretch;
    margin-bottom: 4px;
}

.key-target {
    flex-shrink: 0;
    text-align: right;
    font-weight: 600;
}

.key-header {
    font-size: 0.92rem;
    font-weight: bold;
    color: var(--primary);
    margin-top: 10px;
    margin-bottom: 4px;
}

.key-link {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1.5px dashed var(--primary);
    transition: var(--transition);
    cursor: pointer;
}

.key-link:hover {
    color: var(--secondary);
    border-bottom-style: solid;
    background-color: var(--primary-light);
    border-radius: 2px;
    padding: 0 2px;
}

.future-sp {
    color: var(--text-muted);
    border-bottom-color: var(--text-muted);
    cursor: help;
}

/* Species Card */
.species-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    scroll-margin-top: 80px;
}

.species-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 20px;
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.species-number {
    width: 26px;
    height: 26px;
    background-color: var(--primary);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.species-title-cn {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.species-aliases {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.page-badge {
    margin-left: auto;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-family: monospace;
}

.species-scientific {
    margin-top: 6px;
    font-size: 1.05rem;
}

.la-binomial i {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: bold;
    color: var(--primary);
}

.species-synonyms {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 6px 12px;
    background-color: var(--bg-main);
    border-radius: 6px;
    border-left: 3px solid var(--secondary);
}

.species-synonyms i {
    font-family: var(--font-serif);
    font-style: italic;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.species-morphology {
    text-align: justify;
}

.species-description-p, .species-desc {
    font-size: 0.98rem;
    text-indent: 2em;
    margin-bottom: 8px;
    text-align: justify;
}

.species-description-p:last-of-type, .species-desc:last-of-type {
    margin-bottom: 0;
}

/* Highlights & Boxes */
.species-meta-section {
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
}

.distribution-box {
    border-left: 4px solid var(--primary);
}

.uses-box {
    border-left: 4px solid #f9a825;
    background-color: rgba(249, 168, 37, 0.03);
}
[data-theme="dark"] .uses-box {
    background-color: rgba(249, 168, 37, 0.1);
}

.meta-label {
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    color: var(--primary-dark);
}

.uses-box .meta-label {
    color: #f57f17;
}

.meta-label .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.meta-content {
    font-size: 0.92rem;
    color: var(--text-main);
    text-align: justify;
}

/* Image Gallery */
.species-gallery {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.grid-single {
    grid-template-columns: 1fr;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.grid-double {
    grid-template-columns: 1fr 1fr;
}

.grid-multi {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: zoom-in;
    background-color: var(--bg-main);
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.zoom-indicator {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    opacity: 0;
    transition: var(--transition);
}

.gallery-item:hover .zoom-indicator {
    opacity: 1;
}

.zoom-indicator svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 2100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2.5rem;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    cursor: pointer;
    z-index: 2110;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background-color 0.2s;
}

.lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
    max-width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    transform-origin: center center;
    touch-action: none;
    cursor: zoom-in;
    will-change: transform;
    user-drag: none;
    -webkit-user-drag: none;
}

.lightbox-content img.zoomed {
    cursor: grab;
}

.lightbox-content img.grabbing {
    cursor: grabbing;
}

.lightbox-caption {
    color: #ffffff;
    font-size: 0.95rem;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    position: absolute;
    bottom: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    padding: 6px 16px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 2105;
}


/* Full text search highlights */
mark.search-highlight {
    background-color: var(--highlight-bg);
    color: #000000;
    border-radius: 2px;
    padding: 0 1px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

mark.search-highlight-active {
    background-color: var(--highlight-active-bg) !important;
    color: #ffffff !important;
}

/* Sticky Full text Navigation Bar - Highly Visible Forest Theme */
.search-nav-bar {
    position: fixed;
    bottom: 80px;
    left: calc(var(--sidebar-width) + (100% - var(--sidebar-width) - 460px)/2);
    width: 460px;
    background-color: #095E3F;
    color: #ffffff;
    border: 2px solid #ffe082;
    border-radius: 50px;
    padding: 10px 20px;
    box-shadow: 0 12px 40px rgba(9, 94, 63, 0.35);
    z-index: 990;
    display: none;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
}

[data-theme="dark"] .search-nav-bar {
    background-color: #1b2620;
    border-color: #52b788;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.search-nav-info {
    font-size: 0.95rem;
    font-weight: 700;
}

.search-nav-index {
    color: #ffe082;
    font-weight: 700;
    margin-left: 4px;
}

.search-nav-actions {
    display: flex;
    gap: 10px;
}

.search-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.search-nav-btn:hover {
    background-color: #ffe082;
    color: #095E3F;
    border-color: #ffe082;
}

.search-nav-btn.close-btn:hover {
    background-color: #ff8a80;
    color: #ffffff;
    border-color: #ff8a80;
}

.search-nav-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Backdrop overlay for mobile */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1000;
    transition: opacity 0.3s;
    opacity: 0;
}
.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 480px;
}

.toast {
    background-color: var(--primary-dark);
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .search-nav-bar {
        left: 50%;
        transform: translateX(-50%);
        width: 90%;
        max-width: 420px;
        bottom: 80px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
    }

    .main-content {
        margin-left: 0 !important;
    }
    
    .sidebar {
        z-index: 1010;
        transform: translateX(-100%);
    }

    .sidebar-expanded .sidebar {
        transform: translateX(0) !important;
        box-shadow: var(--shadow-xl);
    }

    .search-nav-bar {
        bottom: 80px;
        width: 92%;
        max-width: 420px;
    }

    .species-card {
        padding: 20px;
    }

    .intro-card {
        padding: 16px;
    }
    
    .tree-children {
        padding-left: 8px;
    }
    .tree-node-species > .tree-header {
        padding-left: 14px;
    }
    .node-cn {
        font-size: 0.82rem;
    }
    .node-la {
        font-size: 0.72rem;
    }

    .key-line {
        flex-direction: column;
        gap: 2px;
        border-bottom: 1px solid var(--border-color);
        padding: 6px 0;
    }
    .key-dots {
        display: none;
    }
    .key-target {
        text-align: left;
        padding-left: 1.5em;
    }
}

@media (max-width: 480px) {
    .header-subtitle {
        display: none;
    }
    .menu-toggle-text {
        font-size: 0.8rem;
    }
    .menu-toggle {
        padding: 5px 10px;
        gap: 4px;
    }
}

/* Reconstructed Genus Header Style */
.genus-header {
    border-left: 6px solid var(--secondary);
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-main) 100%);
    border-radius: 8px;
    padding: 14px 20px;
    margin-top: 25px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    border-left-width: 6px;
    scroll-margin-top: 80px;
    transition: var(--transition);
}

.genus-header:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.genus-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.genus-tag {
    background-color: var(--primary-light);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.genus-scientific {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: normal;
    color: var(--text-muted);
    margin-left: auto;
}

/* General Section Container (Avoids Loose Floating Paragraphs) */
.general-section {
    background-color: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.general-section .intro-p {
    margin-bottom: 0; /* managed by container gap */
}

/* Author metadata lines */
.author-line {
    text-align: center;
    text-indent: 0 !important;
    margin-bottom: 6px;
    font-size: 0.95rem;
}



/* Fix genus scroll positioning */
.genus-title {
    scroll-margin-top: 80px;
}

/* Premium Family Card Accent Styling */
#fam-header {
    border-left: 6px solid var(--primary);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-card) 100%);
    padding: 24px 30px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

#fam-header:hover {
    box-shadow: var(--shadow-md);
}

#fam-header h2 {
    font-size: 1.8rem;
    color: var(--primary-dark);
}

#fam-header h2 .la-name {
    color: var(--secondary) !important;
}


/* Sidebar Skeleton Loader */
.skeleton-tree {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

.skeleton-item {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 24px;
    width: 100%;
}

.skeleton-icon {
    width: 16px;
    height: 16px;
    background-color: var(--border-color);
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.skeleton-text {
    height: 14px;
    background-color: var(--border-color);
    border-radius: 4px;
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

/* Differentiated text widths for visual realism */
.skeleton-item:nth-child(3n+1) .skeleton-text { max-width: 80%; }
.skeleton-item:nth-child(3n+2) .skeleton-text { max-width: 60%; }
.skeleton-item:nth-child(3n) .skeleton-text { max-width: 70%; }

/* Shimmer Animation Effect */
.skeleton-icon::after,
.skeleton-text::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: skeleton-shimmer 1.6s infinite;
}

/* Dark mode compatibility adaptation */
[data-theme="dark"] .skeleton-icon::after,
[data-theme="dark"] .skeleton-text::after {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0) 100%
    );
}

@keyframes skeleton-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}


/* Mobile Search Bar Position & Size Adjustments */
@media (max-width: 768px) {
    .floating-search-bar {
        left: 0 !important;
        right: 0 !important;
        padding: 0 12px !important;
        height: 56px !important;
        z-index: 2050 !important; /* Make sure it stays above headers */
    }
    .floating-search-inner {
        gap: 6px !important;
    }
    .floating-search-inner input {
        font-size: 0.85rem !important;
        padding: 8px 12px 8px 30px !important;
        height: 36px !important;
        box-sizing: border-box;
    }
    .floating-search-inner .search-icon {
        left: 8px !important;
    }
    .search-action-btn {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
        height: 36px !important;
        box-sizing: border-box;
        white-space: nowrap;
    }
    .floating-search-close {
        padding: 6px !important;
    }
    .floating-search-close svg {
        width: 18px !important;
        height: 18px !important;
    }
}
