:root {
    --bg-page: #f4f7f9;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    
    --chong: #f97316; --chong-bg: rgba(249,115,22,0.1);
    --wen: #10b981;   --wen-bg: rgba(16,185,129,0.1);
    --bao: #3b82f6;   --bao-bg: rgba(59,130,246,0.1);

    --radius-lg: 16px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 32px 0 24px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
    text-align: center;
}
.header-inner {
    padding: 0 15vw;
}
.app-header h1 { 
    font-size: 2.2rem; font-weight: 800; 
    background: linear-gradient(135deg, #1d4ed8, #3b82f6, #0ea5e9);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 12px;
}
.app-header .subtitle { 
    font-size: 1rem; color: var(--text-muted); 
    display: flex; align-items: center; justify-content: center; gap: 12px;
}
.app-header .subtitle .dot { width: 4px; height: 4px; background: var(--primary); border-radius: 50%; opacity: 0.5; }

/* Main Layout */
.main-layout {
    flex: 1;
    display: flex;
    gap: 24px;
    padding: 24px 15vw;
    overflow: hidden;
}

.layout-left {
    flex: 0 0 350px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 150px);
}

.layout-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}
.card.full-height { height: 100%; }
.flex-col { display: flex; flex-direction: column; }
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; color: #0f172a; }
.card-header-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }

/* Score Input */
.score-input-wrapper { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.score-input {
    width: 90px; height: 48px; border: 2px solid var(--border-color);
    border-radius: var(--radius); text-align: center; font-size: 1.4rem; font-weight: 700;
    color: var(--primary); outline: none; transition: border-color 0.2s;
}
.score-input:focus { border-color: var(--primary); }
.score-slider { flex: 1; cursor: pointer; }
.score-level-display { text-align: center; }
.level-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: 0.85rem; font-weight: 600; background: var(--border-color); color: var(--text-muted);
}
.total-count { font-size: 0.9rem; font-weight: 600; background: var(--bg-page); padding: 4px 10px; border-radius: var(--radius); }
.total-count span { color: var(--primary); font-size: 1.1rem; margin-left: 4px; }

/* History List (Left) */
.history-list {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
    padding-right: 4px;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.empty-state-small { font-size: 0.9rem; color: var(--text-muted); text-align: center; padding: 20px 0; font-style: italic;}
.history-item {
    padding: 12px 16px; border: 1px solid var(--border-color); border-radius: var(--radius);
    background: #fafafa; cursor: pointer; transition: all 0.2s; display: flex; justify-content: space-between; align-items: center;
}
.history-item:hover { border-color: #cbd5e1; background: #fff; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.history-item.active { border-color: var(--primary); background: #eff6ff; box-shadow: inset 3px 0 0 var(--primary); }
.h-title { font-weight: 600; color: #0f172a; margin-bottom: 2px; font-size: 0.95rem; }
.h-meta { font-size: 0.75rem; color: var(--text-muted); }
.h-tag { font-size: 0.75rem; background: var(--border-color); padding: 2px 6px; border-radius: 10px; font-weight:600; }
.history-item.active .h-tag { background: #bfdbfe; color: #1d4ed8; }

/* Right Editor */
.editor-stats-area {
    background: linear-gradient(135deg, #f0f4ff, #eef2ff); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px; color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}
.stats-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-card .stat-value { font-size: 2rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; font-weight: 500; }
.stat-card.chong .stat-value { color: var(--chong); }
.stat-card.wen .stat-value { color: var(--wen); }
.stat-card.bao .stat-value { color: var(--bao); }

.tier-dist { background: transparent; padding: 0; border: none; margin-bottom: 0px; }
.tier-dist h3 { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; font-weight: 500;}
.tier-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; }
.tier-segment { display: flex; align-items: center; justify-content: center; font-size: 0px; font-weight: 700; color: transparent; transition: flex 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.tier-segment.t-双高 { background: #8b5cf6; }
.tier-segment.t-公办 { background: #10b981; }
.tier-segment.t-偏远公办 { background: #06b6d4; }
.tier-segment.t-好的民办 { background: #f59e0b; }
.tier-segment.t-普通民办 { background: #64748b; }
.tier-segment.t-其它民办 { background: #ef4444; }

.tier-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; justify-content: center; }
.tier-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: #475569; }
.tier-legend-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Editor Content */
.editor-header-flex { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border-color); background: #f8fafc;}
.editor-title { font-size: 1rem; font-weight: 600; color: #334155; margin: 0; }
.editor-total { font-size: 0.9rem; color: #475569; }
.editor-total strong { color: var(--primary); font-size: 1.1rem; }

.editor-content { flex: 1; overflow-y: auto; padding: 20px 24px; background: #fff;}
.editor-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); background: #fff; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.strategy-group { margin-bottom: 24px; }
.strategy-title {
    font-size: 1rem; font-weight: 600; margin-bottom: 16px; padding: 10px 14px;
    border-radius: var(--radius); display: flex; align-items: center; justify-content: space-between;
}
.strategy-title.chong { background: var(--chong-bg); color: var(--chong); }
.strategy-title.wen { background: var(--wen-bg); color: var(--wen); }
.strategy-title.bao { background: var(--bao-bg); color: var(--bao); }

.college-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.college-card {
    border: 1px solid var(--border-color); border-radius: var(--radius);
    padding: 16px; transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff; position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
}
.college-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow-md); }
.c-index {
    position: absolute; top: -1px; left: -1px; background: #f1f5f9; color: #64748b;
    font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: var(--radius) 0 8px 0;
}
.c-name { font-size: 1.05rem; font-weight: 600; margin: 6px 0 12px; color: #0f172a; padding-right: 20px;}
.c-meta { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap:wrap;}
.c-tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 12px; background: #f1f5f9; color: #475569; }

.c-bottom-action { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--border-color); padding-top: 12px;}
.c-score-box { display: flex; align-items: baseline; gap: 4px; }
.c-score { font-size: 1.25rem; font-weight: 700; line-height: 1; }
.c-card-chong .c-score { color: var(--chong); }
.c-card-wen .c-score { color: var(--wen); }
.c-card-bao .c-score { color: var(--bao); }
.c-score-label { font-size: 0.75rem; color: var(--text-muted); }

.adj-stepper { display: flex; align-items: center; gap: 6px; background: #f8fafc; padding: 4px; border-radius: 6px; border:1px solid #cbd5e1;}
.adj-stepper-btn {
    width: 24px; height: 24px; border-radius: 4px; border: none;
    background: #fff; cursor: pointer; color: #475569; font-weight: 600; transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.adj-stepper-btn:hover:not(:disabled) { color: var(--primary); background: #eff6ff; }
.adj-stepper-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow:none;}
.adj-val { width: 20px; text-align: center; font-weight: 700; font-size: 0.95rem; color: var(--primary);}

.empty-state { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: var(--text-muted); }
.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }

.btn-primary {
    width: 100%; padding: 14px; background: var(--primary); color: white;
    border: none; border-radius: var(--radius); font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }

/* Tab Bar for switching editor views */
.tab-bar {
    display: flex; gap: 4px; padding: 8px; background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
}
.tab-btn {
    flex: 1; padding: 8px 14px; border: none; border-radius: 6px;
    background: transparent; color: var(--text-muted);
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.6); }
.tab-btn.active {
    background: var(--bg-card); color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

/* Plan View */
.plan-view { padding: 24px; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.plan-header {
    text-align: center; margin-bottom: 24px;
    padding-bottom: 18px; border-bottom: 2px solid var(--border-color);
}
.plan-header h2 {
    font-size: 1.3rem; font-weight: 800;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 6px;
}
.plan-header p { color: var(--text-muted); font-size: 0.85rem; }
.plan-badge {
    display: inline-block; margin-top: 10px;
    padding: 5px 20px; border-radius: 20px;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: white; font-weight: 700; font-size: 0.9rem;
}
.plan-summary {
    display: flex; justify-content: space-around; align-items: center;
    background: #f8fafc; border-radius: var(--radius);
    padding: 14px; margin-bottom: 20px;
    border: 1px solid var(--border-color);
}
.plan-summary-item { text-align: center; }
.plan-val { font-size: 1.3rem; font-weight: 800; }
.plan-lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.plan-table {
    width: 100%; border-collapse: collapse;
    background: var(--bg-card); border-radius: var(--radius);
    overflow: hidden; border: 1px solid var(--border-color);
}
.plan-table thead th {
    background: #f8fafc; padding: 10px 12px;
    font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
    text-align: left; border-bottom: 2px solid var(--border-color);
}
.plan-table tbody td {
    padding: 10px 12px; border-bottom: 1px solid #f1f5f9;
    font-size: 0.85rem;
}
.plan-table tbody tr:hover { background: #f8fafc; }
.plan-table tbody tr:last-child td { border-bottom: none; }

.btn-print {
    display: block; margin: 18px auto 0; padding: 10px 28px;
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
    color: white; border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: opacity 0.2s;
}
.btn-print:hover { opacity: 0.85; }
.plan-footer {
    text-align: center; margin-top: 16px; padding: 12px;
    color: var(--text-muted); font-size: 0.75rem;
}
@media print {
    .app-header, .layout-left, .tab-bar, .btn-print { display: none !important; }
    .main-layout { padding: 0 !important; }
    .layout-right { flex: 1; }
    body { height: auto; }
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .main-layout, .header-inner { padding-left: 5vw; padding-right: 5vw; }
}
@media (max-width: 768px) {
    .main-layout { flex-direction: column; overflow-y: auto; }
    .layout-left { flex: none; width: 100%; height: auto; }
    .layout-right { min-height: 500px; }
    body { height: auto; }
}
