:root {
    --heritage-bronze: #8b6914;
    --ancient-jade: #00a896;
    --imperial-vermilion: #c0392b;
    --scholar-ink: #2c3e50;
    --rice-paper: #fdfcfb;
    --silk-cream: #f5f0e8;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);

    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-mono: "JetBrains Mono", monospace;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #c19a6b 0%, #8b6914 50%, #5c4a2a 100%);
    color: var(--scholar-ink);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 96vw;
    height: 92vh;
    max-width: 1900px;
    background: var(--rice-paper);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 3px solid rgba(139, 105, 20, 0.3);
}

/* Header */
.main-header {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--heritage-bronze) 0%, #6b5310 100%);
    border-bottom: 3px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.6rem;
    color: white;
    margin-bottom: 4px;
}

.highlight {
    font-family: var(--font-title);
    font-size: 1.9rem;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: white;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.header-badge .icon {
    font-size: 1.3rem;
}

/* Main Stage */
.main-stage {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 360px;
    overflow: hidden;
}

.visualization-area {
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--silk-cream) 0%, #fdfcfb 100%);
    padding: 20px;
    overflow-y: auto;
}

.canvas-wrapper {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    margin-bottom: 24px;
}

.coordinate-system {
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 2px solid rgba(139, 105, 20, 0.2);
}

.coordinate-system h3 {
    text-align: center;
    font-size: 1rem;
    color: var(--heritage-bronze);
    margin-bottom: 12px;
    font-family: var(--font-title);
    letter-spacing: 1px;
}

.coordinate-system canvas {
    display: block;
    width: 100%;
    height: 400px;
    background: #fafafa;
    border-radius: 8px;
}

.system-info {
    text-align: center;
    margin-top: 12px;
    font-size: 0.85rem;
    color: #777;
}

.transform-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.transform-arrow {
    font-size: 2.5rem;
    color: var(--ancient-jade);
    font-weight: bold;
}

.transform-arrow.reverse {
    color: var(--imperial-vermilion);
}

.transform-label,
.inverse-label {
    text-align: center;
    padding: 12px;
    background: rgba(0, 168, 150, 0.1);
    border-radius: 10px;
    border: 2px solid var(--ancient-jade);
}

.inverse-label {
    background: rgba(192, 57, 43, 0.1);
    border-color: var(--imperial-vermilion);
}

.transform-label strong,
.inverse-label strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.transform-label p,
.inverse-label p {
    font-size: 0.75rem;
    color: #666;
    margin: 0;
}

/* Controls */
.controls-section {
    background: white;
    padding: 24px;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    border-top: 4px solid var(--heritage-bronze);
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.control-icon {
    font-size: 1.1rem;
    margin-right: 8px;
}

.control-name {
    flex: 1;
    font-weight: 600;
}

.control-value {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--heritage-bronze);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, var(--ancient-jade), var(--heritage-bronze));
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--heritage-bronze);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--heritage-bronze);
    cursor: pointer;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    background: #f0f0f0;
    color: var(--scholar-ink);
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.action-btn.primary {
    background: var(--ancient-jade);
    color: white;
}

.action-btn.secondary {
    background: var(--imperial-vermilion);
    color: white;
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border-left: 3px solid rgba(139, 105, 20, 0.2);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.panel-section {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

.panel-icon {
    font-size: 1.2rem;
}

.panel-header h3 {
    font-size: 0.95rem;
    color: var(--scholar-ink);
}

.heritage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.heritage-item {
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.heritage-item:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

.heritage-item strong {
    display: block;
    margin-bottom: 4px;
    color: var(--heritage-bronze);
}

.heritage-item span {
    color: #666;
    font-size: 0.8rem;
    font-family: var(--font-mono);
}

.formula-display h4 {
    font-size: 0.9rem;
    color: var(--ancient-jade);
    margin: 12px 0 8px 0;
}

.formula-display h4:first-child {
    margin-top: 0;
}

.formula-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.85rem;
    overflow-x: auto;
}

.insight-panel {
    border-top: 3px solid var(--imperial-vermilion);
}

.insight-content {
    font-size: 0.85rem;
    line-height: 1.7;
}

.insight-content h4 {
    color: var(--imperial-vermilion);
    margin: 10px 0 6px 0;
    font-size: 0.9rem;
}

.insight-content h4:first-child {
    margin-top: 0;
}

.insight-content p {
    color: #555;
    margin-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.stat-item.highlight {
    grid-column: span 2;
    background: linear-gradient(135deg, rgba(139, 105, 20, 0.1) 0%, rgba(139, 105, 20, 0.05) 100%);
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    color: #777;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--heritage-bronze);
}