/* ui.css — visual layer for the copywriter's generator (loaded after style.css and the inline styles).
   Same dark system as the site generator's panel (gen.weblovers.org): slate ground #0f172a, cards #1e293b
   with #334155 borders, blue primary, green for "done", amber for hints, red for errors, Inter.
   The article itself is rendered on a white sheet. The working flow is vertical — form → status → plan →
   status → result — and the status card is moved by JS to sit right under the button the operator pressed. */

:root {
    --bg: #0f172a; --card: #1e293b; --card-2: #172033; --line: #334155; --line-soft: #273449;
    --text: #e2e8f0; --text-2: #cbd5e1; --muted: #94a3b8; --muted-2: #64748b;
    --primary: #3b82f6; --primary-2: #2563eb; --primary-soft: rgba(59, 130, 246, .14);
    --ok: #22c55e; --ok-text: #4ade80; --ok-soft: #1a3a2a;
    --warn-text: #fbbf24; --warn-soft: #3a2f1a;
    --err: #ef4444; --err-text: #f87171; --err-soft: #3a1a1a;
    --radius: 8px;
}

html { background: var(--bg); }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.container, .history-container { max-width: 1040px; margin: 0 auto; padding: 24px 24px 60px; color: var(--text); }
a { color: #60a5fa; }
a:hover { color: #93bbfd; }

/* ---------- header ---------- */
header, .history-header { margin-bottom: 18px; padding: 0 0 14px; border: 0; border-bottom: 1px solid var(--line-soft); background: none; }
header h1, .history-header h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; color: #f1f5f9; line-height: 20px; background: none; -webkit-text-fill-color: initial; -webkit-background-clip: initial; background-clip: initial; margin: 0; }
header h1::after { content: 'COPYWRITER'; display: block; font-size: 10px; font-weight: 500; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted-2); margin-top: 2px; line-height: 12px; }
header a[href="/prompts"], header a[href="/history"], .history-header a, .btn-back { background: #475569 !important; color: #fff !important; border: 0; padding: 8px 14px !important; border-radius: 6px !important; font-weight: 500 !important; font-size: 13px; text-decoration: none; }
header a[href="/prompts"]:hover, header a[href="/history"]:hover, .history-header a:hover, .btn-back:hover { background: #64748b !important; }
.version-badge, .subtitle { color: var(--muted-2); }

/* ---------- cards ---------- */
.form-section, .plan-section, .result-section, .error-section, .pipeline-stages, .progress-section, .filters-section {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; padding: 20px; margin: 0 0 14px;
}
.progress-section { padding: 10px 14px; }
.progress-section:empty { display: none; }
.error-section { background: var(--err-soft); border-color: #7f1d1d; }
.error-section h2 { color: var(--err-text); font-size: 15px; margin: 0 0 8px; }
.error-message { color: #fecaca; font-size: 14px; }

/* ---------- form ---------- */
.form-group { margin-bottom: 16px; }
.form-group label, .brand-info-group > label, .filters-row label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea, .brand-info-group select, .brand-info-group textarea, .manual-source-item textarea, .new-section-input, .new-section-type, .filters-row input, .filters-row select {
    width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .brand-info-group select:focus, .brand-info-group textarea:focus, .new-section-input:focus, .filters-row input:focus, .filters-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select { appearance: auto; color-scheme: dark; }
.form-group input::placeholder, textarea::placeholder, .filters-row input::placeholder { color: var(--muted-2); }
.preset-description { background: var(--primary-soft); color: #93c5fd; border: 0; border-radius: 6px; padding: 9px 12px; font-size: 13px; }
.brand-info-group { margin: 4px 0 16px; }
.brand-info-hint { color: var(--muted-2); font-size: 12.5px; line-height: 1.5; margin-top: 6px; }
.brand-hint-error { color: var(--err-text); }
#brandPreview summary { color: var(--muted); }
#brandPreviewText { background: var(--bg) !important; color: var(--text-2) !important; border: 1px solid var(--line); }
.manual-sources-section { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.manual-sources-section h3, .manual-sources-section > div:first-child { font-size: 13px; font-weight: 600; color: var(--text-2); }
.manual-sources-section p, .manual-sources-section label { color: var(--muted); font-size: 12.5px; }

/* ---------- buttons ---------- */
.btn-primary, .button-group .btn-primary, .btn-search, .btn-open { background: var(--primary); color: #fff; border: 0; border-radius: 6px; padding: 10px 18px; font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; box-shadow: none; transition: background .2s; }
.btn-primary:hover:not(:disabled), .btn-search:hover, .btn-open:hover { background: var(--primary-2); transform: none; box-shadow: none; }
.btn-primary:disabled { background: #1d4ed8; color: #bfdbfe; cursor: default; opacity: .8; }
.btn-secondary, .btn-clear, .btn-restore { background: #475569; color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer; }
.btn-secondary:hover, .btn-clear:hover, .btn-restore:hover { background: #64748b; color: #fff; }
.btn-cancel, .btn-delete { background: var(--err-soft); color: var(--err-text); border: 1px solid #7f1d1d; border-radius: 6px; padding: 10px 16px; font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer; }
.btn-cancel:hover, .btn-delete:hover { background: #4c1d1d; }
.btn-approve { background: var(--ok); color: #fff; border: 0; border-radius: 6px; padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; box-shadow: none; }
.btn-approve:hover { background: #16a34a; transform: none; box-shadow: none; }
.btn-approve:disabled { background: #166534; color: #bbf7d0; cursor: default; }
.btn-add-source, .btn-add-section { background: #2a2a3e; color: #ccc; border: 0; border-radius: 6px; padding: 6px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer; }
.btn-add-source:hover, .btn-add-section:hover { background: #3b3b55; color: #fff; }
.button-group { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.btn-loading { display: inline-flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.link-btn { background: none; border: 0; color: #60a5fa; font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: #93bbfd; }

/* ---------- status card (moved under the active button by JS) ---------- */
.pipeline-stages { display: none; flex-direction: column; gap: 12px; padding: 16px 20px; border-left: 3px solid var(--primary); }
.pipeline-stages.is-done { border-left-color: var(--ok); }
.pipeline-stages.is-error { border-left-color: var(--err); }
.status-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.status-title { font-size: 15px; font-weight: 600; color: #f1f5f9; }
.status-total { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stepper { display: flex; gap: 6px; margin: 0; }
.step { flex: 1; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; background: var(--card-2); color: var(--muted-2); font-size: 12.5px; font-weight: 500; border: 1px solid var(--line-soft); }
.step-dot { width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: #cbd5e1; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step.active { background: var(--primary-soft); color: #bfdbfe; border-color: #1d4ed8; }
.step.active .step-dot { background: var(--primary); color: #fff; }
.step.done { background: var(--ok-soft); color: var(--ok-text); border-color: #14532d; }
.step.done .step-dot { background: var(--ok); color: #fff; font-size: 0; }
.step.done .step-dot::before { content: '✓'; font-size: 11px; }
.progress-track { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #60a5fa); border-radius: 3px; transition: width .6s ease; }
.pipeline-stages.is-done .progress-fill { background: var(--ok); }
.pipeline-stages.is-error .progress-fill { background: var(--err); }
.progress-status { margin: 0; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; min-height: 20px; }
.pipeline-stages.is-error .progress-status { color: var(--err-text); }
.progress-hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.progress-hint:empty { display: none; }

/* debug log (visible only with ?debug=1) */
.progress-log, .log-item, .analysis-content, .thinking-content, .tool-input, .usage-stats, .report-container, .search-result-block, .parsed-page-block, .agent-decisions, .decision-block { background: var(--bg); color: var(--text-2); border-color: var(--line); }
.progress-details summary { color: var(--muted-2); font-size: 12.5px; }
.log-live { opacity: .8; font-style: italic; }

/* ---------- plan ---------- */
.plan-section { display: none; }
.plan-header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; border: 0; padding: 0; margin-bottom: 16px; }
.plan-header h2 { font-size: 16px; font-weight: 600; color: #f1f5f9; margin: 0; }
#planNote { background: var(--warn-soft); color: var(--warn-text); border: 1px solid #78350f; border-radius: 12px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.plan-hint { background: var(--warn-soft); color: #fde68a; border: 1px solid #78350f; }
.plan-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; background: none; border: 0; padding: 0; }
.plan-stat { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; text-align: left; }
.plan-stat-value { font-size: 22px; font-weight: 600; color: #f1f5f9; font-variant-numeric: tabular-nums; }
.plan-stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plan-section .entities-section > h3, .plan-section .structure-section > h3 { background: none !important; color: var(--muted) !important; padding: 0 0 6px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-radius: 0 !important; font-size: 12px !important; font-weight: 600 !important; letter-spacing: .06em; text-transform: uppercase; margin: 22px 0 12px !important; text-shadow: none; }
.entity-tier, .tier-must, .tier-should, .tier-nice { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 12px 14px; margin-bottom: 8px; }
.tier-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; border: 0; }
.tier-badge, .tier-must .tier-badge, .tier-should .tier-badge, .tier-nice .tier-badge { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 0; }
.tier-must .tier-badge { background: var(--err-soft); color: var(--err-text); }
.tier-should .tier-badge { background: var(--warn-soft); color: var(--warn-text); }
.tier-nice .tier-badge { background: var(--primary-soft); color: #93c5fd; }
.tier-description, .tier-desc { color: var(--muted-2); font-size: 12.5px; }
.entity-list { display: flex; flex-wrap: wrap; gap: 6px; }
.entity-tag, .tier-must .entity-tag, .tier-should .entity-tag, .tier-nice .entity-tag { background: var(--bg); color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 8px; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.entity-tag:hover { border-color: var(--primary); background: var(--primary-soft); }
input[type="checkbox"] { accent-color: var(--primary); }
.structure-item { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; color: var(--text); display: flex; align-items: center; gap: 10px; }
.structure-item.disabled { opacity: .45; }
.structure-item.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.structure-item.dragging { opacity: .5; }
.drag-handle { color: var(--muted-2); }
.plan-section .structure-type { font-size: 11px !important; font-weight: 600 !important; color: var(--muted) !important; background: var(--line) !important; border-radius: 4px; padding: 2px 6px; text-transform: uppercase; }
.plan-section .structure-item.custom .structure-type { background: var(--primary-soft) !important; color: #93c5fd !important; }
.structure-item.custom { border-color: #1d4ed8; }
.structure-title { color: var(--text); }
.btn-remove-section, .btn-remove-source { background: none; border: 0; color: var(--muted-2); cursor: pointer; }
.btn-remove-section:hover, .btn-remove-source:hover { color: var(--err-text); }
.add-section-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; background: none; border: 1px dashed var(--line); border-radius: 6px; padding: 10px; }
.new-section-type { width: auto; }
.plan-actions { display: flex; gap: 10px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.plan-summary { display: none; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--ok-soft); border: 1px solid #14532d; border-radius: var(--radius); padding: 11px 16px; margin-bottom: 14px; color: var(--ok-text); font-size: 13.5px; }
.plan-summary b { font-weight: 600; color: #bbf7d0; }

/* ---------- result: dark frame, white sheet for the article ---------- */
.result-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; border: 0; padding: 0; }
.result-header h2 { font-size: 16px; font-weight: 600; color: #f1f5f9; margin: 0; }
.result-actions { display: flex; gap: 8px; }
.entity-coverage { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 6px; padding: 12px 14px; margin-bottom: 14px; }
.entity-coverage h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .06em; }
.data-gaps-report { background: var(--warn-soft); border: 1px solid #78350f; color: #fde68a; }
.seo-block, .word-stats-section, .seo-metadata-section { background: var(--card-2); border: 1px solid var(--line-soft); color: var(--text-2); border-radius: 6px; }
.seo-block-header h3, .seo-field-header label, .seo-label { color: var(--muted); }
.seo-value, .seo-field textarea, .seo-field input { color: var(--text); background: var(--bg); border-color: var(--line); }
.stat-box { background: var(--bg); border: 1px solid var(--line); color: var(--text-2); }
.stat-box .stat-value, .word-count-big { color: #f1f5f9; }

.article-preview { background: #ffffff; color: #111827; border-radius: 6px; padding: 32px 40px; margin-top: 4px; font-size: 15.5px; line-height: 1.7; max-width: none; }
.article-preview > * { max-width: 780px; }
.article-preview h1 { font-size: 27px; font-weight: 700; color: #111827; margin: 0 0 16px; line-height: 1.25; background: none; -webkit-text-fill-color: initial; }
.article-preview h2 { font-size: 20px; font-weight: 600; color: #111827; margin: 30px 0 10px; border: 0; padding: 0; }
.article-preview h3 { font-size: 16.5px; font-weight: 600; color: #1f2937; margin: 22px 0 8px; }
.article-preview p, .article-preview li { color: #1f2937; }
.article-preview p { margin: 0 0 12px; }
.article-preview strong { color: #111827; }
.article-preview blockquote { border-left: 3px solid #d1d5db; color: #4b5563; background: none; padding: 4px 14px; margin: 12px 0; }
.article-preview table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 12px 0 18px; }
.article-preview th, .article-preview td { border: 1px solid #e5e7eb; padding: 8px 10px; text-align: left; color: #1f2937; background: #fff; }
.article-preview th { background: #f3f4f6; font-weight: 600; color: #111827; }
.article-preview tr:hover td { background: #fafafa; }
.article-preview a { color: #1d4ed8; }
.article-preview code { background: #f3f4f6; color: #111827; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.article-preview hr { border: 0; border-top: 1px solid #e5e7eb; margin: 20px 0; }
.copy-all-btn { background: var(--primary); color: #fff; border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 500; box-shadow: 0 6px 16px rgba(0, 0, 0, .4); }
.copy-all-btn:hover { background: var(--primary-2); }

/* ---------- history page ---------- */
.filters-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters-row > * { flex: 1 1 160px; }
.filters-row button { flex: 0 0 auto; }
.article-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.article-card:hover { border-color: #475569; background: #223047; }
.article-card.deleted { opacity: .5; }
.article-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.article-card h3, .article-card .article-title, .article-card-header h3 { font-size: 15px; font-weight: 600; color: #f1f5f9; margin: 0; }
.article-card .article-meta, .article-card small, .article-meta { color: var(--muted); font-size: 12.5px; }
.article-card .badge, .status-badge, .preset-badge, .country-badge, .model-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; background: #475569; color: #fff; }
.status-completed, .badge-completed { background: var(--ok-soft); color: var(--ok-text); }
.status-failed, .badge-failed, .status-error { background: var(--err-soft); color: var(--err-text); }
.status-in_progress, .badge-in_progress { background: var(--warn-soft); color: var(--warn-text); }
.article-card .article-actions, .article-actions { display: flex; gap: 8px; }
.pagination button, .btn-page { background: #475569; color: #fff; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.pagination button:disabled { opacity: .4; }
.empty-state, .no-articles { color: var(--muted-2); text-align: center; padding: 40px; }

footer { color: var(--muted-2); }
::selection { background: rgba(59, 130, 246, .35); }
@media (max-width: 720px) {
    .container, .history-container { padding: 16px 12px 40px; }
    .plan-stats { grid-template-columns: repeat(2, 1fr); }
    .stepper { flex-wrap: wrap; }
    .step { flex: 1 1 45%; }
    .article-preview { padding: 20px 18px; }
}

/* history page specifics */
.back-link { display: inline-block; color: var(--muted); font-size: 13px; margin-bottom: 6px; background: none !important; padding: 0 !important; border: 0; }
.back-link:hover { color: var(--text); background: none !important; }
.history-header { display: flex; justify-content: space-between; align-items: flex-end; }
.filter-group { flex: 1 1 150px; }
.filter-group label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; text-transform: none; }
.filter-group select, .filter-group input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13.5px; font-family: inherit; }
.btn-search, .btn-clear { padding: 9px 16px; font-size: 13.5px; }
.stats-summary { display: flex; gap: 10px; flex-wrap: wrap; background: none; border: 0; padding: 0; margin: 0 0 14px; }
.stats-summary .stat-item { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; flex: 1 1 140px; }
.stats-summary .stat-label { color: var(--muted); font-size: 12px; }
.stats-summary .stat-value { color: #f1f5f9; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-summary .stat-value.cost { color: var(--warn-text); }
.stats-summary .stat-detail { color: var(--muted-2); font-size: 12px; }
.stats-total-label { color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--line-soft); padding-bottom: 8px; }
.tab-btn { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 13.5px; }
.tab-btn:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.tab-btn.active { background: rgba(163, 230, 53, .08); color: #a3e635; }
.tab-btn .tab-count { background: var(--line); color: var(--text-2); border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 6px; }
.tab-btn.active .tab-count { background: rgba(163, 230, 53, .18); color: #a3e635; }
.results-header { display: flex; justify-content: space-between; align-items: center; margin: 0 0 10px; }
.results-count { color: var(--muted); font-size: 13px; }
.articles-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.article-keyword { font-size: 15px; font-weight: 600; color: #f1f5f9; }
.article-status { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.article-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.article-meta span { color: var(--muted); }
.version-tag, .version-tag.v2, .version-tag.v3 { background: var(--line); color: var(--text-2); border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 600; }
.article-stages { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.stage-badge { background: var(--bg); color: var(--muted-2); border: 1px solid var(--line-soft); border-radius: 4px; padding: 2px 7px; font-size: 11px; }
.stage-badge.active { background: var(--ok-soft); color: var(--ok-text); border-color: #14532d; }
.article-date, .deleted-date { color: var(--muted-2); font-size: 12px; }
.article-actions { margin-top: 12px; }
.btn-open, .btn-delete, .btn-restore { padding: 7px 12px; font-size: 13px; }
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button { background: var(--card); color: var(--text-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-family: inherit; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: default; }
.empty-state { background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted-2); }
.empty-state h3 { color: var(--muted); font-size: 15px; }
.loading-overlay { background: rgba(15, 23, 42, .7); }
.loading-overlay .spinner { width: 28px; height: 28px; border-width: 3px; border-color: rgba(255,255,255,.2); border-top-color: var(--primary); }

/* login page */
.login-container, .login-box, .login-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.login-box h1, .login-card h1, .login-container h1 { color: #f1f5f9; background: none; -webkit-text-fill-color: initial; }
.login-box input, .login-card input, .login-container input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.login-box button, .login-card button, .login-container button { background: var(--primary); color: #fff; border: 0; border-radius: 6px; }

/* report blocks the JS injects INSIDE the white article sheet — light variants */
.article-preview .seo-block { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; color: #111827; padding: 14px 16px; margin: 0 0 14px; box-shadow: none; }
.article-preview .seo-block-header h3, .article-preview .seo-block h3 { color: #111827; font-size: 14px; margin: 0 0 10px; }
.article-preview .seo-field { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; color: #111827; padding: 10px 12px; margin-bottom: 8px; }
.article-preview .seo-field-header label, .article-preview .seo-label, .article-preview .seo-char-count, .article-preview .seo-length { color: #6b7280; }
.article-preview .seo-value, .article-preview .seo-field textarea, .article-preview .seo-field input { color: #111827; background: #fff; border-color: #d1d5db; }
.article-preview .btn-seo-edit { background: #f3f4f6; color: #1f2937; border: 1px solid #d1d5db; }
.article-preview .article-summary { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; color: #1f2937; padding: 10px 12px; margin: 0 0 14px; }
.article-preview .article-summary span, .article-preview .article-summary div { background: #fff; color: #1f2937; border: 1px solid #e5e7eb; }
.article-preview .data-gaps-report { background: #fffbeb; border: 1px solid #fde68a; border-left-width: 4px; color: #78350f; border-radius: 6px; padding: 12px 16px; margin: 0 0 14px; font-size: 13px; }
.article-preview .data-gaps-report *, .article-preview .data-gaps-report strong { color: #78350f; }
.article-preview .data-gaps-report del, .article-preview .data-gaps-report s { color: #b45309; }
.article-preview .data-gaps-report li { color: #78350f; }

/* history: back link is a plain link, action buttons keep their natural width */
.history-header a.back-link { background: none !important; padding: 0 !important; color: var(--muted) !important; font-weight: 500 !important; }
.history-header a.back-link:hover { color: var(--text) !important; }
.article-actions { display: flex; gap: 8px; }
.article-actions .btn-open, .article-actions .btn-delete, .article-actions .btn-restore { flex: 0 0 auto; width: auto; }

/* ---------- copywriter editor ---------- */
.result-title { display: flex; align-items: center; gap: 10px; }
.version-badge { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text-2); letter-spacing: .02em; }
.version-badge.is-edited { background: var(--ok-soft); color: var(--ok-text); border: 1px solid #14532d; }
.result-actions { display: flex; gap: 8px; align-items: center; position: relative; }
.export-menu { position: relative; }
.export-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.45); z-index: 20; padding: 6px 0; }
.export-dropdown.open { display: block; }
.export-dropdown a { display: block; padding: 8px 14px; color: var(--text-2); font-size: 13px; text-decoration: none; }
.export-dropdown a:hover { background: rgba(255,255,255,.05); color: var(--text); }
.draft-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--warn-soft); border: 1px solid #78350f; color: #fde68a; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.draft-banner .link-btn { color: #fde68a; } .draft-banner .link-btn.muted { color: var(--muted); }
.editor-panel { margin-bottom: 14px; }
.editor-meta { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 12px; }
.editor-field label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.editor-field .count { color: var(--muted-2); font-variant-numeric: tabular-nums; } .editor-field .count.over { color: var(--err-text); }
.editor-field input, .editor-field textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font-size: 14px; font-family: inherit; resize: vertical; }
.editor-field input:focus, .editor-field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.editor-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.autosave-status { color: var(--muted-2); font-size: 12.5px; margin-left: auto; }
#tuiEditor { border-radius: 6px; overflow: hidden; }
.toastui-editor-dark .toastui-editor-defaultUI { border-color: var(--line); }
.toastui-editor-dark .toastui-editor-defaultUI-toolbar { background: var(--card-2); border-bottom-color: var(--line); }
.toastui-editor-dark .toastui-editor-md-container, .toastui-editor-dark .toastui-editor-ww-container { background: #fff; }
.toastui-editor-dark .toastui-editor-ww-container .toastui-editor-contents, .toastui-editor-dark .toastui-editor-md-preview .toastui-editor-contents { color: #111827; }
.toastui-editor-contents { font-family: 'Inter', sans-serif; font-size: 15px; line-height: 1.65; }
.toastui-editor-contents h1 { font-size: 26px; } .toastui-editor-contents h2 { font-size: 20px; } .toastui-editor-contents h3 { font-size: 16px; }
.toastui-editor-contents table th { background: #f3f4f6; }
.toastui-editor-dark .toastui-editor-mode-switch { background: var(--card-2); border-top-color: var(--line); }
.diff-panel { background: #fff; color: #111827; border-radius: 6px; padding: 20px 26px; margin-bottom: 14px; }
.diff-head { font-size: 13px; color: #4b5563; margin-bottom: 10px; }
.diff-meta { font-size: 13.5px; margin-bottom: 12px; padding: 10px 12px; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 6px; }
.diff-body { white-space: pre-wrap; word-wrap: break-word; font-family: 'Inter', sans-serif; font-size: 14.5px; line-height: 1.65; margin: 0; }
.diff-panel ins { background: #dcfce7; color: #14532d; text-decoration: none; border-radius: 2px; }
.diff-panel del { background: #fee2e2; color: #7f1d1d; text-decoration: line-through; border-radius: 2px; }
.toast-msg { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: #166534; color: #bbf7d0; padding: 12px 18px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 1000; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast-msg.show { opacity: 1; transform: translate(-50%, 0); }
.edited-tag { display: inline-block; margin-right: 8px; padding: 3px 9px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--ok-soft); color: var(--ok-text); border: 1px solid #14532d; }
/* editor: dark chrome, white sheet — the dark theme paints text light, force it dark inside the sheet */
.toastui-editor-dark .toastui-editor-contents, .toastui-editor-dark .toastui-editor-contents :is(p, h1, h2, h3, h4, h5, h6, li, td, th, blockquote, span, strong, em, b, i, a, code, div) { color: #111827 !important; }
.toastui-editor-dark .toastui-editor-contents a { color: #1d4ed8 !important; }
.toastui-editor-dark .toastui-editor-contents th { background: #f3f4f6 !important; }
.toastui-editor-dark .toastui-editor-contents td, .toastui-editor-dark .toastui-editor-contents th { border-color: #d1d5db !important; }
.toastui-editor-dark .toastui-editor-contents h1, .toastui-editor-dark .toastui-editor-contents h2 { border-bottom-color: #e5e7eb !important; }
.toastui-editor-dark .toastui-editor-ww-container, .toastui-editor-dark .toastui-editor-md-container, .toastui-editor-dark .toastui-editor-md-preview, .toastui-editor-dark .ProseMirror { background: #fff !important; }
.toastui-editor-dark .toastui-editor-md-container .toastui-editor-md-code-block-line-background, .toastui-editor-dark .toastui-editor-md-container .CodeMirror { background: #fff !important; color: #111827 !important; }
.toastui-editor-dark .toastui-editor-md-container .toastui-editor-md-heading, .toastui-editor-dark .toastui-editor-md-container .toastui-editor-md-delimiter, .toastui-editor-dark .toastui-editor-md-container .toastui-editor-md-table, .toastui-editor-dark .toastui-editor-md-container .toastui-editor-md-list-item { color: #111827 !important; }
.toastui-editor-dark .toastui-editor-contents table { border-color: #d1d5db; }
.toastui-editor-dark .toastui-editor-md-container .ProseMirror, .toastui-editor-dark .toastui-editor-md-container .ProseMirror * { color: #111827 !important; }
.toastui-editor-dark .toastui-editor-md-container .ProseMirror { font-family: 'Inter', sans-serif; font-size: 14px; line-height: 1.6; }
.toastui-editor-dark .toastui-editor-md-tab-container { background: var(--card-2) !important; }

/* editor polish */
.result-actions > button, .result-actions .export-menu > button { white-space: nowrap; }
.editing-hint { font-size: 12px; color: var(--muted-2); margin-left: 6px; }
.editor-meta { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 14px 16px 6px; margin-bottom: 14px; display: block; }
.editor-meta-head { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.editor-meta .editor-field { margin-bottom: 12px; }
.editor-field label em { font-style: normal; color: var(--muted-2); font-weight: 400; margin-left: 6px; }
.editor-sheet-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px 2px; }
.toastui-editor-defaultUI .toastui-editor-ww-container, .toastui-editor-defaultUI .toastui-editor-md-container { min-height: 560px; }
.editor-actions { position: sticky; bottom: 0; z-index: 5; background: var(--card); border-top: 1px solid var(--line); margin: 0 -20px -20px; padding: 12px 20px; border-radius: 0 0 var(--radius) var(--radius); }
.editor-words { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-left: 6px; }
.stage-reports { background: var(--card-2); border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: 14px; }
.stage-reports summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.stage-reports summary::-webkit-details-marker { display: none; }
.stage-reports summary::before { content: '▸'; color: var(--muted-2); font-size: 12px; transition: transform .15s; }
.stage-reports[open] summary::before { transform: rotate(90deg); }
.stage-reports-sub { font-weight: 400; color: var(--muted-2); font-size: 12.5px; }
.stage-reports > div { padding: 4px 14px 14px; }
.stage-reports .article-summary { background: none; border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.stage-reports .article-summary span { background: var(--bg); border: 1px solid var(--line); color: var(--text-2); border-radius: 6px; padding: 5px 10px; font-size: 12.5px; }
.stage-reports .data-gaps-report { margin: 0 0 8px; font-size: 12.5px; }
.stage-reports .data-gaps-report ul { margin: 6px 0 0; padding-left: 18px; }
.result-section, .editor-panel { overflow: visible; }
/* editing: toolbar sticks to the top of the viewport, the save bar to the bottom */
#tuiEditor { overflow: visible; }
.toastui-editor-defaultUI { overflow: visible !important; }
.toastui-editor-defaultUI .toastui-editor-defaultUI-toolbar, .toastui-editor-defaultUI .toastui-editor-toolbar { position: sticky; top: 0; z-index: 40; border-radius: 6px 6px 0 0; }
.toastui-editor-dark .toastui-editor-defaultUI-toolbar { background: #172033; box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.editor-actions { z-index: 60; }
