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

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

body {
    background: #0a0e27;
    color: #00ff41;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Screen Management */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

.screen-header {
    padding: 20px;
    border-bottom: 1px solid #004d1a;
    background: #0f1433;
}

.screen-header h2 {
    font-size: 20px;
    margin-bottom: 5px;
    color: #00ff41;
}

.subtitle {
    font-size: 14px;
    color: #00b333;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-top: 0;
}

/* Control Panel */
.control-panel {
    position: sticky;
    top: 0;
    background: #0f1433;
    padding: 15px 0;
    border-bottom: 1px solid #004d1a;
    margin-bottom: 15px;
    z-index: 10;
}

.control-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.control-buttons button {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
}

.btn-square {
    flex: 0 0 auto;
    width: 50px;
    height: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen-footer {
    padding: 20px;
    border-top: 1px solid #004d1a;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #0f1433;
}

/* Loading */
.loading-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 20px;
}

.content-title {
    font-size: 20px;
    font-weight: 600;
    color: #00ff41;
    text-align: center;
    max-width: 80%;
    margin: 0;
    min-height: 30px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #004d1a;
    border-top-color: #00ff41;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

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

.progress-bar-container {
    width: 100%;
    max-width: 300px;
    margin-top: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #004d1a;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #00ff41;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-label {
    font-size: 12px;
    color: #00b333;
    text-align: center;
    margin-top: 8px;
}

.analysis-log {
    width: 100%;
    max-width: 300px;
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid #004d1a;
    border-radius: 4px;
    padding: 10px;
    font-size: 12px;
    background: #0a0e27;
    margin-top: 20px;
}

.analysis-log-entry {
    margin-bottom: 5px;
    padding: 4px 8px;
    border-radius: 3px;
    line-height: 1.4;
}

.analysis-log-entry.success {
    color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
}

.analysis-log-entry.error {
    color: #ff4141;
    background: rgba(255, 65, 65, 0.1);
}

.error-notice {
    width: 100%;
    max-width: 300px;
    text-align: center;
    padding: 15px;
    border: 2px solid #ff4141;
    border-radius: 8px;
    background: rgba(255, 65, 65, 0.1);
    margin-top: 20px;
}

.error-notice p {
    color: #ff4141;
    margin: 0 0 12px 0;
    font-size: 13px;
}

/* Episodes List */
.episodes-list {
    display: grid;
    gap: 10px;
}

.episode-item {
    padding: 12px;
    border: 2px solid #004d1a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #0f1433;
}

.episode-item:active {
    background: #1a2847;
}

.episode-item label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
}

.episode-item input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.episode-item.selected {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
}

.episode-item.episode-error {
    border-color: #ff4141;
    background: rgba(255, 65, 65, 0.1);
    opacity: 0.6;
}

.episode-item.episode-error label {
    cursor: not-allowed;
}

.episode-item.episode-error input[type="checkbox"] {
    cursor: not-allowed;
    opacity: 0.5;
}

.episode-item.hidden-downloaded {
    display: none;
}

.episode-details {
    flex: 1;
    min-width: 0;
}

.episode-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #00ff41;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #004d1a;
    color: #00ff41;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
    border: 1px solid #00ff41;
}

.episode-info {
    font-size: 13px;
    color: #00b333;
    margin-bottom: 4px;
    line-height: 1.4;
}

.episode-info:last-child {
    margin-bottom: 0;
}

.episode-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.episode-controls button {
    flex: 1;
}

/* Quality List */
.quality-list {
    display: grid;
    gap: 10px;
}

.quality-item {
    padding: 15px;
    border: 2px solid #004d1a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #0f1433;
}

.quality-item input[type="radio"] {
    margin-right: 10px;
    cursor: pointer;
}

.quality-item:active {
    background: #1a2847;
}

.quality-item.selected {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
}

.quality-label {
    display: block;
    font-weight: 500;
    color: #00ff41;
}

.quality-info {
    font-size: 12px;
    color: #00b333;
    margin-top: 5px;
}

/* Audio Tracks List */
.audio-list {
    display: grid;
    gap: 10px;
}

.audio-item {
    padding: 12px;
    border: 2px solid #004d1a;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #0f1433;
}

.audio-item:active {
    background: #1a2847;
}

.audio-item input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
}

.audio-item.selected {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.1);
}

.audio-title-main {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
    color: #00ff41;
}

.audio-lang-light {
    font-size: 13px;
    font-weight: 400;
    color: #00b333;
    display: block;
}

/* Modal Windows */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: none;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.modal.active {
    display: flex;
    flex-direction: column;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 101;
}

.modal-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 90vh;
    background: #0f1433;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    z-index: 102;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #004d1a;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #00ff41;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #00b333;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.modal-close-btn:active {
    opacity: 1;
}

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

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #004d1a;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 80px;
}

/* Summary */
.summary-content {
    display: grid;
    gap: 15px;
}

.summary-section {
    padding: 15px;
    background: var(--tg-theme-secondary-bg-color, #f0f0f0);
    border-radius: 8px;
}

.summary-section-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--tg-theme-text-color, #000000);
}

.summary-item {
    font-size: 14px;
    color: var(--tg-theme-hint-color, #999999);
    line-height: 1.5;
}

.summary-episode-item {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    border-left: 3px solid var(--tg-theme-button-color, #0088cc);
}

.episode-number {
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--tg-theme-text-color, #000000);
}

.episode-quality {
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--tg-theme-hint-color, #999999);
}

.episode-audio {
    font-size: 13px;
    color: var(--tg-theme-hint-color, #999999);
}

.audio-track-line {
    line-height: 1.6;
    display: block;
}

.overwrite-option {
    padding: 15px;
    border: 1px solid #004d1a;
    border-radius: 8px;
    background: #0f1433;
}

.overwrite-option label {
    display: flex;
    align-items: center;
    cursor: pointer;
    gap: 10px;
    color: #00ff41;
}

.overwrite-option input[type="checkbox"] {
    cursor: pointer;
}

/* Success/Error */
.success-content,
.error-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    gap: 15px;
    text-align: center;
    padding: 20px;
    color: #00ff41;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: #004d1a;
    color: #00ff41;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border: 2px solid #00ff41;
}

.error-icon {
    width: 60px;
    height: 60px;
    background: #4d001a;
    color: #ff4141;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border: 2px solid #ff4141;
}

/* Buttons */
.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:active {
    opacity: 0.8;
}

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

.btn-primary {
    background: #00ff41;
    color: #0a0e27;
    font-weight: 600;
}

.btn-secondary {
    background: #004d1a;
    color: #00ff41;
    border: 1px solid #00ff41;
}

.btn-success {
    background: #00ff41;
    color: #0a0e27;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 600px) {
    .screen-header {
        padding: 15px;
    }

    .screen-content {
        padding: 15px;
    }

    .screen-footer {
        padding: 15px;
        gap: 8px;
    }

    .btn {
        padding: 10px 12px;
        font-size: 14px;
    }

    .screen-footer {
        flex-direction: column-reverse;
    }

    .screen-footer .btn {
        width: 100%;
    }
}

/* Summary Screen Episode Delete Button */
.summary-episode-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.episode-delete-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.episode-delete-btn:hover {
    opacity: 1;
}

.warning-text {
    color: var(--tg-theme-hint-color, #999999);
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

/* ==================== Per-Episode Settings Styles ==================== */

/* Episode content sections */
.episode-content-collapsed {
    display: block;
}

.episode-content-expanded {
    display: none;
    padding-top: 15px;
    border-top: 1px solid #004d1a;
    margin-top: 15px;
}

.episode-item.expanded .episode-content-expanded {
    display: block;
}

/* Episode summary (collapsed view) */
.episode-summary {
    font-size: 13px;
    color: #00b333;
    margin-top: 8px;
    line-height: 1.4;
    white-space: normal;
}

/* Expanded episode highlight */
.episode-item.expanded {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.05);
}

/* Inline quality selector */
.inline-quality-selector {
    margin-bottom: 15px;
}

.inline-quality-label {
    display: block;
    font-size: 12px;
    color: #00b333;
    margin-bottom: 8px;
    font-weight: 500;
}

.inline-quality-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-quality-option {
    padding: 8px 12px;
    border: 2px solid #004d1a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: #0f1433;
    font-size: 13px;
    color: #00ff41;
    font-weight: 500;
    user-select: none;
}

.inline-quality-option.selected {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.15);
    font-weight: 600;
}

.inline-quality-option:active {
    background: #1a2847;
}

/* Inline audio selector */
.inline-audio-selector {
    margin-bottom: 10px;
}

.inline-audio-label {
    display: block;
    font-size: 12px;
    color: #00b333;
    margin-bottom: 8px;
    font-weight: 500;
}

.inline-audio-options {
    display: grid;
    gap: 8px;
}

.inline-audio-option {
    padding: 10px;
    border: 2px solid #004d1a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: #0f1433;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.inline-audio-option.selected {
    border-color: #00ff41;
    background: rgba(0, 255, 65, 0.15);
}

.inline-audio-option:active {
    background: #1a2847;
}

.inline-audio-option input[type="checkbox"] {
    cursor: pointer;
    flex-shrink: 0;
}

.inline-audio-title {
    font-size: 13px;
    color: #00ff41;
    font-weight: 500;
    flex: 1;
}

.inline-audio-lang {
    font-size: 11px;
    color: #00b333;
    white-space: nowrap;
    flex-shrink: 0;
}
