:root {
    --primary: #FF4444;
    --secondary: #4CAF50;
    --warning: #FFC107;
    --dark: #1a1a1a;
    --light: #f5f5f5;
    --gray: #666;
    --radius: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    overflow-x: hidden;
}

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

.screen.active {
    display: block;
    animation: slideIn 0.3s ease;
}

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

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px 0;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.tagline {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.stat-box {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.85em;
    color: var(--gray);
}

/* Buttons */
.primary-btn, .secondary-btn, .decide-btn, .danger-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.primary-btn {
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 20px rgba(255, 68, 68, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 68, 68, 0.5);
}

.primary-btn.pulse {
    animation: pulse 2s infinite;
}

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

.secondary-btn {
    background: white;
    color: var(--dark);
    border: 2px solid var(--dark);
}

.decide-btn {
    background: var(--secondary);
    color: white;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.decide-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.danger-btn {
    background: #ff5252;
    color: white;
}

.back-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Menu Grid */
.menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.menu-btn {
    background: white;
    border: none;
    padding: 30px 20px;
    border-radius: var(--radius);
    font-size: 1em;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

/* Importance Buttons */
.importance-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
}

.importance-btn {
    background: white;
    border: 3px solid transparent;
    padding: 25px;
    border-radius: var(--radius);
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.importance-btn:hover {
    transform: translateX(5px);
}

.importance-btn.low:hover {
    border-color: #4CAF50;
}

.importance-btn.medium:hover {
    border-color: #FFC107;
}

.importance-btn.high:hover {
    border-color: #FF4444;
}

.importance-icon {
    font-size: 2em;
    margin-bottom: 10px;
}

.importance-title {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 5px;
}

.importance-desc {
    color: var(--gray);
    margin-bottom: 10px;
}

.importance-time {
    font-size: 0.9em;
    color: var(--primary);
    font-weight: bold;
}

/* Timer */
.timer-container {
    text-align: center;
    margin: 30px 0;
}

.timer-circle {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 20px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-bg {
    fill: none;
    stroke: rgba(255,255,255,0.3);
    stroke-width: 8;
}

.timer-progress {
    fill: none;
    stroke: white;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5em;
    font-weight: bold;
    color: white;
}

.timer-toggle {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 10px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
}

/* Decision Input */
.decision-input {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.decision-input label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.decision-input input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
}

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

/* Framework Content */
#frameworkContent {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.framework-section {
    margin-bottom: 25px;
}

.framework-section h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

.pros-cons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.pros-cons-column h4 {
    margin-bottom: 10px;
}

.pros-cons-column textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
}

/* Clarity Questions */
.clarity-questions {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.clarity-questions h3 {
    margin-bottom: 15px;
}

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

.question-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--light);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.question-item:hover {
    background: #e0e0e0;
}

.question-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
}

/* Result Screen */
.result-animation {
    text-align: center;
    margin: 50px 0;
}

.checkmark {
    font-size: 5em;
    color: var(--secondary);
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.result-animation h2 {
    color: white;
    margin-top: 20px;
}

.result-summary {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 30px;
}

.result-actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
}

/* Journal */
.journal-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.journal-entry {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.journal-entry h3 {
    margin-bottom: 10px;
    color: var(--dark);
}

.journal-meta {
    font-size: 0.85em;
    color: var(--gray);
    margin-bottom: 10px;
}

.journal-decision {
    font-weight: bold;
    margin-bottom: 5px;
}

/* Practice */
.practice-challenge {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 20px;
}

.challenge-number {
    color: var(--gray);
    margin-bottom: 15px;
}

.practice-challenge h3 {
    font-size: 1.5em;
    margin-bottom: 25px;
    color: var(--dark);
}

.practice-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.practice-option {
    padding: 15px;
    background: var(--light);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.practice-option:hover {
    border-color: var(--primary);
    background: white;
}

.practice-timer {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary);
}

.practice-stats {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    text-align: center;
}

/* Stats */
.stats-detailed {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: var(--radius);
}

.stat-card h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

#speedChart {
    width: 100%;
    height: auto;
}

/* Settings */
.settings-group {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.settings-group h3 {
    margin-bottom: 15px;
    color: var(--primary);
}

.settings-group label {
    display: block;
    margin-bottom: 12px;
}

.settings-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-top: 10px;
}

/* Daily Budget stat box */
.stats-container {
    grid-template-columns: repeat(2, 1fr);
}

.budget-box { border-top: 3px solid #4CAF50; }
.budget-box.budget-warning { border-top-color: #FFC107; }
.budget-box.budget-warning .stat-number { color: #FFC107; }
.budget-box.budget-danger { border-top-color: #FF4444; }
.budget-box.budget-danger .stat-number { color: #FF4444; }

/* Confidence Rating */
.confidence-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    text-align: center;
}

.confidence-card h3 { margin-bottom: 6px; color: var(--dark); }

.confidence-sub {
    font-size: 0.85em;
    color: var(--gray);
    margin-bottom: 18px;
}

.confidence-stars {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}

.conf-star {
    font-size: 2em;
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.2s, transform 0.2s;
    padding: 4px;
}

.conf-star:hover,
.conf-star.active { opacity: 1; transform: scale(1.2); }

.confidence-label {
    font-size: 0.9em;
    color: var(--gray);
    min-height: 20px;
}

/* Weekly Review */
.weekly-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.weekly-stat {
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    padding: 16px 10px;
    text-align: center;
    color: white;
}

.weekly-stat span {
    display: block;
    font-size: 2em;
    font-weight: bold;
    line-height: 1;
}

.weekly-stat small {
    font-size: 0.75em;
    opacity: 0.85;
    margin-top: 4px;
    display: block;
}

.weekly-insight {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 0.9em;
    margin-bottom: 16px;
    font-weight: 500;
}

.weekly-insight.warning { background: rgba(255,193,7,0.2); color: #fff; border-left: 4px solid #FFC107; }
.weekly-insight.success { background: rgba(76,175,80,0.2); color: #fff; border-left: 4px solid #4CAF50; }

.weekly-empty {
    background: rgba(255,255,255,0.1);
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: white;
}

.weekly-empty p { margin-bottom: 8px; font-size: 1.1em; }

/* Dark mode additions */
body.dark .confidence-card { background: #1e1e2e; }
body.dark .confidence-card h3 { color: #e0e0e0; }
body.dark .confidence-label { color: #aaa; }

/* ===== HELP SCREEN ===== */
.help-btn { grid-column: span 2; background: linear-gradient(135deg, #667eea, #764ba2); color: white; font-weight: bold; }
body.dark .help-btn { background: linear-gradient(135deg, #3a3a6e, #4a2a6e); }

.help-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.help-tab {
    padding: 8px 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.help-tab:hover { background: rgba(255,255,255,0.2); }
.help-tab.active { background: white; color: #764ba2; border-color: white; }

.help-panel { display: none; }
.help-panel.active { display: block; animation: slideIn 0.25s ease; }

.help-intro {
    background: rgba(255,255,255,0.12);
    border-left: 4px solid rgba(255,255,255,0.5);
    padding: 14px 18px;
    border-radius: 0 10px 10px 0;
    color: white;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* Accordion */
.accordion { display: flex; flex-direction: column; gap: 10px; }

.acc-item { background: white; border-radius: 12px; overflow: hidden; }
body.dark .acc-item { background: #1e1e2e; }

.acc-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--dark);
    text-align: left;
    gap: 10px;
}

body.dark .acc-header { color: #e0e0e0; }

.acc-arrow {
    font-size: 0.75em;
    transition: transform 0.25s;
    flex-shrink: 0;
    opacity: 0.6;
}

.acc-item.open .acc-arrow { transform: rotate(180deg); }

.acc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, padding 0.25s;
    padding: 0 18px;
    font-size: 0.9em;
    line-height: 1.65;
    color: #444;
}

body.dark .acc-body { color: #ccc; }

.acc-item.open .acc-body {
    max-height: 600px;
    padding: 0 18px 18px;
}

.acc-tag {
    font-size: 0.7em;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    margin-left: 8px;
    vertical-align: middle;
}

.acc-tag.low  { background: #e8f5e9; color: #2e7d32; }
.acc-tag.medium { background: #fff8e1; color: #f57f17; }
.acc-tag.high { background: #ffebee; color: #c62828; }

.psych-tip {
    margin-top: 12px;
    padding: 10px 14px;
    background: #f0f4ff;
    border-radius: 8px;
    border-left: 3px solid #667eea;
    font-size: 0.88em;
    color: #333;
}

body.dark .psych-tip { background: #2a2a4e; color: #ccc; border-left-color: #667eea; }

/* Bias Grid */
.bias-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bias-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
}

body.dark .bias-card { background: #1e1e2e; }

.bias-icon { font-size: 1.8em; margin-bottom: 8px; }

.bias-card h4 {
    font-size: 0.9em;
    color: var(--primary);
    margin-bottom: 6px;
}

.bias-card p {
    font-size: 0.8em;
    color: #555;
    line-height: 1.5;
    margin-bottom: 10px;
}

body.dark .bias-card p { color: #bbb; }

.bias-counter {
    font-size: 0.78em;
    background: #f0f4ff;
    border-radius: 6px;
    padding: 8px 10px;
    color: #444;
    border-left: 3px solid #667eea;
}

body.dark .bias-counter { background: #2a2a4e; color: #ccc; }

/* Help list */
.help-list {
    margin: 10px 0 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9em;
}

.help-list li { line-height: 1.5; }

/* Habit Stack */
.habit-stack { display: flex; flex-direction: column; gap: 14px; }

.habit-card {
    background: white;
    border-radius: 12px;
    padding: 18px;
    border-top: 3px solid #667eea;
}

body.dark .habit-card { background: #1e1e2e; }

.habit-time {
    font-size: 0.78em;
    font-weight: 700;
    color: #764ba2;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.habit-card h4 {
    font-size: 1em;
    color: var(--dark);
    margin-bottom: 8px;
}

body.dark .habit-card h4 { color: #e0e0e0; }

.habit-card p {
    font-size: 0.88em;
    line-height: 1.6;
    color: #555;
    margin-bottom: 12px;
}

body.dark .habit-card p { color: #bbb; }

.habit-action {
    font-size: 0.83em;
    background: #f5f0ff;
    border-radius: 8px;
    padding: 10px 14px;
    color: #4a2a6e;
    border-left: 3px solid #764ba2;
    line-height: 1.5;
}

body.dark .habit-action { background: #2a1a3e; color: #c9a0ff; }

/* Responsive */
@media (max-width: 600px) {
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .menu-grid {
        grid-template-columns: 1fr;
    }
    
    .pros-cons-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons, .result-actions {
        grid-template-columns: 1fr;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1a1a1a;
    color: white;
    padding: 16px 28px;
    border-radius: 12px;
    font-size: 1em;
    font-weight: bold;
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90vw;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success { border-left: 4px solid #4CAF50; }
.toast.warning { border-left: 4px solid #FFC107; }
.toast.danger  { border-left: 4px solid #FF4444; }

/* Regret Score */
.regret-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.regret-stars {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.regret-star {
    background: none;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.regret-star:hover, .regret-star.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.outcome-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    margin-left: 8px;
}

.outcome-great  { background: #e8f5e9; color: #2e7d32; }
.outcome-ok     { background: #fff8e1; color: #f57f17; }
.outcome-regret { background: #ffebee; color: #c62828; }

/* Journal controls */
.journal-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.journal-controls input {
    flex: 1;
    min-width: 160px;
    padding: 10px 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.95em;
}

.journal-controls input::placeholder { color: rgba(255,255,255,0.7); }

.journal-controls select {
    padding: 10px 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.95em;
    cursor: pointer;
}

.journal-controls select option { background: #333; color: white; }

/* Quality Score */
.quality-score-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.quality-bar-track {
    flex: 1;
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.quality-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #FF4444, #FFC107, #4CAF50);
    border-radius: 5px;
    transition: width 0.6s ease;
}

.quality-label {
    font-size: 0.85em;
    color: var(--gray);
    min-width: 50px;
    text-align: right;
}

/* Dark Mode */
body.dark {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e0e0e0;
}

body.dark .stat-box,
body.dark .menu-btn,
body.dark .importance-btn,
body.dark #frameworkContent,
body.dark .clarity-questions,
body.dark .result-summary,
body.dark .journal-entry,
body.dark .practice-challenge,
body.dark .practice-stats,
body.dark .stat-card,
body.dark .settings-group,
body.dark .decision-input {
    background: #1e1e2e;
    color: #e0e0e0;
}

body.dark .stat-label,
body.dark .journal-meta { color: #aaa; }

body.dark .question-item { background: #2a2a3e; }
body.dark .question-item:hover { background: #333350; }

body.dark .practice-option { background: #2a2a3e; }
body.dark .practice-option:hover { background: #333350; border-color: var(--primary); }

body.dark .decision-input input,
body.dark .pros-cons-column textarea,
body.dark .settings-group select {
    background: #2a2a3e;
    border-color: #444;
    color: #e0e0e0;
}

body.dark .back-btn { background: rgba(255,255,255,0.15); color: white; }

body.dark .secondary-btn { background: #2a2a3e; color: #e0e0e0; border-color: #555; }

body.dark .regret-star { border-color: #555; color: #ccc; }
body.dark .quality-bar-track { background: #333; }

/* Subtitle */
.subtitle {
    text-align: center;
    color: rgba(255,255,255,0.9);
    margin-bottom: 20px;
    font-size: 1.1em;
}

h2 {
    color: white;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2em;
}