/* =========================================================
   Subtitle Studio
========================================================= */

:root {

    --bg: #f4f6f8;

    --panel: #ffffff;

    --soft: #f8fafc;

    --border: #e5e7eb;

    --border-dark: #d1d5db;

    --text: #111827;

    --secondary: #64748b;

    --muted: #94a3b8;

    --primary: #4f46e5;

    --primary-soft: #eef2ff;

    --danger: #ef4444;

    --topbar: 64px;

    --statusbar: 30px;

    --left: 310px;

    --right: 270px;
}


* {
    box-sizing: border-box;
}


html,
body {

    width: 100%;

    height: 100%;

    margin: 0;
}


body {

    font-family:
        Inter,
        "Segoe UI",
        "Microsoft YaHei",
        Arial,
        sans-serif;

    background:
        var(--bg);

    color:
        var(--text);

    overflow:
        hidden;
}


button,
input,
textarea,
select {

    font:
        inherit;
}


button {

    cursor:
        pointer;
}


/* =========================================================
   App
========================================================= */

.subtitle-app {

    width: 100vw;

    height: 100vh;

    display: flex;

    flex-direction: column;
}


/* =========================================================
   Topbar
========================================================= */

.topbar {

    height: var(--topbar);

    flex-shrink: 0;

    display: flex;

    align-items: center;

    gap: 20px;

    padding: 0 18px;

    background:
        #ffffff;

    border-bottom:
        1px solid var(--border);

    z-index: 10;
}


.brand {

    width: 270px;

    display: flex;

    align-items: center;

    gap: 10px;
}


.brand-icon {

    width: 38px;

    height: 38px;

    display: flex;

    align-items: center;

    justify-content: center;

    border-radius: 9px;

    background:
        var(--primary-soft);

    color:
        var(--primary);

    font-size: 16px;

    font-weight: 800;
}


.brand-title {

    font-size: 15px;

    font-weight: 700;
}


.brand-subtitle {

    margin-top: 2px;

    color:
        var(--muted);

    font-size: 10px;
}


.top-actions {

    margin-left: auto;

    display: flex;

    gap: 7px;
}


.button {

    height: 36px;

    padding: 0 13px;

    border-radius: 8px;

    font-size: 11px;

    font-weight: 600;

    white-space: nowrap;
}


.button.secondary {

    background: #ffffff;

    border:
        1px solid var(--border-dark);

    color:
        var(--secondary);
}


.button.secondary:hover {

    background:
        var(--soft);

    color:
        var(--text);
}


.button.primary {

    background:
        var(--primary);

    color:
        #ffffff;

    border:
        1px solid var(--primary);
}


.button.danger {

    background:
        #fff5f5;

    border:
        1px solid #fecaca;

    color:
        var(--danger);
}


.button.full {

    width: 100%;

    margin-top: 12px;
}


/* =========================================================
   Workspace
========================================================= */

.workspace {

    min-height: 0;

    flex: 1;

    display: grid;

    grid-template-columns:
        var(--left) minmax(0, 1fr) var(--right);

    overflow: hidden;
}


/* =========================================================
   Left
========================================================= */

.left-panel {

    min-width: 0;

    overflow-y: auto;

    background:
        #ffffff;

    border-right:
        1px solid var(--border);
}


.panel-section {

    padding:
        16px;

    border-bottom:
        1px solid var(--border);
}


.section-title {

    margin-bottom:
        12px;

    font-size:
        11px;

    font-weight:
        700;

    color:
        var(--secondary);
}


.upload-card {

    padding:
        17px 13px;

    text-align:
        center;

    border:
        1px dashed var(--border-dark);

    border-radius:
        10px;

    background:
        var(--soft);
}


.upload-icon {

    width:
        40px;

    height:
        40px;

    margin:
        0 auto 9px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    border-radius:
        10px;

    background:
        var(--primary-soft);

    color:
        var(--primary);

    font-size:
        20px;
}


.upload-card strong {

    display:
        block;

    font-size:
        12px;
}


.upload-card span {

    display:
        block;

    margin-top:
        5px;

    color:
        var(--muted);

    font-size:
        9px;

    line-height:
        1.5;
}


.form-group {

    margin-top:
        11px;
}


.form-group label {

    display:
        block;

    margin-bottom:
        6px;

    color:
        var(--secondary);

    font-size:
        10px;
}


textarea,
input,
select {

    width:
        100%;

    border:
        1px solid var(--border);

    border-radius:
        7px;

    background:
        #ffffff;

    color:
        var(--text);

    outline:
        none;
}


textarea {

    padding:
        8px;

    resize:
        vertical;

    line-height:
        1.5;

    font-size:
        11px;
}


input,
select {

    height:
        34px;

    padding:
        0 8px;

    font-size:
        10px;
}


textarea:focus,
input:focus,
select:focus {

    border-color:
        #c7d2fe;

    box-shadow:
        0 0 0 3px var(--primary-soft);
}


.time-grid,
.style-grid {

    display:
        grid;

    grid-template-columns:
        1fr 1fr;

    gap:
        7px;
}


.editing-actions {

    display:
        grid;

    grid-template-columns:
        1fr 1fr 1fr;

    gap:
        6px;

    margin-top:
        13px;
}


.editing-actions .button {

    padding:
        0 6px;
}


input[type="color"] {

    height:
        34px;

    padding:
        3px;
}


/* =========================================================
   Range
========================================================= */

input[type="range"] {

    height:
        4px;

    padding:
        0;

    border:
        0;

    appearance:
        none;

    background:
        #e2e8f0;
}


input[type="range"]::-webkit-slider-thumb {

    appearance:
        none;

    width:
        14px;

    height:
        14px;

    border-radius:
        50%;

    background:
        var(--primary);

    border:
        2px solid #ffffff;

    box-shadow:
        0 1px 4px rgba(15, 23, 42, .2);
}


/* =========================================================
   Center
========================================================= */

.center-area {

    min-width:
        0;

    min-height:
        0;

    display:
        flex;

    flex-direction:
        column;

    background:
        #eef1f5;
}


/* =========================================================
   Player
========================================================= */

.player {

    position:
        relative;

    width:
        min(900px, calc(100% - 40px));

    aspect-ratio:
        16 / 9;

    margin:
        24px auto 14px;

    background:
        #111827;

    border-radius:
        10px;

    overflow:
        hidden;

    box-shadow:
        0 10px 30px rgba(15, 23, 42, .14);
}


.player video {

    width:
        100%;

    height:
        100%;

    display:
        block;

    object-fit:
        contain;

    background:
        #111827;
}


.subtitle-preview {

    position:
        absolute;

    left:
        50%;

    transform:
        translateX(-50%);

    max-width:
        90%;

    padding:
        5px 12px;

    color:
        #ffffff;

    font-family:
        "Microsoft YaHei",
        sans-serif;

    font-size:
        30px;

    font-weight:
        700;

    line-height:
        1.4;

    text-align:
        center;

    white-space:
        pre-wrap;

    pointer-events:
        none;

    text-shadow:
        0 2px 6px rgba(0, 0, 0, .8);

    -webkit-text-stroke:
        2px #000000;
}


/* =========================================================
   Playback
========================================================= */

.playback-bar {

    width:
        min(900px, calc(100% - 40px));

    margin:
        0 auto;

    display:
        flex;

    align-items:
        center;

    gap:
        9px;
}


.play-button {

    width:
        38px;

    height:
        34px;

    border-radius:
        8px;

    background:
        var(--primary);

    color:
        #ffffff;

    font-size:
        13px;
}


.current-time,
.duration {

    width:
        78px;

    font-family:
        Consolas,
        monospace;

    font-size:
        9px;

    color:
        var(--secondary);

    text-align:
        center;
}


.playback-bar input {

    flex:
        1;
}


/* =========================================================
   Timeline
========================================================= */

.timeline-panel {

    min-height:
        0;

    flex:
        1;

    margin:
        18px 20px 20px;

    display:
        flex;

    flex-direction:
        column;

    background:
        #ffffff;

    border:
        1px solid var(--border);

    border-radius:
        10px;

    overflow:
        hidden;
}


.timeline-header {

    height:
        42px;

    flex-shrink:
        0;

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    padding:
        0 13px;

    border-bottom:
        1px solid var(--border);

    font-size:
        11px;

    font-weight:
        700;
}


.timeline-header div:last-child {

    color:
        var(--muted);

    font-weight:
        500;
}


.subtitle-timeline {

    position:
        relative;

    min-height:
        0;

    flex:
        1;

    overflow:
        auto;

    padding:
        15px;
}


.empty-timeline {

    height:
        100%;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    color:
        var(--muted);

    font-size:
        11px;
}


.timeline-item {

    position:
        relative;

    height:
        42px;

    margin-bottom:
        7px;

    border-radius:
        7px;

    background:
        var(--primary-soft);

    border:
        1px solid #dbe3ff;

    cursor:
        pointer;
}


.timeline-item:hover {

    border-color:
        #a5b4fc;
}


.timeline-item.active {

    border:
        2px solid var(--primary);

    background:
        #e9eaff;
}


.timeline-item-text {

    position:
        absolute;

    left:
        9px;

    right:
        9px;

    top:
        50%;

    transform:
        translateY(-50%);

    overflow:
        hidden;

    text-overflow:
        ellipsis;

    white-space:
        nowrap;

    font-size:
        10px;

    color:
        var(--text);
}


/* =========================================================
   Right
========================================================= */

.right-panel {

    min-width:
        0;

    overflow-y:
        auto;

    background:
        #ffffff;

    border-left:
        1px solid var(--border);
}


.right-section {

    padding:
        15px;

    border-bottom:
        1px solid var(--border);
}


.right-title {

    margin-bottom:
        11px;

    font-size:
        11px;

    font-weight:
        700;
}


.subtitle-list {

    display:
        flex;

    flex-direction:
        column;

    gap:
        5px;
}


.subtitle-item {

    padding:
        9px;

    border:
        1px solid transparent;

    border-radius:
        8px;

    cursor:
        pointer;
}


.subtitle-item:hover {

    background:
        var(--soft);
}


.subtitle-item.active {

    background:
        var(--primary-soft);

    border-color:
        #c7d2fe;
}


.subtitle-item-time {

    margin-bottom:
        3px;

    color:
        var(--primary);

    font-family:
        Consolas,
        monospace;

    font-size:
        8px;
}


.subtitle-item-text {

    font-size:
        10px;

    line-height:
        1.45;

    color:
        var(--text);
}


.ai-button {

    width:
        100%;

    padding:
        11px;

    margin-bottom:
        7px;

    text-align:
        left;

    border:
        1px solid var(--border);

    border-radius:
        8px;

    background:
        var(--soft);
}


.ai-button strong {

    display:
        block;

    font-size:
        10px;
}


.ai-button span {

    display:
        block;

    margin-top:
        4px;

    color:
        var(--muted);

    font-size:
        8px;
}


.info-row {

    display:
        flex;

    justify-content:
        space-between;

    padding:
        8px 0;

    border-bottom:
        1px solid var(--border);

    font-size:
        10px;
}


.info-row:last-child {

    border-bottom:
        0;
}


.info-row span {

    color:
        var(--secondary);
}


.info-row strong {

    color:
        var(--text);
}


/* =========================================================
   Status
========================================================= */

.statusbar {

    height:
        var(--statusbar);

    flex-shrink:
        0;

    display:
        flex;

    align-items:
        center;

    justify-content:
        space-between;

    padding:
        0 12px;

    background:
        #ffffff;

    border-top:
        1px solid var(--border);

    color:
        var(--muted);

    font-size:
        9px;
}


.statusbar>div:first-child {

    display:
        flex;

    align-items:
        center;

    gap:
        6px;
}


.status-dot {

    width:
        6px;

    height:
        6px;

    border-radius:
        50%;

    background:
        #22c55e;
}


.status-dot.loading {

    background:
        #f59e0b;
}


.status-dot.error {

    background:
        #ef4444;
}


/* =========================================================
   Scrollbar
========================================================= */

.left-panel::-webkit-scrollbar,
.right-panel::-webkit-scrollbar,
.subtitle-timeline::-webkit-scrollbar {

    width:
        6px;
}


.left-panel::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb,
.subtitle-timeline::-webkit-scrollbar-thumb {

    background:
        #d8dde5;

    border-radius:
        999px;
}

.upload-hint {
    margin: 12px 0 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
}

.upload-hint.is-warning {
    color: #b45309;
}


/* =========================================================
   Media Import Card
   导入媒体 / 自动生成字幕
========================================================= */

.upload-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.upload-card .upload-icon {
    flex-shrink: 0;
}

.upload-card strong {
    color: var(--text);
    font-size: 13px;
}

.upload-card>span {
    margin-top: -4px;
    color: var(--secondary);
    font-size: 11px;
    line-height: 1.7;
}

.upload-card .button.full {
    width: 100%;
    min-height: 38px;
    height: auto;
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 8px;
    font-size: 12px;
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.upload-card #importMediaBtn {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--border-dark);
}

.upload-card #importMediaBtn:hover {
    background: #f8fafc;
    border-color: #a5b4fc;
}

.upload-card #importMediaBtn:active,
.upload-card #generateSubtitleBtn:active {
    transform: translateY(1px);
}

.upload-card #generateSubtitleBtn {
    margin-top: 0;
}

.upload-hint {
    width: 100%;
    margin: 0;
    color: var(--secondary);
    font-size: 11px;
    line-height: 1.6;
    text-align: center;
    overflow-wrap: anywhere;
}

.upload-hint.is-warning {
    color: #b45309;
}

.upload-hint.is-success {
    color: #15803d;
}

@media (max-width: 480px) {
    .upload-card {
        padding: 14px 11px;
        gap: 9px;
    }

    .upload-card>span {
        font-size: 11px;
    }

    .upload-card .button.full {
        min-height: 40px;
    }
}