/* ===================================================================
   pub-gen — Enterprise-grade, playful design system
   =================================================================== */

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

/* --- Design Tokens --- */
:root {
    --gray-50:  #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-500: #71717a;
    --gray-600: #52525b;
    --gray-700: #3f3f46;
    --gray-800: #27272a;
    --gray-900: #18181b;
    --gray-950: #09090b;

    --primary:        #4f46e5;
    --primary-hover:  #4338ca;
    --primary-light:  #e0e7ff;
    --primary-alpha:  rgba(79, 70, 229, 0.12);
    --secondary:      #7c3aed;
    --accent:         #f472b6;

    --success:       #22c55e;
    --success-light: #dcfce7;
    --error:         #ef4444;
    --error-light:   #fee2e2;
    --warning:       #eab308;
    --warning-light: #fef9c3;

    --bg:             var(--gray-50);
    --surface:        #ffffff;
    --surface-raised: #ffffff;
    --border:         var(--gray-200);
    --border-light:   var(--gray-100);
    --text:           var(--gray-900);
    --text-secondary: var(--gray-500);
    --text-tertiary:  var(--gray-400);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;

    --hero-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
    --hero-gradient-size: 200% 200%;
}

[data-theme="dark"] {
    --primary:        #818cf8;
    --primary-hover:  #6366f1;
    --primary-light:  #312e81;
    --primary-alpha:  rgba(129, 140, 248, 0.15);
    --secondary:      #a78bfa;
    --accent:         #f472b6;

    --success:       #4ade80;
    --success-light: #052e16;
    --error:         #f87171;
    --error-light:   #450a0a;
    --warning:       #facc15;
    --warning-light: #422006;

    --bg:             var(--gray-950);
    --surface:        var(--gray-900);
    --surface-raised: var(--gray-800);
    --border:         var(--gray-800);
    --border-light:   rgba(255,255,255,0.06);
    --text:           var(--gray-50);
    --text-secondary: var(--gray-400);
    --text-tertiary:  var(--gray-600);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);

    --hero-gradient: linear-gradient(135deg, #312e81 0%, #4c1d95 50%, #581c87 100%);
}

/* --- Base --- */
body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- Navbar --- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

[data-theme="dark"] .navbar {
    background: rgba(24, 24, 27, 0.85);
}

.navbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand-icon {
    width: 24px;
    height: 24px;
    color: var(--primary);
}

.brand-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-btn svg {
    width: 18px;
    height: 18px;
}

.nav-btn:hover {
    background: var(--border-light);
    color: var(--text);
    border-color: var(--border);
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.375rem;
}

/* Theme toggle icons */
.sun-icon { display: block; }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }

/* --- Hero Strip --- */
.hero-strip {
    background: var(--hero-gradient);
    background-size: var(--hero-gradient-size);
    animation: heroShift 8s ease-in-out infinite;
    padding: 2.5rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-strip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><defs><pattern id="g" width="40" height="40" patternUnits="userSpaceOnUse"><circle cx="20" cy="20" r="1" fill="rgba(255,255,255,0.08)"/></pattern></defs><rect width="200" height="200" fill="url(%23g)"/></svg>');
    opacity: 0.5;
}

@keyframes heroShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-inner {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.hero-strip h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.hero-strip p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    font-weight: 400;
}

/* --- Main Content --- */
.main-content {
    max-width: 1080px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* --- Panels --- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: border-color 0.2s ease, background-color 0.3s ease;
}

.panel-header {
    padding: 1.25rem 1.5rem 0;
}

.panel-body {
    padding: 1rem 1.5rem 1.5rem;
}

.panel-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0 1.5rem;
}

.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

/* --- Dropzone --- */
.dropzone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    position: relative;
    background: transparent;
}

.dropzone:hover,
.dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-alpha);
}

/* Marching ants animation */
.dropzone {
    background-image: none;
}

.dropzone:hover {
    animation: none;
}

.dropzone.drag-over {
    border-style: solid;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.dropzone.success {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.06);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.dropzone-icon {
    width: 40px;
    height: 40px;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.dropzone:hover .dropzone-icon,
.dropzone.drag-over .dropzone-icon {
    color: var(--primary);
    transform: translateY(-2px);
}

.dropzone-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.dropzone-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.dropzone-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    max-width: 200px;
    margin: 0.75rem 0;
    color: var(--text-tertiary);
    font-size: 12px;
}

.dropzone-divider::before,
.dropzone-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.dropzone-formats {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 0.25rem;
}

.dropzone-sm {
    padding: 2rem 1.5rem;
}

/* --- Ghost Button --- */
.btn-ghost {
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-ghost:hover {
    background: var(--surface-raised);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- File Tree --- */
.file-tree {
    margin-top: 1rem;
}

.file-tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0.5rem;
}

.file-tree-header strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-tree-header .file-count-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-alpha);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
}

.file-tree-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-text-sm {
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.btn-text-sm:hover {
    color: var(--error);
    background: var(--error-light);
}

/* Folder groups */
.folder-group {
    margin-bottom: 0.25rem;
}

.folder-group-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: background 0.15s ease;
    user-select: none;
}

.folder-group-header:hover {
    background: var(--border-light);
}

.folder-group-header svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    transition: transform 0.15s ease;
}

.folder-group-header .chevron {
    transition: transform 0.15s ease;
}

.folder-group.collapsed .chevron {
    transform: rotate(-90deg);
}

.folder-group.collapsed .folder-files {
    display: none;
}

.folder-files {
    padding-left: 1.25rem;
}

/* File items */
.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3125rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text);
    transition: background 0.1s ease;
    position: relative;
}

.file-item:hover {
    background: var(--border-light);
}

.file-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.file-dot.md { background: #2dd4bf; }
.file-dot.html { background: #fb923c; }
.file-dot.folder { background: var(--primary); }
.file-dot.img { background: var(--accent); }

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

.file-size {
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.file-item .remove-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.125rem;
    border-radius: var(--radius-sm);
    transition: all 0.1s ease;
    display: flex;
    flex-shrink: 0;
}

.file-item:hover .remove-btn {
    opacity: 1;
}

.file-item .remove-btn:hover {
    color: var(--error);
    background: var(--error-light);
}

.file-item .remove-btn svg {
    width: 14px;
    height: 14px;
}

.warning-badge {
    font-size: 10px;
    font-weight: 600;
    background: var(--warning-light);
    color: var(--warning);
    padding: 0 0.375rem;
    border-radius: 8px;
    flex-shrink: 0;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.required {
    color: var(--error);
}

input[type="text"],
select {
    width: 100%;
    height: 40px;
    padding: 0 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]::placeholder {
    color: var(--text-tertiary);
}

input[type="text"]:hover,
select:hover {
    border-color: var(--gray-300);
}

[data-theme="dark"] input[type="text"]:hover,
[data-theme="dark"] select:hover {
    border-color: var(--gray-600);
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

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

.input-with-counter {
    position: relative;
}

.char-counter {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-tertiary);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

.char-counter.warn {
    color: var(--warning);
}

.char-counter.error {
    color: var(--error);
}

/* --- Cover Upload --- */
.cover-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.cover-preview {
    width: 80px;
    height: 110px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.cover-preview:hover {
    border-color: var(--primary);
    background: var(--primary-alpha);
}

.cover-placeholder svg {
    width: 24px;
    height: 24px;
    color: var(--text-tertiary);
    transition: color 0.2s ease;
}

.cover-preview:hover .cover-placeholder svg {
    color: var(--primary);
}

#coverImg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--radius-md) - 2px);
}

.remove-cover {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
    box-shadow: var(--shadow-sm);
}

.remove-cover:hover {
    transform: scale(1.15);
}

.cover-info-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.cover-info-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* --- Live Preview Card --- */
.preview-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    perspective: 800px;
}

.preview-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.preview-card.wiggle {
    animation: wiggle 0.5s ease;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-2deg); }
    75% { transform: rotate(2deg); }
}

.preview-cover {
    width: 48px;
    height: 64px;
    background: var(--primary-alpha);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.preview-cover svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
    opacity: 0.5;
}

.preview-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-meta {
    flex: 1;
    min-width: 0;
}

.preview-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.preview-symbol {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-bottom: 0.375rem;
}

.preview-badges {
    display: flex;
    gap: 0.375rem;
}

.preview-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 0.0625rem 0.5rem;
    border-radius: 10px;
}

.preview-badge.type {
    background: var(--primary-alpha);
    color: var(--primary);
}

.preview-badge.files {
    background: var(--border-light);
    color: var(--text-secondary);
}

/* --- Generate Button --- */
.generate-bar {
    margin-top: 1.5rem;
    text-align: center;
}

.btn-generate {
    width: 100%;
    height: 52px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background-color 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.btn-generate:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.btn-generate:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(79, 70, 229, 0.2);
}

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

.btn-generate.success-state {
    background: var(--success);
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-arrow {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.btn-generate:hover:not(:disabled) .btn-arrow {
    transform: translateX(3px);
}

.btn-loading, .btn-success {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.btn-loading:not([hidden]) { display: flex; }
.btn-success:not([hidden]) { display: flex; }
.btn-text[hidden], .btn-loading[hidden], .btn-success[hidden] { display: none !important; }
[hidden] .btn-arrow { display: none; }

.btn-generate.loading .btn-arrow,
.btn-generate.success-state .btn-arrow {
    display: none;
}

.spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

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

.btn-success svg {
    width: 20px;
    height: 20px;
}

.generate-hint {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 11px;
    color: var(--text-tertiary);
}

/* --- Footer --- */
.footer {
    max-width: 1080px;
    margin: 2rem auto 0;
    padding: 1.25rem 1.5rem;
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
}

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer a:hover {
    color: var(--primary);
}

/* --- Modal --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 1rem;
}

.modal-backdrop:not([hidden]) {
    opacity: 1;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.2s ease;
}

.modal-backdrop:not([hidden]) .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

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

.modal-body {
    padding: 1.5rem;
}

/* --- Validation Result --- */
.validation-result {
    margin-top: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.validation-result.success {
    border-color: var(--success);
}

.validation-result.error {
    border-color: var(--error);
}

.validation-result.loading {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    border-color: var(--border);
}

.validation-result-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 14px;
}

.validation-result.success .validation-result-header {
    background: var(--success-light);
    color: var(--success);
}

.validation-result.error .validation-result-header {
    background: var(--error-light);
    color: var(--error);
}

.validation-result-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.validation-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.validation-table tr {
    border-top: 1px solid var(--border-light);
}

.validation-table td {
    padding: 0.5rem 1.25rem;
}

.validation-table td:first-child {
    color: var(--text-secondary);
    font-weight: 500;
    width: 100px;
}

.validation-table td:last-child {
    color: var(--text);
}

.validation-issues {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-light);
}

.validation-issues-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.validation-issues-title.errors { color: var(--error); }
.validation-issues-title.warnings { color: var(--warning); }

.validation-issues ul {
    list-style: none;
    padding: 0;
}

.validation-issues li {
    font-size: 13px;
    padding: 0.25rem 0;
    color: var(--text-secondary);
}

.validation-issues li code {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--border-light);
    padding: 0.0625rem 0.375rem;
    border-radius: 4px;
    margin-right: 0.375rem;
}

.spinner-inline {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* --- Slide-out Panel --- */
.slideout-backdrop {
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0,0,0,0.15);
    transition: opacity 0.2s ease;
}

.slideout-backdrop[hidden] {
    display: none;
}

.slideout {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 380px;
    max-width: 90vw;
    z-index: 200;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.slideout:not([hidden]) {
    transform: translateX(0);
}

.slideout[hidden] {
    display: flex;
    pointer-events: none;
}

.slideout-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.slideout-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.slideout-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

/* --- Accordion --- */
.accordion {
    border-bottom: 1px solid var(--border-light);
}

.accordion summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    padding: 0.75rem 0;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.15s ease;
    user-select: none;
}

.accordion summary::-webkit-details-marker { display: none; }

.accordion summary::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--text-tertiary);
    border-bottom: 1.5px solid var(--text-tertiary);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.accordion[open] summary::after {
    transform: rotate(45deg);
}

.accordion summary:hover {
    color: var(--primary);
}

.accordion-body {
    padding: 0 0 1rem;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    animation: fadeIn 0.15s ease;
}

.accordion-body p {
    margin-bottom: 0.625rem;
}

.code-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.625rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    transition: background 0.1s ease;
}

.code-row:hover {
    background: var(--border-light);
}

.code-row code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--primary-alpha);
    color: var(--primary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.code-row span {
    flex: 1;
    font-size: 12px;
    color: var(--text-tertiary);
}

.copy-btn {
    width: 24px;
    height: 24px;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    opacity: 0;
    transition: all 0.1s ease;
    flex-shrink: 0;
}

.code-row:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    color: var(--primary);
    background: var(--primary-alpha);
}

.copy-btn svg {
    width: 100%;
    height: 100%;
}

.copy-btn.copied {
    color: var(--success);
}

.code-block {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 12px;
    margin-top: 0.5rem;
}

.code-line {
    padding: 0.125rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code-line.indent {
    padding-left: 1.25rem;
}

.hint {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

.feature-list {
    padding-left: 1.25rem;
    line-height: 1.8;
}

.feature-list code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--primary-alpha);
    color: var(--primary);
    padding: 0.0625rem 0.375rem;
    border-radius: 4px;
}

/* Keyboard shortcuts */
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    font-size: 13px;
}

.shortcut-row span {
    color: var(--text-secondary);
    margin-left: auto;
}

kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 0.375rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border);
}

/* --- Notifications --- */
.notification {
    position: fixed;
    top: 72px;
    right: 1rem;
    z-index: 300;
    max-width: 380px;
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.25s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 0.875rem 1.25rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 14px;
    font-weight: 500;
}

.notification.success .notification-content {
    border-color: var(--success);
}

.notification.error .notification-content {
    border-color: var(--error);
}

.notification-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: white;
}

.notification.success .notification-icon {
    background: var(--success);
}

.notification.error .notification-icon {
    background: var(--error);
}

/* --- Confetti --- */
.confetti-container {
    position: fixed;
    pointer-events: none;
    z-index: 500;
}

.confetti-piece {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: confettiFall 0.8s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(var(--x), var(--y)) scale(0.5) rotate(360deg);
    }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.panel {
    animation: fadeInUp 0.4s ease-out;
}

.panel:nth-child(2) {
    animation-delay: 0.05s;
    animation-fill-mode: both;
}

.file-item {
    animation: fadeIn 0.15s ease-out;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    .hero-strip {
        padding: 2rem 1rem;
    }

    .hero-strip h1 {
        font-size: 1.25rem;
    }

    .main-content {
        padding: 1.25rem 1rem;
    }

    .navbar-inner {
        padding: 0 1rem;
    }

    .nav-btn-label {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .panel-body {
        padding: 1rem 1.25rem 1.25rem;
    }

    .panel-header {
        padding: 1rem 1.25rem 0;
    }

    .panel-divider {
        margin: 0 1.25rem;
    }

    .generate-bar {
        margin-top: 1.25rem;
    }

    .cover-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .hero-strip h1 {
        font-size: 1.125rem;
    }

    .hero-strip p {
        font-size: 0.825rem;
    }

    .navbar-inner {
        height: 48px;
    }

    .panel-body {
        padding: 0.875rem 1rem 1rem;
    }

    .dropzone {
        padding: 2rem 1rem;
    }

    .btn-generate {
        height: 48px;
        font-size: 14px;
    }
}

/* --- Compare Modal --- */
.modal-wide {
    width: 90%;
    max-width: 900px;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.compare-file-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.compare-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.compare-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 1.75rem;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-tertiary);
}

.file-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
}

.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.remove-file {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.5rem;
    margin: -0.5rem 0;
    transition: color 0.15s;
}

.remove-file:hover {
    color: var(--error);
}

.compare-options {
    margin-bottom: 1.5rem;
}

.compare-option-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.radio-label:hover {
    background-color: var(--surface-secondary);
}

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

.option-hint {
    color: var(--text-tertiary);
    font-size: 12px;
}

.compare-warning {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem;
    background-color: #FEF3C7;
    border: 1px solid #FCD34D;
    border-radius: 8px;
    margin-top: 0.75rem;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.warning-icon {
    width: 20px;
    height: 20px;
    color: #D97706;
    flex-shrink: 0;
    margin-top: 2px;
}

.compare-warning span {
    font-size: 12px;
    color: #92400E;
    line-height: 1.5;
}

.spinner-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    margin-bottom: 1rem;
}

.spinner-container[hidden] {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--surface-secondary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite, pulse 2s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.1) rotate(180deg);
    }
}

.spinner-text {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    animation: fadeInOut 2s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn-compare {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-compare:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-compare:disabled {
    background: var(--surface-secondary);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.btn-compare svg {
    width: 18px;
    height: 18px;
}

/* --- Comparison Results --- */
.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.comparison-column h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.validation-issues-title.differences {
    color: var(--primary);
}

.validation-issues-title.info {
    color: var(--text-secondary);
}

.diff-table {
    width: 100%;
    font-size: 13px;
    border-collapse: collapse;
}

.diff-table thead th {
    text-align: left;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-secondary);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}

.diff-table tbody tr {
    border-bottom: 1px solid var(--border-light);
}

.diff-table tbody td {
    padding: 0.5rem 1rem;
}

.diff-table tbody td:first-child {
    font-weight: 500;
    color: var(--text);
}

.diff-table tbody td:not(:first-child) {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

.diff-major {
    background: rgba(239, 68, 68, 0.05);
}

.diff-warning {
    background: rgba(245, 158, 11, 0.05);
}

.diff-info {
    background: rgba(59, 130, 246, 0.05);
}

.doc-changes-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-secondary);
    border-radius: 6px;
}

.doc-stat {
    font-size: 13px;
    font-weight: 600;
}

.doc-stat.added {
    color: #10b981;
}

.doc-stat.removed {
    color: #ef4444;
}

.doc-stat.unchanged {
    color: var(--text-tertiary);
}

.doc-changes-section {
    margin-top: 1rem;
}

.doc-changes-section strong {
    font-size: 13px;
    color: var(--text-secondary);
}

.doc-changes-section ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.doc-changes-section li {
    font-size: 13px;
    padding: 0.25rem 0;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.doc-added {
    color: #10b981;
}

.doc-removed {
    color: #ef4444;
}

/* Word-level diff display */
.content-diff-section {
    margin-top: 1.5rem;
}

.content-diff-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.content-diff-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.content-diff-stats {
    display: flex;
    gap: 1rem;
    font-size: 12px;
}

.diff-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.diff-stat.added {
    color: #10b981;
}

.diff-stat.removed {
    color: #ef4444;
}

.diff-stat.unchanged {
    color: var(--text-tertiary);
}

.word-diff-container {
    background: var(--surface-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.word-diff-text {
    font-size: 13px;
    line-height: 1.8;
    color: var(--text);
    word-wrap: break-word;
}

.word-change {
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
}

.word-added {
    background-color: #D1FAE5;
    color: #065F46;
    border-bottom: 2px solid #10b981;
}

.word-removed {
    background-color: #FEE2E2;
    color: #991B1B;
    border-bottom: 2px solid #ef4444;
    text-decoration: line-through;
}

.content-diff-document {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.content-diff-doc-title {
    background: var(--surface-secondary);
    padding: 0.75rem 1rem;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.content-diff-doc-body {
    padding: 1rem;
}

/* Responsive compare modal */
@media (max-width: 768px) {
    .modal-wide {
        width: 95%;
        max-width: none;
    }

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

    .compare-vs {
        display: none;
    }

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

/* Prevent FOUC during theme load */
html:not([data-theme]) body {
    visibility: hidden;
}
