:root {
    --app-bg: #fdfbf7;
    --sidebar-bg: rgba(255, 248, 240, 0.8);
    --glass-border: rgba(214, 59, 29, 0.2);
    --text-primary: #8b0000;
    --text-secondary: #a05a5a;
    --accent-red: #d63b1d;
    --accent-gold: #ffb400;
    --accent-hover: #b32b12;
    --danger-red: #ff3b30;
    --code-blue: #3b82f6;
    --code-green: #10b981;
    --code-purple: #8b5cf6;
    --shadow-lg: 0 20px 40px rgba(139, 0, 0, 0.15);
    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-title: "Ma Shan Zheng", cursive;
    --font-mono: 'Courier New', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #2c1810, #1a0e0a);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1500px;
    margin: 7.5vh auto;
    background: rgba(255, 252, 245, 0.92);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 340px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.2rem;
    gap: 0.7rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.window-controls {
    display: flex;
    gap: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.dot.red {
    background: linear-gradient(135deg, #ff5f57, #ff3b30);
}

.dot.yellow {
    background: linear-gradient(135deg, #ffbd2e, #ffaa00);
}

.dot.green {
    background: linear-gradient(135deg, #28ca42, #27c93f);
}

h1 {
    font-family: var(--font-title);
    font-size: 1.5rem;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.9;
    font-style: italic;
}

.highlight {
    color: var(--accent-red);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.step-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.step-btn {
    padding: 0.65rem 0.5rem;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid rgba(139, 0, 0, 0.15);
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.step-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent-red);
    transform: translateY(-1px);
}

.step-btn.active {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

.step-btn.completed {
    background: var(--code-green);
    color: white;
    border-color: var(--code-green);
}

.info-panel {
    background: rgba(255, 255, 255, 0.5);
    padding: 0.7rem;
    border-radius: 8px;
    border: 1px solid rgba(139, 0, 0, 0.1);
}

.info-panel p {
    font-size: 0.75rem;
    margin-bottom: 0.3rem;
}

.info-panel strong {
    color: var(--accent-red);
    margin-right: 0.3rem;
}

.matrix-display {
    background: rgba(255, 255, 255, 0.7);
    padding: 0.8rem;
    border-radius: 8px;
    border: 2px solid var(--code-blue);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.matrix-row {
    padding: 0.25rem 0;
    text-align: center;
    color: var(--text-primary);
    font-weight: 600;
}

.input-vector {
    display: flex;
    gap: 0.4rem;
}

.input-vector input {
    flex: 1;
    padding: 0.65rem;
    border: 2px solid var(--code-purple);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
}

.encode-btn {
    padding: 0.65rem 0.9rem;
    background: var(--code-purple);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.encode-btn:hover {
    background: #7c3aed;
    transform: translateY(-1px);
}

.codeword-display {
    background: rgba(16, 185, 129, 0.1);
    padding: 0.9rem;
    border-radius: 8px;
    border: 2px solid var(--code-green);
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.3em;
    color: var(--code-green);
}

.info-box {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(255, 180, 0, 0.05));
    padding: 0.7rem;
    border-radius: 10px;
    border: 1px solid rgba(214, 59, 29, 0.2);
}

.info-box h3 {
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    color: var(--accent-red);
}

.info-box p {
    font-size: 0.68rem;
    line-height: 1.4;
    margin-bottom: 0.3rem;
}

.actions-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.apple-btn {
    flex: 1;
    min-width: 95px;
    padding: 0.65rem;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}

.action-btn {
    background: var(--accent-red);
    color: white;
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.danger-btn {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-red);
    border: 2px solid var(--danger-red);
}

.danger-btn:hover {
    background: var(--danger-red);
    color: white;
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    overflow-y: auto;
}

.glass-pane {
    width: 100%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
}

.graph-title {
    text-align: center;
}

.graph-title h2 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--accent-red);
    margin-bottom: 0.3rem;
}

.graph-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.quote-banner {
    background: linear-gradient(90deg, rgba(214, 59, 29, 0.1), transparent);
    border-left: 3px solid var(--accent-red);
    padding: 0.8rem 1rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.quote-icon {
    font-size: 1.5rem;
}

.quote-text {
    font-family: var(--font-title);
    font-size: 1rem;
    color: var(--text-primary);
    flex: 1;
}

.quote-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.visualization-container {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 320px;
}

#codeSvg {
    max-width: 100%;
    height: auto;
}

#visualGroup {
    transition: opacity 0.3s ease-in-out;
}

.distance-table {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    transition: opacity 0.3s ease-in-out;
}

.distance-table h3 {
    color: var(--accent-red);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.comparison-panel {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    padding: 1.5rem;
    transition: opacity 0.3s ease-in-out;
}

.comparison-panel h3 {
    color: var(--accent-red);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.capability-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.capability-item {
    background: white;
    padding: 1.2rem;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #ccc;
}

.capability-item.highlight {
    border-color: var(--code-green);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.1));
}

.capability-item h4 {
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.capability-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-red);
}

.capability-arrow {
    font-size: 2rem;
    color: var(--accent-red);
    font-weight: 700;
}

.analysis-box {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid var(--code-green);
}

.analysis-box p {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.analysis-box strong {
    color: var(--code-green);
}

.ideology-content-box {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.05), rgba(255, 180, 0, 0.05));
    border: 1px solid rgba(214, 59, 29, 0.2);
    border-radius: 12px;
    padding: 1.2rem;
}

.ideology-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.red-star {
    color: var(--accent-red);
    font-size: 1.2rem;
}

.ideology-header h3 {
    color: var(--accent-red);
    font-family: var(--font-title);
    font-size: 1.2rem;
}

.ideology-text {
    font-size: 0.9rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.social-analogy {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(139, 0, 0, 0.1);
}

.social-analogy label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.social-analogy p {
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.sidebar::-webkit-scrollbar,
.visualizer-stage::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.visualizer-stage::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar::-webkit-scrollbar-thumb,
.visualizer-stage::-webkit-scrollbar-thumb {
    background: var(--accent-red);
    border-radius: 3px;
}