/* ============================================================
   人生传记自动化生成系统 - 主样式表
   Life Biography Auto-Generation System - Main Stylesheet
   ============================================================ */

/* --- CSS Variables / 色彩系统 --- */
:root {
    --primary:        #8B4513;
    --primary-dark:   #6B3410;
    --primary-light:  #A0522D;
    --secondary:      #D4A574;
    --secondary-light:#E8C9A0;
    --background:     #FDF5E6;
    --bg-alt:         #FAF0DC;
    --bg-card:        #FFFBF0;
    --accent:         #B8860B;
    --accent-light:   #DAA520;
    --success:        #2E7D32;
    --success-light:  #4CAF50;
    --success-bg:     #E8F5E9;
    --warning:        #F57F17;
    --warning-light:  #FFB300;
    --warning-bg:     #FFF8E1;
    --error:          #C62828;
    --error-light:    #EF5350;
    --error-bg:       #FFEBEE;
    --text:           #3E2723;
    --text-light:     #5D4037;
    --text-muted:     #8D6E63;
    --text-on-primary:#FFFFFF;
    --border:         #D7CCC8;
    --border-light:   #EFEBE9;
    --shadow-sm:      0 1px 3px rgba(62,39,35,0.10);
    --shadow-md:      0 4px 12px rgba(62,39,35,0.12);
    --shadow-lg:      0 8px 24px rgba(62,39,35,0.16);
    --shadow-xl:      0 12px 40px rgba(62,39,35,0.20);
    --radius-sm:      4px;
    --radius-md:      8px;
    --radius-lg:      12px;
    --radius-xl:      16px;
    --font-sans:      "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
    --font-serif:     "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
    --font-mono:      "JetBrains Mono", "Fira Code", "Source Code Pro", monospace;
    --sidebar-width:  280px;
    --header-height:  64px;
    --statusbar-height: 36px;
    --transition:     0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--background);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); text-decoration: underline; }

::selection {
    background: var(--secondary);
    color: var(--text);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- App Shell Layout --- */
.app-shell {
    display: grid;
    grid-template-rows: var(--header-height) 1fr var(--statusbar-height);
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-areas:
        "header  header"
        "sidebar main"
        "status  status";
    height: 100vh;
    width: 100vw;
}

/* --- Header --- */
.app-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-on-primary);
    box-shadow: var(--shadow-md);
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
    font-size: 20px;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.header-subtitle {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 1px;
    font-weight: 400;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.12);
    color: var(--text-on-primary);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
}

.header-btn:hover {
    background: rgba(255,255,255,0.22);
}

/* --- Sidebar --- */
.app-sidebar {
    grid-area: sidebar;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-search {
    position: relative;
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: var(--background);
    color: var(--text);
    transition: var(--transition);
    font-family: var(--font-sans);
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

.sidebar-search .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.sidebar-actions {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.btn-create-project {
    width: 100%;
    padding: 9px 14px;
    background: var(--primary);
    color: var(--text-on-primary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-sans);
}

.btn-create-project:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.project-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.project-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.project-item:hover {
    background: var(--bg-alt);
}

.project-item.active {
    background: var(--secondary-light);
    box-shadow: inset 3px 0 0 var(--primary);
}

.project-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary);
    color: var(--primary-dark);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-right: 10px;
}

.project-item.active .project-item-icon {
    background: var(--primary);
    color: var(--text-on-primary);
}

.project-item-info {
    flex: 1;
    min-width: 0;
}

.project-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.project-item-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.project-item-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    padding: 4px;
    font-size: 0.85rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.project-item:hover .project-item-delete {
    opacity: 1;
}

.project-item-delete:hover {
    color: var(--error-light);
}

.sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.sidebar-empty p {
    font-size: 0.85rem;
    line-height: 1.5;
}

/* --- Main Content --- */
.app-main {
    grid-area: main;
    overflow-y: auto;
    padding: 20px 24px;
    background: var(--bg-alt);
}

/* --- Welcome Screen (no project selected) --- */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
}

.welcome-screen h2 {
    font-size: 1.3rem;
    color: var(--text-light);
    margin-bottom: 8px;
    font-weight: 600;
}

.welcome-screen p {
    font-size: 0.9rem;
    max-width: 380px;
    line-height: 1.6;
}

/* --- Project Info Panel --- */
.project-info-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--secondary-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 5px;
}

.form-group label .required {
    color: var(--error);
    margin-left: 2px;
}

.form-control {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: #fff;
    color: var(--text);
    transition: var(--transition);
    font-family: var(--font-sans);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139,69,19,0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

textarea.form-control {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%235D4037' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.form-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check label {
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    margin-bottom: 0;
}

.form-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* --- Pipeline Progress Bar --- */
.pipeline-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.pipeline-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    padding: 0 8px;
    overflow-x: auto;
}

.pipeline-bar::before {
    content: '';
    position: absolute;
    top: 18px;
    left: 28px;
    right: 28px;
    height: 3px;
    background: var(--border);
    z-index: 0;
}

.pipeline-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    min-width: 80px;
    cursor: pointer;
    transition: var(--transition);
}

.pipeline-step:hover .step-circle {
    transform: scale(1.1);
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    border: 3px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.pipeline-step.completed .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.pipeline-step.current .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(139,69,19,0.2);
    animation: pulse-ring 2s ease-in-out infinite;
}

.pipeline-step.blocked .step-circle {
    background: var(--border);
    border-color: var(--border);
    color: var(--text-muted);
}

.pipeline-step.error .step-circle {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

@keyframes pulse-ring {
    0%, 100% { box-shadow: 0 0 0 4px rgba(139,69,19,0.2); }
    50% { box-shadow: 0 0 0 8px rgba(139,69,19,0.08); }
}

.step-label {
    font-size: 0.68rem;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.3;
    max-width: 90px;
    word-break: keep-all;
}

.pipeline-step.completed .step-label { color: var(--success); font-weight: 600; }
.pipeline-step.current .step-label  { color: var(--primary); font-weight: 700; }

/* --- Stage Work Panels --- */
.stage-panels {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stage-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stage-panel.active {
    border-color: var(--secondary);
    box-shadow: var(--shadow-md);
}

.stage-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg-card) 100%);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    user-select: none;
}

.stage-panel-header:hover {
    background: var(--secondary-light);
}

.stage-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stage-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.stage-panel.completed .stage-number { background: var(--success); color: #fff; }
.stage-panel.active .stage-number     { background: var(--primary); color: #fff; }

.stage-header-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

.stage-header-status {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
}

.stage-header-status.completed { background: var(--success-bg); color: var(--success); }
.stage-header-status.running   { background: var(--warning-bg); color: var(--warning); }
.stage-header-status.pending   { background: var(--border-light); color: var(--text-muted); }
.stage-header-status.error     { background: var(--error-bg); color: var(--error); }

.stage-panel-body {
    padding: 20px;
    display: none;
}

.stage-panel.active .stage-panel-body,
.stage-panel.expanded .stage-panel-body {
    display: block;
}

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 30px 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    background: var(--bg-alt);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(139,69,19,0.04);
}

.upload-area.dragover {
    border-color: var(--accent);
    background: rgba(184,134,11,0.06);
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--text-muted);
}

.upload-text {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.upload-file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upload-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}

.upload-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-file-size {
    color: var(--text-muted);
    margin-left: 10px;
    flex-shrink: 0;
}

.upload-file-remove {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    padding: 2px 6px;
    margin-left: 6px;
    font-size: 0.9rem;
}

/* --- Text Viewer / Reader --- */
.text-viewer {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    max-height: 500px;
    overflow-y: auto;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    line-height: 1.9;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.text-viewer.chapter-view {
    font-size: 1rem;
    line-height: 2;
    max-height: 600px;
}

.text-viewer .chapter-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--secondary-light);
}

.text-viewer .chapter-title:first-child {
    margin-top: 0;
}

.text-viewer p {
    text-indent: 2em;
    margin-bottom: 0.6em;
}

/* --- Tag / Label Pills --- */
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--secondary-light);
    color: var(--primary-dark);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.tag-pill.person   { background: #E3F2FD; color: #1565C0; }
.tag-pill.place    { background: #E8F5E9; color: #2E7D32; }
.tag-pill.time     { background: #FFF3E0; color: #E65100; }
.tag-pill.event    { background: #FCE4EC; color: #C62828; }
.tag-pill.emotion  { background: #F3E5F5; color: #6A1B9A; }

/* --- Conflict / Annotation Highlights --- */
.conflict-highlight {
    background: rgba(198,40,40,0.1);
    border-left: 3px solid var(--error);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 0.85rem;
}

.conflict-highlight.warning {
    background: rgba(245,127,23,0.1);
    border-left-color: var(--warning);
}

.conflict-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: var(--transition);
}

.conflict-item:hover {
    box-shadow: var(--shadow-sm);
}

.conflict-severity {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.conflict-severity.high   { background: var(--error); }
.conflict-severity.medium { background: var(--warning); }
.conflict-severity.low    { background: var(--success); }

.conflict-content {
    flex: 1;
}

.conflict-title {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.conflict-desc {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.5;
}

.conflict-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* --- Layout Preview --- */
.layout-preview {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 30px;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
    font-family: var(--font-serif);
}

.layout-preview .page-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--primary);
}

.layout-preview .page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.layout-preview .page-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.layout-preview .photo-placeholder {
    width: 100%;
    height: 180px;
    background: var(--bg-alt);
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 16px 0;
}

.layout-preview .qr-placeholder {
    width: 100px;
    height: 100px;
    background: var(--bg-alt);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-align: center;
    margin: 12px auto;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
    white-space: nowrap;
    user-select: none;
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
    border-color: var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: #fff;
    color: var(--primary);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-alt);
    border-color: var(--primary);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-light);
    box-shadow: var(--shadow-sm);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: var(--success-light);
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-light);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-lg {
    padding: 12px 28px;
    font-size: 0.95rem;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* --- Action Bar (execute stage) --- */
.action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.action-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.action-bar-info {
    font-size: 0.85rem;
    color: var(--text-light);
}

.action-bar-right {
    display: flex;
    gap: 8px;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(62,39,35,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    backdrop-filter: blur(2px);
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    transform: translateY(20px) scale(0.97);
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.visible .modal-dialog {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-alt);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-alt);
}

/* --- Toast Notification --- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 420px;
    animation: toast-in 0.3s ease;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--error); }

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    flex-shrink: 0;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: toast-out 0.25s ease forwards;
}

@keyframes toast-out {
    to { opacity: 0; transform: translateX(40px); }
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253,245,230,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 14px;
}

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

.loading-text {
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

/* --- Status Bar --- */
.app-statusbar {
    grid-area: status;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    font-size: 0.72rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.statusbar-left,
.statusbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.statusbar-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Section Title with Divider --- */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
}

.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

/* --- Export Panel --- */
.export-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.export-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.export-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.export-item-icon {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--primary);
}

.export-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.export-item-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Progress Indicator (inline) --- */
.progress-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
}

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

/* --- Chapter Navigation --- */
.chapter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.chapter-nav-btn {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-light);
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
}

.chapter-nav-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chapter-nav-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* --- Style Report Card --- */
.style-report {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}

.style-report h4 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--secondary-light);
}

.style-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 0.85rem;
}

.style-metric-label {
    color: var(--text-light);
}

.style-metric-value {
    font-weight: 600;
    color: var(--text);
}

/* --- Framework / Outline Tree --- */
.framework-tree {
    padding: 12px 0;
}

.framework-chapter {
    padding: 8px 0 8px 0;
}

.framework-chapter-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.framework-section {
    padding: 4px 0 4px 24px;
    font-size: 0.82rem;
    color: var(--text-light);
    border-left: 2px solid var(--secondary-light);
    margin-left: 8px;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 0.85rem;
    max-width: 300px;
    line-height: 1.5;
}

/* --- Tab Navigation --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 18px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-sans);
}

.tab-btn:hover {
    color: var(--text);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "main"
            "status";
    }

    .app-sidebar {
        display: none;
    }

    .app-sidebar.mobile-open {
        display: flex;
        position: fixed;
        top: var(--header-height);
        left: 0;
        bottom: var(--statusbar-height);
        width: var(--sidebar-width);
        z-index: 500;
        box-shadow: var(--shadow-xl);
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 0 14px;
    }

    .header-title {
        font-size: 1rem;
    }

    .header-subtitle {
        display: none;
    }

    .app-main {
        padding: 14px;
    }

    .pipeline-bar {
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .step-label {
        font-size: 0.6rem;
    }

    .export-items {
        grid-template-columns: 1fr;
    }
}

/* --- Print Styles --- */
@media print {
    .app-header,
    .app-sidebar,
    .app-statusbar,
    .action-bar,
    .btn,
    .upload-area,
    .toast-container,
    .modal-overlay,
    .loading-overlay {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .app-main {
        overflow: visible;
        padding: 0;
    }

    .text-viewer {
        max-height: none;
        overflow: visible;
        border: none;
        padding: 0;
    }

    .stage-panel {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* --- Style Workshop --- */
.style-workshop {
    max-width: 1200px;
    margin: 0 auto;
}

.workshop-section {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.8rem; }
.text-xs     { font-size: 0.72rem; }
.font-bold   { font-weight: 700; }
.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.p-0   { padding: 0; }
.p-1   { padding: 8px; }
.p-2   { padding: 16px; }
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1  { gap: 8px; }
.gap-2  { gap: 16px; }

/* --- Outline Editor --- */
.outline-editor {
    max-width: 900px;
    margin: 0 auto;
}

.outline-editor .chapter-card {
    transition: border-color var(--transition), box-shadow var(--transition);
}

.outline-editor .chapter-card:hover {
    border-color: var(--secondary);
    box-shadow: var(--shadow-md);
}

/* --- Chapter Card --- */
.chapter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.chapter-card:hover {
    border-color: var(--secondary);
    box-shadow: var(--shadow-md);
}

.chapter-card-editable input,
.chapter-card-editable textarea {
    transition: border-color var(--transition), box-shadow var(--transition);
}

.chapter-card-editable input:focus,
.chapter-card-editable textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

/* --- Quality Badge --- */
.quality-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    transition: transform var(--transition);
}

.quality-badge:hover {
    transform: scale(1.05);
}

/* --- Dimension Bar (5-dimension visual bars) --- */
.dimension-bar {
    transition: opacity var(--transition);
}

.dimension-bar:hover {
    opacity: 0.85;
}

/* --- Style DNA Box --- */
.style-dna-box {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.style-dna-box pre {
    margin: 0;
    border: none;
}

/* --- Token Usage Meter --- */
.token-usage-meter {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-alt);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.token-usage-meter span {
    white-space: nowrap;
}
