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

:root {
    --bg: #0f0f10;
    --bg2: #17171a;
    --border: #2a2a2f;
    --accent: #ff4444;
    --accent2: #e03030;
    --text: #e8e8ec;
    --muted: #888;
    --green: #6dbf6d;
    --sidebar-w: 280px;
}

body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; height: 100vh; overflow: hidden; }

.layout { display: flex; height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden;
}

.sidebar-header { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.logo { color: var(--text); text-decoration: none; font-size: 16px; font-weight: 700; }
.logo:hover { color: var(--accent); }
.settings-btn { color: var(--muted); text-decoration: none; font-size: 18px; line-height: 1; padding: 4px; border-radius: 6px; transition: color .2s, background .2s; }
.settings-btn:hover, .settings-btn.active { color: var(--text); background: rgba(255,255,255,.07); }

/* Settings rows */
.sidebar-setting { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.setting-row { display: flex; gap: 6px; }
.mono-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    outline: none;
    transition: border-color .2s, color .2s;
    min-width: 0;
}
.mono-input:focus { border-color: #555; color: var(--text); }
.mono-input::placeholder { color: #3a3a40; }
.mono-input.has-value { color: var(--green); border-color: #3a5c3a; }
.icon-btn {
    background: none; border: 1px solid var(--border); color: var(--muted);
    padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px;
    flex-shrink: 0; transition: border-color .2s, color .2s;
}
.icon-btn:hover { border-color: var(--green); color: var(--green); }
.setting-status { font-size: 11px; color: var(--muted); min-height: 14px; margin-top: 3px; }
.setting-status.ok { color: var(--green); }
.setting-status.err { color: #ff6b6b; }

/* URL input */
.sidebar-input { padding: 12px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-input input {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 8px 10px; border-radius: 6px; font-size: 13px; outline: none; transition: border-color .2s;
}
.sidebar-input input:focus { border-color: var(--accent); }
.sidebar-input input::placeholder { color: var(--muted); }
#parseBtn {
    background: var(--accent); color: #fff; border: none;
    padding: 9px; border-radius: 6px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background .2s;
}
#parseBtn:hover { background: var(--accent2); }
#parseBtn:disabled { background: #555; cursor: not-allowed; }
#parseStatus { font-size: 12px; color: var(--muted); min-height: 16px; }
#parseStatus.error { color: #ff6b6b; }
#parseStatus.success { color: var(--green); }

/* History */
.sidebar-history { flex: 1; overflow-y: auto; padding: 10px 0; }
.history-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; padding: 4px 16px 8px; }
.history-list { list-style: none; }
.history-item {
    position: relative; display: flex; align-items: center;
    border-radius: 6px; margin: 1px 6px; transition: background .15s;
}
.history-item:hover { background: rgba(255,255,255,.04); }
.history-item.active { background: rgba(255,68,68,.12); }
.history-item a {
    flex: 1; text-decoration: none; color: var(--text);
    padding: 8px 32px 8px 10px; overflow: hidden;
    display: flex; flex-direction: column; gap: 2px;
}
.history-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { font-size: 11px; color: var(--muted); }
.history-item.active .history-title { color: var(--accent); }
.delete-btn {
    position: absolute; right: 8px;
    background: none; border: none; color: var(--muted);
    cursor: pointer; font-size: 16px; opacity: 0; transition: opacity .15s; padding: 2px 4px;
}
.history-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: #ff6b6b; }

/* ── Main ────────────────────────────────────────────────────────────── */
.main-content { flex: 1; overflow-y: auto; padding: 36px 48px; }

/* Welcome */
.welcome { max-width: 560px; margin: 80px auto 0; text-align: center; }
.welcome-icon { font-size: 56px; margin-bottom: 20px; }
.welcome h1 { font-size: 28px; font-weight: 700; margin-bottom: 12px; }
.welcome p { color: var(--muted); line-height: 1.7; font-size: 15px; }
.welcome-steps { display: flex; gap: 20px; justify-content: center; margin-top: 36px; }
.step { background: var(--bg2); border: 1px solid var(--border); padding: 16px 20px; border-radius: 10px; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 110px; }
.step span { background: var(--accent); color: #fff; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* Video page */
.video-page { max-width: 860px; }
.video-meta { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.yt-link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
.yt-link:hover { text-decoration: underline; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.back-link:hover { color: var(--text); }
.video-lang, .video-date { font-size: 12px; color: var(--muted); }

.video-title-row { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.video-title { font-size: 22px; font-weight: 700; line-height: 1.35; flex: 1; min-width: 200px; }
.video-actions { display: flex; gap: 10px; flex-shrink: 0; align-items: flex-start; flex-wrap: wrap; }

.btn-rewrite {
    background: linear-gradient(135deg, #6b3fa0, #9b4fd0);
    color: #fff; border: none; padding: 9px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: opacity .2s, transform .1s; white-space: nowrap; text-decoration: none;
    display: inline-block;
}
.btn-rewrite:hover { opacity: .9; transform: translateY(-1px); }
.btn-rewrite:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-rewrite-view { background: linear-gradient(135deg, #2a6040, #3a8060); }

/* Transcript block */
.transcript-block { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.transcript-toolbar { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.toolbar-label { font-size: 13px; color: #a07fd0; font-weight: 600; }
.copy-btn {
    background: none; border: 1px solid var(--border); color: var(--text);
    padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
    transition: border-color .2s, color .2s; margin-left: auto;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.transcript-text { padding: 20px; line-height: 1.85; font-size: 15px; color: #d4d4dc; white-space: pre-wrap; word-break: break-word; }
.rewrite-text { color: #e0e0ea; line-height: 1.9; }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.7);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    backdrop-filter: blur(4px);
}
.modal-box {
    background: #1e1e24; border: 1px solid #3a3a45; border-radius: 14px;
    padding: 32px 28px; width: 420px; max-width: 92vw;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.modal-desc { font-size: 13px; color: var(--muted); margin-bottom: 18px; line-height: 1.6; }
.modal-input {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); padding: 11px 14px; border-radius: 8px;
    font-size: 13px; font-family: monospace; outline: none;
    transition: border-color .2s; margin-bottom: 10px;
}
.modal-input:focus { border-color: #6b3fa0; }
.modal-input::placeholder { color: #3a3a45; }
.modal-error { font-size: 12px; color: #ff6b6b; min-height: 18px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.btn-modal-cancel {
    background: none; border: 1px solid var(--border); color: var(--muted);
    padding: 9px 20px; border-radius: 8px; cursor: pointer; font-size: 13px;
    transition: border-color .2s;
}
.btn-modal-cancel:hover { border-color: var(--text); color: var(--text); }
.btn-modal-start {
    background: linear-gradient(135deg, #6b3fa0, #9b4fd0);
    color: #fff; border: none; padding: 9px 22px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity .2s;
}
.btn-modal-start:hover { opacity: .9; }

/* Rewrite overlay */
.rewrite-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.75);
    display: flex; align-items: center; justify-content: center; z-index: 999;
    backdrop-filter: blur(4px);
}
.rewrite-overlay.hidden { display: none; }
.rewrite-spinner { text-align: center; }
.spinner-big {
    width: 52px; height: 52px; border: 4px solid #333; border-top-color: #9b4fd0;
    border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 20px;
}
.rewrite-label { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.rewrite-sub { font-size: 13px; color: var(--muted); }

.empty-state { padding: 40px; text-align: center; color: var(--muted); font-size: 15px; }

/* Spinner inline */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Publish button ──────────────────────────────────────────────────────── */
.btn-publish {
    background: linear-gradient(135deg, #1a6b40, #2a9d5c);
    color: #fff; border: none; padding: 9px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: opacity .2s, transform .1s; white-space: nowrap;
}
.btn-publish:hover { opacity: .9; transform: translateY(-1px); }
.btn-publish-action { background: linear-gradient(135deg, #1a6b40, #2a9d5c); }

/* Publication history */
.pub-history { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.pub-item {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 14px; font-size: 13px;
}
.pub-item.pub-status-future { border-color: #4a7a40; }
.pub-icon { font-size: 15px; }
.pub-site { font-weight: 600; }
.pub-cat { background: rgba(255,255,255,.06); padding: 2px 8px; border-radius: 10px; font-size: 12px; color: var(--muted); }
.pub-time { color: var(--muted); font-size: 12px; margin-left: auto; }
.pub-link { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
.pub-link:hover { text-decoration: underline; }

/* Modal select */
.modal-select {
    width: 100%; background: var(--bg); border: 1px solid var(--border);
    color: var(--text); padding: 10px 12px; border-radius: 8px;
    font-size: 13px; outline: none; cursor: pointer;
    transition: border-color .2s;
}
.modal-select:focus { border-color: #2a9d5c; }
.modal-select:disabled { opacity: .5; cursor: not-allowed; }
.modal-select option { background: #1e1e24; }

/* Radio group */
.radio-group { display: flex; gap: 20px; margin-top: 6px; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--text); }
.radio-label input { accent-color: #2a9d5c; }

/* Wide modal */
.modal-box-wide { width: 520px; }

/* Form grid in modal */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.form-field-full { grid-column: 1 / -1; }
.field-hint { font-size: 11px; color: #555; margin-top: 3px; line-height: 1.5; }
.field-hint-inline { font-size: 11px; color: #555; font-weight: 400; text-transform: none; letter-spacing: 0; }
.wide-input { width: 100%; }

/* ── Settings page ───────────────────────────────────────────────────────── */
.settings-page { max-width: 860px; }
.settings-header { margin-bottom: 24px; }
.settings-header h1 { font-size: 24px; font-weight: 700; }

.settings-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 12px; margin-bottom: 20px; overflow: hidden;
}
.settings-card-title {
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: space-between;
}
.settings-card-body { padding: 20px; }
.settings-field { margin-bottom: 16px; }
.settings-field:last-child { margin-bottom: 0; }
.settings-field label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; font-weight: 500; }

.btn-add-integration {
    background: none; border: 1px solid var(--accent); color: var(--accent);
    padding: 5px 14px; border-radius: 6px; font-size: 12px; cursor: pointer;
    font-weight: 600; transition: background .2s, color .2s;
}
.btn-add-integration:hover { background: var(--accent); color: #fff; }

/* Integrations list */
.integrations-list { display: flex; flex-direction: column; gap: 10px; }
.integration-row {
    background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
}
.intg-info { flex: 1; min-width: 200px; }
.intg-name { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.intg-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; flex-shrink: 0; }
.intg-status-dot.enabled { background: var(--green); }
.intg-url { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.intg-meta { font-size: 11px; color: #555; }
.intg-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.intg-actions button {
    background: none; border: 1px solid var(--border); color: var(--muted);
    padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
    transition: border-color .2s, color .2s;
}
.intg-actions button:hover { border-color: var(--text); color: var(--text); }
.btn-del-intg:hover { border-color: #ff6b6b !important; color: #ff6b6b !important; }
.intg-test-result {
    width: 100%; font-size: 12px; padding-top: 6px; display: none;
}
.intg-test-result:not(:empty) { display: block; }
.intg-test-result.ok { color: var(--green); }
.intg-test-result.err { color: #ff6b6b; }

.empty-integrations { padding: 20px 0; }
.empty-hint { color: var(--muted); font-size: 14px; }

/* Quick add sites */
.quick-sites { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-quick-add {
    background: none; border: 1px solid var(--border); color: var(--muted);
    padding: 6px 14px; border-radius: 20px; font-size: 12px; cursor: pointer;
    font-family: monospace; transition: border-color .2s, color .2s;
}
.btn-quick-add:hover { border-color: var(--accent); color: var(--text); }

.settings-card-hints { border-color: #2a2a3a; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 700px) {
    .layout { flex-direction: column; overflow: hidden; }
    .sidebar { width: 100%; min-width: 0; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .sidebar-history { max-height: 180px; }
    .main-content { padding: 20px 16px; }
    .welcome { margin-top: 20px; }
    .welcome-steps { flex-direction: column; align-items: center; }
    .video-title-row { flex-direction: column; }
}
