* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #d63b1d;
    --primary-gold: #ffb400;
    --success-green: #10b981;
    --danger-red: #ff3b30;
    --coset-1: #10b981;
    --coset-2: #4ecdc4;
    --coset-3: #a78bfa;
    --bg-light: #f8f9fa;
    --text-dark: #2c3e50;
    --border-color: #e0e0e0;
}

body {
    font-family: "Noto Serif SC", "Outfit", sans-serif;
    background: linear-gradient(135deg, #001a33, #5B2C6F);
    color: var(--text-dark);
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.app-header {
    background: linear-gradient(135deg, var(--primary-red), #8B4789);
    color: white;
    padding: 24px 32px;
    text-align: center;
}

.app-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.header-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    font-style: italic;
}

.main-content {
    display: flex;
    min-height: calc(100vh - 180px);
}

.control-panel {
    width: 340px;
    background: var(--bg-light);
    padding: 20px;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

.panel-section {
    background: white;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.panel-section h3 {
    font-size: 0.95rem;
    color: var(--primary-red);
    margin-bottom: 12px;
    font-weight: 700;
}

.info-text {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 12px;
}

.hint {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 10px;
}

.group-elements {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.element-badge {
    background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.2s;
    cursor: pointer;
}

.element-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.element-badge.coset-0 {
    border-color: var(--coset-1);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
}

.element-badge.coset-1 {
    border-color: var(--coset-2);
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.2), rgba(78, 205, 196, 0.05));
}

.element-badge.coset-2 {
    border-color: var(--coset-3);
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(167, 139, 250, 0.05));
}

.cosets-display {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.coset-group {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 12px;
    border-left: 4px solid;
}

.coset-group.coset-0 {
    border-color: var(--coset-1);
}

.coset-group.coset-1 {
    border-color: var(--coset-2);
}

.coset-group.coset-2 {
    border-color: var(--coset-3);
}

.coset-group h4 {
    font-size: 0.85rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.coset-members {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.coset-member {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid;
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    font-weight: 600;
}

.highlight-section {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(139, 71, 137, 0.05));
    border: 2px solid var(--primary-red);
}

.message-input {
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    border: 2px solid var(--primary-red);
    border-radius: 8px;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 3px;
    text-align: center;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-gold);
    box-shadow: 0 0 0 3px rgba(255, 180, 0, 0.2);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin-bottom: 8px;
}

.btn-large {
    font-size: 1.1rem;
    padding: 16px;
}

.btn-primary {
    background: var(--primary-red);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #b32b12;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--success-green);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-reset {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger-red);
    border: 2px solid var(--danger-red);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.stats-section {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(78, 205, 196, 0.05));
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-item {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 2px solid var(--border-color);
}

.stat-item span {
    display: block;
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 4px;
}

.stat-item strong {
    font-size: 1.3rem;
    color: var(--primary-red);
}

.stat-item.success strong {
    color: var(--success-green);
}

.visualization-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.vis-section {
    margin-bottom: 24px;
}

.vis-section h3 {
    color: var(--primary-red);
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.cayley-table-container {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cayley-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-family: 'Courier New', monospace;
}

.cayley-table th,
.cayley-table td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: center;
    font-size: 0.8rem;
}

.cayley-table th {
    background: var(--primary-red);
    color: white;
    font-weight: 700;
}

.cayley-table td {
    background: #f9f9f9;
    font-weight: 600;
}

.cayley-table td.coset-0 {
    background: rgba(16, 185, 129, 0.15);
}

.cayley-table td.coset-1 {
    background: rgba(78, 205, 196, 0.15);
}

.cayley-table td.coset-2 {
    background: rgba(167, 139, 250, 0.15);
}

.crypto-flow {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.flow-stage {
    flex: 1;
    text-align: center;
}

.flow-stage h4 {
    font-size: 0.85rem;
    color: var(--primary-red);
    margin-bottom: 10px;
}

.flow-content {
    background: var(--bg-light);
    border-radius: 8px;
    padding: 16px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.flow-arrow {
    font-size: 1.5rem;
    color: var(--primary-red);
    font-weight: 700;
}

.empty-hint {
    color: #999;
    font-size: 0.8rem;
}

.char-badge,
.number-badge,
.coset-badge,
.cipher-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
}

.char-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.number-badge {
    background: linear-gradient(135deg, #f093fb, #f5576c);
    color: white;
}

.coset-badge {
    border: 2px solid;
    background: rgba(255, 255, 255, 0.9);
    font-family: 'Courier New', monospace;
}

.coset-badge.coset-0 {
    border-color: var(--coset-1);
    color: var(--coset-1);
}

.coset-badge.coset-1 {
    border-color: var(--coset-2);
    color: var(--coset-2);
}

.coset-badge.coset-2 {
    border-color: var(--coset-3);
    color: var(--coset-3);
}

.cipher-badge {
    background: linear-gradient(135deg, #fa709a, #fee140);
    color: #333;
    font-family: 'Courier New', monospace;
}

.decrypt-flow {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(78, 205, 196, 0.05));
    border: 2px solid var(--success-green);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.decrypt-flow h3 {
    color: var(--success-green);
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.decrypt-steps {
    font-size: 0.9rem;
    line-height: 1.8;
}

.decrypt-steps div {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.process-log {
    background: linear-gradient(135deg, rgba(214, 59, 29, 0.05), rgba(139, 71, 137, 0.05));
    border: 2px solid var(--primary-red);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.process-log h4 {
    color: var(--primary-red);
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.process-content {
    font-size: 0.9rem;
    line-height: 1.8;
}

.ideology-box {
    background: linear-gradient(135deg, rgba(139, 0, 0, 0.05), rgba(139, 71, 137, 0.05));
    border: 2px solid var(--primary-red);
    border-radius: 12px;
    padding: 20px;
}

.ideology-box h4 {
    color: var(--primary-red);
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
}

.ideology-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.ideology-item {
    background: white;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ideology-item strong {
    display: block;
    color: var(--primary-red);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.ideology-item p {
    font-size: 0.8rem;
    line-height: 1.5;
    color: #555;
}

.quote {
    background: rgba(255, 255, 255, 0.7);
    border-left: 4px solid var(--primary-gold);
    padding: 12px 16px;
    font-style: italic;
    font-size: 0.9rem;
    color: #444;
    border-radius: 4px;
}

.control-panel::-webkit-scrollbar,
.visualization-area::-webkit-scrollbar {
    width: 8px;
}

.control-panel::-webkit-scrollbar-thumb,
.visualization-area::-webkit-scrollbar-thumb {
    background: var(--primary-red);
    border-radius: 4px;
}