/* CSS Custom Properties for Library Theme */
:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --accent-color: #CD853F;
    --text-primary: #2C1810;
    --text-secondary: #5D4E37;
    --text-muted: #8B7355;
    --background-primary: #FFF8DC;
    --background-secondary: #F5DEB3;
    --background-paper: #FFFEF7;
    --border-color: #DEB887;
    --success-color: #228B22;
    --error-color: #B22222;
    --warning-color: #DAA520;
    
    --shadow-light: 0 2px 4px rgba(139, 69, 19, 0.1);
    --shadow-medium: 0 4px 12px rgba(139, 69, 19, 0.15);
    --shadow-heavy: 0 8px 24px rgba(139, 69, 19, 0.2);
    
    --border-radius: 8px;
    --border-radius-large: 12px;
    
    --font-serif: 'Playfair Display', serif;
    --font-body: 'Crimson Text', serif;

    /* Animation variables */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--background-primary), var(--background-secondary));
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.library-container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--background-paper);
    box-shadow: var(--shadow-heavy);
}

/* Header Styles */
.library-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    flex: 1;
    min-width: 300px;
}

.library-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
    to { text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 30px rgba(205, 133, 63, 0.5); }
}

.library-title i {
    color: var(--accent-color);
    animation: bookFloat 2s ease-in-out infinite alternate;
}

@keyframes bookFloat {
    from { transform: translateY(0px) rotate(0deg); }
    to { transform: translateY(-3px) rotate(2deg); }
}

.library-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.network-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.network-selector label {
    font-weight: 600;
}

.network-selector select {
    padding: 0.5rem;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: var(--transition-normal);
}

.network-selector select:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

/* Wallet Section */
.wallet-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1rem;
    min-width: 200px;
}

.wallet-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition-normal);
}

.wallet-status.connected {
    background: rgba(34, 139, 34, 0.2);
    border: 2px solid rgba(34, 139, 34, 0.3);
    animation: pulseGreen 2s ease-in-out infinite;
}

.wallet-status.disconnected {
    background: rgba(178, 34, 34, 0.2);
    border: 2px solid rgba(178, 34, 34, 0.3);
    animation: pulseRed 2s ease-in-out infinite;
}

@keyframes pulseGreen {
    0%, 100% { box-shadow: 0 0 5px rgba(34, 139, 34, 0.3); }
    50% { box-shadow: 0 0 20px rgba(34, 139, 34, 0.6); }
}

@keyframes pulseRed {
    0%, 100% { box-shadow: 0 0 5px rgba(178, 34, 34, 0.3); }
    50% { box-shadow: 0 0 20px rgba(178, 34, 34, 0.6); }
}

.wallet-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: statusBlink 1.5s ease-in-out infinite;
}

@keyframes statusBlink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.wallet-info {
    text-align: right;
    font-size: 0.9rem;
    line-height: 1.4;
}

.wallet-info small {
    display: block;
    opacity: 0.8;
    font-weight: 600;
}

.wallet-address {
    margin-bottom: 0.25rem;
}

.connect-btn, .disconnect-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    color: var(--primary-color);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.connect-btn:hover, .disconnect-btn:hover {
    background: var(--background-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

/* Navigation */
.library-nav {
    background: var(--background-secondary);
    padding: 0;
    display: flex;
    border-bottom: 3px solid var(--border-color);
    overflow-x: auto;
}

.nav-btn {
    flex: 1;
    min-width: 150px;
    padding: 1.25rem 2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border-bottom: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(139, 69, 19, 0.1), transparent);
    transition: var(--transition-slow);
}

.nav-btn:hover::before {
    left: 100%;
}

.nav-btn:hover {
    background: rgba(139, 69, 19, 0.1);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: var(--background-paper);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    box-shadow: 0 -2px 10px rgba(139, 69, 19, 0.2);
}

.nav-btn i {
    transition: var(--transition-normal);
}

.nav-btn:hover i {
    transform: scale(1.1);
}

/* Main Content */
.library-main {
    padding: 2rem;
}

.library-section {
    display: none;
    animation: fadeInUp 0.5s ease-out;
}

.library-section.active {
    display: block;
}

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

.section-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(139, 69, 19, 0.05), rgba(210, 105, 30, 0.05));
    border-radius: var(--border-radius-large);
    border: 2px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.section-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 69, 19, 0.03) 0%, transparent 70%);
    animation: backgroundRotate 20s linear infinite;
}

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

.section-header h2 {
    font-family: var(--font-serif);
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    position: relative;
    z-index: 1;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    position: relative;
    z-index: 1;
}

/* Content Grid */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* Audio Library Grid */
.audio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
    align-items: start;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    align-items: start;
}

@media (max-width: 968px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .audio-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Styles */
.card {
    background: var(--background-paper);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    transform: translateX(-100%);
    transition: var(--transition-slow);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-heavy);
}

.card:hover::before {
    transform: translateX(0);
}

.card h3 {
    font-family: var(--font-serif);
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.3rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition-normal);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
    transform: translateY(-1px);
}

/* Arguments Section */
.arguments-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

.arguments-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.argument-group {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    transition: var(--transition-normal);
    animation: slideInDown 0.3s ease-out;
}

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

.argument-group:hover {
    background: rgba(245, 222, 179, 0.7);
    transform: translateX(5px);
}

.argument-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.arg-type {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
}

.remove-arg-btn {
    padding: 0.5rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.remove-arg-btn:hover {
    background: #8B0000;
    transform: scale(1.1) rotate(180deg);
}

.argument-input {
    position: relative;
}

.arg-value, .arg-text-area {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    transition: var(--transition-normal);
}

.arg-text-area {
    resize: vertical;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
}

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

.add-arg-btn {
    width: 100%;
    padding: 0.75rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-arg-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Submit Buttons */
.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 2rem;
    position: relative;
    overflow: hidden;
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: var(--transition-slow);
}

.submit-btn:hover::before {
    left: 100%;
}

.read-btn {
    background: var(--success-color);
    color: white;
}

.read-btn:hover:not(:disabled) {
    background: #1F7A1F;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.write-btn {
    background: var(--primary-color);
    color: white;
}

.write-btn:hover:not(:disabled) {
    background: #723A10;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.submit-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Results Display */
.results-display, .transaction-status {
    height: fit-content;
    min-height: 300px;
}

.results-content {
    min-height: 200px;
    max-height: 600px;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Writing Tools Section */
.writing-tools-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 3px solid var(--border-color);
}

.writing-tool {
    background: var(--background-paper);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-large);
    padding: 1.5rem;
    box-shadow: var(--shadow-medium);
    transition: var(--transition-normal);
}

.writing-tool:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

.tool-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chapter and Formatter Editors */
.chapter-textarea,
.formatter-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-normal);
}

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

/* Editor Actions */
.editor-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.75rem 1.25rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.tool-btn.small {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}

.tool-btn.secondary {
    background: var(--text-muted);
}

.tool-btn.secondary:hover {
    background: var(--text-secondary);
}

/* Editor Stats */
.editor-stats {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.1rem;
    color: var(--primary-color);
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

/* Format Toolbar */
.format-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    gap: 0.25rem;
    border-right: 1px solid var(--border-color);
    padding-right: 0.5rem;
}

.toolbar-group:last-child {
    border-right: none;
    padding-right: 0;
}

.format-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.format-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.format-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Format Costs */
.format-costs {
    padding: 1rem;
    background: rgba(139, 69, 19, 0.05);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.cost-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.cost-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
}

.cost-item {
    padding: 0.5rem;
    background: white;
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* Preview Section */
.preview-section {
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.preview-header {
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.preview-content {
    padding: 1rem;
    background: white;
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    font-family: var(--font-body);
    line-height: 1.6;
}

.preview-content em {
    color: var(--text-muted);
    font-style: italic;
}

/* Progress Info */
.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.progress-percentage {
    font-weight: bold;
    color: var(--primary-color);
}

.progress-goal {
    color: var(--text-secondary);
    font-style: italic;
}

/* Writing Tools Specific Styles */

/* Progress Section */
.progress-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.progress-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-counter {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--primary-color);
}

.progress-bar {
    position: relative;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--error-color));
    border-radius: 4px;
    transition: var(--transition-normal);
    width: 0%;
}

.progress-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 1px;
}

.marker.warning {
    background: var(--warning-color);
}

.marker.danger {
    background: var(--error-color);
}

/* Additional Progress Section Styles */
.progress-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.progress-label {
    font-weight: 600;
    color: var(--text-secondary);
}

.progress-counter {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--primary-color);
}

.progress-bar {
    position: relative;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--error-color));
    border-radius: 4px;
    transition: var(--transition-normal);
    width: 0%;
}

.progress-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 1px;
}

.marker.warning {
    background: var(--warning-color);
}

.marker.danger {
    background: var(--error-color);
}

.progress-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

/* Goal Section */
.goal-section {
    margin-bottom: 1.5rem;
}

.goal-section .form-group {
    display: flex;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.5rem;
}

.goal-section input {
    flex: 1;
    margin-bottom: 0;
}

.tool-btn-small {
    padding: 0.5rem 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    white-space: nowrap;
}

.tool-btn-small:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.tool-btn-small.secondary {
    background: var(--text-muted);
}

.tool-btn-small.secondary:hover {
    background: var(--text-secondary);
}

.goal-display {
    padding: 0.75rem;
    background: rgba(139, 69, 19, 0.1);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    margin-top: 0.5rem;
}

.goal-progress {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.goal-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
    transition: var(--transition-normal);
    width: 0%;
}

/* Editor Container */
.editor-container {
    margin-bottom: 1rem;
}

.chapter-textarea {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-normal);
}

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

.chapter-textarea.warning {
    border-color: var(--warning-color);
}

.chapter-textarea.danger {
    border-color: var(--error-color);
}

/* Editor Actions */
.editor-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tool-btn {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.tool-btn.secondary {
    background: var(--text-muted);
}

.tool-btn.secondary:hover {
    background: var(--text-secondary);
}

/* Word Stats */
.word-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.stat-item {
    text-align: center;
    padding: 0.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.stat-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.stat-item span {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

/* Formatting Toolbar */
.formatting-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.toolbar-group {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.format-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.format-btn:hover {
    background: var(--background-secondary);
    color: var(--primary-color);
    transform: scale(1.1);
}

.format-btn.active {
    background: var(--primary-color);
    color: white;
}

/* Format Costs */
.format-costs {
    margin-bottom: 1rem;
}

.cost-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cost-toggle {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--border-radius);
    transition: var(--transition-normal);
}

.cost-toggle:hover {
    background: var(--background-secondary);
}

.cost-list {
    padding: 0.75rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color);
}

.cost-item:last-child {
    border-bottom: none;
}

/* Formatter Container */
.formatter-container {
    margin-bottom: 1rem;
}

.formatter-textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-normal);
}

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

/* Formatter Progress */
.formatter-progress {
    margin-bottom: 1rem;
}

.formatter-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.formatter-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.formatter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--warning-color), var(--error-color));
    border-radius: 3px;
    transition: var(--transition-normal);
    width: 0%;
}

/* Formatter Actions */
.formatter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Preview Panel */
.audio-preview {
    grid-column: 1 / -1;
}

.preview-content {
    min-height: 300px;
}

.preview-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.preview-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
}

.preview-tab:hover {
    color: var(--primary-color);
    background: rgba(139, 69, 19, 0.05);
}

.preview-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: rgba(139, 69, 19, 0.1);
}

.preview-panels {
    position: relative;
    min-height: 250px;
}

.preview-panel {
    display: none;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    min-height: 250px;
    overflow-y: auto;
}

.preview-panel.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    text-align: center;
}

.preview-placeholder i {
    font-size: 2rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Reformatter Options */
.reformatter-options {
    margin-bottom: 1.5rem;
}

.reformatter-options h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-normal);
}

.option-item:hover {
    background: var(--background-secondary);
    transform: translateX(2px);
}

.option-item input[type="checkbox"] {
    margin: 0;
    transform: scale(1.2);
    accent-color: var(--primary-color);
}

/* Reformatter Input/Output */
.reformatter-input,
.reformatter-output {
    margin-bottom: 1rem;
}

.reformatter-textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    transition: var(--transition-normal);
}

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

.reformatter-actions,
.output-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Gallery Styles */
.gallery-tool,
.gallery-output,
.audio-tool {
    /* Inherit from .card */
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-normal);
    margin-bottom: 1rem;
}

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

.upload-area.dragover {
    border-color: var(--secondary-color);
    background: rgba(210, 105, 30, 0.1);
    transform: scale(1.02);
}

.upload-placeholder i {
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-placeholder p {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-placeholder small {
    color: var(--text-muted);
}

/* Image Preview */
.image-preview {
    text-align: center;
    margin-bottom: 1rem;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
    margin-bottom: 0.5rem;
}

.image-info {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Encoding Options */
.encoding-options {
    margin-bottom: 1rem;
}

.encoding-options h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.encoding-options .form-group {
    margin-bottom: 0.75rem;
}

.encoding-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.encoding-options input[type="checkbox"] {
    transform: scale(1.2);
    accent-color: var(--primary-color);
}

.encoding-options input[type="range"] {
    flex: 1;
    margin: 0 0.5rem;
}

/* Output Content */
.output-content {
    min-height: 200px;
}

.output-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
}

.output-stats .stat {
    text-align: center;
    padding: 0.5rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.output-stats label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.output-stats span {
    font-weight: bold;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.output-textarea,
.input-textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: white;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    resize: vertical;
    transition: var(--transition-normal);
}

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

/* Decoded Preview */
.decoded-preview {
    margin-top: 1rem;
}

.preview-container {
    text-align: center;
    margin: 1rem 0;
}

.preview-container img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-medium);
}

.decoded-info {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ASCII Output */
.ascii-output {
    margin-top: 1rem;
}

.ascii-output h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

#ascii-result {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.2;
    overflow-x: auto;
    white-space: pre;
    margin-bottom: 1rem;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--background-paper);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-heavy);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideInUp 0.3s ease-out;
}

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

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

.modal-header h3 {
    color: var(--primary-color);
    font-family: var(--font-serif);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header.error h3 {
    color: var(--error-color);
}

.modal-header.success h3 {
    color: var(--success-color);
}

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

.modal-close:hover {
    background: var(--background-secondary);
    color: var(--primary-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.wallet-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.wallet-option {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition-normal);
}

.wallet-option:hover {
    border-color: var(--primary-color);
    background: rgba(139, 69, 19, 0.05);
    transform: translateY(-2px);
}

.wallet-icon {
    width: 48px;
    height: 48px;
    background: var(--background-secondary);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.wallet-info h4 {
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

.wallet-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Loading Modal */
.loading-modal .modal-content {
    max-width: 300px;
    text-align: center;
}

.loading-content {
    padding: 2rem;
}

.loading-spinner {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.loading-spinner i {
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .library-header {
        flex-direction: column;
        text-align: center;
    }
    
    .wallet-section {
        align-items: center;
    }
    
    .library-nav {
        flex-direction: column;
    }
    
    .nav-btn {
        min-width: auto;
    }
    
    .library-main {
        padding: 1rem;
    }
    
    .section-header {
        padding: 1rem;
    }
    
    .section-header h2 {
        font-size: 1.5rem;
    }
    
    .formatting-toolbar {
        justify-content: center;
    }
    
    .toolbar-group {
        flex-wrap: wrap;
    }
    
    .editor-actions,
    .formatter-actions,
    .reformatter-actions {
        justify-content: center;
    }
    
    .option-grid {
        grid-template-columns: 1fr;
    }
    
    .word-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .formatter-stats {
        flex-direction: column;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .library-title {
        font-size: 2rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .word-stats {
        grid-template-columns: 1fr;
    }
    
    .toolbar-group {
        width: 100%;
        justify-content: center;
    }
    
    .preview-tabs {
        flex-direction: column;
    }
    
    .preview-tab {
        text-align: center;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    transition: var(--transition-normal);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Selection Styling */
::selection {
    background: rgba(139, 69, 19, 0.2);
    color: var(--text-primary);
}

/* Focus Indicators for Accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-muted: #333;
        --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-heavy: 0 8px 24px rgba(0, 0, 0, 0.5);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Print Styles */
@media print {
    .library-header,
    .library-nav,
    .modal {
        display: none !important;
    }
    
    .library-section {
        display: block !important;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    body {
        background: white;
        color: black;
    }
}
