:root {
    /* Red Culture Theme */
    --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;

    /* Ring Colors */
    --ring-main: #d63b1d;
    --ring-secondary: #ff8c75;
    --ring-ideal: #ffb400;
    --ring-element: #fff8f0;
    --ring-highlight: #8b0000;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(139, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(139, 0, 0, 0.12);
    --shadow-lg: 0 20px 40px rgba(139, 0, 0, 0.15);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--app-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url('https://images.unsplash.com/photo-1533038590840-1cde6e668a91?q=80&w=2574&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
}

.app-container {
    width: 90vw;
    height: 85vh;
    max-width: 1400px;
    background: rgba(255, 252, 245, 0.85);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 340px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    gap: 1.5rem;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.window-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot.red {
    background: #ff5f56;
    border: 1px solid #e0443e;
}

.dot.yellow {
    background: #ffbd2e;
    border: 1px solid #dea123;
}

.dot.green {
    background: #27c93f;
    border: 1px solid #1aab29;
}

h1 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.highlight {
    color: var(--accent-red);
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    flex-grow: 1;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Select */
.apple-select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(139, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b0000' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.apple-select:hover {
    border-color: var(--accent-red);
    background: rgba(255, 255, 255, 0.8);
}

.apple-select:focus {
    outline: 2px solid var(--accent-red);
    outline-offset: 2px;
}

.apple-select.mini {
    padding: 8px 10px;
    width: 60px;
    font-size: 0.85rem;
}

/* Input */
.apple-input {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(139, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    flex: 1;
}

.apple-input:hover {
    border-color: var(--accent-red);
    background: rgba(255, 255, 255, 0.8);
}

.apple-input:focus {
    outline: 2px solid var(--accent-red);
    outline-offset: 2px;
    background: rgba(255, 255, 255, 0.9);
}

.apple-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Concept Buttons */
.concept-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.concept-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--accent-red);
    background: rgba(255, 255, 255, 0.5);
    color: var(--accent-red);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.concept-btn .icon {
    font-size: 1.1rem;
}

.concept-btn:hover {
    background: var(--accent-red);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.concept-btn.active {
    background: var(--accent-red);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Operation Panel */
.operation-panel {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 8px;
    align-items: center;
}

/* Result Box */
.result-box {
    background: rgba(255, 255, 255, 0.5);
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(139, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 45px;
}

.result-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}

#resultValue {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-red);
}

/* Buttons */
.apple-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-family);
    gap: 8px;
}

.calculate-btn {
    background: var(--accent-gold);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.85rem;
}

.calculate-btn:hover {
    background: #ffc933;
    transform: scale(1.05);
}

.action-btn {
    background: var(--accent-red);
    color: white;
    width: 100%;
    box-shadow: var(--shadow-md);
}

.action-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.danger-btn {
    background: rgba(139, 0, 0, 0.1);
    color: var(--text-primary);
    width: 100%;
}

.danger-btn:hover {
    background: rgba(139, 0, 0, 0.2);
}

.apple-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Ideological Panel */
.ideological-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ideology-card {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(255, 180, 0, 0.05));
    border: 1px solid rgba(214, 59, 29, 0.2);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s ease;
}

.ideology-card.active {
    border-color: var(--accent-red);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.card-icon {
    font-size: 1.2rem;
    color: var(--accent-gold);
}

.card-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-red);
}

.card-content {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Main Stage */
.visualizer-stage {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
}

.glass-pane {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.visualization-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.visualization-header h2 {
    font-family: var(--font-title);
    font-size: 1.8rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

#vizSubtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

.viz-area {
    flex-grow: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    opacity: 0.7;
}

.star-container {
    width: 200px;
    height: 200px;
    animation: rotate 20s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.red-star {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 12px rgba(214, 59, 29, 0.3));
}

.welcome-text {
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Properties Panel */
.properties-panel {
    position: absolute;
    top: 2rem;
    right: 2rem;
    width: 250px;
    background: rgba(255, 248, 240, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 1rem;
    box-shadow: var(--shadow-md);
}

.properties-panel h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-red);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.properties-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.property-item {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(139, 0, 0, 0.1);
    font-size: 0.8rem;
}

.property-item:last-child {
    border-bottom: none;
}

.prop-key {
    color: var(--text-secondary);
    font-weight: 600;
}

.prop-value {
    color: var(--text-primary);
    font-weight: 700;
}

/* Ring Visualization Elements */
.ring-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ring-circle {
    width: 400px;
    height: 400px;
    border: 4px solid var(--ring-main);
    border-radius: 50%;
    position: relative;
    background: radial-gradient(circle, rgba(214, 59, 29, 0.05), transparent 70%);
    box-shadow: 0 0 30px rgba(214, 59, 29, 0.2);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 30px rgba(214, 59, 29, 0.2);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 50px rgba(214, 59, 29, 0.4);
    }
}

.ring-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-red);
    text-align: center;
}

.ring-element {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--ring-element);
    border: 2px solid var(--ring-main);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    animation: float 2s ease-in-out infinite;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ring-element:hover {
    transform: scale(1.2);
    background: var(--accent-gold);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* Subring Visualization */
.subring-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.nested-rings {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.outer-ring {
    width: 450px;
    height: 450px;
    border: 3px dashed var(--ring-main);
    border-radius: 50%;
    position: absolute;
    opacity: 0.6;
}

.inner-ring {
    width: 300px;
    height: 300px;
    border: 4px solid var(--accent-gold);
    border-radius: 50%;
    position: absolute;
    background: radial-gradient(circle, rgba(255, 180, 0, 0.1), transparent 70%);
    box-shadow: 0 0 20px rgba(255, 180, 0, 0.3);
}

.ring-annotation {
    position: absolute;
    background: rgba(255, 248, 240, 0.95);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
}

/* Ideal Visualization */
.ideal-container {
    display: flex;
    gap: 3rem;
    align-items: center;
    justify-content: center;
}

.ideal-set {
    position: relative;
}

.ideal-box {
    width: 180px;
    height: 180px;
    border: 3px solid var(--accent-gold);
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 180, 0, 0.1), rgba(255, 180, 0, 0.05));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(255, 180, 0, 0.2);
}

.ideal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.ideal-elements {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.ideal-elem {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--ring-ideal);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.absorption-arrow {
    font-size: 2rem;
    color: var(--accent-red);
    animation: arrow-pulse 1.5s ease-in-out infinite;
}

@keyframes arrow-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Footer */
.actions-footer {
    display: flex;
    gap: 10px;
}