/* Subtitle Generator */

.sg-app {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--glass-shadow);
    padding: 22px;
}

.sg-app h3 {
    font-size: 0.95rem;
    color: var(--text-heading);
    margin: 0 0 10px;
}

.sg-hint {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin: 10px 0 0;
    line-height: 1.5;
}

.sg-alert {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.35);
    color: #e25555;
    font-size: 0.92rem;
    line-height: 1.5;
}

.sg-alert[hidden],
.sg-panel[hidden] {
    display: none;
}

/* ---- start ---- */

.sg-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    min-height: 240px;
    padding: 28px 20px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.sg-drop:hover,
.sg-drop:focus-visible,
.sg-drop.is-over {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.06);
    outline: none;
}

.sg-drop-icon {
    color: #ff6b6b;
}

.sg-drop h2 {
    font-size: 1.25rem;
    color: var(--text-heading);
    margin: 4px 0 0;
}

.sg-drop p {
    margin: 0;
    font-size: 0.92rem;
}

.sg-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.sg-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-main);
    min-width: 0;
}

.sg-field > span {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.sg-field output {
    color: #ff6b6b;
}

.sg-field select,
.sg-field input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    font: inherit;
    font-weight: 500;
}

.sg-field input[type="range"] {
    width: 100%;
    accent-color: #ff6b6b;
}

/* ---- working ---- */

.sg-work-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px 16px;
    color: var(--text-heading);
    margin-bottom: 10px;
}

.sg-work-head span {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sg-bar {
    height: 12px;
    border-radius: 6px;
    background: var(--input-bg);
    overflow: hidden;
}

.sg-bar > div {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    border-radius: 6px;
    transition: width 0.25s ease;
}

.sg-bar.is-busy > div {
    width: 35% !important;
    animation: sg-slide 1.2s ease-in-out infinite alternate;
}

@keyframes sg-slide {
    from { margin-left: 0; }
    to { margin-left: 65%; }
}

.sg-live {
    min-height: 4.5em;
    max-height: 9em;
    overflow: hidden;
    margin: 16px 0 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 0.95rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.sg-live:empty::before {
    content: "The transcript appears here as it is written.";
    color: var(--text-muted);
}

.sg-work-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.sg-btn,
.sg-btn-quiet {
    padding: 8px 18px;
    font-size: 0.88rem;
    border-radius: 50px;
    background: transparent;
    color: var(--text-heading);
    border: 1px solid var(--border-color);
}

.sg-btn:hover,
.sg-btn-quiet:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

/* ---- editor ---- */

.sg-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.sg-fileinfo {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
}

.sg-fileinfo strong {
    color: var(--text-heading);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sg-fileinfo span {
    color: var(--text-muted);
    font-size: 0.86rem;
}

.sg-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 12px 16px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: rgba(255, 142, 83, 0.12);
    border: 1px solid rgba(255, 142, 83, 0.4);
    color: var(--text-main);
    font-size: 0.92rem;
}

.sg-notice[hidden] {
    display: none;
}

.sg-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.sg-player {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #101014;
    border-radius: 10px;
    overflow: hidden;
    min-height: 200px;
}

.sg-player canvas {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    width: auto;
    height: auto;
}

.sg-transport {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0 18px;
}

.sg-play {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-gradient);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sg-transport input[type="range"] {
    flex: 1;
    min-width: 0;
    accent-color: #ff6b6b;
}

.sg-time {
    flex: none;
    font-variant-numeric: tabular-nums;
    font-size: 0.86rem;
    color: var(--text-muted);
    min-width: 4.5em;
    text-align: right;
}

.sg-controls h3 {
    margin-top: 18px;
}

.sg-controls h3:first-child {
    margin-top: 0;
}

.sg-styles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sg-style {
    position: relative;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.sg-style[aria-checked="true"] {
    border-color: #ff6b6b;
    background: rgba(255, 107, 107, 0.12);
    color: #ff6b6b;
}

.sg-style .sg-star,
.sg-style-note .sg-star {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(135deg, #ffd166, #ff9f43);
    color: #4a2c00;
    vertical-align: middle;
}

.sg-style-note .sg-star {
    margin-left: 0;
}

.sg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 16px;
    margin-top: 12px;
}

.sg-color input[type="color"] {
    width: 100%;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    cursor: pointer;
}

.sg-check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    align-self: end;
    padding-bottom: 6px;
}

.sg-check input {
    width: 18px;
    height: 18px;
    accent-color: #ff6b6b;
}

.sg-right {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.sg-file-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sg-count {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.sg-transcript .sg-hint {
    margin: -4px 0 10px;
}

.sg-cues {
    position: relative;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--input-bg);
}

.sg-cue {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 2px 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.sg-cue:last-child {
    border-bottom: none;
}

.sg-cue.is-now {
    background: rgba(255, 107, 107, 0.1);
}

.sg-cue.is-selected {
    background: var(--bg-surface);
    box-shadow: inset 3px 0 0 #ff6b6b;
}

.sg-cue-time {
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-top: 3px;
    white-space: nowrap;
}

.sg-cue-text {
    color: var(--text-main);
    font-size: 0.94rem;
    line-height: 1.45;
    outline: none;
    border-radius: 4px;
    padding: 1px 4px;
    margin: 0 -4px;
    cursor: text;
    word-break: break-word;
}

.sg-cue-text:focus {
    background: var(--input-focus-bg, #fff);
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.5);
}

.sg-cue-tools {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: default;
}

.sg-cue-tools input {
    width: 5.6em;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font: inherit;
    font-variant-numeric: tabular-nums;
}

.sg-cue-tools button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font: inherit;
    cursor: pointer;
}

.sg-cue-tools button:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

.sg-export {
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
}

.sg-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.sg-export-btn {
    width: 100%;
}

.sg-export-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sg-export-progress {
    margin-top: 12px;
}

.sg-export-progress[hidden],
.sg-result[hidden] {
    display: none;
}

.sg-export-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.sg-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-top: 12px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.sg-result a {
    text-decoration: none;
}

.sg-plan {
    margin: 12px 0 0;
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.sg-plan button {
    padding: 0;
    border: none;
    background: none;
    color: #ff6b6b;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

.sg-app[data-kind="audio"] #sg-style-panel,
.sg-app[data-kind="audio"] #sg-export-box {
    display: none;
}

.sg-app[data-kind="audio"] .sg-player canvas {
    max-height: 220px;
}

@media (max-width: 900px) {
    .sg-columns {
        grid-template-columns: minmax(0, 1fr);
    }

    .sg-options {
        grid-template-columns: minmax(0, 1fr);
    }

    .sg-player canvas {
        max-height: 56vh;
    }
}

@media (max-width: 560px) {
    .sg-app {
        padding: 14px;
    }

    .sg-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .sg-drop {
        min-height: 190px;
    }
}

/* The site's phone stylesheet makes every button and input a full-width block (with !important).
   These controls are laid out here, so they opt out. */
.sg-app [hidden] {
    display: none !important;
}

.sg-app .sg-play {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    flex: 0 0 40px !important;
}

.sg-app input[type="range"] {
    padding: 0 !important;
    height: auto !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.sg-app .sg-transport input[type="range"] {
    width: auto !important;
    flex: 1 1 auto !important;
}

.sg-app .sg-style {
    width: auto !important;
    padding: 8px 14px !important;
    font-size: 0.86rem !important;
}

.sg-app .sg-file-buttons .btn,
.sg-app .sg-btn-quiet,
.sg-app .sg-notice .btn {
    width: auto !important;
    padding: 8px 18px !important;
    font-size: 0.88rem !important;
}

.sg-app .sg-plan button {
    display: inline !important;
    width: auto !important;
    padding: 0 !important;
    font-size: inherit !important;
}

.sg-app .sg-cue-tools input {
    width: 5.6em !important;
    padding: 4px 6px !important;
}

.sg-app .sg-cue-tools button {
    width: auto !important;
    padding: 4px 10px !important;
    font-size: 0.8rem !important;
}

.sg-app .sg-check input {
    width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
}

.sg-app .sg-color input[type="color"] {
    width: 100% !important;
    height: 34px !important;
    padding: 2px !important;
}
