/* =====================================================
   銝剛晓摮血�霂閗扇敹�頂蝏� - �唬葉撘䙛瑟偌憓函��誯��� (TCM Zen)
   ===================================================== */

:root {
    /* --- 瘞游◢�脫踎 --- */
    /* �峕艶嚗𡁜恐蝥� */
    --bg-paper: #f4f0e6;
    --bg-card: #fcfaf2;
    /* �港漁��爾撘㰘𠧧 */
    --bg-texture: radial-gradient(#d0c8b0 1px, transparent 0);
    /* 璅⊥��曹���捶��爾�� */

    /* 憓刻𠧧嚗𡁏�摮� */
    --ink-dark: #2b2b2b;
    /* 瘚枏◢ */
    --ink-medium: #4a4a4a;
    /* 銝剖◢ */
    --ink-light: #888888;
    /* 瘛∪◢ */

    /* �梁�嚗𡁻���/鈭支� */
    --cinnabar: #b83b3b;
    /* �梁�蝥� */
    --cinnabar-light: #d65c5c;
    --cinnabar-dark: #8f2a2a;

    /* 蝡寥�嚗𡁏���/�𣂼� */
    --bamboo: #4e6e44;
    --bamboo-light: #6b8f60;

    /* 颲�𨭌�� */
    --ochre: #d99f2e;
    /* �日� (L2) */
    --indigo: #4a5c6e;
    /* 暺𥡝� (L3/L4) */

    /* 撅�漣�� (撖孵�銋见�����賡�餉�) */
    --l1-color: var(--cinnabar);
    --l2-color: var(--ochre);
    --l3-color: var(--bamboo);
    --l4-color: var(--indigo);

    /* 颲寞� */
    --border-ink: #d4d0c2;

    /* 摮𦯀�隡睃� */
    /* ���摮𦯀�嚗帋���扑雿�/銋行�雿� */
    --font-heading: "Ma Shan Zheng", "Kaiti SC", "STKaiti", "KaiTi", "璆瑚�", "BiauKai", serif;
    /* 甇��摮𦯀�嚗帋������捶摰衤�嚗諹�屸��桅�𡁶�摰衤� */
    --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", "摰衤�", serif;
    /* 憭�鍂暺睲�嚗𡁶鍂鈭擧㺭摮埈�UI��� */
    --font-sans: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;

    /* �渲�銝𤾸�閫� */
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --padding-card: 32px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* 游蔣 - 𥪜 */
    --shadow-paper: 0 4px 12px rgba(45, 45, 40, 0.08);
    --shadow-float: 0 8px 24px rgba(45, 45, 40, 0.12);
}

/* =====================================================
   深色模式 (Dark Mode) - 黑金风格
   ===================================================== */
[data-theme="dark"] {
    /* 背景：深沉的炭黑/深蓝灰 */
    --bg-paper: #1a1a1a;
    --bg-card: #252525;

    /* 文字：柔和的米白 */
    --ink-dark: #f0f0f0;
    --ink-medium: #cccccc;
    --ink-light: #999999;

    /* 强调色：调亮一点以适应黑底 */
    --cinnabar: #ef9a9a;
    /* 浅红 */
    --cinnabar-light: #ffcdd2;
    --cinnabar-dark: #b71c1c;

    --bamboo: #a5d6a7;
    /* 浅绿 */
    --bamboo-light: #c8e6c9;

    --ochre: #ffe082;
    /* 浅金 */

    --indigo: #90caf9;
    /* 浅蓝 */

    /* 边框 */
    --border-ink: #444;

    /* 阴影：改用纯黑 */
    --shadow-paper: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* 深色模式下的特殊覆盖 */
[data-theme="dark"] body {
    background: linear-gradient(145deg, #1a1a1a 0%, #222 50%, #1a1a1a 100%);
}

[data-theme="dark"] .flashcard {
    background: #2a2a2a;
    border: 1px solid #333;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .flashcard-front,
[data-theme="dark"] .flashcard-back {
    background-color: #2a2a2a;
    background-image: none;
    /* 去掉浅色的纸张纹理 */
}

[data-theme="dark"] .flashcard-herb-name {
    color: #f0f0f0;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .flashcard-effects {
    color: #ff8a80;
    /* 荧光红，更醒目 */
}

[data-theme="dark"] .flashcard-supplements {
    color: #aaa;
    border-top-color: #444;
}

[data-theme="dark"] .flashcard-controls {
    background: rgba(40, 40, 40, 0.8);
    border: 1px solid #444;
}

[data-theme="dark"] .nav-bar {
    background: rgba(30, 30, 30, 0.8) !important;
    border-top: 1px solid #333;
}

[data-theme="dark"] .nav-btn {
    color: #888;
}

[data-theme="dark"] .nav-btn.active {
    color: #ffcc80;
    /* 金色高亮 */
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .study-header {
    background: rgba(30, 30, 30, 0.8);
    border-bottom: 1px solid #333;
}

[data-theme="dark"] select {
    background-color: #333;
    color: #eee;
    border-color: #555;
}

[data-theme="dark"] .custom-select-trigger {
    background-color: #333;
    color: #eee;
    border-color: #555;
}

[data-theme="dark"] .custom-select-options {
    background-color: #333;
    border-color: #555;
}

[data-theme="dark"] .custom-select-option {
    color: #eee;
}

[data-theme="dark"] .custom-select-option:hover,
[data-theme="dark"] .custom-select-option.selected {
    background-color: #444;
}

[data-theme="dark"] .app-container {
    background-color: #1a1a1a;
}

/* ========== 逻辑模拟器夜间模式 ========== */

[data-theme="dark"] .im-home {
    color: #ddd;
}

[data-theme="dark"] .im-home h1 {
    color: #e0e0e0;
}

[data-theme="dark"] .im-home p {
    color: #aaa;
}

[data-theme="dark"] .category-section {
    border-color: #444;
}

[data-theme="dark"] .category-header {
    background: #2a2a2a;
}

[data-theme="dark"] .category-header:hover {
    background: #333;
}

[data-theme="dark"] .category-title {
    color: #64b5f6;
}

[data-theme="dark"] .category-toggle {
    color: #888;
}

[data-theme="dark"] .category-content {
    background: #1e1e1e;
}

[data-theme="dark"] .disease-card {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .disease-card:hover {
    background: #333;
    border-color: #555;
}

[data-theme="dark"] .disease-card .disease-name {
    color: #ddd;
}

[data-theme="dark"] .btn-back {
    background: #333;
    border-color: #555;
    color: #ccc;
}

[data-theme="dark"] .btn-back:hover {
    background: #444;
    color: #fff;
}

/* 逻辑模拟器答题卡 */
[data-theme="dark"] .answer-sheet {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .answer-sheet.paper-texture {
    background-image: none;
}

[data-theme="dark"] .sheet-header h2 {
    color: #e0e0e0;
}

[data-theme="dark"] .sheet-row label,
[data-theme="dark"] .sheet-section label {
    color: #aaa;
}

[data-theme="dark"] .sheet-row .handwriting,
[data-theme="dark"] .sheet-section .handwriting {
    color: #ddd;
}

[data-theme="dark"] .highlight-red {
    color: #ff8a80;
}

[data-theme="dark"] .hidden-content {
    color: #ccc;
}

[data-theme="dark"] .btn-home {
    background: #333;
    border-color: #555;
    color: #ccc;
}

[data-theme="dark"] .btn-home:hover {
    background: #444;
}

/* 逻辑模拟器步骤页面 */
[data-theme="dark"] .step-container {
    color: #ddd;
}

[data-theme="dark"] .case-card {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .case-card h3 {
    color: #e0e0e0;
}

[data-theme="dark"] .case-card .highlight {
    color: #ff8a80;
}

[data-theme="dark"] .btn-option {
    background: #2a2a2a;
    border-color: #444;
    color: #ddd;
}

[data-theme="dark"] .btn-option:hover {
    background: #333;
    border-color: #555;
}

[data-theme="dark"] .btn-option.correct {
    background: #1b5e20;
    border-color: #2e7d32;
    color: #a5d6a7;
}

[data-theme="dark"] .btn-option.wrong {
    background: #b71c1c;
    border-color: #c62828;
    color: #ef9a9a;
}

[data-theme="dark"] .tag-cloud .tag {
    background: #333;
    border-color: #555;
    color: #ccc;
}

[data-theme="dark"] .tag-cloud .tag.selected {
    background: #1e3a5f;
    border-color: #64b5f6;
    color: #64b5f6;
}

[data-theme="dark"] .card-flip-container .card-front,
[data-theme="dark"] .card-flip-container .card-back {
    background: #2a2a2a;
    border-color: #444;
    color: #ddd;
}

[data-theme="dark"] .btn-next {
    background: #1976d2;
    color: #fff;
}

/* =====================================================
   箇霈曉
   ===================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-serif);
    /* 高级渐变背景 - 温暖中药房感觉 */
    background: linear-gradient(145deg, #fef9f3 0%, #f8f0e6 50%, #f3e8db 100%);
    background-attachment: fixed;
    color: var(--ink-dark);
    line-height: 1.7;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

html {
    overflow-x: hidden;
}



/* �典����摮𦯀�霈曉�嚗帋蝙�冽扑雿�/銋行�雿� */
h1,
h2,
h3,
h4,
h5,
h6,
.app-title,
.browse-unit,
.herb-name,
.flashcard-herb-name,
.mobile-unit-title,
#quiz-question {
    font-family: var(--font-heading) !important;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
}

.app-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* =====================================================
   憭湧� - 銋行�憌擧聢
   ===================================================== */
.app-header {
    text-align: center;
    padding: 30px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-ink);
    position: relative;
}

.app-header h1 {
    font-family: var(--font-serif);
    font-size: 2.4rem;
    font-weight: bold;
    color: var(--ink-dark);
    letter-spacing: 2px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.05);
}

/* 餈𥕦漲�航��碶貌銵函� */
.progress-dashboard {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin: 20px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 12px;
    flex-wrap: wrap;
}

/* 餈𥕦漲�� */
.progress-ring-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--bamboo);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 251.2;
    /* 2 * PI * 40 */
    stroke-dashoffset: 251.2;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-percent {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--ink-dark);
}

.progress-label {
    display: block;
    font-size: 0.75rem;
    color: var(--ink-light);
}

/* 隞𦠜𠯫蝏蠘恣 */
.today-stats {
    display: flex;
    gap: 30px;
}

.today-stat {
    text-align: center;
    padding: 10px 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    min-width: 80px;
}

.today-stat .stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--cinnabar);
}

.today-stat .stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--ink-light);
    margin-top: 5px;
}

.header-stats {
    font-family: var(--font-serif);
    color: var(--ink-medium);
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 1rem;
}

.stat {
    position: relative;
    padding: 0 10px;
}

.stat::after {
    content: "|";
    position: absolute;
    right: -20px;
    color: var(--border-ink);
    opacity: 0.5;
}

.stat:last-child::after {
    content: none;
}

/* =====================================================
   撖潸⏛ - 蝑暹辺憌擧聢
   ===================================================== */
.main-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    padding: 8px 25px;
    background: transparent;
    border: 1px solid var(--border-ink);
    border-radius: 40px;
    /* �嗅�敶� */
    color: var(--ink-medium);
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.nav-btn.active {
    background: var(--cinnabar);
    color: #fff;
    border-color: var(--cinnabar);
    box-shadow: 0 4px 10px rgba(184, 59, 59, 0.3);
}

/* =====================================================
   �𡁶鍂 - 閫�㦛摰孵膥
   ===================================================== */
.content-area {
    flex: 1;
    position: relative;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: slowFadeIn 0.6s ease;
}

.hidden {
    display: none !important;
}

@keyframes slowFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =====================================================
   蝏�辣 - �∠� (摰�爾韐冽�)
   ===================================================== */
.study-card {
    background: var(--bg-card);
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-sm);
    /* 敺桀�閫𡜐��游�蝥� */
    padding: 40px;
    box-shadow: var(--shadow-paper);
    position: relative;
    margin-bottom: 30px;
}

/* 鋆�弘嚗𡁜㨃���閫垍�蝥Ｘ�蝥� */
.study-card::before,
.study-card::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--cinnabar);
    opacity: 0.3;
    pointer-events: none;
}

.study-card::before {
    top: 10px;
    left: 10px;
    border-right: 0;
    border-bottom: 0;
}

.study-card::after {
    bottom: 10px;
    right: 10px;
    border-left: 0;
    border-top: 0;
}

/* 憭湧�靽⊥� */
.card-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 1px dashed var(--border-ink);
    padding-bottom: 20px;
}

.herb-name {
    display: block;
    font-family: var(--font-serif);
    font-size: 3rem;
    color: var(--ink-dark);
    margin-bottom: 10px;
}

.herb-category {
    font-size: 0.95rem;
    color: var(--ink-light);
    letter-spacing: 1px;
}

/* =====================================================
   蝏�辣 - ��捆�瑕�
   ===================================================== */
/* 摮虫��鞟內 */
.hint-text {
    text-align: center;
    font-size: 1.2rem;
    color: var(--ink-medium);
    margin: 40px 0;
    font-family: var(--font-serif);
}

/* �厰★�厰僼 */
.options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.option-btn {
    padding: 15px 20px;
    background: #fff;
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-sm);
    text-align: left;
    font-size: 1rem;
    color: var(--ink-dark);
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: var(--cinnabar);
    background-color: #fffbfb;
}

.option-btn.correct {
    background-color: rgba(78, 110, 68, 0.1);
    border-color: var(--bamboo);
    color: var(--bamboo);
}

.option-btn.incorrect {
    background-color: rgba(184, 59, 59, 0.1);
    border-color: var(--cinnabar);
    color: var(--cinnabar);
}

/* �嗆挾 2: 蝑娍�撅閧內�� */
.standard-answer {
    margin-top: 20px;
}

.layer {
    padding: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-left: 4px solid var(--border-ink);
    margin-bottom: 15px;
}

.layer.l1 {
    border-left-color: var(--cinnabar);
}

.layer.l2 {
    border-left-color: var(--ochre);
}

.layer.l3 {
    border-left-color: var(--bamboo);
}

.layer.l4 {
    border-left-color: var(--indigo);
}

.layer-label {
    font-family: var(--font-serif);
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--ink-light);
}

.layer-content {
    font-size: 1.1rem;
    line-height: 1.7;
    font-weight: 500;
}

/* �嗆挾 3: 颲枏��� */
#user-output {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    background: #fff;
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    margin-bottom: 15px;
    outline: none;
}

#user-output:focus {
    border-color: var(--cinnabar);
}

.output-result {
    margin-top: 15px;
    padding: 15px;
    background: #fdfdfd;
    border: 1px solid var(--border-ink);
}

.diff-expected {
    color: var(--bamboo);
    font-weight: bold;
}

.diff-user {
    color: var(--cinnabar);
    text-decoration: line-through;
}

/* =====================================================
   �厰僼 - �啁�憌擧聢
   ===================================================== */
.btn {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    padding: 10px 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 1px;
}

.btn-primary,
.btn-submit,
.btn-next,
.btn-start,
.btn-confirm {
    background: var(--cinnabar);
    color: #fff;
    box-shadow: 0 4px 10px rgba(184, 59, 59, 0.2);
}

.btn:hover {
    transform: translateY(-1px);
    background: var(--cinnabar-light);
    box-shadow: 0 6px 14px rgba(184, 59, 59, 0.3);
}

.btn-skip {
    background: transparent;
    color: var(--ink-light);
    border: 1px solid transparent;
}

.btn-skip:hover {
    color: var(--ink-medium);
    border-color: var(--border-ink);
}

/* 銝𧢲䲮�批��誩�撅� */
.study-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-bottom: 40px;
}

/* =====================================================
   瘚钅�璅∪��瑕�
   ===================================================== */
.quiz-type-selector {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-ink);
    margin-bottom: 20px;
}

.quiz-type-selector label {
    font-weight: bold;
    color: var(--ink-dark);
    margin-right: 10px;
}

.quiz-type-selector select {
    min-width: 220px;
    padding: 8px 12px;
    border: 1px solid var(--border-ink);
    border-radius: 6px;
    font-size: 1rem;
    font-family: var(--font-serif);
    color: var(--ink-dark);
    background: #fff;
}

.quiz-setting {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 20px;
}

.quiz-area {
    background: #fff;
    padding: 30px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-ink);
    min-height: 300px;
}

.quiz-question {
    font-size: 1.2rem;
    color: var(--ink-dark);
    margin-bottom: 20px;
    padding: 15px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px dashed var(--border-ink);
}

.quiz-input textarea {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 1px solid var(--border-ink);
    border-radius: 8px;
    font-size: 1rem;
    font-family: var(--font-serif);
    resize: vertical;
}

.quiz-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: center;
}

.option-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    margin-bottom: 10px;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border-ink);
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: #f5f5f5;
    border-color: var(--cinnabar);
}

.option-btn.selected {
    background: #fff5f5;
    border-color: var(--cinnabar);
    color: var(--cinnabar);
    font-weight: bold;
}

/* 憿園��㗇𥋘�冽� */
.study-controls {
    background: #fff;
    padding: 15px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.unit-selector select {
    padding: 5px 10px;
    border: 1px solid var(--border-ink);
    border-radius: 4px;
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--ink-dark);
    outline: none;
}

/* �嗆挾��內�典�撅� */
.phase-indicator {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.phase-indicator .phase {
    color: var(--ink-light);
    font-size: 0.85rem;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 20px;
    white-space: nowrap;
}

.phase-indicator .phase.active {
    color: #fff;
    background: var(--cinnabar);
    font-weight: bold;
    border-bottom: none;
}

.phase-arrow {
    color: var(--border-ink);
    margin: 0 3px;
    font-size: 0.8rem;
}

/* =====================================================
   �芸㨃璅∪� (�孵�)
   ===================================================== */
.flashcard-container {
    perspective: 1200px;
    min-height: 400px;
    margin: 40px 0;
}

.flashcard {
    max-width: 500px;
    height: 320px;
    margin: 0 auto;
    cursor: pointer;
}

.flashcard-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    background-image: var(--bg-texture);
}

.flashcard-front {
    background-color: #fffef9;
    /* 甇日𢒰憸𡏭𠧧 */
    border: 4px double var(--cinnabar);
    /* �𣬚瑪颲寞�嚗峕凒銝剖� */
}

.flashcard-back {
    background-color: #fcfcfc;
    transform: rotateY(180deg);
    border: 1px solid var(--border-ink);
}

.flashcard-herb-name {
    font-family: var(--font-serif);
    font-size: 3.5rem;
    color: var(--ink-dark);
    margin-bottom: 10px;
}

.flashcard-effects {
    font-size: 1.4rem;
    color: var(--ink-dark);
    line-height: 1.6;
    margin-bottom: 20px;
    font-weight: bold;
}

.flashcard-supplements {
    font-size: 1rem;
    color: var(--ochre);
}

/* 銝餃𢆡�𧼮��鞟內 */
.recall-prompt {
    text-align: center;
    padding: 20px;
    margin: 20px 0;
    background: linear-gradient(135deg, #fff9e6 0%, #fff5f5 100%);
    border-radius: 12px;
    border: 2px dashed var(--ochre);
}

.recall-prompt p {
    font-size: 1.2rem;
    color: var(--ink-dark);
    margin-bottom: 15px;
}

.recall-prompt .btn {
    font-size: 1.1rem;
    padding: 15px 40px;
}

/* �芸㨃�厰僼 */
.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 30px;
    /* �曇�憓𧼮��厰僼�渲� */
    margin-top: 20px;
}

.btn-success {
    background: var(--bamboo);
}

.btn-danger {
    background: var(--cinnabar);
}

/* =====================================================
   瘚讛�憿菟𢒰 & 憭滢�憿菟𢒰 (���)
   ===================================================== */
.browse-container {
    background: #fff;
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.browse-sidebar {
    background: #f9f9f9;
    border-right: 1px solid var(--border-ink);
}

.browse-unit {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.browse-unit.active {
    background: #fff;
    border-left: 4px solid var(--cinnabar);
    color: var(--cinnabar);
    font-weight: bold;
}

/* �舀��滚�蝢𤾸�嚗��閫�芋撘𧶏� */
.browse-herb-name {
    font-size: 1.6rem;
    color: var(--cinnabar);
    /* �梁�蝥Ｗ� */
    background-color: rgba(184, 59, 59, 0.05);
    /* ��楚蝥Ｗ�嚗���寞釣�� */
    padding: 10px 15px;
    border-left: 6px solid var(--ink-dark);
    /* 憓券�蝡𣇉瑪 */
    margin: 25px 0 15px 0;
    /* �匧之銝𠹺��渲� */
    font-family: var(--font-serif);
    font-weight: bold;
    border-radius: 0 10px 10px 0;
    /* �喃儒��� */
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.05);
}

.browse-herb-effects {
    margin-bottom: 10px;
    line-height: 1.6;
    padding-left: 5px;
}

.browse-herb-supplements {
    background-color: #fff9c4;
    /* 瘛⊥楚����脰��航”蝷箄‘�� */
    padding: 10px;
    border-radius: 8px;
    margin-top: 5px;
    font-size: 0.95rem;
    color: #555;
    border-left: 3px solid var(--ochre);
}

.weakness-item {
    background: #fff;
    border: 1px solid var(--border-ink);
    padding: 10px 20px;
    margin: 5px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-serif);
}

.app-footer {
    padding-top: 20px;
    margin-top: 20px;
    font-family: var(--font-serif);
}

.mobile-only {
    display: none;
}

/* =====================================================
   �𢲡 蝘餃𢆡蝡� H5 ��� (Mobile Responsive)
   ===================================================== */
@media (max-width: 768px) {
    :root {
        /* 蝘餃𢆡蝡臬抅蝖�摮堒噡�曉之 */
        font-size: 18px;
    }

    body {
        /* �誩��峕艶蝥寧�撟脫贋嚗䔶���㟲瘣� */
        background-color: var(--bg-paper);
    }

    .app-container {
        padding: 10px;
        max-width: 100%;
    }

    /* 憭湧�靚�㟲 */
    .app-header {
        padding: 20px 0;
        margin-bottom: 25px;
    }

    .app-header h1 {
        font-size: 2.2rem;
        /* �惩之��� */
        line-height: 1.3;
        margin-bottom: 15px;
    }

    .header-stats {
        gap: 15px;
        font-size: 0.9rem;
        flex-wrap: wrap;
        justify-content: center;
        background: rgba(255, 255, 255, 0.4);
        padding: 10px;
        border-radius: 8px;
    }

    .stat::after {
        display: none;
    }

    .stat {
        padding: 2px 0;
        font-weight: bold;
        color: var(--ink-medium);
    }

    /* 撖潸⏛�𧶏��嫣蛹 2�㛖��澆�撅�嚗峕凒憭扳凒�梶� */
    .main-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* 銝文� */
        gap: 12px;
        margin-bottom: 25px;
        padding: 0 5px;
        justify-content: stretch;
        overflow: visible;
    }

    .nav-btn {
        width: 100%;
        padding: 15px 10px;
        /* �𣳇��孵稬�箏� */
        font-size: 1rem;
        text-align: center;
        display: flex;
        /* 霈拙㦛������撅�葉 */
        justify-content: center;
        align-items: center;
        border-radius: 12px;
        background-color: #fff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
        /* 頧餃凝瘚株絲 */
        white-space: normal;
        /* ��捂�Ｚ� */
    }

    .nav-btn.active {
        background-color: var(--cinnabar);
        color: #fff;
        box-shadow: 0 4px 12px rgba(184, 59, 59, 0.3);
    }

    /* ��捆�箏�嚗𡁜�撠𤏸器頝嘅��拍鍂撅誩�蝛粹𡢿 */
    .study-card,
    .browse-container,
    .review-summary {
        margin: 0;
        padding: 20px 15px;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    }

    /* �臬��孵之 */
    .herb-name {
        font-size: 2.6rem;
        margin-bottom: 15px;
    }

    .herb-category {
        font-size: 1rem;
    }

    /* �厰★�厰僼嚗𡁜�憭� */
    .options {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .option-btn {
        padding: 16px;
        font-size: 1.1rem;
        border-radius: 8px;
    }

    /* 颲枏�獢���惩之 */
    #user-output,
    #quiz-answer {
        font-size: 1.1rem;
        padding: 12px;
        min-height: 150px;
    }

    /* 蝏蠘恣�Ｘ踎嚗𡁏辺�桀�憭� */
    .weakness-item {
        margin: 8px 0;
        padding: 15px;
        font-size: 1rem;
    }

    /* �芸㨃嚗𡁜�皛∪�撟閖�摨衣�70% */
    .flashcard-container {
        min-height: auto;
        height: 65vh;
        /* 閫�藁擃睃漲��65% */
        margin: 20px 0;
    }

    .flashcard {
        height: 100%;
        width: 100%;
    }

    .flashcard-herb-name {
        font-size: 3.5rem;
        /* 摮㛖鸌憭� */
    }

    .flashcard-effects {
        font-size: 1.4rem;
        line-height: 1.5;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 20px;
    }

    /* 摨閖��滢��𧶏��箏��典��剁��𤥁���憭� */
    .study-actions,
    .flashcard-actions,
    .quiz-actions {
        flex-direction: column;
        gap: 15px;
        margin-top: 30px;
    }

    .btn {
        width: 100%;
        padding: 16px 0;
        /* �𣳇��厰僼 */
        font-size: 1.2rem;
        /* �惩之摮堒噡 */
        border-radius: 50px;
        /* �典�閫𡜐��𧢲�憟� */
    }

    /* 靽桀�嚗𡁏綉�嗆�撣���嫣蛹銝𠹺�蝏𤘪�嚗屸俈甇Ｘ�摮㛖��� */
    .study-controls,
    .flashcard-controls {
        flex-direction: column !important;
        /* 撘箏�銝𠹺� */
        align-items: stretch !important;
        padding: 15px;
        gap: 15px;
        height: auto;
    }

    .unit-selector {
        width: 100%;
        margin-right: 0;
    }

    /* 靽桀�銝𧢲�獢��摮埈遬蝷� */
    .unit-selector select {
        width: 100%;
        text-overflow: ellipsis;
        padding-right: 30px;
        /* 蝏嗵悌憭渡�雿� */
    }

    /* 隡睃��嗆挾��內�剁��渡揮�𡢅�璅芸��鍦� */
    .phase-indicator {
        width: 100%;
        justify-content: space-between;
        background: #fff;
        padding: 12px;
        border-radius: 8px;
        font-size: 0.85rem;
        flex-direction: row !important;
        /* 撘箏�璅芸� */
    }

    .phase {
        white-space: nowrap;
        /* 蝳�迫����Ｚ� */
        padding: 4px 8px;
        border-radius: 4px;
        background: #f5f5f5;
        color: #999;
        flex: 1;
        text-align: center;
        margin: 0 2px;
    }

    .phase.active {
        background: var(--cinnabar);
        color: #fff;
        font-weight: bold;
    }

    /* 靽桀�銝𧢲�獢� */
    .unit-selector select,
    #quiz-type-select {
        height: 44px;
        font-size: 1rem;
        background-color: #fff;
    }

    .quiz-setting {
        margin-top: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        font-size: 1.1rem;
    }

    #quiz-passing-score {
        padding: 8px;
        width: 80px;
        text-align: center;
        font-size: 1.1rem;
    }

    /* 瘚讛�璅∪�嚗𡁏��箇垢�孵��瑕� */
    .mobile-only {
        display: block !important;
    }

    .mobile-browse-nav {
        margin-bottom: 20px;
    }

    .mobile-browse-nav select {
        width: 100%;
        padding: 15px;
        font-size: 1.1rem;
        border: 2px solid var(--cinnabar);
        border-radius: 8px;
        background: #fff;
        color: var(--ink-dark);
        font-family: var(--font-serif);
        outline: none;
    }

    /* �鞱�撌虫儒靘扯器�� */
    .browse-sidebar {
        display: none !important;
    }

    /* ��捆�箏�摰� */
    .browse-content {
        padding: 0;
        border: none;
    }

    .browse-container {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    /* ==================== 
       瘚钅�璅∪�銝枏�隡睃� (�𧢲㦤蝡�)
       ==================== */
    .quiz-input {
        display: flex;
        flex-direction: column;
        gap: 15px;
        margin-top: 20px;
    }

    #quiz-question {
        font-size: 1.3rem;
        /* 憸条𤌍�惩之 */
        line-height: 1.6;
        margin-bottom: 20px;
        background: #fafafa;
        padding: 15px;
        border-radius: 8px;
        border: 1px dashed var(--border-ink);
    }

    /* �厰★蝡𡝗�嚗峕��� */
    #quiz-input-area .option-btn {
        width: 100%;
        text-align: left;
        margin-bottom: 0;
        padding: 18px 20px;
        font-size: 1.1rem;
        border-radius: 10px;
        display: block;
        /* 撘箏��Ｚ� */
        background: #fff;
        border: 1px solid var(--border-ink);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    }

    #quiz-input-area .option-btn.selected {
        background: #fff5f5;
        border-color: var(--cinnabar);
        color: var(--cinnabar);
        font-weight: bold;
    }

    /* 霈曄蔭�箏�靚�㟲 */
    .quiz-setting {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        background: #f5f5f5;
        padding: 15px;
        border-radius: 8px;
    }

    /* �芸㨃璅∪�蝘餃𢆡蝡舐鸌�吔��厰僼蝡𡝗��脰秤閫� */
    .flashcard-actions {
        flex-direction: column !important;
        gap: 25px !important;
        /* 憭批之����湧𡢿頝� */
        padding: 0 10px;
        width: 100%;
    }

    .flashcard-actions .btn {
        width: 100%;
        padding: 20px 0;
        /* 憓𧼮�擃睃漲 */
        font-size: 1.4rem;
        /* 憓𧼮�摮堒噡 */
        border-radius: 50px;
        /* ��隋�誯��萇𨺗 */
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    }
}

/* ==================== 
   衙癩泔桵 (Concept Game) 欴宒 
   ==================== */
#view-concept-game {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.game-header h2 {
    font-family: var(--font-serif);
    color: var(--ink-dark);
}

.game-stats {
    display: flex;
    gap: 15px;
    font-weight: bold;
    color: var(--cinnabar);
    background: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 辣茩賜醱 */
.game-phase {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-intro {
    text-align: center;
    color: var(--ink-medium);
    margin-bottom: 20px;
    font-style: italic;
}

.game-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.btn-game-mode {
    padding: 30px 20px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    background: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s;
    text-align: center;
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--ink-dark);
}

.btn-game-mode b {
    display: block;
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: var(--cinnabar);
}

.btn-game-mode small {
    color: var(--ink-light);
    font-size: 0.9rem;
}

.btn-game-mode:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(184, 59, 59, 0.15);
}

/* 蚔牁輛俴賜醱 */
.game-question-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border-left: 5px solid var(--cinnabar);
    margin-bottom: 30px;
}

.game-question-label {
    text-transform: uppercase;
    color: var(--ink-light);
    font-size: 0.8rem;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.game-question-content {
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--ink-dark);
}

.game-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.btn-game-option {
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #eee;
    background: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-serif);
}

.btn-game-option:hover:not(:disabled) {
    border-color: var(--cinnabar);
    background: #fff5f5;
}

.btn-game-option:disabled {
    cursor: default;
    opacity: 0.7;
}

/* 淏昫詢謠 */
.btn-game-option.correct {
    background-color: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
}

.btn-game-option.wrong {
    background-color: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

/* 毀嚏Е郖 */
.game-feedback {
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    background: #f8fafc;
    border-left: 4px solid #64748b;
    animation: slideUp 0.3s ease;
}

.game-feedback.success {
    background: #ecfdf5;
    border-left-color: #10b981;
    color: #064e3b;
}

.game-feedback.error {
    background: #fef2f2;
    border-left-color: #ef4444;
    color: #7f1d1d;
}

.game-controls {
    margin-top: 20px;
    text-align: center;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 幗雄党葩硃間 */
body,
html* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.7;
    color: var(--ink-dark);
    /* 优雅的渐变背景 */
    background: linear-gradient(135deg, #fef9f3 0%, #fdf2e9 50%, #f8e8dc 100%);
    background-attachment: fixed;
    min-height: 100vh;
    /* 微妙的纹理 */
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23b83b3b' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: #fff;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    height: 100%;
    overflow-y: auto;
}

.view.active {
    display: block !important;
    width: 100%;
}

#game-container {
    width: 100%;
    max-width: 600px;
    margin-bottom: 50px;
}

/* =========================================
   V2 Knowledge Layer Styles
   ========================================= */

/* 容器基础 */
.v2-content {
    line-height: 1.8;
    font-size: 1.1em;
    color: #333;
}

/* 1. 骨架层 (Bold) */
.layer-bold {
    font-weight: bold;
    color: #000;
}

/* 2. 核心层 (Red) - 必背口诀 */
.layer-core {
    color: #d32f2f;
    /* Material Red 700 */
    font-weight: 500;
    transition: all 0.3s ease;
}

.mode-recite .layer-core {
    background-color: #ef9a9a !important;
    color: transparent !important;
    border-radius: 4px;
    cursor: pointer;
}

.mode-recite .layer-core:hover {
    color: #d32f2f !important;
    /* Hover to peek */
}

.mode-recite .layer-core.revealed {
    color: #d32f2f !important;
    background-color: transparent !important;
}

/* 遮红模式下隐藏补充说明文字（防止泄露答案） */
.mode-recite .v2-content {
    display: none !important;
}

/* 当药物条目被点击揭示后，补充说明也显示 */
.mode-recite .herb-entry.revealed .v2-content {
    display: block !important;
}

/* 3. 反射层 (Underline) - 标准功效 */
.layer-reflex {
    border-bottom: 2px solid #333;
    padding-bottom: 1px;
    cursor: pointer;
    /* Click for reverse index */
    transition: all 0.3s ease;
}

.layer-reflex:hover {
    background-color: #e0e0e0;
}

.mode-reflex .layer-reflex {
    background-color: #bdbdbd;
    color: transparent;
    border-bottom-color: transparent;
    border-radius: 4px;
}

/* 4. 进阶层 (Purple) - 特殊考点 */
.layer-advanced {
    color: #7b1fa2;
    /* Material Purple 700 */
    font-weight: 500;
}

.mode-expert .layer-advanced {
    background-color: #e1bee7;
    box-shadow: 0 0 5px #e1bee7;
}

/* 5. 降噪 (Dim) - 连接词 */
.dim {
    opacity: 0.6;
    font-size: 0.9em;
    font-weight: normal;
}

/* 控制面板 */
.layer-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
    overflow-x: auto;
}

.toggle-btn {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background: white;
    font-size: 0.9em;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}

.toggle-btn.active {
    background: #2196f3;
    color: white;
}

/* Clinical Blitz View */
#view-blitz {
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.blitz-container {
    width: 100%;
    max-width: 500px;
    perspective: 1000px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.blitz-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    min-height: 300px;
    padding: 30px;
    position: relative;
    cursor: pointer;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid #eee;
}

.blitz-card:active {
    transform: scale(0.98);
}

.blitz-category {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 0.9em;
    color: #888;
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 15px;
}

.blitz-count {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 0.9em;
    color: #ccc;
}

.blitz-question {
    font-size: 1.8em;
    color: #333;
    margin: 20px 0;
    line-height: 1.4;
    font-weight: bold;
}

.blitz-answer {
    font-size: 2em;
    color: #d32f2f;
    margin-top: 30px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    font-weight: 900;
}

.blitz-card.revealed .blitz-answer {
    opacity: 1;
    transform: translateY(0);
}

.blitz-hint {
    margin-top: auto;
    color: #bbb;
    font-size: 0.9em;
}

.blitz-actions {
    margin-top: 30px;
    width: 100%;
    max-width: 500px;
}

.btn-blitz {
    width: 100%;
    padding: 15px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
}

/* =====================================================
   可折叠侧边栏样式
   ===================================================== */
.browse-unit-container {
    margin-bottom: 2px;
}

.browse-sidebar-item.unit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px 15px;
    background: var(--bg-card);
    border-left: 3px solid transparent;
    transition: all 0.2s;
    font-weight: bold;
}

.browse-sidebar-item.unit-header:hover {
    background: #f5f0e5;
    border-left-color: var(--cinnabar);
}

.expand-icon {
    font-size: 0.7em;
    color: var(--ink-light);
    transition: transform 0.2s;
}

.browse-unit-container.expanded .expand-icon {
    transform: rotate(90deg);
}

/* 节列表 - 默认隐藏 */
.section-list {
    display: none;
    padding-left: 20px;
    background: rgba(0, 0, 0, 0.02);
}

.browse-unit-container.expanded .section-list {
    display: block;
}

.browse-sidebar-item.section-item {
    padding: 10px 15px;
    font-size: 0.9em;
    color: var(--ink-medium);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.2s;
}

.browse-sidebar-item.section-item:hover {
    background: rgba(184, 59, 59, 0.05);
    color: var(--cinnabar);
}

.browse-sidebar-item.section-item.active {
    background: rgba(184, 59, 59, 0.1);
    border-left-color: var(--cinnabar);
    color: var(--cinnabar);
    font-weight: bold;
}

/* =====================================================
   🎨 World Class UI Upgrade Patch
   ===================================================== */

:root {
    /* Premium Shadows */
    --shadow-soft-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-soft-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-soft-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.03);
    --shadow-glow: 0 0 15px rgba(184, 59, 59, 0.25);

    /* Modern Spacing */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 1. Global Polish */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

/* 2. Enhanced Card Interactions */
.study-card,
.flashcard-front,
.flashcard-back,
.blitz-card,
.quiz-area {
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: var(--shadow-soft-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.study-card:hover,
.flashcard:hover .flashcard-front,
.blitz-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-soft-lg);
}

/* 3. Button Micro-interactions */
.btn,
.nav-btn,
.option-btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.btn:active,
.nav-btn:active {
    transform: scale(0.96) !important;
    /* Satisfying click feel */
}

.btn-primary,
.btn-start,
.btn-confirm,
.btn-submit,
.btn-next {
    background: linear-gradient(135deg, var(--cinnabar) 0%, #d32f2f 100%);
    box-shadow: 0 4px 6px rgba(184, 59, 59, 0.2);
}

.btn-primary:hover,
.btn-start:hover {
    box-shadow: 0 8px 12px rgba(184, 59, 59, 0.3);
    filter: brightness(1.1);
}

/* 4. Refined Navigation */
/* 4. Refined Navigation (Segmented Control) */
.segmented-control-container {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
}

.segmented-control {
    display: inline-flex;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 4px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.nav-btn {
    border: none;
    background: transparent;
    color: var(--ink-light);
    font-family: "Songti SC", "Noto Serif SC", serif;
    font-size: 1.05rem;
    letter-spacing: 2px;
    padding: 8px 32px;
    border-radius: 8px;
    /* Slightly smaller radius for inner buttons */
    cursor: pointer;
    font-weight: normal;
    min-width: 80px;
    text-align: center;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    color: var(--cinnabar);
    background: rgba(255, 255, 255, 0.5);
}

.nav-btn.active {
    background: #fff;
    color: var(--cinnabar);
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(184, 59, 59, 0.15);
}

/* Dark Mode Adaptation */
[data-theme="dark"] .segmented-control {
    background: rgba(255, 255, 255, 0.08);
    /* Lighter bg for container in dark */
    border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .nav-btn {
    color: #aaa;
    /* Dimmer text inactive */
}

[data-theme="dark"] .nav-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .nav-btn.active {
    background: #444;
    /* Dark grey active bg */
    color: #ff8a80;
    /* Light red text */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 5. Input Formatting */
select,
textarea,
input[type="text"],
input[type="number"] {
    border: 1px solid #e0e0e0;
    transition: all var(--transition-fast);
    background-color: #fafafa;
}

select:focus,
textarea:focus,
input:focus {
    border-color: var(--cinnabar);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(184, 59, 59, 0.1);
    outline: none;
}

/* 6. Typography Refinements */
.herb-name {
    letter-spacing: -0.5px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.02);
}

.layer-label {
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* 7. Progress Ring Glow */
.progress-ring-fill {
    filter: drop-shadow(0 0 4px rgba(78, 110, 68, 0.4));
}

/* 自定义下拉选择器（替代原生select，支持完整滚动） */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    padding: 12px 15px;
    background: white;
    border: 1px solid var(--border-ink);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    color: var(--ink-dark);
}

.custom-select-trigger:hover {
    border-color: var(--cinnabar);
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-ink);
    border-radius: 8px;
    box-shadow: var(--shadow-soft-lg);
    z-index: 1000;
    margin-top: 5px;
}

.custom-select-option {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.custom-select-option:hover {
    background: rgba(184, 59, 59, 0.05);
    color: var(--cinnabar);
}

.custom-select-option:last-child {
    border-bottom: none;
}

/* 按钮闪烁提示动画（切换单元后提示用户点击） */
@keyframes pulse-hint {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(184, 59, 59, 0.2);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(184, 59, 59, 0.5);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(184, 59, 59, 0.2);
    }
}


/* =====================================================
   闪卡模式样式 (Flashcard Mode)
   ===================================================== */
.flashcard-container {
    perspective: 1000px;
    width: 100%;
    max-width: 400px;
    height: 300px;
    /* 卡片高度 */
    margin: 20px auto;
}

.flashcard {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1), opacity 0.2s;
    transform-style: preserve-3d;
    cursor: pointer;
    background: #fffafa;
    /* 象牙白 */
    border-radius: 12px;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.05),
        0 1px 3px rgba(0, 0, 0, 0.1),
        inset 0 0 20px rgba(244, 240, 230, 0.5);
    /* 内发光营造质感 */
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 翻转状态 */
.flashcard.flipped {
    transform: rotateY(180deg);
}

/* 触摸滑动时的过渡优化 */
.flashcard.swiping {
    transition: none;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    /* Safari */
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    border-radius: 12px;
}

.flashcard-front {
    background-color: #fff;
    /* 纸张纹理 */
    background-image:
        linear-gradient(90deg, transparent 95%, rgba(0, 0, 0, 0.02) 95%),
        linear-gradient(transparent 95%, rgba(0, 0, 0, 0.02) 95%);
    background-size: 20px 20px;
}

.flashcard-back {
    background-color: #fff;
    transform: rotateY(180deg);
    overflow-y: auto;
    background-image: linear-gradient(to bottom right, #ffffff, #fcfcfc);
    /* 弹性布局实现垂直居中 */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    /* 上下分布 */
    align-items: center;
    padding: 30px;
}


/* 优化：正面标题样式 */
.flashcard-herb-name {
    font-size: 2.2em;
    /* 稍微调小一点默认值 */
    font-weight: bold;
    color: #333;
    font-family: var(--font-heading);
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);

    /* 允许长标题换行和缩小 */
    word-wrap: break-word;
    max-width: 100%;
    line-height: 1.3;
}

/* 针对长标题的特殊处理 (通过JS添加类名或使用较小的通用字号) */
/* 这里使用 clamp 确保在移动端也不会太大 */
@media (max-width: 480px) {
    .flashcard-herb-name {
        font-size: clamp(1.5em, 5vw, 2.2em);
    }
}

.flashcard-hint {
    color: #999;
    font-size: 0.9em;
    margin-top: 15px;
}

/* 优化：背面内容样式 - 采用宋体/衬线体 */
.flashcard-effects {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;

    /* 使用 clamp 动态调整字号 - 调小下限以适应长文本 */
    font-size: clamp(1rem, 3.5vw, 1.6em);

    line-height: 1.5;
    /* 更加透气 */
    color: #b71c1c;
    font-weight: 500;

    /* 核心修改：使用衬线体 */
    font-family: var(--font-serif);

    letter-spacing: 1px;
    /* 增加字间距 */
    margin: 0;
    width: 100%;

    /* 允许长内容滚动/换行 */
    overflow-y: auto;
    /* max-height: 80%;  Removed to let flex handle it */
    padding: 0 15px;
    text-align: left;
    /* 长文本左对齐更易读 */
}

/* 深色模式下的调整 */
[data-theme="dark"] .flashcard-effects {
    color: #ff8a80;
    font-weight: 400;
    text-shadow: 0 0 1px rgba(255, 138, 128, 0.3);
}

.flashcard-supplements {
    flex-shrink: 0;
    font-size: 0.95em;
    color: #666;
    text-align: left;
    width: 100%;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    padding-top: 12px;
    line-height: 1.5;
    margin-top: 12px;
    font-family: var(--font-sans);
    /* 补充内容保持黑体 */
}

.flashcard-supplements {
    flex-shrink: 0;
    font-size: 0.95em;
    /* 稍微调小 */
    color: #555;
    text-align: left;
    width: 100%;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);

    .flashcard-stats {
        font-size: 0.9em;
        color: #666;
        display: flex;
        gap: 15px;
    }

    [data-theme="dark"] .flashcard-stats {
        color: #aaa;
    }

    /* =====================================================
   Review / Dashboard Styling (新增)
   ===================================================== */
    .review-summary {
        padding: 20px;
        background: #fff;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-paper);
        margin-bottom: 20px;
    }

    [data-theme="dark"] .review-summary {
        background: var(--bg-card);
        box-shadow: none;
        border: 1px solid var(--border-ink);
    }

    .review-summary h2 {
        font-family: var(--font-heading);
        color: var(--l2-color);
        margin-bottom: 5px;
    }

    .review-summary p {
        color: #666;
        margin-bottom: 20px;
        font-size: 0.9em;
    }

    [data-theme="dark"] .review-summary p {
        color: #aaa;
    }

    .weakness-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 15px;
    }

    .weakness-item {
        background: #fdfdfd;
        border: 1px solid #eee;
        padding: 15px 10px;
        border-radius: 12px;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    [data-theme="dark"] .weakness-item {
        background: #333;
        border-color: #444;
    }

    .weakness-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    }

    .weakness-item .level-badge {
        font-size: 0.8em;
        padding: 4px 8px;
        border-radius: 4px;
        margin-bottom: 8px;
        background: #eee;
        color: #555;
        display: inline-block;
    }

    [data-theme="dark"] .weakness-item .level-badge {
        background: #444;
        color: #ccc;
    }

    .weakness-item .count {
        font-size: 1.8em;
        font-weight: bold;
        color: #333;
        font-family: var(--font-heading);
        line-height: 1.1;
    }

    [data-theme="dark"] .weakness-item .count {
        color: #eee;
    }

    /* 针对不同等级的微调 */
    .level-0 {
        background-color: rgba(255, 235, 238, 0.5);
        color: #c62828;
    }

    [data-theme="dark"] .level-0 {
        background-color: rgba(183, 28, 28, 0.2);
        color: #ef9a9a;
    }

    .level-5 {
        background-color: rgba(232, 245, 233, 0.5);
        color: #2e7d32;
    }

    [data-theme="dark"] .level-5 {
        background-color: rgba(27, 94, 32, 0.2);
        color: #a5d6a7;
    }

    /* Progress Bar Styles & Rules Modal */
    .weakness-item {
        flex-wrap: wrap;
    }

    .progress-bar-bg {
        width: 100%;
        height: 6px;
        background: var(--line-light);
        margin-top: 8px;
        border-radius: 3px;
        overflow: hidden;
    }

    [data-theme='dark'] .progress-bar-bg {
        background: var(--line-dark);
    }

    .progress-bar-fill {
        height: 100%;
        border-radius: 3px;
        transition: width 0.3s ease;
    }

    .level-0-fill {
        background: var(--ink-light);
        opacity: 0.5;
    }

    .level-1-fill {
        background: #8D6E63;
    }

    .level-2-fill {
        background: #66BB6A;
    }

    .level-3-fill {
        background: #2E7D32;
    }

    .level-4-fill {
        background: #e91e63;
    }

    .level-5-fill {
        background: #FFD700;
    }

    .rules-modal {
        display: none;
        /* 默认隐藏 */
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: var(--bg-card);
        padding: 2rem;
        border-radius: 12px;
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        width: 90%;
        max-width: 500px;
        border: 1px solid var(--border-ink);
    }

    [data-theme='dark'] .rules-modal {
        border-color: var(--bamboo);
        box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    }

    .rules-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .rules-close-btn {
        margin-top: 20px;
        width: 100%;
        padding: 10px;
        background: var(--cinnabar);
        color: white;
        border: none;
        border-radius: 6px;
        cursor: pointer;
    }
}

/* V2 Browser Controls - Refined */
.layer-controls {
    display: flex;
    justify-content: flex-end;
    padding: 10px 0;
}

.toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-ink);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--ink-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: var(--cinnabar);
    color: var(--cinnabar);
}

.toggle-btn.active {
    background: var(--cinnabar);
    color: white;
    border-color: var(--cinnabar);
}

/* Segmented Control (Premium UI) */
.segmented-control {
    position: relative;
    display: flex;
    align-items: center;
    background: #eee;
    padding: 4px;
    border-radius: 99px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    width: fit-content;
    margin-left: auto;
}

[data-theme='dark'] .segmented-control {
    background: #333;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.segmented-control input {
    display: none;
}

.segment-label {
    position: relative;
    z-index: 2;
    padding: 8px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--ink-light);
    cursor: pointer;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.segment-label .icon {
    font-size: 1.1em;
}

.segment-glider {
    position: absolute;
    top: 4px;
    left: 4px;
    height: calc(100% - 8px);
    width: calc(50% - 4px);
    /* Fix: Account for left:4px to prevent overflow */
    background: #fff;
    border-radius: 99px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1;
    pointer-events: none;
}

[data-theme='dark'] .segment-glider {
    background: #444;
}

/* Logic for Glider Slide */
/* Assuming 2 items, 50% width each roughly. Actually specific sizes are better. Let's assume fixed width or flex. */
.segmented-control {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 300px;
    /* Responsive max width */
    overflow: hidden;
    /* Safety net */
}

.segment-label {
    justify-content: center;
}

#mode-read:checked~.segment-label[for='mode-read'] {
    color: var(--ink-dark);
}

#mode-recite:checked~.segment-label[for='mode-recite'] {
    color: var(--cinnabar);
}

[data-theme='dark'] #mode-recite:checked~.segment-label[for='mode-recite'] {
    color: #ff8a80;
}

#mode-read:checked~.segment-glider {
    transform: translateX(0);
}

#mode-recite:checked~.segment-glider {
    transform: translateX(100%);
}

/* Active Glider Color */
#mode-read:checked~.segment-glider {
    background: #fff;
}

#mode-recite:checked~.segment-glider {
    background: #fff;
    border: 1px solid var(--cinnabar-light);
}

[data-theme='dark'] #mode-read:checked~.segment-glider {
    background: #f0f0f0;
    color: #333;
}

[data-theme='dark'] #mode-recite:checked~.segment-glider {
    background: #400;
    border-color: #800;
}

/* Comparator Mode Styles */
.comparator-container {
    padding: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.comp-presets-wrapper {
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft-sm);
    border: 1px solid var(--border-ink);
}

.comp-presets-label {
    font-weight: bold;
    color: var(--cinnabar);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.comp-presets-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    scrollbar-width: thin;
}

.btn-preset {
    white-space: nowrap;
    padding: 8px 12px;
    border: 1px solid #eee;
    background: #fafafa;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    min-width: 120px;
    transition: all 0.2s;
}

.btn-preset:hover {
    border-color: var(--cinnabar);
    background: #fff5f5;
    transform: translateY(-2px);
}

.preset-title {
    display: block;
    font-weight: bold;
    font-size: 0.85rem;
    color: #333;
}

.preset-herbs {
    display: block;
    font-size: 0.75rem;
    color: #666;
    margin-top: 2px;
}

.comp-selectors {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft-sm);
}

.herb-select {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.vs-badge {
    font-weight: 900;
    color: var(--cinnabar);
    font-size: 1.2rem;
    font-style: italic;
}

.comp-table-wrapper {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-soft-md);
    overflow: hidden;
}

.comp-table {
    width: 100%;
    border-collapse: collapse;
}

.comp-table th {
    background: #f8f8f8;
    padding: 15px;
    color: #555;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.comp-table td {
    padding: 15px;
    vertical-align: top;
    border-bottom: 1px solid #eee;
    line-height: 1.6;
}

.section-header td {
    background: #fdfdfd;
    font-weight: bold;
    color: var(--cinnabar);
    font-size: 0.85rem;
    text-align: center;
    border-bottom: 2px solid #f0f0f0;
    padding: 8px;
}

.cell-center {
    text-align: center;
    background: #fafafa;
    border-left: 1px solid #eee;
    border-right: 1px solid #eee;
}

.cell-left,
.cell-right {
    font-size: 0.95rem;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 2px;
}

.badge-common {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.badge-unique {
    background: #fff3e0;
    color: #ef6c00;
    border: 1px solid #ffe0b2;
}

/* Hierarchy Tags */
.comp-tag {
    font-size: 0.75rem;
    color: #999;
    margin-bottom: 4px;
    display: inline-block;
    background: #eee;
    padding: 2px 8px;
    border-radius: 99px;
}

.comp-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

/* Card Type Selector */
.card-type-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-type-selector label {
    font-size: 0.9em;
    color: #666;
}

.card-type-selector select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    font-size: 0.9em;
}

[data-theme="dark"] .card-type-selector label {
    color: #aaa;
}

[data-theme="dark"] .card-type-selector select {
    background: #333;
    color: #eee;
    border-color: #555;
}

/* Quiz Option Group */
.quiz-option-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.quiz-option-group label {
    font-size: 0.9em;
    color: #666;
}

.quiz-option-group select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    font-size: 0.9em;
}

[data-theme="dark"] .quiz-option-group label {
    color: #aaa;
}

[data-theme="dark"] .quiz-option-group select {
    background: #333;
    color: #eee;
    border-color: #555;
}

/* =====================================================
   Refining Flashcard UI (New Chinese Elegant)
   ===================================================== */

/* 1. 布局容器 */
.flashcard-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    /* 限制最大宽度，防止太宽 */
    margin: 0 auto;
}

/* 2. 操作按钮并排容器 */
.action-row {
    display: flex;
    gap: 15px;
    width: 100%;
}

/* 3. 通用按钮样式优化 */
.flashcard-actions .btn {
    padding: 14px;
    border-radius: 8px;
    /* 精致圆角 */
    font-size: 1rem;
    font-family: "Songti SC", serif;
    /* 宋体增强质感 */
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 4. 返回按钮：线框风格 (雅致棕色) */
#btn-reset-flashcard {
    background: transparent;
    border: 1px solid #8d7b68;
    color: #8d7b68;
    box-shadow: none;
    width: 100%;
}

#btn-reset-flashcard:hover {
    background-color: #f5f0e6;
    /* 浅米色悬停 */
}

/* 5. 没记住按钮：朱砂红 */
#btn-flashcard-unknown {
    flex: 1;
    /* 平分宽度 */
    background-color: #c0392b;
    color: white;
    border: 1px solid #a93226;
}

#btn-flashcard-unknown:hover {
    background-color: #d35400;
    transform: translateY(-1px);
}

/* 6. 记住了按钮：玉色/墨绿 */
#btn-flashcard-known {
    flex: 1;
    /* 平分宽度 */
    background-color: #27ae60;
    color: white;
    border: 1px solid #1e8449;
}

#btn-flashcard-known:hover {
    background-color: #2ecc71;
    transform: translateY(-1px);
}

/* 7. 开始按钮：保持显眼 */
#btn-start-flashcard {
    width: 100%;
    background: var(--cinnabar);
    color: white;
    font-size: 1.1rem;
}

/* 8. JS 逻辑辅助样式 */
.hidden {
    display: none !important;
}

/* 注意：当 JS 移除 action-row 的 hidden 类时，它应该显示为 flex */
.action-row:not(.hidden) {
    display: flex !important;
}

/* =====================================================
   FIX: Dark Mode Overrides for Hardcoded Light Styles
   (Enhanced Specificity & Helper Classes)
   ===================================================== */
/* Force dark background on all white-bg containers in dark mode */
[data-theme="dark"] .quiz-question,
[data-theme="dark"] #quiz-question,
[data-theme="dark"] .mobile-only #quiz-question,
[data-theme="dark"] .flashcard,
[data-theme="dark"] .flashcard-front,
[data-theme="dark"] .flashcard-back,
[data-theme="dark"] .quiz-area,
[data-theme="dark"] .browse-container,
[data-theme="dark"] .study-card,
[data-theme="dark"] .option-btn,
[data-theme="dark"] .btn,
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea {
    background-color: #2a2a2a !important;
    background-image: none !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
}

/* Ensure text inputs are readable */
[data-theme="dark"] ::placeholder {
    color: #888 !important;
}

/* Stronger override for quiz options and active states */
[data-theme="dark"] .option-btn:hover,
[data-theme="dark"] .btn:hover:not(:disabled) {
    background-color: #383838 !important;
    border-color: var(--cinnabar) !important;
}

[data-theme="dark"] .option-btn.selected {
    background-color: #444 !important;
    color: var(--cinnabar) !important;
    border-color: var(--cinnabar) !important;
    font-weight: bold;
}

/* Fix for Select Dropdowns specially */
[data-theme="dark"] select option {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

/* 
   FIX: Flashcard 3D Logic & Backface Visibility 
   Updated to use explicit z-index swap for mobile browsers.
*/
.flashcard {
    perspective: 1000px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.flashcard-front,
.flashcard-back {
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.flashcard-front {
    z-index: 2;
}

.flashcard-back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* Force layer swap on flipped state */
.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard.flipped .flashcard-front {
    z-index: 1;
}

.flashcard.flipped .flashcard-back {
    z-index: 2;
}

/* Dark mode flashcard specifics */
[data-theme="dark"] .flashcard-herb-name {
    color: #f0f0f0 !important;
    text-shadow: none !important;
}

[data-theme="dark"] .flashcard-effects {
    color: #ef9a9a !important;
    /* Lighter red */
}

/* =====================================================
   NUCLEAR DARK MODE RESET
   Use this if specific overrides fail.
   ===================================================== */

/* 1. Global Dark Background Enforcement */
[data-theme="dark"] .quiz-question,
[data-theme="dark"] .option-btn,
[data-theme="dark"] .flashcard,
[data-theme="dark"] .flashcard-front,
[data-theme="dark"] .flashcard-back,
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] button.option-btn {
    background-color: #2a2a2a !important;
    background: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #555 !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

/* 2. Specific Fix for the Quiz Question Box (Dotted Border) */
[data-theme="dark"] #quiz-question,
[data-theme="dark"] .quiz-question {
    background-color: #252525 !important;
    color: #f0f0f0 !important;
    /* Brighter text */
    border: 2px dashed #444 !important;
}

/* 3. Specific Fix for Quiz Options */
[data-theme="dark"] #quiz-input-area .option-btn,
[data-theme="dark"] .options .option-btn {
    background-color: #2a2a2a !important;
    color: #cccccc !important;
}

[data-theme="dark"] .option-btn:hover {
    background-color: #383838 !important;
    border-color: #d65c5c !important;
    /* Cinnabar Light */
}

/* 4. Flashcard 3D & Visibility Fixes (Redundant Check) */
.flashcard-inner {
    transform-style: preserve-3d !important;
}

.flashcard-front,
.flashcard-back {
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    background-color: #fff;
    /* Light mode default */
}

[data-theme="dark"] .flashcard-front,
[data-theme="dark"] .flashcard-back {
    background-color: #2a2a2a !important;
}

/* 闪卡背面文字 - 夜间模式全面修复 */
[data-theme="dark"] .flashcard-effects,
[data-theme="dark"] .flashcard-supplements,
[data-theme="dark"] #flashcard-effects,
[data-theme="dark"] #flashcard-supplements {
    color: #e0e0e0 !important;
}

/* 方剂闪卡背面 - 夜间模式 (强制覆盖内联样式) */
[data-theme="dark"] #formula-flashcard-inner .flashcard-back,
[data-theme="dark"] #formula-flashcard-inner .flashcard-back *,
[data-theme="dark"] #formula-flashcard-effects,
[data-theme="dark"] #formula-flashcard-effects *,
[data-theme="dark"] #formula-flashcard-pattern,
[data-theme="dark"] #formula-flashcard-pattern *,
[data-theme="dark"] #formula-flashcard-song,
[data-theme="dark"] #formula-flashcard-mnemonic,
[data-theme="dark"] #formula-flashcard-composition {
    color: #e0e0e0 !important;
}

[data-theme="dark"] #formula-flashcard-song {
    background: #333 !important;
    border-left-color: #8b7355 !important;
}

[data-theme="dark"] .flashcard-label {
    color: #9ca3af !important;
}

/* 腧穴闪卡背面 - 夜间模式 (强制覆盖内联样式) */
[data-theme="dark"] #acupoint-flashcard-inner .flashcard-back,
[data-theme="dark"] #acupoint-flashcard-inner .flashcard-back *,
[data-theme="dark"] #acupoint-flashcard-card .flashcard-back,
[data-theme="dark"] #acupoint-flashcard-card .flashcard-back * {
    color: #e0e0e0 !important;
}

[data-theme="dark"] #acupoint-flashcard-inner .flashcard-back h3,
[data-theme="dark"] #acupoint-flashcard-inner .flashcard-back h4,
[data-theme="dark"] #acupoint-flashcard-card .flashcard-back h3,
[data-theme="dark"] #acupoint-flashcard-card .flashcard-back h4 {
    color: #4db6ac !important;
}

/* 通用闪卡标签样式 */
.flashcard-label {
    font-weight: bold;
    color: #555;
}

/* 方剂闪卡背面 - 日间/夜间模式 */
.formula-flashcard-text {
    color: #333;
}

.formula-flashcard-pattern {
    color: #d32f2f;
}

.formula-flashcard-song {
    color: #555;
    background: #f9f9f9;
}

[data-theme="dark"] .formula-flashcard-text {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .formula-flashcard-pattern {
    color: #ff8a80 !important;
}

[data-theme="dark"] .formula-flashcard-song {
    color: #e0e0e0 !important;
    background: #333 !important;
}

[data-theme="dark"] .flashcard-back {
    background-color: #2a2a2a !important;
}

/* 方剂闪卡背面样式 */
.formula-pattern-label {
    color: #666;
    font-weight: normal;
}

[data-theme="dark"] .formula-pattern-label {
    color: #aaa !important;
}

[data-theme="dark"] #formula-flashcard-pattern {
    color: #ff8a80 !important;
}

[data-theme="dark"] #formula-flashcard-effects {
    color: #e0e0e0 !important;
}

[data-theme="dark"] #formula-flashcard-song {
    color: #e0e0e0 !important;
    background: #333 !important;
}

[data-theme="dark"] #formula-flashcard-mnemonic {
    color: #bbb !important;
}

/* 闪卡背面夜间模式 - 强制覆盖所有内联样式 */
[data-theme="dark"] .flashcard-back *,
[data-theme="dark"] #formula-flashcard-inner *,
[data-theme="dark"] #acupoint-flashcard-inner * {
    color: #e0e0e0 !important;
}

[data-theme="dark"] .flashcard-back [style*="background"],
[data-theme="dark"] #formula-flashcard-song,
[data-theme="dark"] #formula-flashcard-inner [style*="background"] {
    background: #333 !important;
    background-color: #333 !important;
}

/* 5. Mobile Select Fix */
[data-theme="dark"] .mobile-browse-nav select,
[data-theme="dark"] .unit-selector select {
    background-color: #333 !important;
    color: white !important;
}

/* 6. Text Visibility Scanner Fix (Force all headings to light) */
/* Text Visibility Scanner Fix (Force all headings to light) - Removed empty rule to fix lint */
/* [data-theme="dark"] h1... rule removed */

/* Force specific text containers */
[data-theme="dark"] .quiz-description,
[data-theme="dark"] #quiz-mode-description,
[data-theme="dark"] .flashcard-hint {
    color: #999 !important;
}

/* =====================================================
   学科切换器 (Subject Switcher)
   ===================================================== */
.subject-switcher {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.subject-btn {
    font-family: var(--font-serif);
    font-size: 1rem;
    padding: 8px 20px;
    background: transparent;
    border: 2px solid var(--border-ink);
    border-radius: 8px;
    color: var(--ink-medium);
    cursor: pointer;
    transition: all 0.3s ease;
}

.subject-btn:hover {
    border-color: var(--cinnabar);
    color: var(--cinnabar);
}

.subject-btn.active {
    background: var(--bamboo);
    color: #fff;
    border-color: var(--bamboo);
    box-shadow: 0 4px 10px rgba(78, 110, 68, 0.3);
}

.subject-btn[data-subject="formula"].active {
    background: #6a5acd;
    border-color: #6a5acd;
    box-shadow: 0 4px 10px rgba(106, 90, 205, 0.3);
}

[data-theme="dark"] .subject-btn {
    border-color: #444;
    color: #aaa;
}

[data-theme="dark"] .subject-btn:hover {
    border-color: var(--cinnabar);
    color: var(--cinnabar);
}

[data-theme="dark"] .subject-btn.active {
    background: var(--bamboo);
    border-color: var(--bamboo);
    color: #fff;
}

[data-theme="dark"] .subject-btn[data-subject="formula"].active {
    background: #7b68ee;
    border-color: #7b68ee;
}

/* =====================================================
   方剂学模块样式 (Formula Module Styles)
   ===================================================== */

/* 方剂详情页 */
.formula-detail {
    padding: 20px;
}

.formula-detail h2 {
    color: var(--cinnabar);
    font-size: 2rem;
    margin-bottom: 10px;
}

.formula-source {
    color: var(--ink-light);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.detail-section {
    background: rgba(255, 255, 255, 0.6);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid var(--bamboo);
}

.detail-section h4 {
    color: var(--ink-dark);
    font-size: 1rem;
    margin-bottom: 8px;
}

.detail-section p,
.detail-section ul {
    color: var(--ink-medium);
    line-height: 1.8;
}

.detail-section ul {
    padding-left: 20px;
}

.detail-section ul li {
    margin-bottom: 5px;
}

.mnemonic-section {
    border-left-color: var(--ochre);
    background: rgba(217, 159, 46, 0.1);
}

.mnemonic-text {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--ochre) !important;
}

.mnemonic-explain {
    font-size: 0.9rem;
    color: var(--ink-light) !important;
    font-style: italic;
}

.caution-section {
    border-left-color: var(--cinnabar);
    background: rgba(184, 59, 59, 0.05);
}

.btn-back {
    background: transparent;
    border: 1px solid var(--border-ink);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 15px;
    color: var(--ink-medium);
    transition: all 0.2s;
}

.btn-back:hover {
    border-color: var(--cinnabar);
    color: var(--cinnabar);
}

/* 方剂卡片列表 */
.formula-section {
    margin-bottom: 30px;
}

.formula-section h3 {
    color: var(--bamboo);
    font-size: 1.2rem;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border-ink);
}

.formula-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.formula-card {
    background: #fff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border-ink);
    cursor: pointer;
    transition: all 0.2s;
}

.formula-card:hover {
    border-color: var(--cinnabar);
    transform: translateY(-2px);
    box-shadow: var(--shadow-paper);
}

.formula-card .formula-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--ink-dark);
    margin-bottom: 5px;
}

.formula-card .formula-effects {
    font-size: 0.9rem;
    color: var(--cinnabar);
}

/* 深色模式适配 */
[data-theme="dark"] .formula-detail h2 {
    color: #ef9a9a;
}

[data-theme="dark"] .detail-section {
    background: rgba(40, 40, 40, 0.6);
}

[data-theme="dark"] .mnemonic-section {
    background: rgba(255, 224, 130, 0.1);
}

[data-theme="dark"] .caution-section {
    background: rgba(239, 154, 154, 0.1);
}

[data-theme="dark"] .formula-card {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .formula-card:hover {
    border-color: #ef9a9a;
}

[data-theme="dark"] .formula-card .formula-name {
    color: #f0f0f0;
}

[data-theme="dark"] .formula-card .formula-effects {
    color: #ef9a9a;
}

[data-theme="dark"] .btn-back {
    border-color: #444;
    color: #aaa;
}

[data-theme="dark"] .btn-back:hover {
    border-color: #ef9a9a;
    color: #ef9a9a;
}

/* 方剂闪卡结果页 */
.flashcard-result {
    text-align: center;
    padding: 40px 20px;
}

.flashcard-result h3 {
    font-size: 1.8rem;
    color: var(--bamboo);
    margin-bottom: 30px;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
}

.result-stats .stat {
    text-align: center;
}

.result-stats .stat-value {
    display: block;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--cinnabar);
}

.result-stats .stat-label {
    font-size: 0.9rem;
    color: var(--ink-light);
}

/* =====================================================
   方剂模块强化样式 (Formula Enhanced Styles)
   ===================================================== */

/* 搜索框 */
.formula-search {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    font-family: var(--font-sans);
    margin-bottom: var(--spacing-lg);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* 分单元盒子 */
.unit-box {
    margin-bottom: var(--spacing-lg);
}

.unit-box h3 {
    font-family: var(--font-heading);
    color: var(--bamboo);
    border-bottom: 1px solid var(--border-ink);
    padding-bottom: 8px;
    margin-bottom: 12px;
}

/* 方剂迷你卡片网格 */
.formula-flex-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.formula-card-small {
    background: var(--bg-card);
    border: 1px solid var(--border-ink);
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 80px;
}

.formula-card-small:hover {
    border-color: var(--l1-color);
    box-shadow: var(--shadow-paper);
    transform: translateY(-2px);
}

.formula-card-small .f-name {
    font-weight: bold;
    color: var(--ink-dark);
}

.formula-card-small .f-marks {
    font-size: 0.8em;
    margin-top: 4px;
}

/* 标记颜色 */
.m-year {
    color: var(--l1-color);
}

.m-prev {
    color: var(--l2-color);
}

.m-cli {
    color: var(--l3-color);
}

.m-herb {
    color: var(--l4-color);
}

.m-assist {
    color: var(--ink-light);
    font-size: 0.85em;
}

/* 方剂详情页 V2 */
.formula-detail-v2 {
    animation: fadeIn 0.3s ease-out;
}

.btn-back {
    background: none;
    border: none;
    color: var(--l1-color);
    cursor: pointer;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.detail-top {
    border-bottom: 2px solid var(--l1-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.detail-top .title {
    font-family: var(--font-heading);
    font-size: 2.2em;
    color: var(--l1-color);
}

.detail-body .section {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: 80px 1fr;
}

.detail-body label {
    font-weight: bold;
    color: var(--ink-light);
}

.detail-body .val {
    color: var(--ink-dark);
    line-height: 1.7;
}

.detail-body .verse {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--indigo);
}

/* 中药联动标签 */
.herb-link-tag {
    color: var(--bamboo);
    border-bottom: 1px dashed var(--bamboo-light);
    cursor: help;
    transition: color 0.2s;
}

.herb-link-tag:hover {
    color: var(--cinnabar);
    background: rgba(184, 59, 59, 0.05);
}

/* 闪卡盒子 */
.flashcard-box {
    width: 300px;
    height: 400px;
    margin: 0 auto;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.card-inner {
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    position: relative;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-paper);
}

.flashcard-box.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.card-back {
    transform: rotateY(180deg);
}

.card-hint {
    font-size: 1.1em;
    color: var(--ink-medium);
}

.card-tap {
    margin-top: 20px;
    color: var(--ink-light);
    font-size: 0.8em;
}

.card-name {
    font-family: var(--font-heading);
    font-size: 2.5em;
    color: var(--l1-color);
    margin-bottom: 20px;
}

.card-info {
    font-size: 0.9em;
    color: var(--ink-dark);
    text-align: left;
}

.card-footer {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.8em;
    color: var(--ink-light);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 方剂备考模式 (Exam Mode) */
.exam-view-v2 {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-md);
    animation: fadeIn 0.4s ease-out;
}

.exam-header {
    margin-bottom: var(--spacing-lg);
}

.symptom-box {
    background: rgba(184, 59, 59, 0.03);
    border: 1px dashed var(--l1-color);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
}

.symptom-box label {
    display: block;
    color: var(--l1-color);
    font-weight: bold;
    margin-bottom: 8px;
}

.exam-questions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.q-item {
    background: var(--bg-card);
    border: 1px solid var(--border-ink);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    transition: all 0.2s;
}

.q-text {
    font-weight: bold;
    color: var(--ink-light);
    margin-bottom: 10px;
    font-size: 0.9em;
}

.a-text {
    color: var(--l1-color);
    font-family: var(--font-heading);
    font-size: 1.3em;
    padding: 5px 0;
    border-top: 1px solid var(--border-ink);
    margin-top: 5px;
}

.btn-reveal {
    background: var(--bg-paper);
    border: 1px solid var(--border-ink);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85em;
}

.btn-reveal:hover {
    background: var(--l2-color);
    color: white;
}

.exam-footer {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-lg);
}

.exam-footer button {
    padding: 10px 20px;
    border: 1px solid var(--border-ink);
    background: var(--bg-card);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.exam-footer button:hover {
    background: var(--bg-paper);
    border-color: var(--l1-color);
}

/* =====================================================
   药材关联弹窗 (Herb Tooltip)
   ===================================================== */
.herb-link {
    color: var(--bamboo);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: all 0.2s;
}

.herb-link:hover {
    color: var(--bamboo-light);
    text-decoration-style: solid;
}

#herb-tooltip {
    position: fixed;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--border-ink);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 15px;
    max-width: 320px;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(5px);
    transition: all 0.2s ease;
    pointer-events: none;
}

#herb-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

#herb-tooltip .tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-ink);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

#herb-tooltip .tooltip-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--bamboo);
}

#herb-tooltip .tooltip-category {
    font-size: 0.8rem;
    color: var(--ink-light);
}

#herb-tooltip .tooltip-effects {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--ink-dark);
}

#herb-tooltip .tooltip-notfound {
    color: var(--ink-light);
    font-style: italic;
}

/* =====================================================
   Graph View - Enhanced Master Card
   ===================================================== */
.master-card.enhanced {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* Key fix: Responsive width */
    max-width: 600px;
    /* Reasonable constraint on desktop */
    min-width: 0;
    /* Allow flex items to shrink */
    padding: 0;
    overflow: hidden;
}

.master-card.enhanced .master-header {
    background: var(--bg-paper);
    padding: 12px 16px;
    border-bottom: 1px dashed var(--border-ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    /* Allow wrapping on small screens */
    gap: 8px;
}

.master-card.enhanced .master-title {
    font-size: 1.4em;
    color: var(--l1-color);
    font-weight: bold;
}

.master-card.enhanced .master-idx {
    font-size: 0.85em;
    color: #fff;
    background: var(--bamboo);
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: normal;
    white-space: nowrap;
    /* Prevent line break inside badge */
}

/* ... existing styles for master-body, info-row ... */

.master-card.enhanced .master-body {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.master-card.enhanced .info-row {
    display: flex;
    align-items: baseline;
    line-height: 1.5;
}

.master-card.enhanced .label {
    flex-shrink: 0;
    width: 65px;
    color: var(--ink-light);
    font-weight: bold;
    font-size: 0.9em;
}

.master-card.enhanced .val {
    color: var(--ink-dark);
    font-size: 0.95em;
    word-break: break-all;
    /* Prevent overflow on long text */
}

.master-card.enhanced .val.pattern {
    color: var(--l3-color);
    /* color: #d32f2f; */
    font-weight: bold;
}

.master-card.enhanced .composition-row .val {
    line-height: 1.6;
}

/* Variant Card - Category Badge Style */
.variant-idx {
    font-size: 0.75em;
    color: var(--ink-light);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
    /* Push to right */
    white-space: nowrap;
}

[data-theme="dark"] .variant-idx {
    background: rgba(255, 255, 255, 0.1);
    color: #aaa;
}

/* Variant Info (功用/证型) */
.variant-info {
    display: flex;
    gap: 6px;
    font-size: 0.85em;
    line-height: 1.4;
    margin-top: 6px;
    padding: 0 4px;
}

.variant-info .vi-label {
    color: #888;
    flex-shrink: 0;
}

.variant-info .vi-val {
    color: #555;
    word-break: break-word;
}

.variant-info .vi-val.pattern {
    color: #c62828;
    font-weight: 500;
}

[data-theme="dark"] .variant-info .vi-label {
    color: #777;
}

[data-theme="dark"] .variant-info .vi-val {
    color: #bbb;
}

[data-theme="dark"] .variant-info .vi-val.pattern {
    color: #ef5350;
}

/* Dark Mode Support for Enhanced Card */
[data-theme="dark"] .master-card.enhanced {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .master-card.enhanced .master-header {
    background: #333;
    border-bottom-color: #444;
}

[data-theme="dark"] .master-card.enhanced .master-title {
    color: #ef9a9a;
}

[data-theme="dark"] .master-card.enhanced .master-idx {
    background: #5c8d6d;
    /* Darker bamboo */
}

[data-theme="dark"] .master-card.enhanced .label {
    color: #888;
}

[data-theme="dark"] .master-card.enhanced .val {
    color: #ddd;
}

[data-theme="dark"] .master-card.enhanced .val.pattern {
    color: #ef5350;
}

/* =========================================
   Clinical Case Exam (Masked Mode)
   ========================================= */
.case-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid #eee;
}

.case-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #666;
    font-size: 0.9em;
}

.case-main {
    padding: 25px;
}

.case-stem {
    margin-bottom: 25px;
    padding: 15px;
    background: #fff9ed;
    /* Light orange tint for case */
    border-left: 4px solid var(--bamboo);
    border-radius: 4px;
    font-size: 1.1em;
    line-height: 1.6;
    color: #444;
}

.case-question-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.case-q-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.case-q-label {
    font-weight: bold;
    color: var(--l1-color);
    /* Bamboo green */
    font-size: 1em;
}

/* The Answer Box (Masked/Revealed) */
.case-q-answer {
    position: relative;
    background: #f8f8f8;
    border: 1px dashed #ccc;
    border-radius: 6px;
    min-height: 44px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    /* Prevent peeking by selection */
    display: flex;
    align-items: center;
    padding: 10px 15px;
}

.case-q-answer:hover {
    background: #f0f0f0;
    border-color: #bbb;
}

/* Masked State */
.case-q-answer.masked .ans-content {
    opacity: 0;
    /* Fully hide content */
    visibility: hidden;
}

.case-q-answer.masked::after {
    content: "点击查看答案";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 0.9em;
    pointer-events: none;
}

/* Revealed State */
.case-q-answer.revealed {
    background: #fff;
    border: 1px solid #e0e0e0;
    cursor: default;
}

.case-q-answer.revealed .ans-content {
    opacity: 1;
    visibility: visible;
    color: #333;
    font-size: 1.05em;
    width: 100%;
}

/* Formula Name Row with Badge */
.ans-formula-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.ans-formula-name {
    font-size: 1.3em;
    font-weight: bold;
    color: #2c3e50;
}

.ans-badge {
    background: var(--l1-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    opacity: 0.9;
}

/* Controls */
.case-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn-case {
    padding: 10px 25px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: transform 0.1s;
}

.btn-case:active {
    transform: scale(0.98);
}

.btn-prev {
    background: #f0f0f0;
    color: #666;
}

.btn-next {
    background: var(--l1-color);
    color: white;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

/* Dark Mode */
[data-theme="dark"] .case-card {
    background: #2a2a2a;
    border-color: #444;
}

[data-theme="dark"] .case-header {
    background: #333;
    border-color: #444;
    color: #aaa;
}

[data-theme="dark"] .case-stem {
    background: #2d2620;
    /* Dark orange tint */
    border-left-color: #5c8d6d;
    color: #ddd;
}

[data-theme="dark"] .case-q-label {
    color: #8ab69b;
}

[data-theme="dark"] .case-q-answer {
    background: #333;
    border-color: #444;
}

[data-theme="dark"] .case-q-answer:hover {
    background: #383838;
}

[data-theme="dark"] .case-q-answer.revealed {
    background: #333;
    border-color: #555;
}

[data-theme="dark"] .case-q-answer.revealed .ans-content {
    color: #ccc;
}

[data-theme="dark"] .ans-formula-name {
    color: #e0e0e0;
}

[data-theme="dark"] .btn-prev {
    background: #333;
    color: #aaa;
}

[data-theme="dark"] .case-stem {
    background: #3d3020;
    color: #ddd;
    border-left-color: #b78a48;
}

/* Darker Orange/Brown */
[data-theme="dark"] .case-q-answer {
    background: #333;
    border-color: #555;
}

[data-theme="dark"] .case-q-answer.revealed {
    background: #2a2a2a;
    border-color: #555;
}

[data-theme="dark"] .case-q-answer.revealed .ans-content {
    color: #eee;
}

[data-theme="dark"] .case-q-answer.masked::after {
    color: #666;
}

[data-theme="dark"] .ans-formula-name {
    color: #fff;
}

/* ========================================= */
/* 面试实战模拟器 - 夜间模式 */
/* ========================================= */

[data-theme="dark"] .exam-view,
[data-theme="dark"] .exam-home-container,
[data-theme="dark"] .exam-content {
    background: var(--bg-paper);
    color: var(--ink-dark);
}

[data-theme="dark"] .exam-station-card {
    background: var(--bg-card) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] .exam-station-card h3,
[data-theme="dark"] .exam-station-card p {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] .exam-station-card ul {
    background: #333 !important;
}

[data-theme="dark"] .exam-station-card li {
    color: var(--ink-medium) !important;
}

[data-theme="dark"] .exam-station-card li span {
    color: #10b981 !important;
}

[data-theme="dark"] .exam-station-card li[style*="color:#999"] span,
[data-theme="dark"] .exam-station-card li[style*="color:#999"] {
    color: #666 !important;
}

[data-theme="dark"] .exam-ai-toggle {
    background: rgba(102, 126, 234, 0.2) !important;
}

[data-theme="dark"] .exam-ai-toggle span {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] .exam-ai-toggle p {
    color: var(--ink-light) !important;
}

[data-theme="dark"] .exam-header {
    background: var(--bg-card) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #exam-station-label {
    color: #a5b4fc !important;
}

[data-theme="dark"] #exam-question-progress {
    color: var(--ink-light) !important;
}

[data-theme="dark"] .exam-timer,
[data-theme="dark"] #exam-timer {
    background: #333 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-current-question-label {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] .exam-draw-card-area > div {
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4) !important;
}

[data-theme="dark"] #exam-question-view > div,
[data-theme="dark"] #exam-answer-view > div,
[data-theme="dark"] #exam-followup-view > div {
    background: var(--bg-card) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #exam-question-category {
    background: #333 !important;
    color: var(--ink-light) !important;
}

[data-theme="dark"] #exam-question-title {
    color: #a5b4fc !important;
}

[data-theme="dark"] #exam-question-view div[style*="background:#f8f9fa"],
[data-theme="dark"] #exam-followup-question {
    background: #333 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-question-main {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-examiner-prompt {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d3748 100%) !important;
}

[data-theme="dark"] .exam-examiner-text {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-answer-view div[style*="border:1px solid #e5e7eb"] {
    border-color: #444 !important;
}

[data-theme="dark"] #exam-answer-view div[style*="background:#f9fafb"],
[data-theme="dark"] #exam-followup-view div[style*="background:#f9fafb"] {
    background: #333 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-answer-content,
[data-theme="dark"] #exam-followup-answer-content {
    background: var(--bg-card) !important;
    border-color: #444 !important;
}

[data-theme="dark"] #exam-answer-details,
[data-theme="dark"] #exam-followup-answer-details {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-answer-details h4,
[data-theme="dark"] #exam-answer-details h5 {
    color: #a5b4fc !important;
    border-color: #444 !important;
}

[data-theme="dark"] .exam-score-btn {
    background: var(--bg-card) !important;
    border-color: #444 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #view-exam-result > div > div {
    background: var(--bg-card) !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #view-exam-result h2 {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #exam-score-list {
    background: #333 !important;
}

[data-theme="dark"] #exam-score-list > div {
    border-color: #444 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] .exam-modal > div {
    background: var(--bg-card) !important;
}

[data-theme="dark"] .exam-modal h2 {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] .exam-modal p {
    color: var(--ink-light) !important;
}

/* 考试模拟器 - 关键要点样式 */
.exam-key-points {
    background: #fef3c7;
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 12px;
}

.exam-key-points strong {
    color: #f59e0b;
}

.exam-key-points-text {
    color: #92400e;
}

[data-theme="dark"] .exam-key-points {
    background: #3d3014;
}

[data-theme="dark"] .exam-key-points strong {
    color: #fbbf24;
}

[data-theme="dark"] .exam-key-points-text {
    color: #fcd34d;
}

/* ========================================= */
/* 技能手册模块 - 夜间模式 */
/* ========================================= */

[data-theme="dark"] .skill-view,
[data-theme="dark"] #view-skill-handbook {
    background: var(--bg-paper);
    color: var(--ink-dark);
}

[data-theme="dark"] #view-skill-handbook > div > div:first-child {
    background: var(--bg-card) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #view-skill-handbook h2 {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #skill-search-input {
    background: var(--bg-card) !important;
    border-color: #444 !important;
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #skill-search-input::placeholder {
    color: var(--ink-light) !important;
}

[data-theme="dark"] .skill-chip {
    background: #333 !important;
    color: var(--ink-medium) !important;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

[data-theme="dark"] .skill-chip:hover {
    background: #444 !important;
}

[data-theme="dark"] .skill-chip.active {
    background: var(--l1-color) !important;
    color: white !important;
}

[data-theme="dark"] #skill-stats-bar {
    color: var(--ink-light) !important;
}

[data-theme="dark"] #skill-results-grid > div {
    background: var(--bg-card) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

[data-theme="dark"] #skill-results-grid > div span[style*="font-weight:bold"] {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #skill-results-grid > div div[style*="color:#888"],
[data-theme="dark"] #skill-results-grid > div div[style*="color:#555"] {
    color: var(--ink-light) !important;
}

[data-theme="dark"] #skill-detail-modal > div {
    background: var(--bg-card) !important;
}

[data-theme="dark"] #skill-detail-modal > div > div:first-child {
    border-color: #444 !important;
}

[data-theme="dark"] #skill-modal-title {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #skill-modal-subtitle {
    color: var(--ink-light) !important;
}

[data-theme="dark"] #skill-modal-body {
    color: var(--ink-dark) !important;
}

[data-theme="dark"] #skill-modal-body h3,
[data-theme="dark"] #skill-modal-body h4 {
    color: #a5b4fc !important;
    border-color: #444 !important;
}

[data-theme="dark"] #skill-modal-body ul,
[data-theme="dark"] #skill-modal-body ol,
[data-theme="dark"] #skill-modal-body p {
    color: var(--ink-medium) !important;
}

[data-theme="dark"] #skill-modal-body div[style*="background:#fff8e1"],
[data-theme="dark"] #skill-modal-body div[style*="background:#f0f7ff"],
[data-theme="dark"] #skill-modal-body div[style*="background:#fff1f0"],
[data-theme="dark"] #skill-modal-body div[style*="background:#fff3e0"],
[data-theme="dark"] #skill-modal-body div[style*="background:#f6ffed"],
[data-theme="dark"] #skill-modal-body div[style*="background:#f9f0ff"],
[data-theme="dark"] #skill-modal-body div[style*="background:#f9f9f9"] {
    background: #333 !important;
    border-color: #444 !important;
}

/* 技能手册筛选标签基础样式（亮色模式） */
.skill-chip {
    padding: 6px 16px;
    background: #eee;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.2s;
    user-select: none;
}

.skill-chip:hover {
    background: #ddd;
}

.skill-chip.active {
    background: var(--l1-color);
    color: white;
}

/* 技能手册卡片样式 */
.skill-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    border-left: 4px solid #666;
    transition: transform 0.2s, box-shadow 0.2s;
}

.skill-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.skill-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.skill-card-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.skill-card-subtitle {
    font-size: 13px;
    color: #888;
    margin-bottom: 8px;
}

.skill-card-snippet {
    font-size: 14px;
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

/* 卡片类型边框颜色 */
.skill-card-technique { border-left-color: #0d47a1; }
.skill-card-diagnostic { border-left-color: #f5222d; }
.skill-card-history { border-left-color: #722ed1; }
.skill-card-complication { border-left-color: #e65100; }
.skill-card-acupoint { border-left-color: #7b1fa2; }
.skill-card-emergency { border-left-color: #b71c1c; }

/* 技能标签样式 */
.skill-tag {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.skill-tag-technique { background: #bbdefb; color: #0d47a1; }
.skill-tag-diagnostic { background: #fff1f0; color: #f5222d; }
.skill-tag-history { background: #f9f0ff; color: #722ed1; }
.skill-tag-complication { background: #ffe0b2; color: #e65100; }
.skill-tag-acupoint { background: #e1bee7; color: #7b1fa2; }
.skill-tag-emergency { background: #ffcdd2; color: #b71c1c; }

/* 技能手册卡片 - 夜间模式 */
[data-theme="dark"] .skill-card {
    background: var(--bg-card);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .skill-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .skill-card-title {
    color: var(--ink-dark);
}

[data-theme="dark"] .skill-card-subtitle {
    color: var(--ink-light);
}

[data-theme="dark"] .skill-card-snippet {
    color: var(--ink-medium);
}

/* 技能标签 - 夜间模式（保持高对比度） */
[data-theme="dark"] .skill-tag-technique { background: #1e3a5f; color: #90caf9; }
[data-theme="dark"] .skill-tag-diagnostic { background: #3d1a1a; color: #ff8a80; }
[data-theme="dark"] .skill-tag-history { background: #2d1b4e; color: #ce93d8; }
[data-theme="dark"] .skill-tag-complication { background: #3d2814; color: #ffcc80; }
[data-theme="dark"] .skill-tag-acupoint { background: #2d1b3d; color: #ce93d8; }
[data-theme="dark"] .skill-tag-emergency { background: #3d1a1a; color: #ef9a9a; }

/* 技能手册弹窗内容样式 */
#skill-modal-body h3 {
    color: #00796b;
    border-left: 4px solid #00796b;
    padding-left: 10px;
    margin-top: 20px;
    margin-bottom: 10px;
}

#skill-modal-body h4 {
    margin-top: 15px;
    margin-bottom: 8px;
}

#skill-modal-body ul,
#skill-modal-body ol {
    margin: 10px 0;
    padding-left: 20px;
}

#skill-modal-body li {
    margin: 5px 0;
    line-height: 1.6;
}

#skill-modal-body p {
    margin: 8px 0;
    line-height: 1.6;
}

/* 口诀盒子 */
.mnemonic-box {
    background: #fff8e1;
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed #ffb300;
    font-family: 'KaiTi', 'STKaiti', serif;
    font-size: 18px;
    text-align: center;
    margin: 10px 0;
}

/* 技能手册弹窗图片 */
.skill-modal-images {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
    background: #fafafa;
    padding: 15px;
    border-radius: 8px;
}

.skill-modal-img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: zoom-in;
}

/* 技能手册弹窗 - 夜间模式 */
[data-theme="dark"] #skill-detail-modal > div {
    background: var(--bg-card);
}

[data-theme="dark"] #skill-modal-body {
    color: var(--ink-dark);
}

[data-theme="dark"] #skill-modal-body h3 {
    color: #4db6ac;
    border-left-color: #4db6ac;
}

[data-theme="dark"] #skill-modal-body h4 {
    color: var(--ink-dark);
}

[data-theme="dark"] .mnemonic-box {
    background: #3d3014;
    border-color: #8d6e00;
    color: #ffd54f;
}

[data-theme="dark"] .skill-modal-images {
    background: #2a2a2a;
}

[data-theme="dark"] #skill-modal-body div[style*="background:#fff"] {
    background: #2a2a2a !important;
    color: var(--ink-dark);
}

[data-theme="dark"] #skill-modal-body div[style*="background:#f"] {
    background: #2a2a2a !important;
}

[data-theme="dark"] #skill-modal-body ul[style*="background:#"] {
    background: #2a2a2a !important;
}