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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #09090b;
    color: #e4e4e7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Top bar ---- */
.topbar {
    background: #18181b;
    border-bottom: 1px solid #27272a;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fafafa;
}
.logo {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; font-weight: 700; color: #fff;
}
.brand-name { font-size: 1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-link {
    font-size: 0.8rem; color: #a1a1aa; text-decoration: none;
    padding: 4px 10px; border: 1px solid transparent; border-radius: 6px;
    transition: all 0.15s; display: flex; align-items: center; gap: 4px;
}
.topbar-link:hover { color: #e4e4e7; border-color: #3f3f46; }
.user-chip { display: flex; align-items: center; gap: 6px; }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.user-avatar-fallback {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 600; color: #fff; text-transform: uppercase;
}
.user-name { font-size: 0.8rem; color: #a1a1aa; }

/* ---- Main ---- */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
    flex: 1;
}

/* ---- Upload section ---- */
.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 1.4rem; font-weight: 600; color: #fafafa; }
.pipeline-steps { font-size: 0.8rem; color: #52525b; margin-top: 4px; }

.upload-form { margin-bottom: 24px; }
.upload-row {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.drop-zone {
    border: 2px dashed #27272a;
    border-radius: 12px;
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: #2563eb; background: rgba(37,99,235,0.05); }
.drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-icon { width: 32px; height: 32px; color: #52525b; margin-bottom: 8px; }
.drop-text { font-size: 0.85rem; color: #a1a1aa; }
.browse { color: #2563eb; font-weight: 500; }
.file-hint { font-size: 0.75rem; color: #52525b; margin-top: 4px; }
.file-selected { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.85rem; font-weight: 500; color: #e4e4e7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: #71717a; }
.remove-file {
    background: none; border: none; color: #71717a; font-size: 1.2rem;
    cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.remove-file:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

.upload-options { display: flex; flex-direction: column; gap: 14px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 0.8rem; font-weight: 500; color: #a1a1aa; }
.select-wrapper { position: relative; }
select {
    width: 100%; padding: 10px 36px 10px 12px;
    background: #09090b; border: 1px solid #27272a; border-radius: 8px;
    color: #e4e4e7; font-size: 0.85rem; cursor: pointer; appearance: none;
}
select:focus { outline: none; border-color: #2563eb; }
.select-arrow { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #52525b; pointer-events: none; }

/* Toggle */
.toggle-label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-label input[type="checkbox"] { display: none; }
.toggle-switch {
    width: 36px; height: 20px; background: #27272a; border-radius: 100px;
    position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
    content: ""; position: absolute; width: 16px; height: 16px;
    background: #52525b; border-radius: 50%; top: 2px; left: 2px; transition: all 0.2s;
}
.toggle-label input:checked + .toggle-switch { background: #2563eb; }
.toggle-label input:checked + .toggle-switch::after { left: 18px; background: #fff; }
.toggle-text { font-size: 0.85rem; color: #e4e4e7; font-weight: 500; }

/* Submit button */
button[type="submit"] {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff; border: none; border-radius: 8px;
    font-size: 0.95rem; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s;
}
button[type="submit"]:hover { background: linear-gradient(135deg, #1d4ed8, #4338ca); }
button[type="submit"]:disabled { background: #27272a; color: #52525b; cursor: not-allowed; }
.btn-icon { width: 16px; height: 16px; }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Progress ---- */
.progress-section { margin-bottom: 24px; }
.progress-stages {
    display: flex; align-items: center; justify-content: center;
    gap: 0; margin-bottom: 16px; flex-wrap: wrap;
}
.stage { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stage span { font-size: 0.7rem; color: #52525b; transition: color 0.3s; }
.stage-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #27272a; border: 2px solid #3f3f46; transition: all 0.3s;
}
.stage.active .stage-dot { background: #2563eb; border-color: #2563eb; box-shadow: 0 0 8px rgba(37,99,235,0.5); }
.stage.active span { color: #2563eb; font-weight: 500; }
.stage.completed .stage-dot { background: #16a34a; border-color: #16a34a; }
.stage.completed span { color: #a1a1aa; }
.stage-line { width: 32px; height: 2px; background: #27272a; margin-bottom: 18px; transition: background 0.3s; }
.stage-line.completed { background: #16a34a; }
.progress-bar-container { width: 100%; background: #27272a; border-radius: 100px; overflow: hidden; height: 6px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, #2563eb, #7c3aed); width: 0%; transition: width 0.4s ease; border-radius: 100px; }
.progress-info { display: flex; justify-content: space-between; margin-top: 8px; font-size: 0.8rem; }
.progress-info span:first-child { color: #e4e4e7; font-weight: 600; font-variant-numeric: tabular-nums; }
.progress-info span:last-child { color: #71717a; }

/* ---- Waveform player ---- */
.waveform-section { margin-bottom: 24px; }
.waveform-container {
    background: #18181b; border: 1px solid #27272a; border-radius: 12px; padding: 16px;
}
.waveform-controls {
    display: flex; align-items: center; gap: 12px; margin-top: 10px;
}
.waveform-btn {
    width: 36px; height: 36px;
    border: 1px solid #27272a; border-radius: 8px;
    background: #09090b; color: #a1a1aa; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.waveform-btn:hover { border-color: #2563eb; color: #e4e4e7; }
.waveform-btn.active { border-color: #2563eb; background: rgba(37,99,235,0.15); color: #2563eb; }
.waveform-btn svg { width: 14px; height: 14px; }
.waveform-btn .pause-icon { display: none; }
.waveform-btn.playing .play-icon { display: none; }
.waveform-btn.playing .pause-icon { display: block; }
.waveform-time { font-size: 0.8rem; color: #71717a; font-variant-numeric: tabular-nums; font-family: monospace; }
.current-subtitle {
    margin-top: 10px; padding: 8px 12px;
    background: #09090b; border-radius: 6px;
    font-size: 0.9rem; color: #e4e4e7; text-align: center;
    min-height: 36px; display: flex; align-items: center; justify-content: center;
}

/* ---- Subtitle editor (in waveform area) ---- */
.subtitle-editor {
    margin-top: 10px; padding: 12px;
    background: #09090b; border: 1px solid #27272a; border-radius: 8px;
}
.editor-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.editor-time { font-size: 0.75rem; color: #52525b; font-family: monospace; }
.editor-tag {
    font-size: 0.65rem; font-weight: 600; padding: 2px 8px;
    border-radius: 4px; text-transform: uppercase; letter-spacing: 0.05em;
}
.tag-ai { background: rgba(37,99,235,0.15); color: #60a5fa; }
.tag-manual { background: rgba(234,179,8,0.15); color: #eab308; }
.tag-pending { background: rgba(234,179,8,0.1); color: #a3830a; }
.editor-row { display: flex; gap: 8px; align-items: center; }
.editor-input {
    flex: 1; padding: 8px 12px; background: #18181b; border: 1px solid #27272a;
    border-radius: 6px; color: #e4e4e7; font-size: 0.9rem; font-family: inherit;
}
.editor-input:focus { outline: none; border-color: #2563eb; }
.editor-btn {
    width: 36px; height: 36px; border: 1px solid #27272a; border-radius: 6px;
    background: #18181b; cursor: pointer; font-size: 1rem; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
}
.editor-btn.confirm { color: #16a34a; }
.editor-btn.confirm:hover { border-color: #16a34a; background: rgba(22,163,74,0.1); }
.editor-btn.cancel { color: #ef4444; }
.editor-btn.cancel:hover { border-color: #ef4444; background: rgba(239,68,68,0.1); }
.editor-original { font-size: 0.75rem; color: #52525b; margin-top: 6px; font-style: italic; }

/* ---- Review section ---- */
.review-section { margin-bottom: 24px; }
.review-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; flex-wrap: wrap; gap: 10px;
}
.panel-title {
    font-size: 0.95rem; font-weight: 600; color: #fafafa;
    display: flex; align-items: center; gap: 6px; margin: 0;
}
.review-header-actions { display: flex; gap: 8px; }
.review-accept-all {
    padding: 6px 14px; border: 1px solid #27272a; border-radius: 6px;
    background: transparent; color: #a1a1aa; font-size: 0.8rem; cursor: pointer;
}
.review-accept-all:hover { border-color: #16a34a; color: #16a34a; }
.review-submit {
    padding: 6px 20px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff; border: none; border-radius: 6px;
    font-size: 0.8rem; font-weight: 500; cursor: pointer;
}
.review-submit:hover { background: linear-gradient(135deg, #1d4ed8, #4338ca); }
.review-submit:disabled { background: #27272a; color: #52525b; cursor: not-allowed; }

/* Subtitle table */
.subtitle-table {
    background: #18181b; border: 1px solid #27272a; border-radius: 12px; overflow: hidden;
}
.table-header {
    display: grid; grid-template-columns: 70px 1fr 1fr 90px;
    padding: 8px 14px; background: #09090b; border-bottom: 1px solid #27272a;
    font-size: 0.7rem; color: #52525b; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.subtitle-list {
    max-height: 500px; overflow-y: auto;
}
.subtitle-entry {
    display: grid; grid-template-columns: 70px 1fr 1fr 90px;
    padding: 8px 14px; cursor: pointer;
    transition: background 0.1s; font-size: 0.85rem;
    border-bottom: 1px solid #1a1a1e;
    align-items: center;
}
.subtitle-entry:hover { background: #27272a; }
.subtitle-entry.active { background: rgba(37,99,235,0.12); }
.subtitle-entry.editing { background: rgba(37,99,235,0.2); border-left: 3px solid #2563eb; }
.col-time, .subtitle-entry .col-time { font-size: 0.75rem; color: #52525b; font-family: monospace; }
.col-text, .subtitle-entry .col-text { color: #a1a1aa; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.col-suggestion-text { color: #52525b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 10px; }
.col-suggestion-text.ai-pending { color: #60a5fa; }
.col-suggestion-text.modified { color: #86efac; }
.col-status { display: flex; justify-content: flex-end; }
.tag { font-size: 0.6rem; font-weight: 600; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }

/* ---- Download ---- */
.download-section, .error-section { display: flex; justify-content: center; }
.success-card {
    text-align: center; padding: 32px; max-width: 400px; width: 100%;
    background: rgba(22,163,74,0.08); border: 1px solid rgba(22,163,74,0.2); border-radius: 12px;
}
.success-icon { width: 40px; height: 40px; color: #16a34a; margin-bottom: 8px; }
.success-card > p { color: #a1a1aa; font-size: 0.85rem; margin-bottom: 8px; }
.privacy-note { font-size: 0.75rem; color: #52525b; margin-bottom: 16px !important; }
.download-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px; background: #16a34a; color: #fff;
    text-decoration: none; border-radius: 8px; font-size: 0.95rem; font-weight: 500;
}
.download-btn:hover { background: #15803d; }

/* Error */
.error-card {
    text-align: center; padding: 32px; max-width: 400px; width: 100%;
    background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); border-radius: 12px;
}
.error-icon { width: 40px; height: 40px; color: #ef4444; margin-bottom: 8px; }
.error-text { color: #fca5a5; font-size: 0.85rem; margin-bottom: 16px; word-break: break-word; }
.retry-btn {
    padding: 8px 24px; background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5; border-radius: 6px; cursor: pointer; font-size: 0.85rem;
}
.retry-btn:hover { background: rgba(239,68,68,0.25); }

/* ---- Footer ---- */
.app-footer { text-align: center; padding: 16px; }
.app-footer p { color: #3f3f46; font-size: 0.75rem; }

/* ---- Invite pages ---- */
.invite-welcome { text-align: center; margin-bottom: 24px; }
.invite-welcome p:first-child { font-size: 1rem; font-weight: 500; color: #e4e4e7; }
.invite-desc { font-size: 0.8rem; color: #71717a; margin-top: 4px; }
.invite-input {
    width: 100%; padding: 12px; background: #09090b; border: 1px solid #27272a;
    border-radius: 8px; color: #e4e4e7; font-size: 1.1rem;
    text-align: center; letter-spacing: 0.15em; font-family: monospace;
}
.invite-input:focus { outline: none; border-color: #2563eb; }
.invite-error { text-align: center; color: #ef4444; font-size: 0.85rem; margin-bottom: 12px; }
.invite-submit-btn {
    width: 100%; padding: 12px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff; border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 500; cursor: pointer;
}
.invite-submit-btn:hover { background: linear-gradient(135deg, #1d4ed8, #4338ca); }
.invite-footer { text-align: center; margin-top: 20px; }
.logout-link { color: #71717a; font-size: 0.8rem; text-decoration: none; }
.logout-link:hover { color: #a1a1aa; }
.invites-title { font-size: 1.2rem; font-weight: 600; color: #fafafa; margin-bottom: 4px; }
.invites-desc { font-size: 0.8rem; color: #71717a; margin-bottom: 20px; }
.invite-list { display: flex; flex-direction: column; gap: 10px; }
.invite-card { padding: 14px; background: #09090b; border: 1px solid #27272a; border-radius: 10px; }
.invite-card.used { opacity: 0.5; }
.invite-code-display { display: flex; align-items: center; justify-content: space-between; }
.invite-code-text { font-family: monospace; font-size: 1rem; font-weight: 600; color: #e4e4e7; letter-spacing: 0.1em; }
.copy-btn {
    padding: 4px 12px; background: #27272a; border: none; border-radius: 6px;
    color: #a1a1aa; font-size: 0.75rem; cursor: pointer;
}
.copy-btn:hover { background: #3f3f46; color: #e4e4e7; }
.copy-btn.copied { background: rgba(22,163,74,0.2); color: #16a34a; }
.invite-status { margin-top: 6px; font-size: 0.75rem; }
.status-available { color: #16a34a; }
.status-used { color: #71717a; }

/* Invite page card centering */
.invite-page-wrapper {
    max-width: 440px; margin: 60px auto; padding: 0 24px;
}
.invite-page-wrapper .card {
    background: #18181b; border: 1px solid #27272a; border-radius: 16px; padding: 32px;
}

.hidden { display: none !important; }

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
    .topbar-inner { padding: 0 16px; }
    .main { padding: 16px; }
    .upload-row { grid-template-columns: 1fr; }
    .table-header { grid-template-columns: 50px 1fr 80px; }
    .table-header .col-suggestion { display: none; }
    .subtitle-entry { grid-template-columns: 50px 1fr 80px; }
    .subtitle-entry .col-suggestion-text { display: none; }
    .subtitle-list { max-height: 400px; }
    .progress-stages { gap: 0; }
    .stage-line { width: 16px; }
    .stage span { font-size: 0.6rem; }
    .user-name { display: none; }
    .brand-name { display: none; }
    .review-header { flex-direction: column; align-items: flex-start; }
}
