/* ===== CSS Variables & Theme ===== */
:root {
    /* Light Theme */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --text-muted: #a0aec0;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --gradient-card: linear-gradient(180deg, #ffffff 0%, #f5f7fa 100%);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
    --gradient-card: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

#app {
    max-width: 100%;
    min-height: 100vh;
}

/* ===== View System ===== */
.view {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn-outline {
    background: transparent;
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--accent-primary);
    color: white;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 16px;
}

.btn-text:hover:not(:disabled) {
    color: var(--accent-primary);
}

.btn-danger {
    color: var(--accent-danger);
}

.btn-danger:hover:not(:disabled) {
    background: var(--accent-danger);
    color: white;
}

.btn-large {
    padding: 20px 32px;
    font-size: 1.1rem;
    flex-direction: column;
    gap: 4px;
}

.btn-icon {
    font-size: 1.5rem;
}

.btn-desc {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ===== Home View ===== */
.home-container {
    max-width: 500px;
    width: 100%;
    text-align: center;
    padding-top: 10vh;
}

.home-header {
    margin-bottom: 40px;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.last-result {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-sm);
}

.last-result h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.last-result-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.last-result .type-code {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.last-result .type-name {
    font-size: 1.2rem;
    color: var(--text-primary);
}

.entry-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 40px;
}

.quick-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* ===== Question View ===== */
.question-container {
    max-width: 600px;
    width: 100%;
    padding-top: 40px;
}

.question-header {
    width: 100%;
    margin-bottom: 30px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    transition: width 0.3s ease;
    border-radius: 4px;
}

.timer {
    text-align: right;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.question-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.question-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
}

.question-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-item {
    display: block;
    width: 100%;
    padding: 16px 20px;
    text-align: left;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    color: var(--text-primary);
}

.option-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.option-item.selected {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    color: white;
}

.option-item.likert {
    text-align: center;
}

.question-nav {
    display: flex;
    gap: 16px;
    width: 100%;
}

.question-nav .btn {
    flex: 1;
}

.anti-cheat-hint {
    text-align: center;
    margin-top: 16px;
    padding: 12px;
    background: var(--accent-warning);
    color: white;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

/* ===== Result View ===== */
.result-container {
    max-width: 600px;
    width: 100%;
    padding-top: 40px;
}

.result-header {
    text-align: center;
    margin-bottom: 32px;
}

.result-label {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.type-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.type-code-large {
    font-size: 4rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.type-name-large {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.type-tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.dimensions-viz {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.dimensions-viz h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.dimension-bars {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.dimension-bar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dimension-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.dimension-label span:first-child {
    color: var(--text-primary);
    font-weight: 600;
}

.dimension-label span:last-child {
    color: var(--text-muted);
}

.dimension-bar {
    display: flex;
    height: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--border-color);
}

.bar-left, .bar-right {
    transition: width 0.5s ease;
}

.bar-left {
    background: var(--accent-primary);
}

.bar-right {
    background: var(--accent-secondary);
}

.bar-indicator {
    width: 4px;
    background: var(--text-primary);
    transition: left 0.5s ease;
}

.result-detail {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.result-detail h4 {
    color: var(--accent-primary);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.result-detail p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 16px;
}

.result-warning {
    background: var(--accent-warning);
    color: white;
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.result-footer {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

/* ===== History View ===== */
.history-container {
    max-width: 600px;
    width: 100%;
    padding-top: 20px;
}

.page-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 16px;
}

.btn-back:hover {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.page-header h2 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.history-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    transform: translateX(4px);
}

.history-item .type-code {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.history-item .info {
    flex: 1;
}

.history-item .info .type-name {
    font-weight: 600;
    color: var(--text-primary);
}

.history-item .info .test-type {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.history-item .info .test-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item .actions {
    display: flex;
    gap: 8px;
}

.history-item .btn-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
}

.history-item .btn-delete:hover {
    color: var(--accent-danger);
}

.empty-history {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-history p {
    margin-bottom: 20px;
}

.compare-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
}

.compare-section h3 {
    margin-bottom: 16px;
}

.compare-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.compare-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

.compare-item .dim-name {
    font-weight: 600;
}

.compare-item .dim-diff {
    color: var(--accent-primary);
}

/* ===== Guide View ===== */
.guide-container {
    max-width: 800px;
    width: 100%;
    padding-top: 20px;
}

.guide-content {
    width: 100%;
}

.guide-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.guide-section h3 {
    font-size: 1.1rem;
    color: var(--accent-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.dimension-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.dim-card {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.dim-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.dim-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.dim-pair {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.dim-pair span {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.dim-pair span:first-child {
    background: var(--accent-primary);
    color: white;
}

.dim-pair span:last-child {
    background: var(--accent-secondary);
    color: white;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.type-card {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.type-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.type-card .t-code {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 4px;
}

.type-card .t-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.myths-content ul {
    list-style: none;
    padding: 0;
}

.myths-content li {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.myths-content li:last-child {
    border-bottom: none;
}

.myths-content .myth {
    color: var(--accent-danger);
    font-weight: 600;
}

.myths-content .fact {
    color: var(--text-secondary);
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    position: relative;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-small {
    max-width: 360px;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--text-primary);
}

.rules-info {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

.rules-info p {
    margin: 8px 0;
    color: var(--text-secondary);
}

.rules-tips {
    margin-bottom: 20px;
}

.rules-tips h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
}

.rules-tips ul {
    list-style: none;
    padding: 0;
}

.rules-tips li {
    padding: 8px 0;
    color: var(--text-secondary);
    padding-left: 24px;
    position: relative;
}

.rules-tips li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--accent-primary);
}

.privacy-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--accent-success);
    color: white;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

.privacy-notice .privacy-icon {
    font-size: 1.5rem;
}

.privacy-notice p {
    font-size: 0.9rem;
}

.alert-message {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* ===== Loading ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
    
    .home-container {
        padding-top: 5vh;
    }
    
    .logo {
        font-size: 2rem;
    }
    
    .question-card {
        padding: 24px 16px;
    }
    
    .question-title {
        font-size: 1.1rem;
    }
    
    .type-code-large {
        font-size: 3rem;
    }
    
    .result-footer {
        gap: 12px;
    }
    
    .quick-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .type-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .view {
        padding: 16px;
    }
    
    .question-nav .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 24px 16px;
    }
}
