/* ========================================
   ?è²?¨æ?æºæ¥·?¸å?é«?
   ======================================== */

@font-face {
    font-family: 'edukai';
    src: url('./fonts/edukai-4.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
/* =========================================
   0. ONBOARDING (v1.1)
   ========================================= */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 1);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.onboarding-card {
    background: white;
    padding: 3.5rem;
    border-radius: 32px;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.12);
    max-width: 550px;
    width: 100%;
    text-align: center;
}

.onboarding-card h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: #1e293b;
}

.onboarding-card p {
    font-size: 1.1rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.onboarding-q {
    text-align: left;
    margin-top: 1.5rem;
}

.onboarding-q label {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.sem-toggle {
    display: flex;
    gap: 10px;
}

.ob-btn {
    border: 2px solid #e2e8f0;
    background: white;
    padding: 16px 10px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ob-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
}

.ob-btn.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* =========================================
   1. GLOBAL & RESET (Modern SaaS Style)
   ========================================= */
:root {
    /* UI Colors */
    --bg-page: #f8fafc;
    /* Very Pale Blue/White */
    --bg-card: #ffffff;
    --text-main: #334155;
    /* Dark Slate */
    --text-muted: #64748b;
    --primary: #4f46e5;
    /* Indigo */
    --primary-hover: #4338ca;
    --secondary: #0ea5e9;
    /* Sky 500 */
    --secondary-hover: #0284c7;
    /* Sky 600 */
    --border-input: #e2e8f0;
    --focus-ring: #3b82f6;

    /* Workbook Vars (Preserved) */
    --grid-blue: #3B4CCA;
    --stroke-pink: #FF00FF;
    --text-black: #000;
    --a4-width: 210mm;
    --a4-height: 297mm;

    /* Workbook Proportions */
    --h-header: 14%;
    --h-meta: 6%;
    --h-strokes: 35%;
    --h-practice: 45%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-main);
    /* Modern UI Font Stack */
    font-family: "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

/* =========================================
   2. CONTROL PANEL (Modern Card)
   ========================================= */
.container {
    width: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.control-panel {
    background: var(--bg-card);
    width: 100%;
    max-width: 800px;
    padding: 2.5rem;
    border-radius: 12px;
    /* Soft Drop Shadow */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 3rem;
    text-align: left;
}

.app-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 2rem;
    text-align: center;
    letter-spacing: -0.025em;
    position: relative;
    display: table;
    /* Fit content for underline */
    margin-left: auto;
    margin-right: auto;
}

.app-title::after {
    content: '';
    display: block;
    width: 60%;
    height: 4px;
    background: var(--secondary);
    /* Sky Blue underline */
    margin: 4px auto 0;
    border-radius: 2px;
    opacity: 0.6;
}

/* Inputs & Labels */
.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #f8fafc;
}

input:focus {
    outline: none;
    border-color: var(--focus-ring);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Settings Grid (Side by Side) */
.settings-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.btn {
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    /* Pill shape */
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.form-select,
select {
    width: 100%;
    padding: 0.8rem 1rem;
    font-size: 1.1rem;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    background-color: #f8fafc;
    color: var(--text-dark);
}

.btn-primary {
    background: var(--primary);
    color: white;
    font-size: 1.1rem;
    padding: 1rem 2rem;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    /* border: 1px solid var(--border-input); */
    border: none;
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.3);
    /* Sky shadow */
}

.btn-secondary:not(:disabled):hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -1px rgba(14, 165, 233, 0.4);
}

.btn-secondary:disabled {
    background: #cbd5e1;
    color: #f1f5f9;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}


/* =========================================
   3. PREVIEW & WORKBOOK (Realistic Paper)
   ========================================= */
.preview-section {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-bottom: 4rem;
}

.sheet-page {
    /* Reset Font for Workbook Context */
    font-family: "KaiTi", "BiauKai", "DFKai-SB", "æ¨æ¥·é«?, serif;

    width: var(--a4-width);
    height: var(--a4-height);
    background: white;
    margin: 0 auto;
    /* Centered */
    padding: 10mm;

    display: flex;
    flex-direction: column;
    /* Vertical stack for Header + Body */

    /* Realistic Paper Shadow */
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* v1.6 NEW: PAGE HEADER - å·²é±?ä»¥ä¿®æ­£?ç??é? */
.sheet-header {
    display: none !important;
    width: 100%;
    height: 15mm;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--grid-blue);
    margin-bottom: 5mm;
    padding-bottom: 2mm;
    color: var(--grid-blue);
}

.sheet-title-main {
    font-size: 20px;
    font-weight: 900;
}

.sheet-info-meta {
    font-size: 14px;
    flex-grow: 1;
    text-align: center;
    font-weight: 500;
}

.sheet-info-student {
    font-size: 16px;
    font-weight: 500;
}

/* v1.6 NEW: PAGE BODY */
.sheet-body {
    flex-grow: 1;
    display: flex;
    flex-direction: row-reverse;
    /* Restore RTL Global */
}


/* =========================================
   4. WORKBOOK INTERNALS (Preserved Logic)
   ========================================= */

/* 1. SIDEBAR (LEGEND COLUMN) */
.sidebar {
    width: 25mm;
    height: 100%;
    border: 2px solid var(--grid-blue);
    border-left: 1px solid var(--grid-blue);
    display: flex;
    flex-direction: column;
    color: var(--grid-blue);
    text-align: center;
}

/* BLOCK 1: HEADER (Only Vocabulary) */
.sidebar-block-top {
    height: calc(var(--h-header) + var(--h-meta));
    border-bottom: 1px solid var(--grid-blue);
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-title-vocab {
    writing-mode: vertical-rl;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 5px;
}

/* BLOCK 2: STROKES */
.sidebar-block-strokes {
    height: var(--h-strokes);
    border-bottom: 1px solid var(--grid-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    writing-mode: vertical-rl;
    letter-spacing: 0.5em;
}

/* BLOCK 3: PRACTICE */
.sidebar-block-practice {
    height: var(--h-practice);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    writing-mode: vertical-rl;
    letter-spacing: 0.5em;
}


/* 2. CONTENT AREA */
.content-area {
    flex-grow: 1;
    height: 100%;
    display: flex;
    flex-direction: row-reverse;
    border-top: 2px solid var(--grid-blue);
    border-bottom: 2px solid var(--grid-blue);
    border-left: 2px solid var(--grid-blue);
}

.char-col {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--grid-blue);
}

.content-area .char-col:first-child {
    border-right: none;
}


/* SECTIONS */
.sec-header {
    height: var(--h-header);
    border-bottom: 1px solid var(--grid-blue);
    display: flex;
    flex-direction: row-reverse;
}

.sec-meta {
    height: var(--h-meta);
    border-bottom: 1px solid var(--grid-blue);
    display: flex;
    flex-direction: column;
}

/* STROKE SECTION (Vertical Column Flow, Right to Left) */
.sec-strokes {
    height: var(--h-strokes);
    border-bottom: 1px solid var(--grid-blue);
    display: grid;
    grid-template-rows: repeat(10, 1fr);
    /* 10 vertical items */
    grid-auto-flow: column;
    /* Fill columns from right to left */
    grid-auto-columns: 32%;
    /* 3 columns approx */
    gap: 0;
    direction: rtl;
    /* Start columns from the right */
    padding: 2px;
    overflow: hidden;
}

/* Stroke Steps (Compact Grid Items for 3-Col Layout) */
.stroke-step {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0px;
    flex: 0 0 auto;
}

.stroke-step svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sec-practice-group {
    height: var(--h-practice);
    display: flex;
    flex-direction: column;
}

/* INNER STYLING */
/* INNER STYLING */
/* INNER STYLING */
.zhuyin-box {
    width: 20%;
    /* Narrowed to give more room for the character */
    border-left: 1px solid var(--grid-blue);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    position: relative;
    padding: 1px;
}

.zhuyin-symbols {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.zhuyin-symbols div {
    line-height: 0.85;
    /* Tight vertical stack */
}

.zhuyin-tone {
    margin-left: 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    width: 8px;
    /* Fixed tone width */
}

.tone-neutral {
    position: absolute;
    top: 2px;
    left: 40%;
    transform: translateX(-50%);
}

.big-char-box {
    width: 80%;
    position: relative;
}

.meta-row {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--grid-blue);
    font-size: 10px;
}

.meta-row:last-child {
    border-bottom: none;
}

.practice-cell {
    width: 100%;
    flex: 1;
    border-bottom: 1px solid var(--grid-blue);
    position: relative;
}

/* Rule removed by Code Agent */

/* SHARED */
.tian-zi-ge {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.tian-zi-ge::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 0;
    border-top: 1px dashed var(--grid-blue);
    opacity: 0.8;
    pointer-events: none;
    z-index: 1;
}

.tian-zi-ge::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    height: 100%;
    width: 0;
    border-left: 1px dashed var(--grid-blue);
    opacity: 0.8;
    pointer-events: none;
    z-index: 1;
}

.char-text {
    font-size: 3em;
    line-height: 1;
    z-index: 2;
}

.char-trace {
    font-size: 3em;
    line-height: 1;
    z-index: 2;
    color: #ccc;
}

/* [Consolidated into v8.0 Monolith at EOF] */

/* =========================================
   5. UI/UX PHASE 2: MODERN LAYOUT
   ========================================= */

/* A. Navbar (Sticky Top) */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-input);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
}

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

/* B. Main Grid Layout */
.app-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    min-height: calc(100vh - 60px);
    /* Adjust for navbar */
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
}

/* C. Sidebar (Left Controls) */
.app-sidebar {
    background: white;
    border-right: 1px solid var(--border-input);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
    overflow-y: auto;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* D. Tabs Navigation */
.tab-nav {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Tab Panels */
.tab-panel {
    display: none;
    animation: fadeIn 0.2s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0.8;
        transform: translateY(5px);
    }

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

/* E. Sidebar Forms & Groups */
.panel-section {
    margin-bottom: 2rem;
}

.panel-section.border-top {
    border-top: 1px solid var(--border-input);
    padding-top: 1.5rem;
    margin-top: auto;
    /* Push to bottom if space allows */
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    display: block;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-select,
.form-input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border-input);
    border-radius: 8px;
    background-color: var(--bg-page);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.form-select:focus,
.form-input:focus,
.text-input-large:focus {
    outline: none;
    border-color: var(--focus-ring);
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Large Text Area for Manual Input */
.text-input-large {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-input);
    border-radius: 12px;
    background: var(--bg-page);
    font-size: 1.25rem;
    /* Larger font for characters */
    font-family: 'KaiTi', 'BiauKai', serif;
    /* Handwriting feel */
    resize: vertical;
    line-height: 1.6;
}

/* Full Width Buttons */
.full-width {
    width: 100%;
    justify-content: center;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* F. Main Preview Area */
.app-main {
    background: #e2e8f0;
    /* Darker background for contrast */
    padding: 2rem;
    display: flex;
    justify-content: center;
    /* align-items: flex-start; */
    min-height: 100%;
}

.preview-wrapper {
    width: 100%;
    max-width: var(--a4-width);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    background: white;
    border-radius: 16px;
    border: 2px dashed var(--border-input);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: bounceLeft 1s infinite;
}

@keyframes bounceLeft {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(-10px);
    }
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #cbd5e1;
    color: #f8fafc;
    box-shadow: none;
}

/* Override old container styles if necessary */
.container {
    padding: 0 !important;
    display: block !important;
    width: auto !important;
}

/* Consolidated into end-of-file @media print */


/* =========================================
   6. UI Phase 3: COMPONENT POLISH
   ========================================= */

/* A. Visual Grade Selector (Cards) */
.grade-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.grade-card {
    background: var(--bg-page);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.grade-card:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.grade-card.active {
    background: white;
    border-color: var(--secondary);
    /* Sky Blue */
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.2);
}

.grade-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.grade-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
}

.grade-card.active .grade-label {
    color: var(--secondary);
}

/* B. Realistic Paper Texture for Preview */
.practice-sheet-container {
    padding: 2rem;
    display: flex;
    justify-content: center;
    background-color: transparent;
    /* Let container bg show */
}

/* The Sheet Itself */
.sheet-page {

    /* Existing basic styles preserved */
    /* Add subtle texture overlaid */
    /* Textured background */
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0IiBoZWlnaHQ9IjQiPgo8cmVjdCB3aWR0aD0iNCIgaGVpZ2h0PSI0IiBmaWxsPSIjZmZmYmYwIi8+CjxyZWN0IHdpZHRoPSIxIiBoZWlnaHQ9IjEiIGZpbGw9IiMwMDAiIG9wYWNpdHk9IjAuMDUiLz4KPC9zdmc+');
    position: relative;
    /* Folded Corner Effect via Pseudo-element (Optional - keeping simple for now) */
}

/* Ensure empty state looks good in grid */
.empty-state {
    grid-column: 1 / -1;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* =========================================
   7. UI Pro Max: HERO SECTION & THEME
   ========================================= */

/* Pro Max Theme: Earth Tones */
:root {
    --primary-sage: #8DA399;
    /* Sage Green */
    --primary-sage-dark: #6C8279;
    --bg-beige: #F5F5F0;
    /* Beige */
    --text-dark: #2C3E50;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body {
    background-color: var(--bg-beige);
    font-family: 'Noto Sans TC', sans-serif;
    color: var(--text-dark);
}

/* --- Hero Section --- */
.hero-section {
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    transition: all 0.5s ease;
}

/* Smart Card */
.smart-card {
    background: white;
    padding: 3rem 4rem;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    max-width: 600px;
    width: 100%;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.smart-card:hover {
    transform: translateY(-5px);
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--primary-sage-dark);
    font-weight: 500;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    color: var(--text-dark);
}

.card-loading {
    font-size: 1.2rem;
    color: #999;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

/* Hero Actions */
.btn-primary-hero {
    background-color: var(--primary-sage);
    color: white;
    border: none;
    padding: 1rem 3rem;
    font-size: 1.3rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(141, 163, 153, 0.4);
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 1rem;
}

.btn-primary-hero:hover {
    background-color: var(--primary-sage-dark);
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(141, 163, 153, 0.6);
}

.hero-hint {
    font-size: 0.9rem;
    color: #888;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Secondary Actions */
.btn-text {
    background: none;
    border: none;
    color: #999;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    margin: 0 1rem;
    transition: color 0.3s;
}

.btn-text:hover {
    color: var(--primary-sage-dark);
    border-bottom: 1px solid var(--primary-sage-dark);
}

/* Legacy Controls Visibility */
.hidden-controls {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.show-controls {
    display: block;
    opacity: 1;
    animation: fadeIn 0.5s forwards;
}

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

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

/* Legacy Controls Visibility - HIDDEN BY DEFAULT */
.hidden-controls {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Only show when explicitly toggled */
.show-controls {
    display: block;
    opacity: 1;
    animation: fadeIn 0.5s forwards;
}

/* Ensure Settings Panel looks better when it IS shown */
.settings-panel {
    border-right: 1px solid #eee !important;
    background-color: white !important;
    border-radius: 12px;
}

.grade-card.active {
    border-color: var(--primary-sage);
    background-color: rgba(141, 163, 153, 0.1);
}

/* Ensure empty state looks good in grid */
.empty-state {
    grid-column: 1 / -1;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* =========================================
   NEW PRODUCT LAYOUT STYLES
   ========================================= */

/* 1. Minimal Header */
.minimal-header {
    padding: 1rem 2rem;
    background: transparent;
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.minimal-header .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* 2. Hero Section */
.hero-section {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
}

/* 3. Smart Card */
.smart-card {
    background: white;
    padding: 3rem;
    border-radius: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05),
        0 8px 10px -6px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 450px;
    margin-bottom: 2rem;
    transition: transform 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.smart-card:hover {
    transform: translateY(-5px);
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.hero-title {
    font-family: "Noto Serif TC", serif;
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--text-main);
    margin-bottom: 2.5rem;
}

/* 4. Action Buttons */
.btn-primary-hero {
    background-color: #8fa298;
    /* Muted Sage Green from screenshot concept */
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 99px;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(143, 162, 152, 0.3);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-primary-hero:hover {
    background-color: #7b8e84;
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(143, 162, 152, 0.4);
}

.hero-hint {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: #a0aec0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* 5. Secondary Actions */
.secondary-actions {
    margin-top: 1rem;
}

.btn-text {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    padding: 0.5rem 1rem;
    transition: color 0.2s ease;
}

.btn-text:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* 6. Hidden Controls Logic Re-fix */
.hidden-controls {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.show-controls {
    display: block !important;
    opacity: 1 !important;
}

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

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

.card-content {
    animation: fadeIn 0.8s ease-out forwards;
}

/* =========================================
   7. 95+ PRODUCT POLISH: RITUAL SCREEN
   ========================================= */
.btn-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: all 0.2s;
}

.btn-text:hover {
    color: var(--text-main);
    text-decoration: underline;
}

.success-state h2 {
    letter-spacing: -0.01em;
}

.success-state .hero-actions .btn-primary-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.success-state .hero-actions .btn-primary-hero:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* LINE Visual Guide Overlay */
.line-guide-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.line-guide-content {
    background: white;
    width: 100%;
    max-width: 400px;
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.line-guide-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.line-guide-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 1rem;
}

.line-guide-step {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e2e8f0;
}

.step-number {
    background: var(--primary-sage);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.step-text {
    font-size: 0.95rem;
    color: #475569;
    line-height: 1.4;
}

.line-guide-close {
    margin-top: 1.5rem;
    width: 100%;
    padding: 0.8rem;
    background: #f1f5f9;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
}

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

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

/* =========================================
   FINAL UNIFIED PRINT MONOLITH (v8.0)
   Consolidates all print logic for hardware & PDF stability
   ========================================= */
@media print {

    /* 1. Global Box Calibration & Page Setup */
    *,
    *::before,
    *::after {
        box-sizing: border-box !important;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        width: 210mm !important;
        height: auto !important;
        overflow: visible !important;
    }

    /* 2. Professional Isolation */
    .navbar,
    .app-sidebar,
    .sidebar-toggle,
    .btn-float {
        display: none !important;
    }

    body>*:not(.hero-section) {
        display: none !important;
    }

    .hero-section {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background: white !important;
    }

    .hero-section>.container:not(#legacyControls) {
        display: none !important;
    }

    #legacyControls {
        display: block !important;
        padding: 0 !important;
    }

    #legacyControls .row>*:not(.col-lg-8) {
        display: none !important;
    }

    #legacyControls .col-lg-8 {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        flex: 0 0 100% !important;
    }

    .card {
        border: none !important;
        box-shadow: none !important;
        background: transparent !important;
    }

    .card-body {
        padding: 0 !important;
    }

    #previewSection {
        padding: 0 !important;
        margin: 0 !important;
    }

    #previewSection>*:not(#sheets-container) {
        display: none !important;
    }

    #sheets-container {
        display: block !important;
        padding: 0 !important;
    }

    /* 3. Absolute Fixed-MM Worksheet Layout (v8.6 Pure Stability Monolith) */
    .sheet-page {
        display: flex !important;
        flex-direction: column !important;
        width: 210mm !important;
        height: 285mm !important;
        margin: 0 !important;
        padding: 10mm !important;
        /* Standard pure margins */
        background: white !important;
        box-shadow: none !important;
        border: none !important;
        overflow: hidden !important;
        break-after: page !important;
        page-break-after: always !important;
        color: #000 !important;
    }

    .sheet-header {
        display: flex !important;
        height: 15mm !important;
        margin-bottom: 5mm !important;
        border-bottom: 2px solid #3B4CCA !important;
        color: #3B4CCA !important;
        visibility: visible !important;
    }

    .sheet-body {
        display: flex !important;
        flex-direction: row-reverse !important;
        flex-grow: 1 !important;
        width: 100% !important;
        height: 245mm !important;
        /* Standard Proportions */
        min-height: 245mm !important;
        overflow: hidden !important;
    }

    /* Fixed Millimeter Sections - No percentages allowed in Print */
    .sidebar {
        width: 25mm !important;
        height: 100% !important;
        border: 2px solid #3B4CCA !important;
        border-left: 1px solid #3B4CCA !important;
    }

    .content-area {
        flex-grow: 1 !important;
        height: 100% !important;
        border: 2px solid #3B4CCA !important;
        border-right: none !important;
    }

    .sec-header {
        height: 35mm !important;
        border-bottom: 1px solid #3B4CCA !important;
        overflow: hidden !important;
    }

    .sec-meta {
        height: 15mm !important;
        border-bottom: 1px solid #3B4CCA !important;
        overflow: hidden !important;
    }

    .sec-strokes {
        height: 85mm !important;
        border-bottom: 1px solid #3B4CCA !important;
        display: grid !important;
        grid-template-rows: repeat(10, 8.5mm) !important;
        /* 10 fixed vertical cells */
        grid-auto-flow: column !important;
        /* Fill columns first, Move Right-to-Left (v8.7 Request) */
        grid-auto-columns: 32% !important;
        direction: rtl !important;
        padding: 2mm !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    .sec-practice-group {
        height: 110mm !important;
        overflow: hidden !important;
    }

    /* Stroke Steps - Atomic Image Stacking (v8.5 Hybrid Fix) */
    .stroke-step {
        width: 100% !important;
        height: 8.5mm !important;
        position: relative !important;
        /* Standard Anchor */
        display: inline-flex !important;
        /* Use flex context as recommended */
        justify-content: center !important;
        align-items: center !important;
        background: transparent !important;
        /* iOS Compatibility: Force layers visibility */
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .stroke-step img {
        position: absolute !important;
        /* Force hardware stacking override */
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        padding: 10% !important;
        /* Inner safety buffer */
        max-width: 100% !important;
        max-height: 100% !important;
        z-index: 1 !important;
        /* Force stack context for stubborn drivers */
        transform: translateZ(0) !important;
        /* Trigger hardware acceleration lock (v8.6) */
    }

    /* Platform-Specific Force Overrides */
    .desktop-print-mode .stroke-step img {
        display: block !important;
    }

    /* 4. Global Color & Driver Calibration */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        transform: none !important;
    }

    .is-printing-now.print-debug .sheet-page {
        outline: 2px dashed red !important;
    }

    .is-printing-now.print-debug .sidebar {
        outline: 2px solid blue !important;
    }
}
/* ???±è? Bootstrap Card Header (?ç·´ç¿ç°¿?è¦½?æ?é¡? */
@media print {
    .card-header {
        display: none !important;
    }
}
/* ???±è??è¦½???Card Header (?«é¢ + ?å°?½æ?å¤? */
#previewSection .card-header {
    display: none !important;
}

/* ?å°?ä?ä¿éª?è?ä¸? */
@media print {
    #previewSection .card-header {
        display: none !important;
    }
}
/* ??ç²¾æ??±è??è¦½?æ¨é? (?¢å? + ?å°?½æ?å¤? */
#previewSection .card-header>h5.mb-0.fw-bold {
    display: none !important;
}

/* ?å°?ä?ä¿éª?è?ä¸? */
@media print {
    #previewSection .card-header>h5.mb-0.fw-bold {
        display: none !important;
    }
}
/* ???æ??ä¿®æ­?ç¢ºä?ç·´ç?ç°¿å??´é¡¯ç¤?*/
@media (max-width: 768px) {

    /* ç§»é¤?ºå?é«åº¦,è®å§å®¹èª?¶å???*/
    .sheet-page {
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* ç¢ºä?å®¹å¨ä¸æ?è¢«å???*/
    .app-main,
    #previewSection,
    .card-body {
        overflow: visible !important;
        height: auto !important;
    }

    /* ç·´ç?ç°¿å§å®¹å???*/
    .sheet-body {
        height: auto !important;
        min-height: 0 !important;
    }

    /* å­æ ¼???*/
    .content-area {
        height: auto !important;
    }

    .char-col {
        height: auto !important;
    }
}

/* =========================================
   FINAL STABLE PRINT IMPLEMENTATION (Spec v1.1)
   ========================================= */
@media print {
    body > *:not(.hero-section) {
        display: none !important;
    }

    #legacyControls {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    #legacyControls .row > *:not(.col-lg-8),
    .card-header,
    .empty-state {
        display: none !important;
    }

    #legacyControls .col-lg-8 {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        flex: 0 0 100% !important;
    }

    #previewSection {
        padding: 0 !important;
        margin: 0 !important;
        background: white !important;
    }

    #previewSection > *:not(#sheets-container),
    #sheets-container > *:not(.sheet-page) {
        display: none !important;
    }

    #sheets-container {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    @page {
        size: A4 portrait;
        margin: 0;
    }

    html, body {
        width: 210mm !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .sheet-page {
        display: flex !important;
        flex-direction: column !important;
        width: 210mm !important;
        height: 285mm !important;
        margin: 0 !important;
        padding: 10mm !important;
        page-break-after: always !important;
        break-after: page !important;
        box-shadow: none !important;
        border: none !important;
        background: white !important;
        overflow: hidden !important;
    }

    .sheet-header {
        visibility: visible !important;
        border-bottom: 2px solid #3B4CCA !important;
    }

    .sheet-body {
        display: flex !important;
        flex-direction: row-reverse !important;
        width: 100% !important;
        height: 245mm !important;
        overflow: hidden !important;
    }
}

/* Force Border Fix */
.practice-cell {
    border-bottom: 1px solid #3B4CCA !important;
}

/* Force Cross Lines Fix (Tian Zi Ge) for Last Child */
.practice-cell:last-child .tian-zi-ge::before {
    content: '' !important;
    display: block !important;
    width: 100% !important;
    border-top: 1px dashed #3B4CCA !important;
    opacity: 0.8 !important;
    visibility: visible !important;
}

.practice-cell:last-child .tian-zi-ge::after {
    content: '' !important;
    display: block !important;
    height: 100% !important;
    border-left: 1px dashed #3B4CCA !important;
    opacity: 0.8 !important;
    visibility: visible !important;
}

/* NUCLEAR FIX FOR CROSS LINES IN PRINT */
@media print {
    .practice-cell:last-child {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border-bottom: 1px solid #3B4CCA !important;
        position: relative !important;
        z-index: 10 !important;
        overflow: visible !important;
    }

    /* Force Pseudo Elements Visible */
    .practice-cell:last-child::before,
    .practice-cell:last-child::after {
        content: '' !important;
        display: block !important;
        position: absolute !important;
        opacity: 1 !important; /* Force full opacity in print */
        visibility: visible !important;
        border-color: #999 !important; /* Use darker color for print visibility if needed, or keep original */
        border-style: dashed !important;
        border-width: 1px !important;
        z-index: 20 !important;
    }
    
    /* Horizontal Line */
    .practice-cell:last-child::before {
        width: 100% !important;
        height: 0 !important;
        top: 50% !important;
        left: 0 !important;
        border-top: 1px dashed #3B4CCA !important;
    }
    
    /* Vertical Line */
    .practice-cell:last-child::after {
        width: 0 !important;
        height: 100% !important;
        top: 0 !important;
        left: 50% !important;
        border-left: 1px dashed #3B4CCA !important;
    }
}
