:root {
    --bg: #111;
    --bg2: rgba(27, 27, 27, 0.7);
    --text: #eee;
    --accent: #4b6cb7;
    --card-bg: #222;
    --transition-speed: 0.3s;
    --header-height: 60px;
    --blur: 12px;
    --hero-title-color: #ffd700;
}

[data-theme="light"] {
    --bg: #f5f5f5;
    --bg2: rgba(255,255,255,0.7);
    --text: #000;
    --accent: #2a4fa8;
    --card-bg: #e8e8e8;
    --hero-title-color: #000;
}

html {
    transition: background-color 0.4s ease, color 0.4s ease;
}

body,
.app-header,
.sidebar,
.card,
.top-btn,
.sidebar-toggle,
.theme-toggle,
.tree-btn {
    transition: background-color 0.4s ease, color 0.4s ease, backdrop-filter 0.4s ease;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

body {
    display: flex;
    flex-direction: column;
}

.app-header {
    height: var(--header-height);
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1002;
    display: flex;
    align-items: center;
    padding: 0 15px;
}

.header-content {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-toggle,
.theme-toggle,
.top-btn,
.tree-btn {
    background: var(--card-bg);
    border: none;
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover,
.theme-toggle:hover,
.top-btn:hover,
.tree-btn:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}

.tree-controls {
    display: flex;
    gap: 10px;
    padding: 10px 15px 0 15px;
}

.sidebar {
    width: 320px;
    background: var(--bg2);
    backdrop-filter: blur(var(--blur));
    height: calc(100dvh - var(--header-height));
    top: var(--header-height);
    border-right: 1px solid rgba(255,255,255,0.1);
    overflow-y: auto;
    position: fixed;
    left: 0;
    transform: translateX(0);
    transition: transform var(--transition-speed);
    z-index: 1001;
}

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

.tree {
    list-style: none;
    padding: 15px;
    margin: 0;
}

.tree-item {
    margin-bottom: 8px;
}

.tree-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle {
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
    color: var(--accent);
    font-size: 1.2rem;
}

.toggle::before {
    content: "+";
}

.tree-item.open > .tree-header .toggle::before {
    content: "−";
}

.tree-children {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--transition-speed);
    padding-left: 20px;
}

.tree-item.open > .tree-children {
    max-height: 500px;
}

.tree a {
    text-decoration: none;
    color: var(--text);
    padding: 5px 8px;
    display: block;
    border-radius: 6px;
    transition: 0.25s ease;
}

.tree a:hover {
    background: var(--accent);
    color: #fff;
}

.tree a.active {
    background: var(--accent);
    color: #fff;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed);
    z-index: 900;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.main-wrapper {
    flex: 1;
    margin-left: 320px;
    margin-top: var(--header-height);
    transition: margin-left var(--transition-speed);
}

.main-content {
    width: min(1100px, 90vw);
    margin: 0 auto;
    padding: 20px;
}

.hero-title {
    margin-top: 10px;
    text-align: center;
    color: var(--hero-title-color);
    font-size: 2rem;
    text-shadow: 0 0 10px rgba(0,0,0,0.6);
    opacity: 0;
    animation: fadeIn 1.2s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.hero {
    height: 25vh;
    background: url("/img/ironmaking-small.jpg") center/cover;
    border-radius: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

@media (min-width: 768px) {
    .hero { background-image: url("/img/ironmaking-medium.jpg"); }
}

@media (min-width: 1200px) {
    .hero { background-image: url("/img/ironmaking-large.jpg"); }
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: 0.25s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    color: var(--accent);
}

.section-placeholder {
    padding: 20px;
    text-align: center;
    background: var(--card-bg);
    border-radius: 8px;
    margin-top: 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: 0.3s ease;
    z-index: 2000;
}

.to-top:hover {
    transform: translateY(-4px);
    background: #6f8df0;
}

button:focus, a:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    .main-wrapper { margin-left: 0; }
    .sidebar { width: 260px; }
}

@media (max-width: 600px) {
    .top-nav { display: none; }
    .hero-title { font-size: 1.6rem; }
}

[id] { scroll-margin-top: 100px; }

.lang-toggle {
    background: var(--card-bg);
    border: none;
    color: var(--text);
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.25s ease;
    margin-left: 10px;
}

.lang-toggle:hover {
    background: var(--accent);
    color: #fff;
    transform: translateY(-2px);
}
