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

:root {
    --bg: #09090b;
    --bg-2: #111113;
    --card: #18181b;
    --card-hover: #1c1c1f;
    --border: #27272a;
    --border-2: #3f3f46;
    --text: #fafafa;
    --text-2: #a1a1aa;
    --text-3: #71717a;
    --primary-bg: #fafafa;
    --primary-fg: #09090b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-muted: rgba(99, 102, 241, 0.12);
    --success: #22c55e;
    --success-muted: rgba(34, 197, 94, 0.12);
    --error: #ef4444;
    --error-muted: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-muted: rgba(245, 158, 11, 0.12);
    --radius: 6px;
    --radius-lg: 10px;
    --sidebar-w: 320px;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "Fira Code", "Cascadia Code", monospace;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* HEADER */
.header {
    height: 52px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    background: var(--bg);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
}

.logo svg {
    color: var(--accent);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-pill {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-2);
    background: var(--card);
}
.stat-pill.success {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
    background: var(--success-muted);
}
.stat-pill.muted {
    color: var(--text-3);
}

/* LAYOUT */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
    padding-bottom: 16px;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 4px;
}

.panel {
    background: var(--bg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.panel-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
}

/* TEXTAREA */
.textarea {
    width: 100%;
    height: 220px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    padding: 10px 12px;
    resize: none;
    outline: none;
    transition: border-color 0.15s;
}
.textarea:focus {
    border-color: var(--border-2);
}
.textarea::placeholder {
    color: var(--text-3);
}

.text-meta {
    font-size: 11px;
    color: var(--text-3);
    text-align: right;
}

/* RADIO GROUP */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}
.radio-item:hover {
    border-color: var(--border-2);
    background: var(--card-hover);
}
.radio-item.active {
    border-color: var(--accent);
    background: var(--accent-muted);
}
.radio-item input[type="radio"] {
    display: none;
}

.radio-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.radio-label {
    font-size: 13px;
    font-weight: 500;
}
.radio-desc {
    font-size: 11px;
    color: var(--text-3);
}
.radio-item.active .radio-label {
    color: var(--accent);
}
.radio-item.active .radio-desc {
    color: rgba(99, 102, 241, 0.7);
}

/* OPTIONS */
.option-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.option-block.hidden {
    display: none;
}

.field-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* INPUT / SELECT */
.input,
.select {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 7px 10px;
    outline: none;
    transition: border-color 0.15s;
    appearance: none;
}
.input:focus,
.select:focus {
    border-color: var(--border-2);
}
.input[readonly] {
    cursor: pointer;
    color: var(--text-2);
}

.dir-row {
    display: flex;
    gap: 6px;
}
.dir-row .input {
    flex: 1;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary-bg);
    color: var(--primary-fg);
    border-color: var(--primary-bg);
}
.btn-primary:hover {
    background: #e4e4e7;
    border-color: #e4e4e7;
}

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--card-hover);
    border-color: var(--border-2);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    gap: 4px;
}
.btn-icon {
    padding: 6px;
    width: 30px;
    height: 30px;
}

.w-full {
    width: 100%;
}
.mt-1 {
    margin-top: 4px;
}
.mt-2 {
    margin-top: 2px;
}

.divider {
    height: 1px;
    background: var(--border);
}

.action-row {
    display: flex;
    gap: 6px;
}
.action-row .btn {
    flex: 1;
}

/* MAIN CONTENT */
.main {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main::-webkit-scrollbar {
    width: 6px;
}
.main::-webkit-scrollbar-track {
    background: transparent;
}
.main::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* EMPTY STATE */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
}
.empty-icon {
    color: var(--border-2);
}
.empty-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-2);
}
.empty-desc {
    font-size: 13px;
    color: var(--text-3);
    text-align: center;
}
.empty-desc strong {
    color: var(--text-2);
}

/* SECTIONS HEADER */
.sections-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
}
.sections-header.hidden {
    display: none;
}

.sections-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sections-title {
    font-size: 15px;
    font-weight: 600;
}

.progress-summary {
    font-size: 12px;
    color: var(--text-3);
    display: flex;
    gap: 12px;
}

.global-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}
.global-progress.hidden {
    display: none;
}

.progress-bar-track {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s ease;
}
.progress-label {
    font-size: 12px;
    color: var(--text-3);
    white-space: nowrap;
}

/* SECTIONS LIST */
.sections-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* SECTION CARD */
.section-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.15s;
}
.section-card:hover {
    border-color: var(--border-2);
}
.section-card.selected {
    border-color: var(--accent);
}
.section-card.status-converting {
    border-color: var(--warning);
}
.section-card.status-done {
    border-color: rgba(34, 197, 94, 0.4);
}
.section-card.status-error {
    border-color: rgba(239, 68, 68, 0.4);
}

.section-top {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
}

.section-checkbox {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-2);
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.section-card.selected .section-checkbox {
    background: var(--accent);
    border-color: var(--accent);
}
.section-card.selected .section-checkbox::after {
    content: "";
    width: 8px;
    height: 8px;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4L4 7L9 1' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
        center/contain no-repeat;
}

.section-num {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--border);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

.section-title-input {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    width: 100%;
    outline: none;
    cursor: text;
    padding: 0;
}
.section-title-input:focus {
    color: var(--accent);
}

.section-meta {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
    display: flex;
    gap: 10px;
}

.section-status {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

.badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.badge-pending {
    background: var(--card-hover);
    color: var(--text-3);
    border: 1px solid var(--border);
}
.badge-converting {
    background: var(--warning-muted);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulse 1.5s infinite;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-converting::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--warning);
    border-radius: 50%;
    display: inline-block;
}
.badge-done {
    background: var(--success-muted);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.badge-error {
    background: var(--error-muted);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

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

.section-expand-btn {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.15s;
}
.section-expand-btn:hover {
    color: var(--text);
    background: var(--border);
}
.section-expand-btn svg {
    transition: transform 0.2s;
}
.section-card.expanded .section-expand-btn svg {
    transform: rotate(180deg);
}

.section-body {
    display: none;
    border-top: 1px solid var(--border);
}
.section-card.expanded .section-body {
    display: block;
}

.section-preview {
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text-2);
    line-height: 1.7;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    border-bottom: 1px solid var(--border);
}
.section-preview::-webkit-scrollbar {
    width: 4px;
}
.section-preview::-webkit-scrollbar-thumb {
    background: var(--border-2);
    border-radius: 4px;
}

.section-actions {
    padding: 10px 14px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.audio-player-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

audio {
    flex: 1;
    height: 28px;
    border-radius: 4px;
}

audio::-webkit-media-controls-panel {
    background: var(--card-hover);
}

.file-info {
    font-size: 11px;
    color: var(--text-3);
}

/* TOAST */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 13px;
    min-width: 260px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: slideIn 0.2s ease;
}
.toast.success {
    border-color: rgba(34, 197, 94, 0.4);
}
.toast.error {
    border-color: rgba(239, 68, 68, 0.4);
}
.toast.info {
    border-color: rgba(99, 102, 241, 0.3);
}

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

/* SLIDER */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: var(--border-2);
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.15s;
}
.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-marks {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-3);
    margin-top: 4px;
}

.speed-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.speed-val {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

/* TOGGLE ROW */
.toggle-row {
    display: flex;
    gap: 6px;
}
.toggle-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    transition: all 0.15s;
}
.toggle-label input {
    display: none;
}
.toggle-label:hover {
    border-color: var(--border-2);
    color: var(--text);
}
.toggle-label.active {
    border-color: var(--accent);
    background: var(--accent-muted);
    color: var(--accent);
}

/* REPLACEMENTS */
.replacements-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.replace-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--card-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}
.replace-chip .from {
    color: var(--warning);
    font-weight: 500;
}
.replace-chip .arrow {
    color: var(--text-3);
}
.replace-chip .to {
    color: var(--success);
    font-weight: 500;
    flex: 1;
}
.replace-chip .del-btn {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}
.replace-chip .del-btn:hover {
    color: var(--error);
}

.replace-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}
.replace-row.hidden {
    display: none;
}
.replace-row .input {
    flex: 1;
    min-width: 0;
}

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Serif:ital,wght@0,400;0,600;1,400&display=swap");

/* LISTENING MODE */
.listening-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: none;
    flex-direction: row;
    color: #fff;
    font-family: "IBM Plex Serif", serif;
    overflow: hidden;
}

.listening-mode::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("bg.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(8px) brightness(0.5);
    z-index: -1;
}

.listening-video-bg {
    display: none;
}

.listening-mode.active {
    display: flex;
}

.listening-left {
    flex: 0.4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 40px;
    background: transparent;
    position: relative;
    z-index: 10;
}

.listening-info {
    text-align: left;
    width: 100%;
    margin-bottom: 10px;
}

.listening-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    color: #fff;
    text-shadow:
        0px 0px 4px rgba(255, 255, 255, 0.8),
        0px 0px 12px rgba(99, 102, 241, 0.6);
}

.listening-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.listening-right {
    flex: 1.6;
    background: transparent;
    padding: 10vh 60px;
    display: flex;
    flex-direction: column;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

.listening-right::-webkit-scrollbar {
    display: none;
}

.lyrics-container {
    display: flex;
    flex-direction: column;
    gap: 40px;
    max-width: 500px;
    margin: 0 auto;
    padding-bottom: 20vh;
}

.lyric-line {
    font-size: 24px;
    font-weight: 400;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.15);
    transition: all 0.4s ease;
    cursor: pointer;
    text-shadow: none;
    filter: blur(1px);
}

.lyric-line.active {
    color: #fff;
    font-size: 32px;
    filter: blur(0);
    text-shadow:
        0px 0px 12px #ffffff,
        0px 0px 24px rgba(255, 255, 255, 0.7),
        0px 0px 40px rgba(99, 102, 241, 0.5);
    opacity: 1;
    transform: translateX(20px);
}

.lyric-line:hover {
    color: rgba(255, 255, 255, 0.5);
}

/* LISTENING CONTROLS */
.listening-controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    padding: 0;
    max-width: 240px;
}

.player-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
}

.player-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
    border-radius: 1px;
    cursor: pointer;
}

.player-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
}

.player-btns {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 4px;
}

.p-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.p-btn svg {
    width: 16px;
    height: 16px;
}

.p-btn:hover {
    color: #fff;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.6));
    transform: scale(1.1);
}

.p-btn-play {
    width: 32px;
    height: 32px;
    background: transparent;
    color: #fff;
    border: none;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
    display: flex;
    align-items: center;
    justify-content: center;
}

.p-btn-play svg {
    width: 24px;
    height: 24px;
}

.p-btn-play:hover {
    transform: scale(1.15);
}

.listening-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2001;
}

.listening-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.listening-mode-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
}

.listening-mode-btn.visible {
    display: flex;
}
