* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6C5CE7;
    --primary-dark: #5849c2;
    --primary-light: #a29bfe;
    --success: #00B894;
    --success-light: #e8f8f5;
    --error: #FF6B6B;
    --error-light: #ffe8e8;
    --warning: #FDCB6E;
    --bg: #F8F9FE;
    --card: #FFFFFF;
    --text: #2D3436;
    --text-light: #636E72;
    --border: #E0E0E0;
    --shadow: 0 4px 20px rgba(108, 92, 231, 0.15);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
    font-family: 'Nunito', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.app {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Screens */
.screen {
    display: none;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* Welcome Screen */
.welcome-content {
    text-align: center;
    padding: 60px 20px;
}

.logo {
    font-size: 64px;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.welcome-content h1 {
    font-size: 48px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.tagline {
    font-size: 20px;
    color: var(--text-light);
    margin-bottom: 24px;
    font-weight: 600;
}

.subtitle {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 40px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 0 var(--primary-dark);
    font-family: inherit;
}

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

.btn-primary:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--primary-dark);
}

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

.btn-full {
    width: 100%;
}

.btn-secondary {
    background: var(--card);
    color: var(--primary);
    border: 3px solid var(--primary);
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--bg);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-icon {
    font-size: 20px;
}

.loading-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

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

/* Loading states */
.loading-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.4; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

.loading-text {
    color: var(--text-light);
    font-style: italic;
}

.rubric-item.loading {
    opacity: 0.7;
}

/* Progress Bar */
.progress-bar {
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 6px;
    transition: width 0.4s ease;
}

.progress-text {
    text-align: center;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 24px;
}

/* Exercise Container */
.exercise-container {
    background: var(--card);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.exercise-type-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

.ai-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}

.ai-toggle input {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    position: relative;
    transition: background 0.2s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.ai-toggle input:checked + .toggle-slider {
    background: var(--success);
}

.ai-toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

.toggle-label {
    user-select: none;
}

/* Scenario Box */
.scenario-box {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
}

.scenario-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.scenario-text {
    font-size: 17px;
    line-height: 1.6;
    color: var(--text);
}

/* Prompt Input */
.prompt-section {
    margin-bottom: 24px;
    overflow: visible;
}

.prompt-label {
    display: block;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.prompt-input {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-family: inherit;
    border: 3px solid var(--border);
    border-radius: 16px;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.2s ease;
    line-height: 1.5;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
}

.prompt-input::placeholder {
    color: #aaa;
}

.char-count {
    text-align: right;
    font-size: 13px;
    color: var(--text-light);
    margin-top: 8px;
    font-weight: 600;
    transition: color 0.2s ease;
    position: relative;
}

.char-count.near-limit {
    color: var(--warning);
}

.char-count.at-limit {
    color: var(--error);
}

.char-limit-hover {
    cursor: help;
    border-bottom: 1px dashed var(--text-light);
}

.char-limit-hover:hover {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.info-tooltip {
    display: none;
    position: absolute;
    top: 28px;
    right: 0;
    background: #2D3436;
    color: #fff;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    width: 260px;
    text-align: left;
    line-height: 1.5;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.info-tooltip.visible {
    display: block;
}

/* Feedback Screen */
.feedback-container {
    padding: 10px 0;
}

.feedback-header {
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 24px;
    color: var(--primary);
}

.your-prompt-box {
    background: var(--bg);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 28px;
}

.prompt-box-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 8px;
}

.prompt-box-text {
    font-size: 15px;
    color: var(--text);
    font-style: italic;
}

/* Rubric Section */
.rubric-section {
    margin-bottom: 28px;
}

.rubric-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.rubric-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rubric-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--card);
    border-radius: 12px;
    border: 2px solid var(--border);
    font-size: 15px;
}

.rubric-check {
    font-size: 18px;
    flex-shrink: 0;
}

/* Examples Section */
.examples-section {
    margin-bottom: 28px;
}

.examples-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.example-box {
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 12px;
}

.example-box.lazy {
    background: #fff8f0;
    border: 2px solid #e0c9a8;
}

.example-box.ai-feedback {
    background: #f0f7ff;
    border: 2px solid #a8c9e0;
    position: relative;
}

.ai-disclaimer {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 20px;
    height: 20px;
    background: #a8c9e0;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ai-disclaimer:hover + .ai-disclaimer-tooltip,
.ai-disclaimer-tooltip:hover {
    display: block;
}

.ai-disclaimer-tooltip {
    display: none;
    position: absolute;
    top: 38px;
    right: 0;
    background: var(--text);
    color: white;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    width: 260px;
    line-height: 1.5;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.ai-disclaimer-tooltip a {
    color: #a8d4ff;
    text-decoration: underline;
    cursor: pointer;
}

/* Settings Modal */
.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background: white;
    border-radius: 20px;
    padding: 28px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow);
}

.settings-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-option:hover {
    border-color: var(--primary-light);
}

.settings-option.selected {
    border-color: var(--primary);
    background: #f5f3ff;
}

.settings-option input {
    display: none;
}

.option-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-option.selected .option-radio {
    border-color: var(--primary);
}

.settings-option.selected .option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.option-text {
    flex: 1;
}

.option-label {
    font-weight: 700;
    font-size: 15px;
}

.option-desc {
    font-size: 13px;
    color: var(--text-light);
}

.settings-close {
    width: 100%;
    margin-top: 16px;
}

.example-box.sharp {
    background: var(--success-light);
    border: 2px solid var(--success);
}

.example-label {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.example-text {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 8px;
    font-style: italic;
}

.example-why {
    font-size: 13px;
    color: var(--text-light);
}

/* Self Rate Section */
.self-rate-section {
    text-align: center;
    padding-top: 8px;
}

.rate-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
}

.rate-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.rate-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    background: var(--card);
    border: 3px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 90px;
}

.rate-btn:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.rate-emoji {
    font-size: 28px;
}

.rate-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
}

.try-again-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 2px solid var(--border);
    text-align: center;
}

/* Insight Screen */
.insight-container {
    text-align: center;
    padding: 40px 20px;
}

.insight-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: pop 0.4s ease;
}

@keyframes pop {
    0% { transform: scale(0); }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.insight-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text);
}

.insight-text {
    font-size: 16px;
    color: var(--text-light);
    margin-bottom: 28px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.key-principle {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 32px;
    text-align: left;
}

.principle-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 8px;
}

.principle-text {
    font-size: 16px;
    color: var(--text);
    font-weight: 600;
}

/* Complete Screen */
.complete-content {
    text-align: center;
    padding: 50px 20px;
}

.complete-icon {
    font-size: 72px;
    margin-bottom: 20px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.complete-content h1 {
    font-size: 32px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 28px;
}

.stats-grid {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--card);
    border-radius: 16px;
    padding: 20px 28px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 600;
}

.complete-message {
    color: var(--text-light);
    font-size: 16px;
    margin-bottom: 32px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* Responsive */
@media (max-width: 480px) {
    .app {
        padding: 16px;
    }
    
    .welcome-content h1 {
        font-size: 36px;
    }
    
    .exercise-container {
        padding: 20px;
    }
    
    .scenario-text {
        font-size: 15px;
    }
    
    .rate-buttons {
        flex-wrap: wrap;
    }
    
    .rate-btn {
        flex: 1;
        min-width: 80px;
    }
    
    .stats-grid {
        flex-direction: column;
    }
}
