/* ========== 主题变量 ========== */
:root {
    --trunk-w: 100px;
    --canopy-h: 180px;
    --fruit-size: 62px;
    --speed: 0.6s;

    /* 夏季（默认） */
    --leaf: #7cb342;
    --leaf-light: #aed581;
    --branch: #6d4c41;
    --branch-dark: #4e342e;
    --grass: #81c784;
    --grass-dark: #66bb6a;
    --bg: linear-gradient(170deg, #e8f5e9, #f1f8e9, #dcedc8);

    /* 通用 */
    --white: #ffffff;
    --text: #37474f;
    --text2: #78909c;
    --shadow: rgba(0,0,0,0.12);
    --glass: rgba(255,255,255,0.88);
}

/* 秋季主题 */
.theme-autumn {
    --leaf: #ff8a65;
    --leaf-light: #ffab91;
    --branch: #6d4c41;
    --branch-dark: #4e342e;
    --grass: #bcaaa4;
    --grass-dark: #a1887f;
    --bg: linear-gradient(170deg, #fff3e0, #fff8e1, #ffe0b2);
}

/* ========== Reset ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background var(--speed);
}

/* ========== 布局 ========== */
.app {
    display: flex;
    height: 100vh;
}

/* ========== 左侧树干 ========== */
.trunk {
    width: var(--trunk-w);
    background: url('assets/1.jpg') center/cover no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 8px;
    position: relative;
    flex-shrink: 0;
    box-shadow: 3px 0 15px var(--shadow);
    z-index: 20;
    transition: transform 0.3s ease;
}

/* 树干半透明叠加层 */
.trunk::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(78,52,46,0.7) 0%, rgba(78,52,46,0.85) 100%);
    pointer-events: none;
}

/* 树干纹理 */
.trunk::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(0deg, transparent 0 30px, rgba(0,0,0,0.04) 30px 32px),
        repeating-linear-gradient(90deg, transparent 0 20px, rgba(0,0,0,0.03) 20px 22px);
    pointer-events: none;
    border-radius: inherit;
}

.trunk-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: contain;
    background: var(--white);
    padding: 4px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.trunk-btns {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.trunk-btn {
    width: 100%;
    padding: 10px 4px;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 12px;
    color: var(--white);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.trunk-btn-icon { font-size: 20px; }
.trunk-btn-text { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; }

.trunk-btn:hover {
    background: rgba(255,255,255,0.22);
    transform: scale(1.05);
}

.trunk-btn.active {
    background: var(--leaf);
    border-color: var(--leaf-light);
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    transform: scale(1.05);
}

/* ========== 右侧主内容 ========== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

/* ========== 树枝+果实区 ========== */
.canopy {
    height: var(--canopy-h);
    position: relative;
    flex-shrink: 0;
    padding: 5px 20px 0;
}

.branch-svg {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    height: 50px;
    z-index: 1;
}

.branch-path {
    stroke: var(--branch);
    transition: stroke var(--speed);
}

/* SVG叶子颜色过渡 */
.branch-svg ellipse {
    transition: fill var(--speed);
}

/* 果实容器 */
.fruits {
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding-top: 45px;
    height: 100%;
    z-index: 2;
}

/* 单个果实 */
.fruit {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.fruit:hover { transform: translateY(-4px) scale(1.05); }
.fruit.active .fruit-img { border-color: var(--leaf); box-shadow: 0 0 0 3px var(--leaf-light), 0 4px 15px var(--shadow); }

/* 绳子 */
.fruit-rope {
    width: 2px;
    background: linear-gradient(180deg, var(--branch), rgba(109,76,65,0.3));
    border-radius: 1px;
}

/* 果实圆形 */
.fruit-img {
    width: var(--fruit-size);
    height: var(--fruit-size);
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--white);
    box-shadow: 0 3px 12px var(--shadow);
    background: linear-gradient(135deg, #e0e0e0, #bdbdbd);
    transition: all 0.3s ease;
}

.fruit-img.emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: linear-gradient(135deg, #b2dfdb, #80cbc4);
}

/* 叶子装饰（每个果实旁边） */
.fruit-leaf {
    position: absolute;
    top: 34px;
    width: 14px;
    height: 10px;
    background: var(--leaf);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-40deg);
    transition: background var(--speed);
}

.fruit-leaf.right {
    transform: rotate(40deg);
    border-radius: 50% 50% 0 50%;
}

/* 果实标签 */
.fruit-name {
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 70px;
    text-align: center;
}

/* ========== 对话区域 ========== */
.chat {
    flex: 1;
    margin: 0 12px 12px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--white);
    box-shadow: 0 2px 12px var(--shadow);
    min-height: 0;
    z-index: 3;
}

.chat iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ========== 草地 ========== */
.grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(180deg, transparent 0%, var(--grass) 100%);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    transition: background var(--speed);
    z-index: 0;
    pointer-events: none;
}

/* ========== 移动端按钮 ========== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    width: 36px;
    height: 36px;
    background: var(--glass);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 2px 8px var(--shadow);
}

.mobile-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
}

/* ========== 遮罩层 ========== */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    transition: opacity 0.3s ease;
}

.overlay.show {
    display: block;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .trunk {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        z-index: 1000;
    }

    .trunk.open { transform: translateX(0); }

    .mobile-toggle { display: flex; }

    .main {
        width: 100%;
        margin-left: 0;
    }

    .canopy { height: 130px; padding-top: 8px; }

    :root { --fruit-size: 50px; --canopy-h: 130px; }

    .fruit-name { font-size: 10px; }

    .chat { margin: 0 8px 8px; }
}

@media (max-width: 480px) {
    :root { --fruit-size: 44px; --canopy-h: 110px; }
    .fruit-name { font-size: 9px; }
}
