/* ========== 全局调色板 · 温暖森系 ========== */
:root {
    --bg: #f9f2e7;
    --card: #fffef7;
    --border: #e7d6bc;
    --accent: #c28b5c;
    --accent-light: #e7cba5;
    --female: #fef0f0;
    --female-border: #e6b5b5;
    --male: #edf2fa;
    --male-border: #96b5d4;
    --warn: #c0392b;
    --ok: #2d6a4f;
    --text: #4a3724;
    --text-soft: #7c6b5a;
    --shadow: 0 12px 28px rgba(94, 59, 25, 0.06);
    --shadow-hover: 0 14px 32px rgba(94, 59, 25, 0.10);
    --gradient-btn: linear-gradient(135deg, #ffd2aa, #b47b52);
    --gradient-card: linear-gradient(145deg, #ffe084, #fff2d9);
}

/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><circle cx="30" cy="30" r="1.5" fill="%23e7d6bc" opacity="0.4"/></svg>');
    background-attachment: fixed;
    font-family: 'Segoe UI', 'Noto Sans', 'PingFang SC', system-ui, sans-serif;
    padding: 20px;
    display: flex;
    justify-content: center;
    color: var(--text);
    min-height: 100vh;
    align-items: flex-start;
}

/* ========== 主容器 ========== */
.container {
    max-width: 1120px;
    width: 100%;
    background: var(--card) var(--gradient-card);
    border-radius: 36px;
    box-shadow: var(--shadow);
    padding: 32px 28px 36px;
    border: 1px solid var(--border);
    margin: 0 auto;
    backdrop-filter: blur(4px);
}

/* ========== 头部 ========== */
.app-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    border-bottom: 2px dashed #dbbc8c;
    padding-bottom: 18px;
    margin-bottom: 20px;
}
.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #7e5a3c, #b08762);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}
.author {
    font-size: 0.9rem;
    color: var(--text-soft);
    margin-left: auto;
    font-style: italic;
}
.version {
    background: #f2e1c6;
    color: #5e3c24;
    padding: 4px 14px;
    border-radius: 18px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.sub-label {
    font-size: 0.9rem;
    color: var(--text-soft);
    margin-bottom: 12px;
    text-align: center;
    font-weight: 500;
}

.github-link {
    display: inline-block;
    margin: 8px auto 22px;
    background: #fff4e4;
    color: #b45f2a;
    padding: 6px 18px;
    border: 1px solid #f5c48c;
    border-radius: 24px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: 0.2s;
}
.github-link:hover {
    background: #ffe8cf;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(180, 95, 42, 0.15);
}

/* ========== 卡片式控制面板 ========== */
.control-stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 24px;
}

.control-card {
    background: #fffefa;
    border-radius: 24px;
    padding: 20px 22px;
    border: 1px solid #ecdbba;
    box-shadow: 0 4px 12px rgba(146, 107, 56, 0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.control-card:hover {
    border-color: #d4b58c;
    box-shadow: 0 6px 16px rgba(146, 107, 56, 0.08);
}

.control-card label {
    font-weight: 700;
    font-size: 1.05rem;
    color: #5c3e28;
    letter-spacing: 0.3px;
}

/* ---------- 精灵窝数量行（防缩放错位） ---------- */
.nest-row-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

/* 输入框、单位、徽章 不缩小 */
.nest-row-inline input[type=number],
.nest-row-inline .unit,
.nest-row-inline .badge {
    flex-shrink: 0;
}

.nest-row-inline input[type=number] {
    width: 72px;
    padding: 12px 10px;
    font-size: 1.1rem;
    border: 2px solid #d4b68c;
    border-radius: 18px;
    background: #fffefb;
    text-align: center;
    font-weight: 700;
    outline: none;
    transition: 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.nest-row-inline input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(194, 139, 92, 0.15);
}

.unit {
    font-size: 0.9rem;
    color: var(--text-soft);
}

/* 模式切换区 */
.mode-area {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;          /* 宽屏时推到最右 */
    flex-shrink: 0;
    white-space: nowrap;
}

.mode-btn {
    padding: 8px 20px !important;
    border-radius: 30px !important;
    font-size: 0.9rem !important;
}
.mode-status {
    font-size: 0.8rem;
    font-weight: 700;
    color: #b75c3b;
    background: #fff2ec;
    padding: 3px 12px;
    border-radius: 15px;
    white-space: nowrap;
}

/* 双列面板 */
.dual-panel {
    display: flex;
    align-items: stretch;
    gap: 14px;
}
.add-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 130px;
}
.add-btn { width: 100%; justify-content: center; }

.display-panel {
    flex: 1;
    background: #fefcf7;
    border: 1.5px dashed #dbc29e;
    border-radius: 16px;
    padding: 10px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    min-height: 46px;
    overflow-y: auto;
    max-height: 110px;
    transition: background 0.2s;
}
.display-panel:focus-within {
    background: #fffbf2;
}
.empty-hint {
    color: #baa68c;
    font-size: 0.85rem;
    font-style: italic;
    font-weight: 400;
}

/* 精灵标签 */
.pet-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fffaf2;
    border: 2px solid #e5cdab;
    border-radius: 22px;
    padding: 5px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #4d3622;
    transition: 0.15s;
}
.pet-tag:hover { transform: scale(1.02); box-shadow: 0 3px 8px rgba(0,0,0,0.06); }
.pet-tag.female-tag { background: #fff6f6; border-color: #e8c4c4; }
.pet-tag.male-tag { background: #f4f8ff; border-color: #b4cbe0; }
.pet-tag .tag-remove {
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 1.5px solid #d4a3a3;
    background: #fff;
    color: #9d3c3c;
    font-size: 0.72rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}
.pet-tag .tag-remove:hover {
    background: #fde8e8;
    border-color: #c0392b;
    color: #c0392b;
}
.pet-tag .tag-qty {
    background: #f3e3cc;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 0.72rem;
    color: #5a4028;
    font-weight: 700;
}

/* 徽章 */
.badge {
    background: #d4b594;
    color: #fff;
    border-radius: 22px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.badge.warn {
    background: #e3a9a9;
    color: #fff;
}

/* 通用按钮 */
.btn {
    background: var(--gradient-btn);
    border: none;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 26px;
    border-radius: 34px;
    cursor: pointer;
    letter-spacing: 0.5px;
    box-shadow: 0 6px 16px rgba(180, 123, 82, 0.35);
    transition: 0.25s;
    border: 1px solid #c28b5c;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(180, 123, 82, 0.4);
}
.btn:active {
    transform: translateY(1px);
    box-shadow: 0 4px 10px rgba(180, 123, 82, 0.3);
}
.btn-outline {
    background: #fffdf7;
    color: #6b4a30;
    border: 2px solid #d6b07b;
    box-shadow: none;
    text-shadow: none;
}
.btn-outline:hover {
    background: #fff4e4;
    border-color: #b47b52;
}

/* 清空按钮 */
.clear-btn {
    background: #fff;
    border: 2px solid #cfb594;
    color: #6b4e3d;
    font-size: 0.78rem;
    padding: 5px 16px;
    border-radius: 22px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.2s;
}
.clear-btn:hover {
    background: #fdeaea;
    border-color: #c0392b;
    color: #b03a2e;
}

/* 统计行 */
.stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}
.warn-text {
    color: #c0392b;
    font-weight: 700;
    font-size: 0.82rem;
}

/* 按钮组 */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    margin: 24px 0;
}

/* ========== 结果区域 ========== */
#resultArea {
    background: linear-gradient(150deg, #fdf8f0, #f9efdf);
    border-radius: 24px;
    padding: 24px;
    border: 1.5px solid #dec8a4;
    margin-top: 24px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.04);
}
.result-header, .placement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.export-btn {
    padding: 8px 20px !important;
    font-size: 0.88rem !important;
}

/* 巢穴视觉 */
.nest-visual {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 20px 0;
}
.nest-item {
    width: 88px; height: 92px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 6px 14px rgba(0,0,0,0.06);
    border: 2.5px solid;
    font-size: 0.72rem;
    text-align: center;
    padding: 6px;
    background: #fcecd0;
    transition: transform 0.15s;
}
.nest-item:hover { transform: translateY(-2px); }
.nest-item.female { background: #fef0f0; border-color: #e6b0b0; }
.nest-item.male { background: #edf2fa; border-color: #95b5d4; }
.nest-item .icon { font-size: 1.3rem; }

/* 雄性卡片 */
.male-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 16px 0;
}
.male-card {
    background: #f4f8ff;
    border-radius: 18px;
    padding: 14px 18px;
    border: 1.5px solid #c5d4e5;
    min-width: 150px;
    font-size: 0.82rem;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.03);
    transition: 0.15s;
}
.male-card:hover { border-color: #89a9c9; box-shadow: 0 5px 14px rgba(0,0,0,0.05); }
.male-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.male-card .egg-groups {
    font-size: 0.7rem;
    color: #4d4030;
    background: #f3e3cc;
    padding: 3px 10px;
    border-radius: 12px;
    margin-left: 8px;
    white-space: nowrap;
    font-weight: 600;
}
.summary {
    font-weight: 500;
    margin-top: 12px;
    line-height: 1.7;
    color: #4d3c2a;
}

/* ========== 位置图 ========== */
#placementArea {
    margin-top: 24px;
    background: linear-gradient(150deg, #fdf8f0, #f9efdf);
    border-radius: 24px;
    padding: 24px;
    border: 1.5px solid #dec8a4;
}
.svg-container {
    width: 100%;
    max-width: 520px;
    margin: 14px auto;
    touch-action: none;
    user-select: none;
    background: #fffef9;
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}
.svg-container svg {
    width: 100%;
    height: auto;
    display: block;
    user-select: none;
}
.legend {
    text-align: center;
    font-size: 0.78rem;
    color: #7b6148;
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
}

/* ========== 模态弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(40, 20, 10, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-content {
    background: #fffef9;
    border-radius: 28px;
    width: 92vw;
    max-width: 620px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 60px rgba(0,0,0,0.25);
    border: 2px solid #e1c9a2;
    animation: slideUp 0.3s ease;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 14px;
    border-bottom: 1.5px solid #e5cfb0;
    background: #fffcf4;
}
.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #5c3e28;
    letter-spacing: 0.5px;
}
.modal-close-btn {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 2px solid #ccaa7a;
    background: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    color: #6b4e3d;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.modal-close-btn:hover {
    background: #fef0f0;
    border-color: #c0392b;
    color: #c0392b;
}
.modal-body {
    padding: 18px 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    max-height: 55vh;
    background: #fffefb;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 24px 18px;
    border-top: 1.5px solid #e5cfb0;
}

/* 数量编辑输入框 */
.qty-edit-input {
    width: 54px;
    text-align: center;
    font-weight: 700;
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 4px 6px;
    font-size: 0.8rem;
    background: #fffef9;
    color: var(--text);
    outline: none;
    box-shadow: 0 0 0 3px rgba(194, 139, 92, 0.2);
    transition: 0.15s;
}

/* 搜索 */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.search-box input {
    flex: 1;
    padding: 12px 18px;
    border: 2px solid #dbbc8c;
    border-radius: 18px;
    font-size: 0.95rem;
    outline: none;
    background: #fffefb;
    transition: 0.2s;
}
.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(194, 139, 92, 0.12);
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1.5px solid #e5cfb0;
    border-radius: 16px;
    background: #fefaf3;
    gap: 14px;
    transition: background 0.2s, border-color 0.2s;
}
.search-result-item:hover {
    background: #fffdf5;
    border-color: #d4b68c;
}
.search-result-item .left-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.search-result-item .left-info .pet-name {
    font-weight: 700;
    color: #4d3822;
    margin-bottom: 8px;
    font-size: 0.92rem;
}
.search-result-item .qty-ctrl {
    display: flex;
    align-items: center;
    gap: 6px;
}
.search-result-item .qty-ctrl button {
    width: 30px; height: 30px;
    border-radius: 50%;
    border: 1.5px solid #cfb594;
    background: #f7efe2;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}
.search-result-item .qty-ctrl button:hover {
    background: #f0dcc4;
    border-color: #b47b52;
}
.search-result-item .qty-ctrl input {
    width: 44px;
    text-align: center;
    border: 1.5px solid #dbbc8c;
    border-radius: 10px;
    padding: 5px;
    font-size: 0.88rem;
    font-weight: 600;
    background: #fff;
}
.search-result-item .groups {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}
.group-badge {
    background: #e4edf7;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 0.72rem;
    color: #2c3e50;
    white-space: nowrap;
    font-weight: 600;
    letter-spacing: 0.3px;
}
/* 导入导出工具栏 */
.io-bar {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    margin-bottom: 10px;
}
.io-bar .btn {
    padding: 8px 10px !important;
    font-size: 0.9rem !important;
}

/* ========== 页脚 ========== */
footer {
    margin-top: 20px;
    text-align: center;
    color: #9a8268;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.4px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    /* 精灵窝数量行：模式切换区换行居中 */
    .nest-row-inline {
        justify-content: center;
    }
    .mode-area {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .dual-panel { flex-direction: column; }
    .display-panel { max-height: 90px; }
    .container { padding: 20px 16px; }
}
