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

:root {
    --primary: #D4541E;
    --primary-dark: #B8441A;
    --primary-light: #FFF3EE;
    --primary-bg: #FDE8DE;
    --text-dark: #1A1A2E;
    --text-medium: #4A4A68;
    --text-light: #8E8EA0;
    --bg: #F7F7F8;
    --card: #FFFFFF;
    --border: #E5E5E5;
    --success: #2ECC71;
    --success-bg: #E8F8F0;
    --info: #3498DB;
    --info-bg: #EBF5FB;
    --warning: #F39C12;
    --warning-bg: #FEF5E7;
    --danger: #E74C3C;
    --danger-bg: #FDEDEC;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --transition: all 0.25s ease;
    --max-width: 820px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }

/* ===== HEADER ===== */
.header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px); }
.header .container { display: flex; align-items: center; justify-content: space-between; padding-top: 0.75rem; padding-bottom: 0.75rem; gap: 1rem; }
.header-brand { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.header-brand:hover .logo { transform: scale(1.05); }
.logo { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.25rem; transition: var(--transition); }
.header h1 { font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.subtitle { font-size: 0.75rem; color: var(--text-light); font-weight: 400; }
.header-nav { display: flex; gap: 0.25rem; }
.nav-btn { background: none; border: none; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--text-medium); cursor: pointer; transition: var(--transition); font-family: inherit; }
.nav-btn:hover { background: var(--primary-light); color: var(--primary); }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.625rem 1.25rem; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600; border: none; cursor: pointer; transition: var(--transition); font-family: inherit; white-space: nowrap; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 2px 8px rgba(212,84,30,0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(212,84,30,0.4); }
.btn-secondary { background: var(--card); color: var(--text-medium); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); color: var(--text-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-lg { padding: 0.875rem 2rem; font-size: 1rem; border-radius: var(--radius); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

/* ===== WELCOME ===== */
.section-welcome { padding: 4rem 0 3rem; }
.welcome-hero { text-align: center; }
.welcome-badge { display: inline-block; background: var(--primary-light); color: var(--primary); padding: 0.375rem 1rem; border-radius: 2rem; font-size: 0.8rem; font-weight: 600; margin-bottom: 1.5rem; }
.welcome-hero h2 { font-size: 2rem; font-weight: 800; line-height: 1.3; margin-bottom: 1rem; }
.welcome-desc { font-size: 1.05rem; color: var(--text-medium); max-width: 600px; margin: 0 auto 2.5rem; line-height: 1.8; }
.welcome-features { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.25rem; margin-bottom: 2.5rem; }
.feature-card { background: var(--card); padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; transition: var(--transition); }
.feature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.feature-icon { width: 44px; height: 44px; background: var(--primary-light); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; margin: 0 auto 0.75rem; }
.feature-card h3 { font-size: 1rem; margin-bottom: 0.375rem; }
.feature-card p { font-size: 0.85rem; color: var(--text-light); line-height: 1.5; }

/* ===== STEPPER ===== */
.stepper { margin: 2rem 0; position: relative; }
.stepper-track { position: absolute; top: 18px; left: 40px; right: 40px; height: 3px; background: var(--border); border-radius: 2px; z-index: 0; }
.stepper-progress { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.4s ease; width: 0%; }
.stepper-steps { display: flex; justify-content: space-between; position: relative; z-index: 1; }
.step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; background: none; border: none; cursor: pointer; font-family: inherit; transition: var(--transition); }
.step-num { width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 2.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem; color: var(--text-light); transition: var(--transition); }
.step.active .step-num, .step.completed .step-num { background: var(--primary); border-color: var(--primary); color: white; }
.step.completed .step-num { background: var(--success); border-color: var(--success); }
.step-label { font-size: 0.75rem; color: var(--text-light); font-weight: 500; transition: var(--transition); }
.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.completed .step-label { color: var(--success); }

/* ===== CARDS ===== */
.card { background: var(--card); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
.card-desc { color: var(--text-medium); margin-bottom: 1.5rem; font-size: 0.95rem; }

/* ===== FORM ELEMENTS ===== */
.input-textarea, .input-text, .input-select {
    width: 100%; padding: 0.75rem 1rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-size: 0.9rem; font-family: inherit; line-height: 1.6; transition: var(--transition); background: var(--bg); color: var(--text-dark);
}
.input-textarea { resize: vertical; }
.input-text { padding: 0.5rem 0.75rem; font-size: 0.85rem; }
.input-select { padding: 0.5rem 0.75rem; font-size: 0.85rem; cursor: pointer; }
.input-textarea:focus, .input-text:focus, .input-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(212,84,30,0.1); background: var(--card); }
.input-textarea::placeholder, .input-text::placeholder { color: var(--text-light); }

/* ===== SUB-QUESTIONS (Step 0) ===== */
.sub-q-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.sub-q-item label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-medium); margin-bottom: 0.25rem; }

/* ===== FRAMEWORK BLOCKS (Step 1) ===== */
.framework-block { margin-bottom: 1.25rem; padding: 1.25rem; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.framework-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.framework-badge { padding: 0.25rem 0.75rem; border-radius: 2rem; font-size: 0.8rem; font-weight: 700; }
.badge-blue { background: var(--info-bg); color: var(--info); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.framework-en { font-size: 0.75rem; color: var(--text-light); }

.framework-hints { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.625rem; }
.framework-hints span { font-size: 0.75rem; color: var(--text-light); background: var(--card); padding: 0.2rem 0.6rem; border-radius: 2rem; border: 1px solid var(--border); }

/* ===== VALIDATION ===== */
.validation-box { background: var(--primary-light); border: 1.5px dashed var(--primary); padding: 1.25rem; border-radius: var(--radius-sm); margin-top: 0.5rem; }
.validation-box h4 { color: var(--primary); font-size: 0.9rem; margin-bottom: 0.5rem; }
.validation-box p { font-size: 0.88rem; color: var(--text-medium); margin-bottom: 0.5rem; }
.validation-hint { font-size: 0.8rem !important; color: var(--text-light) !important; font-style: italic; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--primary-dark); }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ===== STEP NAV ===== */
.step-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.step-content { display: none; animation: fadeIn 0.3s ease; }
.step-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== HABITS ===== */
.habits-recommended { margin-bottom: 1.5rem; }
.habits-recommended h3 { font-size: 1rem; margin-bottom: 0.75rem; color: var(--primary); }
.habit-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.habit-chip { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.5rem 0.875rem; border-radius: 2rem; font-size: 0.85rem; cursor: pointer; transition: var(--transition); border: 1.5px solid var(--border); background: var(--card); color: var(--text-medium); font-family: inherit; }
.habit-chip:hover { border-color: var(--primary); color: var(--primary); }
.habit-chip.selected { background: var(--primary); border-color: var(--primary); color: white; }
.habit-chip .chip-check { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; flex-shrink: 0; }
.habit-chip.selected .chip-check { background: white; color: var(--primary); border-color: white; }

.habits-all-toggle { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.habits-all-toggle summary { padding: 0.875rem 1.25rem; cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text-medium); background: var(--bg); transition: var(--transition); }
.habits-all-toggle summary:hover { color: var(--primary); }
.habits-all { padding: 1.25rem; }
.habit-category { margin-bottom: 1.5rem; }
.habit-category:last-child { margin-bottom: 0; }
.habit-category-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border); }
.habit-category-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; color: white; flex-shrink: 0; }
.cat-critical .habit-category-icon { background: var(--info); }
.cat-creative .habit-category-icon { background: var(--success); }
.cat-communication .habit-category-icon { background: var(--warning); }
.cat-interaction .habit-category-icon { background: var(--primary); }
.habit-category-header h4 { font-size: 0.95rem; }
.habit-subcategory { margin-bottom: 0.75rem; }
.habit-subcategory h5 { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.375rem; padding-left: 0.25rem; }

/* ===== SPEC & PROMPT OUTPUT ===== */
.spec-output { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1.5rem; margin-bottom: 1rem; font-size: 0.88rem; line-height: 1.8; white-space: pre-wrap; font-family: 'SFMono-Regular','Consolas','Microsoft JhengHei',monospace; }
.prompt-output { background: #1A1A2E; color: #E8E8E8; border-radius: var(--radius-sm); padding: 1.5rem; margin-bottom: 1rem; font-size: 0.83rem; line-height: 1.7; white-space: pre-wrap; font-family: 'SFMono-Regular','Consolas','Microsoft JhengHei',monospace; max-height: 500px; overflow-y: auto; }
.prompt-actions { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }
.copy-toast { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--success); color: white; padding: 0.75rem 1.5rem; border-radius: 2rem; font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow-lg); transition: transform 0.3s ease; z-index: 1000; }
.copy-toast.show { transform: translateX(-50%) translateY(0); }

/* ===== USAGE TIPS ===== */
.usage-tips { background: var(--bg); border-radius: var(--radius-sm); padding: 1.25rem; }
.usage-tips h4 { font-size: 0.9rem; margin-bottom: 0.75rem; color: var(--text-medium); }
.usage-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.usage-item { padding: 0.75rem; background: var(--card); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.usage-item strong { font-size: 0.85rem; display: block; margin-bottom: 0.25rem; }
.usage-item p { font-size: 0.8rem; color: var(--text-light); }

/* ===== REFERENCE ===== */
.section-reference, .section-about { padding: 2rem 0 3rem; }
.section-title { font-size: 1.5rem; margin-bottom: 0.5rem; }
.section-desc { color: var(--text-medium); margin-bottom: 2rem; font-size: 0.95rem; }
.reference-categories { display: flex; flex-direction: column; gap: 1.5rem; }
.ref-category { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ref-category-header { padding: 1.25rem 1.5rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: var(--transition); }
.ref-category-header:hover { background: var(--bg); }
.ref-category-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; color: white; flex-shrink: 0; }
.ref-cat-0 .ref-category-icon { background: var(--info); }
.ref-cat-1 .ref-category-icon { background: var(--success); }
.ref-cat-2 .ref-category-icon { background: var(--warning); }
.ref-cat-3 .ref-category-icon { background: var(--primary); }
.ref-category-header h3 { font-size: 1.05rem; flex: 1; }
.ref-category-header .ref-count { font-size: 0.8rem; color: var(--text-light); background: var(--bg); padding: 0.25rem 0.625rem; border-radius: 2rem; }
.ref-category-body { padding: 0 1.5rem 1.5rem; }
.ref-subcategory { margin-bottom: 1rem; }
.ref-subcategory:last-child { margin-bottom: 0; }
.ref-subcategory h4 { font-size: 0.85rem; color: var(--text-light); margin-bottom: 0.5rem; padding-left: 0.25rem; letter-spacing: 0.5px; }

/* Clickable habit cards in reference */
.ref-habit { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; border-radius: var(--radius-sm); transition: var(--transition); cursor: pointer; border: 1.5px solid transparent; }
.ref-habit:hover { background: var(--primary-light); border-color: var(--primary); }
.ref-habit-name { font-weight: 600; font-size: 0.9rem; min-width: 110px; flex-shrink: 0; color: var(--text-dark); }
.ref-habit-desc { font-size: 0.83rem; color: var(--text-medium); line-height: 1.5; flex: 1; }
.ref-habit-arrow { color: var(--primary); font-size: 1.1rem; opacity: 0; transition: var(--transition); flex-shrink: 0; }
.ref-habit:hover .ref-habit-arrow { opacity: 1; transform: translateX(2px); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; align-items: center; justify-content: center; padding: 1.5rem; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; animation: fadeIn 0.2s ease; }
.modal { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); position: relative; }
.modal-close { position: absolute; top: 0.75rem; right: 0.75rem; background: none; border: none; font-size: 1.5rem; color: var(--text-light); cursor: pointer; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: var(--transition); z-index: 1; }
.modal-close:hover { background: var(--bg); color: var(--text-dark); }

.modal-header { padding: 1.5rem 1.5rem 0; }
.modal-header .modal-badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 2rem; font-size: 0.7rem; font-weight: 700; margin-bottom: 0.5rem; }
.modal-header h2 { font-size: 1.3rem; margin-bottom: 0.125rem; }
.modal-header .modal-name-en { font-size: 0.8rem; color: var(--text-light); margin-bottom: 0.5rem; }
.modal-header .modal-desc { font-size: 0.9rem; color: var(--text-medium); line-height: 1.6; }

.modal-body { padding: 1.25rem 1.5rem; }
.modal-section { margin-bottom: 1.25rem; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h3 { font-size: 0.9rem; color: var(--primary); margin-bottom: 0.625rem; padding-bottom: 0.375rem; border-bottom: 1px solid var(--border); }

.modal-steps { list-style: none; counter-reset: step-counter; }
.modal-steps li { counter-increment: step-counter; padding: 0.375rem 0 0.375rem 2rem; position: relative; font-size: 0.85rem; color: var(--text-medium); line-height: 1.5; }
.modal-steps li::before { content: counter(step-counter); position: absolute; left: 0; top: 0.375rem; width: 22px; height: 22px; background: var(--primary-light); color: var(--primary); border-radius: 50%; font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.modal-question { margin-bottom: 0.75rem; }
.modal-question label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-dark); margin-bottom: 0.25rem; }
.modal-question .input-textarea, .modal-question .input-text { font-size: 0.85rem; }

.modal-output { background: #1A1A2E; color: #E8E8E8; border-radius: var(--radius-sm); padding: 1.25rem; font-size: 0.8rem; line-height: 1.7; white-space: pre-wrap; font-family: 'SFMono-Regular','Consolas','Microsoft JhengHei',monospace; max-height: 300px; overflow-y: auto; margin-bottom: 0.75rem; display: none; }
.modal-output.visible { display: block; }

.modal-footer { padding: 0 1.5rem 1.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ===== ABOUT ===== */
.about-card { background: var(--card); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.about-card h3 { font-size: 1.05rem; margin-bottom: 0.625rem; color: var(--primary); }
.about-card p { font-size: 0.9rem; color: var(--text-medium); margin-bottom: 0.5rem; }
.about-card ul { list-style: none; padding-left: 0; }
.about-card li { padding: 0.25rem 0; font-size: 0.9rem; color: var(--text-medium); }
.about-card li::before { content: ">"; color: var(--primary); font-weight: 700; margin-right: 0.5rem; }

/* ===== FOOTER ===== */
.footer { text-align: center; padding: 2rem 0; color: var(--text-light); font-size: 0.8rem; border-top: 1px solid var(--border); margin-top: 2rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header .container { flex-direction: column; gap: 0.5rem; }
    .header-nav { width: 100%; justify-content: center; }
    .welcome-hero h2 { font-size: 1.5rem; }
    .welcome-features { grid-template-columns: 1fr; gap: 0.75rem; }
    .sub-q-grid { grid-template-columns: 1fr; }
    .sub-prompt-row { grid-template-columns: 1fr; }
    .stepper-steps { gap: 0; }
    .step-label { font-size: 0.65rem; }
    .step-num { width: 30px; height: 30px; font-size: 0.75rem; }
    .card { padding: 1.25rem; }
    .usage-grid { grid-template-columns: 1fr; }
    .prompt-actions { flex-direction: column; }
    .modal { max-height: 95vh; margin: 0.5rem; }
    .ref-habit-name { min-width: 80px; }
}
@media (max-width: 480px) {
    .stepper-track { display: none; }
    .step-label { display: none; }
    .stepper-steps { justify-content: center; gap: 0.5rem; }
}
