/* =========================================================
   AI Detector - Main App Styles
   v8.9 | ai-detector.bg

   FIX LOG (color audit):
   #1  .btn-preview #805ad5 → var(--primary-dark)
   #2  .seo-contact-cta a #2039b1 → var(--primary-dark)
   #3  .doc-icon.purple color #805ad5 → var(--primary-dark)
   #4  .stat-label color #888 → var(--text-muted)
   #5  .keyword-table hover #f0f7ff → var(--kw-hover)
   #6  .keyword-table selected #e0edff → var(--kw-selected)
   #7  .issue-item:hover #e0edff → var(--kw-selected)
   #8  .container subtle glass border added
   #9  .stat-card hover state added
   #10 toast default navy unified to #1e40af
   #11 heading tree badges → use CSS variables
   #12 CodeMirror line highlights → use CSS variables
   #13 btn-success / diff colors / status.success → use CSS variables
   +   semantic bar fill gets score-level color class
   ========================================================= */

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

/* ── Design Tokens ──────────────────────────────────────── */
:root {
    /* Brand */
    --primary:           #667eea;
    --primary-dark:      #764ba2;

    /* Semantic */
    --success:           #48bb78;
    --success-dark:      #276749;   /* was hardcoded #276749 in 4+ places */
    --success-deep:      #166534;   /* was hardcoded #166534 in diff/bars  */
    --danger:            #fc8181;
    --danger-dark:       #c53030;   /* was hardcoded in AI highlights       */
    --warning:           #ed8936;
    --info:              #4299e1;

    /* Text */
    --text:              #2d3748;
    --text-light:        #4a5568;
    --text-muted:        #718096;   /* FIX #4: replaces orphaned #888       */

    /* Surfaces */
    --bg:                #f7fafc;
    --bg-rgb:            247, 250, 252;
    --surface:           #ffffff;   /* FIX #3 new variable                  */
    --border:            #e2e8f0;

    /* Code editors */
    --code-bg:           #1e1e1e;
    --code-text:         #d4d4d4;

    /* Font */
    --font-body:         'Geologica', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* H1-H6 color tokens - FIX #11 + #12: single source of truth */
    --h1-bg:   #fecaca; --h1-color: #b91c1c;
    --h2-bg:   #c6f6d5; --h2-color: #276749;
    --h3-bg:   #ebf4ff; --h3-color: #2c5282;
    --h4-bg:   #e9d8fd; --h4-color: #553c9a;
    --h5-bg:   #fde68a; --h5-color: #92400e;
    --h6-bg:   #e2e8f0; --h6-color: #4a5568;

    /* Diff colors - FIX #13: extracted from 8 scattered hardcodes */
    --diff-old-bg:    #fff5f5; --diff-old-color:    #c62828;
    --diff-new-bg:    #f1f8e9; --diff-new-color:    #2e7d32;
    --diff-lbl-old-bg:#fce8e8; --diff-lbl-old-color:#b71c1c;
    --diff-lbl-new-bg:#e8f5e9; --diff-lbl-new-color:#1b5e20;
    --diff-rm-bg:     #fecaca; --diff-rm-color:     #991b1b;
    --diff-add-bg:    #bbf7d0; --diff-add-color:    #166534;

    /* Selection/hover for keyword + issue lists - FIX #5 #6 #7 */
    --kw-hover:    rgba(102, 126, 234, 0.06);
    --kw-selected: rgba(102, 126, 234, 0.13);
}

/* ── Base ────────────────────────────────────────────────── */
img { max-width: 100%; height: auto; }

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    padding: 24px 22px;
    font-size: 16px;
}

/* Prevent admin-controls flash on public route before JS executes */
body[data-ui-mode="public"] [data-public-hidden="true"] {
    display: none !important;
}

/* ── Container ────────────────────────────────────────────── */
.container {
    background: var(--surface);
    border-radius: 10px;
    /* FIX #8: subtle glass border on the floating card */
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto 1fr auto auto;
    gap: 12px;
    min-height: calc(100vh - 24px);
}

/* ── Header ───────────────────────────────────────────────── */
.header-row {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-body);
}

h1 {
    color: var(--text);
    font-size: 20px;
    margin: 0;
}

.header-row h1 span {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    font-family: var(--font-body);
}

.header-controls label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: var(--text-light);
}

/* ── Small buttons ───────────────────────────────────────── */
.small-btn {
    background: var(--border);
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 11.5px;
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
    box-sizing: border-box;
}

.small-btn:hover {
    background: var(--primary);
    color: white;
}

.small-btn.is-disabled,
.small-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.small-btn.is-disabled:hover,
.small-btn:disabled:hover {
    background: var(--border);
    color: var(--text);
}

/* ── Rewrite select ────────────────────────────────────── */
.rewrite-select { min-width: 130px; }
.rewrite-select.is-disabled {
    opacity: 0.55;
    pointer-events: none;
}

/* ── CodeMirror heading line highlights - FIX #12 ─────── */
.line-h2 {
    font-weight: bold !important;
    background: rgba(198, 246, 213, 0.4);
    color: var(--h2-color) !important;
}
.line-h2 .cm-tag,
.line-h2 .cm-bracket,
.line-h2 .cm-attribute,
.line-h2 .cm-string { font-weight: normal !important; opacity: 0.8; }

.line-h3 {
    font-weight: bold !important;
    background: rgba(235, 244, 255, 0.5);
    color: var(--h3-color) !important;
}
.line-h3 .cm-tag,
.line-h3 .cm-bracket,
.line-h3 .cm-attribute,
.line-h3 .cm-string { font-weight: normal !important; opacity: 0.8; }

.line-h4 {
    font-weight: bold !important;
    background: rgba(233, 216, 253, 0.4);
    color: var(--h4-color) !important;
}
.line-h4 .cm-tag,
.line-h4 .cm-bracket,
.line-h4 .cm-attribute,
.line-h4 .cm-string { font-weight: normal !important; opacity: 0.8; }

.line-p {
    background: rgba(254, 252, 191, 0.4);
    color: #2c2c2c !important;
}
.line-p .cm-strong { color: #2c2c2c !important; font-weight: bold !important; }
.line-p .cm-tag,
.line-p .cm-bracket,
.line-p .cm-attribute,
.line-p .cm-string {
    font-weight: normal !important;
    color: #b7791f !important;
    opacity: 0.8;
}

.line-div .cm-tag:not(.cm-attribute),
.line-div .cm-bracket {
    font-weight: normal !important;
    color: var(--danger-dark) !important;
    background: rgba(254, 226, 226, 0.5);
    border-radius: 2px;
}
.line-div .cm-attribute,
.line-div .cm-string {
    font-weight: normal !important;
    background: none !important;
    opacity: 0.8;
}

/* ── AI Highlight levels ─────────────────────────────────── */
.ai-highlight-critical,
.ai-highlight-critical * { background-color: var(--danger-dark) !important; color: #fff !important; }

.ai-highlight-high,
.ai-highlight-high *     { background-color: #dd6b20 !important; color: #fff !important; }

.ai-highlight-medium,
.ai-highlight-medium *   { background-color: #d69e2e !important; color: #fff !important; }

.ai-highlight-low,
.ai-highlight-low *      { background-color: #5a67d8 !important; color: #fff !important; }

/* CSS Custom Highlight API for visual editors (zero DOM modification) */
::highlight(ai-input-critical), ::highlight(ai-output-critical) {
    background-color: var(--danger-dark); color: #fff;
}
::highlight(ai-input-high), ::highlight(ai-output-high) {
    background-color: #dd6b20; color: #fff;
}
::highlight(ai-input-medium), ::highlight(ai-output-medium) {
    background-color: #d69e2e; color: #fff;
}
::highlight(ai-input-low), ::highlight(ai-output-low) {
    background-color: #5a67d8; color: #fff;
}

/* ── Editor columns ──────────────────────────────────────── */
.editor-column {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.editor-header label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.char-count {
    font-size: 10px;
    color: var(--text-light);
    padding-right: 5px;
}
.char-count.char-limit-warn {
    color: #d97706;
    font-weight: 600;
}
.char-count.char-limit-over {
    color: #dc2626;
    font-weight: 600;
}
.char-upgrade-link {
    margin-left: 6px;
    font-size: 10px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}
.char-upgrade-link:hover {
    text-decoration: underline;
}
/* ℹ icon next to char/word counts */
.count-info-icon {
    display: inline-block;
    font-size: 9px;
    font-style: normal;
    cursor: pointer;
    opacity: 0.45;
    position: relative;
    vertical-align: middle;
    user-select: none;
    outline: none;
}
.count-info-icon:hover,
.count-info-icon:focus { opacity: 1; }
/* Tooltip via title is enough for hover; for mobile tap we show a pseudo tooltip */
.count-info-icon::after {
    content: attr(title);
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: #2d3748;
    color: #fff;
    font-size: 10px;
    white-space: nowrap;
    padding: 3px 7px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 9999;
}
.count-info-icon.show-tip::after { display: block; }

.textarea-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 600px;
    min-height: 600px;
    max-height: 600px;
    /* overflow:hidden so CodeMirror's own internal scroller is the ONLY scroll
       context. A competing overflow-y:auto here left the last lines unreachable. */
    overflow: hidden;
}

.textarea-with-lines {
    flex: 1;
    display: flex;
    border: 1px solid #ccc;
    border-radius: 0;
    overflow: hidden;
    line-height: 1.4;
}

.CodeMirror {
    height: 100%;
    width: 100%;
    min-width: 0;
    flex: 1;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    background: var(--surface);
    color: black;
    line-height: 15px;
}

.CodeMirror-gutters {
    background: var(--surface);
    border-right: 1px solid #ccc;
}

.CodeMirror-wrap pre {
    word-break: normal;
    white-space: pre-wrap;
}
/* Do NOT force overflow-x here. CodeMirror sets .CodeMirror-scroll to
   overflow:scroll with negative margins (-50px) to hide native scrollbars.
   Forcing overflow-x:hidden broke that box model and made the last lines
   unreachable by the vertical scroll. lineWrapping:true already prevents
   any horizontal scrollbar, so no override is needed. */

.line-numbers       { display: none !important; }
.line-numbers.hidden{ display: none; }

.textarea-with-lines textarea {
    flex: 1;
    border: none;
    padding: 10px;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: var(--surface);
    color: #000000;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    overflow-x: hidden;
}

/* ── Issues Badge Animation ──────────────────────────────── */
@keyframes pulse-red {
    0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(229,62,62,.7); }
    70%  { transform: scale(1.05); box-shadow: 0 0 0 6px rgba(229,62,62,0); }
    100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(229,62,62,0); }
}

.issues-header-badge {
    margin-right: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--danger);
    display: none;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    background: rgba(229, 62, 62, 0.1);
    border: 1px solid rgba(229, 62, 62, 0.25);
    white-space: nowrap;
    line-height: 1.4;
}
.issues-header-badge.visible {
    display: inline-flex;
    animation: pulse-red 2s infinite;
    cursor: pointer;
}

#output { background: #f8fafc; }

/* ── Button row ──────────────────────────────────────────── */
.button-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}
.button-row-top {
    margin-bottom: 8px;
    justify-content: center;
    align-items: center;
}
.button-row-top .small-btn,
.button-row-top .action-btn {
    margin: 0;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* FIX #1: was hardcoded #805ad5, now uses brand variable */
/* Unified neutral styling - matches .small-btn (var(--border) bg, primary hover) */
.btn-preview,
.btn-copy,
.btn-reload   { background: var(--border); color: var(--text); }
.btn-preview:hover,
.btn-copy:hover,
.btn-reload:hover { background: var(--primary) !important; color: white; }
.btn-copy-text{ background: var(--info); color: white; }

.action-btn.is-disabled,
.action-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.action-btn.is-disabled:hover,
.action-btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* FIX #13: was hardcoded #276749 */
.btn-success  { background: var(--success-dark) !important; color: white !important; }

.btn-undo     { background: var(--warning); color: white; display: none; }
.btn-undo.show{ display: inline-flex; }
.btn-clear    { background: var(--danger);  color: white; }

/* ── Stats row ───────────────────────────────────────────── */
.stats-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 90px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    transition: background 0.15s;
}
.stat-card:hover {
    background: #eef2f7;
}

.stat-card-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}
.stat-card-label {
    font-size: 9px;
    color: var(--text-light);
    text-transform: uppercase;
    margin-top: 2px;
}
.stat-card.warning .stat-card-value { color: var(--warning); }
.stat-card.danger  .stat-card-value { color: var(--danger); }
.stat-card.success .stat-card-value { color: var(--success); }

/* ── Analyzer sections ───────────────────────────────────── */
.analyzer-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 5fr 4fr 3fr;
    gap: 12px;
    min-height: 220px;
}

.analyzer-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.analyzer-header {
    padding: 8px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 11px;
    color: var(--text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.analyzer-header span:first-child {
    display: flex;
    align-items: center;
    gap: 5px;
}

.analyzer-settings {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 10px;
    font-weight: normal;
}
.analyzer-settings label {
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    color: var(--text-light);
}
.analyzer-settings input[type="number"] {
    width: 35px;
    padding: 2px 4px;
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 10px;
}

.analyzer-tabs { display: flex; border-bottom: 1px solid var(--border); }
.analyzer-tabs button {
    flex: 1;
    padding: 6px;
    border: none;
    background: transparent;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
}
.analyzer-tabs button:hover  { background: var(--bg); }
.analyzer-tabs button.active { background: var(--primary); color: white; }

.analyzer-content {
    flex: 1;
    overflow-y: auto;
    max-height: 200px;
}

/* ── Keyword table ───────────────────────────────────────── */
.keyword-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
}
.keyword-table th {
    position: sticky;
    top: 0;
    background: var(--bg);
    padding: 6px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 9px;
    text-transform: uppercase;
}
.keyword-table th:nth-child(2),
.keyword-table th:nth-child(3) { text-align: center; width: 50px; }

.keyword-table td {
    padding: 5px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.keyword-table td:nth-child(2),
.keyword-table td:nth-child(3) { text-align: center; font-family: monospace; }

.keyword-table tr { cursor: pointer; }

/* FIX #5 */
.keyword-table tr:hover td     { background: var(--kw-hover); }
/* FIX #6 */
.keyword-table tr.selected td  { background: var(--kw-selected); }

.keyword-density { color: var(--primary); font-weight: 600; }
.keyword-word    { font-weight: 500; }

.keyword-forms {
    display: inline-block;
    font-size: 8px;
    background: var(--primary);
    color: white;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 5px;
    font-weight: 600;
}

.lemma-status {
    font-size: 10px;
    color: var(--text-light);
    padding: 3px 6px;
    background: var(--bg);
    border-radius: 4px;
}
.lemma-wrap { display: inline-flex; align-items: center; gap: 4px; }

.no-data {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    font-size: 11px;
}

/* ── Heading tree - FIX #11 ─────────────────────────────── */
.heading-tree { padding: 8px; font-size: 11px; background: var(--surface); }

.heading-item {
    padding: 3px 6px;
    margin: 2px 0;
    border-radius: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.heading-item:hover { background: rgba(102, 126, 234, 0.1); }

.heading-tag {
    font-weight: 700;
    font-size: 9px;
    padding: 2px 5px;
    border-radius: 3px;
    min-width: 24px;
    text-align: center;
}
/* FIX #11: all from single variable source */
.heading-tag.h1 { background: var(--h1-bg); color: var(--h1-color); }
.heading-tag.h2 { background: var(--h2-bg); color: var(--h2-color); }
.heading-tag.h3 { background: var(--h3-bg); color: var(--h3-color); }
.heading-tag.h4 { background: var(--h4-bg); color: var(--h4-color); }
.heading-tag.h5 { background: var(--h5-bg); color: var(--h5-color); }
.heading-tag.h6 { background: var(--h6-bg); color: var(--h6-color); }

.heading-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
}

/* ── Issues list ─────────────────────────────────────────── */
.issues-list { padding: 6px; }

.issue-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px;
    margin-bottom: 4px;
    background: var(--bg);
    border-radius: 0;
    font-size: 10px;
    cursor: pointer;
    border-left: 3px solid transparent;
}
/* FIX #7 */
.issue-item:hover        { background: var(--kw-selected); }
.issue-item.error        { border-left-color: var(--danger); }
.issue-item.warning      { border-left-color: var(--warning); }
.issue-item.info         { border-left-color: var(--info); }

.issue-icon    { font-size: 12px; flex-shrink: 0; }
.issue-content { flex: 1; min-width: 0; }
.issue-title   { font-weight: 600; margin-bottom: 2px; }
.issue-detail  {
    color: var(--text-light);
    font-size: 9px;
    word-break: break-all;
    user-select: text;
    cursor: text;
    background: rgba(0,0,0,0.05);
    padding: 3px 5px;
    border-radius: 3px;
    margin-top: 3px;
}

/* ── Status toasts (inline) ─────────────────────────────── */
.status.show    { opacity: 1 !important; }
/* FIX #13: was hardcoded #c6f6d5 / #22543d */
.status.success { background: var(--h2-bg);     color: var(--success-dark); }
.status.error   { background: #fed7d7;           color: #742a2a; }

/* ── Preview Modal ───────────────────────────────────────── */
.preview-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
}
.preview-modal.show { display: flex; }

.preview-content {
    background: var(--surface);
    border-radius: 10px;
    width: calc(100% - 40px);
    max-width: 1400px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.preview-header h3  { margin: 0; font-size: 14px; }
.preview-title      { display: flex; align-items: center; gap: 10px; }

.view-toggle {
    display: flex;
    background: rgba(255,255,255,0.2);
    padding: 2px;
    border-radius: 4px;
}
.view-toggle button {
    padding: 4px 10px;
    border: none;
    background: transparent;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
}
.view-toggle button.active { background: white; color: var(--primary); }

.input-toggle { background: #e2e8f0; }
.input-toggle button { color: var(--text-muted); }
.input-toggle button.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.preview-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 16px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.preview-close:hover { background: rgba(255,255,255,0.3); }

.preview-body { display: flex; flex: 1; overflow: hidden; }

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e0e0e0;
}
.preview-panel:last-child { border-right: none; }

.panel-header {
    padding: 8px 14px;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #e0e0e0;
}
/* FIX #13: was hardcoded hex pairs */
.panel-header.old { background: var(--diff-old-bg);  color: var(--diff-old-color); }
.panel-header.new { background: var(--diff-new-bg);  color: var(--diff-new-color); }

/* Diff labels bar */
.diff-labels-bar {
    display: none;
    flex-shrink: 0;
    border-bottom: 2px solid #d0d0d0;
}
.diff-labels-bar .diff-label {
    flex: 1;
    text-align: center;
    padding: 9px 14px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
/* FIX #13 */
.diff-labels-bar .diff-label.old { background: var(--diff-lbl-old-bg); color: var(--diff-lbl-old-color); border-right: 1px solid #ddd; }
.diff-labels-bar .diff-label.new { background: var(--diff-lbl-new-bg); color: var(--diff-lbl-new-color); }

/* Column side labels */
.col-side-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}
/* FIX #13 */
.col-side-label.label-predi { background: var(--diff-lbl-old-bg); color: var(--diff-lbl-old-color); border-bottom: 2px solid var(--diff-rm-color); }
.col-side-label.label-sled  { background: var(--diff-lbl-new-bg); color: var(--diff-lbl-new-color); border-bottom: 2px solid var(--diff-add-color); }

.view-container { flex: 1; position: relative; overflow: hidden; }

.view-visual,
.view-code,
.view-diff {
    position: absolute;
    inset: 0;
    overflow: auto;
    padding: 14px;
    display: none;
}
.view-visual.active,
.view-code.active,
.view-diff.active { display: block; }

.view-visual {
    background: var(--surface);
    color: #333;
    line-height: 1.5;
    font-size: 13px;
}
.view-code {
    background: var(--code-bg);
    color: var(--code-text);
    font-family: monospace;
    font-size: 11px;
    white-space: pre;
}

/* ── Tabs ────────────────────────────────────────────────── */
.input-tabs {
    display: flex;
    gap: 10px;
    background: #e2e8f0;
    border: 1px solid var(--border);
    padding: 5px 10px;
    align-items: center;
}
.tabs-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tab-btn {
    padding: 8px 8px;
    border: 1px solid transparent;
    background: var(--surface) !important;
    color: var(--text-muted);
    font-size: 10px !important;
    font-weight: 600 !important;
    font-weight: 500;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tab-btn:hover { background: rgba(255,255,255,0.8); color: var(--primary); }
.tab-btn.active {
    background: var(--surface);
    color: var(--primary);
    font-weight: 500;
    border: 1px solid var(--primary);
    position: relative;
    z-index: 10;
    border-radius: 5px;
}

.editor-view {
    width: 100%;
    height: 100%;
    background: var(--surface);
    display: none;
    flex-direction: column;
    position: relative;
}
.editor-view.active { display: flex; }

/* ── Quill ───────────────────────────────────────────────── */
.quill-host {
    border: none;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}
.quill-host .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    padding: 6px 8px;
}
/* Trap position:fixed/sticky elements inside the visual editor */
.quill-host {
    transform: translateZ(0);
    isolation: isolate;
}
.quill-host .ql-editor [style*="position"] {
    position: relative !important;
}
.quill-host .ql-container.ql-snow {
    border: none;
    flex: 1;
    min-height: 0;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
    overflow: auto;
}
.quill-host .ql-editor {
    min-height: 100%;
    white-space: normal;
    word-break: break-word;
    padding: 12px 14px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 1.2rem;
}

/* Heading sizes inside Quill visual editor */
.ql-snow .ql-editor h2 {
    font-size: 1.5em;
    margin-bottom: 0.3rem;
    margin-top: 0.6rem;
}
.ql-editor p { margin: 0 0 0.4em; padding: 0; }

/* Tables in visual preview */
.ql-editor table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.ql-editor td,
.ql-editor th   { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.ql-editor th   { background: #f0f0f0; font-weight: bold; }
.ql-editor tr:nth-child(even) td { background: #fafafa; }

/* Lists in Quill */
.ql-editor ul > li:not([data-list]) { list-style-type: disc !important; list-style-position: inside !important; display: list-item !important; }
.ql-editor ol > li:not([data-list]) { list-style-type: decimal !important; list-style-position: inside !important; display: list-item !important; }
.ql-editor ul > li:not([data-list])::before,
.ql-editor ol > li:not([data-list])::before { content: none !important; display: none !important; width: 0 !important; margin: 0 !important; }
.ql-editor ul:not([class*="ql-"]),
.ql-editor ol:not([class*="ql-"]) { padding-left: 1.5em !important; margin: 2px 0 !important; }
.ql-editor li:not([data-list]) { margin: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; line-height: 1.5 !important; }
.ql-editor li > p { margin: 0 !important; padding: 0 !important; display: inline !important; }

.quill-fallback-textarea {
    display: block !important;
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 12px 14px;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.7;
}

/* ── Diff view ───────────────────────────────────────────── */
.view-diff {
    background: var(--surface);
    font-family: monospace;
    font-size: 11px;
    white-space: pre-wrap;
}
/* FIX #13 */
.diff-removed { background: var(--diff-rm-bg);  color: var(--diff-rm-color);  text-decoration: line-through; }
.diff-added   { background: var(--diff-add-bg); color: var(--diff-add-color); }

.token-tag    { color: #569cd6; }
.token-attr   { color: #9cdcfe; }
.token-string { color: #ce9178; }

/* ── Preview footer ──────────────────────────────────────── */
.preview-footer {
    padding: 10px 16px;
    background: var(--surface);
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stats-group  { display: flex; gap: 16px; }
.stat-item    { display: flex; flex-direction: column; gap: 2px; }
/* FIX #4: was hardcoded #888 */
.stat-label   { font-size: 9px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.stat-value   { font-family: monospace; font-size: 13px; font-weight: 600; color: #333; }
.stat-value.saved { color: var(--success); }
.preview-actions { display: flex; gap: 8px; }
.preview-actions button { padding: 6px 14px; font-size: 12px; }

/* ── SEO / Layout ────────────────────────────────────────── */
.seo-row { margin-top: 12px; grid-template-columns: 1fr 1fr; }
#topicClusterSection { display: none !important; }

/* ── Cleaner controls ────────────────────────────────────── */
.cleaner-controls button,
.cleaner-controls .small-btn { height: auto; line-height: 1; }

.cleaner-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
    flex-wrap: nowrap;
    line-height: 1;
}
.cleaner-controls:focus-within { background: transparent; }

.cleaner-settings-panel {
    width: 100%;
    background: #e2e8f0;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-top: 6px;
    animation: csetSlide 0.2s ease-out;
}
@keyframes csetSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cleaner-settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.cset-group { display: flex; flex-direction: column; gap: 4px; }

.cset-group-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text);
    margin-bottom: 2px;
}

.cset-lbl {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: var(--text);
    cursor: pointer;
    line-height: 1.3;
    white-space: nowrap;
}

.cset-cb { width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.cset-conditional { margin-left: 19px; }

.cset-input {
    width: 100%;
    padding: 3px 6px;
    font-size: 10.5px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
.cset-input:focus { border-color: var(--primary); }

.cset-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px;
}
.cset-toolbar-spacer { flex: 1; }

.cset-minimize-link {
    font-size: 11px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    margin-left: auto;
}
.cset-minimize-link:hover { color: var(--text); text-decoration: underline; }

.cset-actions-select {
    font-size: 11px;
    padding: 2px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    height: 24px;
}
.cset-actions-select:focus { outline: none; border-color: var(--primary); }

.cset-profile-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    flex-wrap: nowrap;
    overflow: hidden;
}

.cset-profile-select {
    flex: 0 1 auto;
    min-width: 100px;
    max-width: 200px;
    padding: 4px 8px;
    font-size: 11.5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    text-overflow: ellipsis;
}
.cset-profile-select:focus { border-color: var(--primary); }

.cset-profile-name-input {
    flex: 0 0 auto;
    width: 130px;
    padding: 4px 8px;
    font-size: 11.5px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    text-overflow: ellipsis;
}
.cset-profile-name-input:focus { border-color: var(--primary); }

.cset-profile-btn {
    padding: 4px 10px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.cset-profile-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.cset-profile-btn-danger:hover { background: #e74c3c; border-color: #e74c3c; }
.cset-profile-info { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; font-size: 11px; font-style: normal; color: #8895a7; border: 1px solid #d0d5dd; border-radius: 50%; cursor: help; flex-shrink: 0; }
.cset-profile-info:hover { color: var(--primary); border-color: var(--primary); }

.cset-unified-select {
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 500;
    font-family: var(--font-body);
    line-height: 1.4;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #e2e8f0;
    color: var(--text);
    cursor: pointer;
    outline: none;
    box-sizing: border-box;
}
.cset-unified-select:focus { border-color: var(--primary); }

.cset-toggle-panel-link {
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 2px 4px;
}
.cset-toggle-panel-link:hover { opacity: 1; }

.cleaner-mode-native {
    position: absolute !important;
    width: 1px !important; height: 1px !important;
    margin: -1px !important; padding: 0 !important;
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    overflow: hidden !important;
}

.small-select {
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 3px 8px;
    font-size: 12px;
    background: var(--surface);
    color: var(--text);
    height: 30px;
}

/* ── Prompt Generator modal form ────────────────────────── */
.pg-grid          { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 15px; }
.pg-field         { margin-bottom: 15px; }
.pg-label         { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.pg-label-section { display: block; font-weight: 600; margin-bottom: 10px; font-size: 13px; color: var(--primary-dark); }
.pg-input         { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: var(--font-body); }
.pg-input-mono    { width: 100%; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; min-height: 260px; }
.pg-textarea      { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; resize: vertical; font-family: var(--font-body); }
.pg-checks        { display: flex; flex-wrap: wrap; gap: 15px; }
.pg-check-label   { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; }
.pg-check-label input[type="checkbox"] { cursor: pointer; }
.pg-kw-box        { margin-bottom: 15px; background: #f8fafc; padding: 12px; border: 1px solid var(--border); border-radius: 6px; }
.pg-hint          { font-size: 11px; color: var(--text-light); margin-top: 3px; }
.pg-prompt-label  { margin-bottom: 8px; font-size: 12px; font-weight: 700; color: var(--primary-dark); }
.pg-footer        { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; }

/* ── Fixed clean toast ───────────────────────────────────── */
.fixed-clean-toast {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 100001;
    /* FIX #10: unified default toast navy to #1e40af */
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 10px 28px rgba(15,23,42,.14);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    max-width: min(92vw, 420px);
    backdrop-filter: blur(8px);
}
.fixed-clean-toast.show    { opacity: 1; transform: translateY(0); }
.fixed-clean-toast.success { background: #ecfdf3; color: #166534; border-color: #86efac; }
.fixed-clean-toast.error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.fixed-clean-toast.warning { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
/* FIX #10: info now matches default */
.fixed-clean-toast.info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* ── Quota banner ────────────────────────────────────────── */
.quota-error-banner {
    display: none;
    position: sticky;
    top: 0;
    z-index: 9999;
    background: rgba(30, 41, 59, 0.97);
    color: #e2e8f0;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(239, 68, 68, 0.35);
    border-left: 3px solid rgba(239, 68, 68, 0.7);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .01em;
}
.quota-error-banner.visible { display: flex; align-items: center; gap: 14px; }
.quota-error-banner .quota-icon  { font-size: 22px; flex-shrink: 0; }
.quota-error-banner .quota-msg   { flex: 1; }
.quota-error-banner .quota-close {
    flex-shrink: 0;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
}
.quota-error-banner .quota-close:hover { background: rgba(255,255,255,.28); }

/* ── Client notice / CTA ─────────────────────────────────── */
.client-notice {
    grid-column: 1 / -1;
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    color: #475569;
    font-size: 12px;
    line-height: 1.5;
}
.client-notice a       { color: #475569; text-decoration: underline; }
.client-notice a:hover { color: var(--primary); }
.client-notice code    { font-size: 11px; color: #64748b; background: #f1f5f9; border-radius: 3px; padding: 0 3px; }

.seo-contact-cta {
    grid-column: 1 / -1;
    margin-top: 10px;
    background: linear-gradient(135deg, #edf2ff 0%, #f8faff 100%);
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 12px 14px;
    color: #1f2a44;
    font-size: 12.5px;
    line-height: 1.55;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
/* FIX #2: was hardcoded #2039b1 (orphan navy) */
.seo-contact-cta a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 7px;
    background: var(--primary-dark);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
}

/* ── Keyword cloud ────────────────────────────────────────── */
.topic-cluster  { padding: 8px; border-bottom: 1px solid var(--border); }
.cluster-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.cluster-topic  { font-weight: 700; color: var(--primary); font-size: 11px; text-transform: capitalize; }
.cluster-keywords { display: flex; flex-wrap: wrap; gap: 4px; }
.cluster-keyword  { font-size: 9px; background: rgba(102,126,234,0.1); padding: 2px 5px; border-radius: 3px; color: var(--text-light); }

.keyword-cloud { padding: 15px; text-align: center; line-height: 1.6; background: var(--surface); min-height: 220px; }
.cloud-word    { display: inline-block; margin: 3px 6px; cursor: default; transition: color 0.2s; color: var(--primary); font-weight: 500; }
.cloud-word:hover { color: var(--primary); }

/* ── Semantic analysis bars ──────────────────────────────── */
.semantic-analysis { padding: 10px; }
.semantic-item     { margin-bottom: 10px; }
.semantic-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}
.sem-info        { cursor: help; opacity: 0.45; font-size: 9px; font-weight: 400; margin-left: 3px; }
.sem-info:hover  { opacity: 1; }
.sem-score       { font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.sem-score.excellent { background: #bbf7d0; color: var(--success-deep); }
.sem-score.good      { background: #bfdbfe; color: #1d4ed8; }
.sem-score.average   { background: #fde68a; color: var(--h5-color); }
.sem-score.weak      { background: #fecaca; color: var(--h1-color); }

.semantic-bar-bg   { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.semantic-bar-fill { height: 100%; background: var(--primary); transition: width 0.5s ease-out; }

/* + bar fill color matches score badge - the JS adds the class */
.semantic-bar-fill.excellent { background: var(--success); }
.semantic-bar-fill.good      { background: var(--info); }
.semantic-bar-fill.average   { background: var(--warning); }
.semantic-bar-fill.weak      { background: var(--danger); }

.analyzer-badge { font-size: 8px; background: var(--primary); color: white; padding: 1px 5px; border-radius: 10px; font-weight: 700; }

/* ── Documentation section ───────────────────────────────── */
.doc-section {
    grid-column: 1 / -1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 25px;
    margin-top: 15px;
}
.doc-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid var(--bg);
    padding-bottom: 12px;
}
.doc-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }
.doc-item {
    display: flex;
    gap: 25px;
    align-items: center;
    background: #fdfdfd;
    padding: 20px 30px;
    border-radius: 12px;
    border: 1px solid #edf2f7;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 2px 4px rgba(0,0,0,.02);
    position: relative;
    overflow: hidden;
}
.doc-item:hover { transform: translateY(-4px); box-shadow: 0 12px 20px rgba(0,0,0,.08); border-color: var(--primary); background: var(--surface); }
.doc-item::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 0;
    background: var(--primary);
    transition: height 0.3s ease;
}
.doc-item:hover::before { height: 100%; }

.doc-icon {
    font-size: 24px;
    width: 52px; height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}
.doc-item:hover .doc-icon { transform: scale(1.1) rotate(-5deg); }
.doc-icon.blue   { background: #ebf8ff; color: #3182ce; }
/* FIX #3: was hardcoded #805ad5 */
.doc-icon.purple { background: #faf5ff; color: var(--primary-dark); }
.doc-icon.teal   { background: #e6fffa; color: #319795; }
.doc-icon.orange { background: #fffaf0; color: #dd6b20; }

.doc-content h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding-bottom: 5px;
    font-weight: 800;
}
.doc-content p { margin: 0 0 15px 0; font-size: 12px; color: var(--text-light); line-height: 1.6; }
.doc-details   { margin: 8px 0 0 0; display: flex; flex-direction: column; gap: 5px; }
.doc-details li { font-size: 10.5px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.doc-details li::before { content: "•"; color: var(--primary); font-weight: bold; }
.doc-tag { font-family: monospace; background: var(--bg); padding: 1px 4px; border-radius: 3px; border: 1px solid var(--border); font-size: 10px; }
.doc-tech-container { margin-top: 25px; border-top: 1px dashed var(--border); padding-top: 20px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 10px; }
.doc-table th,
.doc-table td { text-align: left; padding: 10px; border: 1px solid var(--border); }
.doc-table th { background: var(--bg); color: var(--primary-dark); text-transform: uppercase; letter-spacing: 0.5px; }
.doc-table td { color: var(--text-light); }
.doc-table strong { color: var(--primary); }
.doc-footer-note { font-size: 10.5px; color: var(--text-light); margin-top: 15px; font-style: italic; text-align: center; }

/* ── AI Detection section ────────────────────────────────── */
.btn-ai-detect {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%) !important;
    color: white !important;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.ai-watermark-section {
    grid-column: 1 / -1;
    background: var(--surface);
    border-radius: 4px;
    margin-top: 15px;
    padding: 0;
    overflow: hidden;
    border: 2px solid #cbd5e0;
    display: none;
    flex-direction: column;
}

.ai-detection-header {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    padding: 15px 20px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}
.ai-detection-header.clean {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}
.ai-detection-header.low {
    background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
}
.ai-detection-header.medium {
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
}
.ai-header-left { display: flex; align-items: center; gap: 12px; }
.ai-header-icon {
    font-size: 24px;
    background: rgba(255,255,255,1);
    width: 44px; height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.ai-header-titles h2 {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 800;
    color: white;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.ai-header-titles p { font-size: 11px; color: rgba(255,255,255,0.9); margin: 0; font-weight: 600; }
.ai-score-large    { text-align: right; }
.ai-score-number   { font-family: var(--font-body); font-size: 34px; font-weight: 900; line-height: 1; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.ai-score-label    { font-size: 10px; font-weight: 800; color: rgba(255,255,255,0.9); text-transform: uppercase; }

.ai-detection-body  { padding: 20px; background: #f1f5f9; }
.ai-dashboard-grid  { display: grid; grid-template-columns: 280px 1fr; gap: 25px; }
.ai-stats-panel     { display: flex; flex-direction: column; gap: 12px; }
.ai-stat-mini-card  { background: var(--surface); border: 2px solid #cbd5e0; border-radius: 4px; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; transition: all 0.2s; }
.ai-stat-mini-card:hover { border-color: var(--primary); transform: translateX(4px); }
.ai-stat-label { font-size: 11px; font-weight: 700; color: var(--text-light); }
.ai-stat-value { font-family: var(--font-body); font-size: 18px; font-weight: 900; color: #1a202c; }

.ai-results-panel { display: flex; flex-direction: column; gap: 15px; }
.ai-interpretation-banner {
    padding: 15px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid transparent;
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    margin-bottom: 5px;
}
.ai-interpretation-banner.clean  { background: var(--h2-bg);   border-color: var(--success);      color: var(--success-dark); }
.ai-interpretation-banner.low    { background: #feebc8;         border-color: #dd6b20;             color: #7b341e; }
.ai-interpretation-banner.medium { background: #fed7d7;         border-color: #e53e3e;             color: #742a2a; }
.ai-interpretation-banner.high   { background: #fff5f5;         border-color: var(--danger-dark);  color: #742a2a; box-shadow: 0 4px 12px rgba(229,62,62,0.2); }

.gpt-marker-notice {
    display: none;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #9f7aea;
    background: #faf5ff;
    color: #553c9a;
    margin-top: -8px;
}
.gpt-marker-notice.active { display: block; }

.model-signal-notice {
    display: none;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: #1e40af;
    margin-top: -8px;
}
.model-signal-notice.active { display: block; }

.watermark-list {
    max-height: 480px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding-right: 5px;
}
.watermark-item { background: var(--surface); border: 2px solid var(--border); border-radius: 6px; padding: 16px; display: flex; flex-direction: column; gap: 12px; transition: border-color 0.2s; position: relative; }
.watermark-item:hover { border-color: var(--primary); }
.wm-meta span:last-of-type { font-size: 10px !important; }
.wm-header   { display: flex; justify-content: space-between; align-items: center; white-space: nowrap; }
.wm-phrase   { font-weight: 900; font-size: 14px; color: #1a202c; font-family: var(--font-body); max-width: 180px; word-break: break-all; }
.wm-count    { background: var(--text); color: white; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 900; }
.wm-meta     { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 11px; color: var(--text-light); font-weight: 600; }
.wm-row-priority { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-light); font-weight: 600; }
.wm-row-priority .wm-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wm-row-priority .wm-type { font-size: 10px; margin-left: auto; flex-shrink: 0; }
.wm-meta code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    background: #f8fafc;
    color: #1f2937;
    font-size: 9px;
    line-height: 1;
    white-space: nowrap;
    vertical-align: middle;
}
.wm-priority          { padding: 2px 6px; border-radius: 3px; font-weight: 800; text-transform: uppercase; font-size: 10px; color: white; }
.wm-priority.critical { background: var(--danger-dark); }
.wm-priority.high     { background: #e53e3e; }
.wm-priority.medium   { background: #dd6b20; }
.wm-priority.low      { background: var(--text-light); }
.wm-priority.human    { background: #c6f6d5; color: #276749; }

.wm-replacement { font-size: 12px; background: #edf2f7; padding: 8px 10px; border-radius: 4px; border-left: 4px solid var(--primary); color: #1a202c; display: flex; align-items: center; gap: 5px; font-weight: 600; }
.wm-replacement strong { font-weight: 800; }
.wm-replacement.critical { border-left-color: var(--danger-dark); background: rgba(153,27,27,0.06); }
.wm-replacement.critical strong { color: var(--danger-dark); }
.wm-replacement.high { border-left-color: #e53e3e; background: rgba(229,62,62,0.06); }
.wm-replacement.high strong { color: #e53e3e; }
.wm-replacement.medium { border-left-color: #dd6b20; background: rgba(221,107,32,0.06); }
.wm-replacement.medium strong { color: #dd6b20; }
.wm-replacement.low { border-left-color: var(--text-light); background: rgba(113,128,150,0.06); }
.wm-replacement.low strong { color: var(--text-light); }
.wm-replacement.human { border-left-color: #276749; background: rgba(198,246,213,0.15); }
.wm-replacement.human strong { color: #276749; }

/* Custom scrollbar */
.watermark-list::-webkit-scrollbar       { width: 8px; }
.watermark-list::-webkit-scrollbar-track { background: #edf2f7; }
.watermark-list::-webkit-scrollbar-thumb { background: #a0aec0; border-radius: 4px; }
.watermark-list::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Extracted inline styles ────────────────────────────────── */

/* Login form */
.email-hint { display: none; color: #e53e3e; font-size: 11px; margin-top: 4px; }
.remember-label { display: flex; align-items: center; gap: 8px; margin: 4px 0 0; cursor: pointer; font-size: 13px; font-weight: 400; color: var(--text-muted); }
.remember-checkbox { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* PRO badge */
.pro-badge { font-size: 8px; font-weight: 700; background: var(--primary-dark); color: #fff; padding: 1px 4px; border-radius: 4px; vertical-align: super; letter-spacing: 0.2px; }
.pro-badge-outline { background: #fff; color: var(--primary-dark); padding: 2px 6px; border: 1px solid rgba(92,114,225,0.3); }

/* Header/toolbar */
.export-dropdown { min-width: 120px; }

/* Editor area */
.btn-header-paste,
.btn-header-reload,
.btn-header-clear {
    padding: 5px 10px;
    margin-left: 5px;
    line-height: 1;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    border: 1px solid transparent;
    font-weight: 600;
    transition: all 0.15s ease;
}
.btn-header-paste .icon-glyph,
.btn-header-reload .icon-glyph,
.btn-header-clear .icon-glyph {
    font-size: 14px;
    line-height: 1;
    display: inline-block;
    font-family: "Segoe UI Symbol", "Arial Unicode MS", Arial, sans-serif;
}
.btn-header-reload {
    background: #d1fae5 !important;
    color: #047857 !important;
    border-color: #6ee7b7 !important;
}
.btn-header-reload:hover {
    background: #047857 !important;
    color: #ffffff !important;
    border-color: #047857 !important;
}
.btn-header-clear {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}
.btn-header-clear:hover {
    background: #b91c1c !important;
    color: #ffffff !important;
    border-color: #b91c1c !important;
}
.btn-header-paste {
    background: #dbeafe !important;
    color: #1d4ed8 !important;
    border-color: #93c5fd !important;
}
.btn-header-paste:hover {
    background: #1d4ed8 !important;
    color: #ffffff !important;
    border-color: #1d4ed8 !important;
}
.ai-score-badge { display: none; background: rgba(102,126,234,0.1); color: var(--primary); border-color: rgba(102,126,234,0.25); }
.hidden-textarea { display: none; }

/* Prompt generator modal */
.modal-translation { max-width: 1000px; height: 90vh; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
select.pg-input { background: white; }
.pg-field-hidden { display: none; }

/* Kimi rewrite modal */
.modal-kimi { max-width: 980px; height: 82vh; }
.modal-body-kimi { padding: 16px 20px; overflow-y: auto; flex: 1; }
/* AI privacy pre-flight modal */
.preview-content.ai-privacy-modal {
    width: calc(100% - 40px);
    max-width: 520px;
    height: auto;
    max-height: calc(100vh - 60px);
    box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.preview-content.ai-privacy-modal .preview-header {
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
}
.preview-content.ai-privacy-modal .preview-header h3 { font-size: 15px; font-weight: 600; }
.ai-privacy-body {
    padding: 20px 24px 8px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text, #1f2937);
}
.ai-privacy-body p { margin: 0 0 12px; }
.ai-privacy-body p:first-child { font-weight: 600; color: #111827; margin-bottom: 14px; }
.ai-privacy-body ul {
    list-style: disc outside;
    margin: 0 0 14px;
    padding-left: 22px;
}
.ai-privacy-body li {
    margin: 8px 0;
    padding-left: 4px;
}
.ai-privacy-body li::marker { color: #ea580c; }
.ai-privacy-body strong { color: #9a3412; font-weight: 700; }
.ai-privacy-responsibility {
    margin: 14px 0 4px !important;
    padding: 12px 14px;
    background: #fff7ed;
    border-left: 4px solid #ea580c;
    border-radius: 6px;
    font-size: 13px;
    color: #7c2d12;
    font-weight: 500;
}
.preview-content.ai-privacy-modal .ai-privacy-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border, #e5e7eb);
    background: #f9fafb;
}
.preview-content.ai-privacy-modal .ai-privacy-footer .action-btn {
    min-width: 120px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
}
.nim-summary { margin-bottom: 10px; font-size: 13px; color: var(--text-light); }
.nim-footer { display: flex; align-items: center; gap: 8px; padding: 12px 20px; }
.nim-select-all-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; margin-right: auto; user-select: none; }
.nim-select-checkbox { width: 15px; height: 15px; cursor: pointer; }

/* Output area */
.clean-score-badge { display: none; background: rgba(34,197,94,0.12); color: #16a34a; border-color: rgba(34,197,94,0.3); }

/* AI breakdown */
.ai-impact-box { margin-top: 10px; padding: 12px; background: var(--surface); border: 2px solid var(--border); border-radius: 4px; }
.ai-impact-title { font-size: 11px; font-weight: 900; color: var(--text); text-transform: uppercase; margin-bottom: 8px; }
.ai-impact-list { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; }
.ai-impact-row { display: flex; justify-content: space-between; }
.ai-impact-critical { color: #fc8181; }
.ai-impact-high { color: #f6ad55; }

/* AI rules panel */
.ai-rules-panel { grid-column: 1 / -1; background: var(--surface); padding: 15px; border-radius: 8px; border: 1px solid var(--border); margin-top: 20px; }
.ai-rules-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ai-rules-title { margin: 0; font-size: 14px; color: var(--text); }
.btn-rules { font-size: 12px; padding: 6px 12px; font-family: var(--font-body); }
.btn-rules-ml { margin-left: 5px; }
.rules-textarea { width: 100%; height: 150px; font-family: monospace; font-size: 11px; padding: 10px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; background: #f8f9fa; color: #4a5568; }

/* Fetch modal */
.modal-fetch { height: 90vh; }
.fetch-url-bar { padding: 12px; background: var(--bg); display: flex; gap: 8px; }
.fetch-url-input { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.fetch-hint { padding: 8px 12px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-light); }
.fetch-frame { flex: 1; border: none; background: white; }

/* JS paywall (classes used in template literals) */
.marker-card-blur { user-select: none; }
.ai-paywall-wrap { grid-column: 1/-1; position: relative; min-height: 400px; }
.ai-paywall-blur { filter: blur(3px); pointer-events: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.ai-paywall-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; background: rgba(var(--bg-rgb,255,255,255),0.55); border-radius: 10px; }
.ai-paywall-icon { font-size: 2rem; margin-bottom: 8px; }
.ai-paywall-title { font-weight: 700; font-size: 1.05rem; color: var(--warning); margin-bottom: 6px; }
.ai-paywall-desc { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 20px; }
.ai-paywall-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ai-paywall-btn-login { display: inline-block; padding: 10px 22px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-radius: 8px; font-weight: 700; font-size: 0.9rem; text-decoration: none; }
.ai-paywall-btn-buy { display: inline-block; padding: 10px 22px; background: #fff; color: #667eea; border: 2px solid #667eea; border-radius: 8px; font-weight: 700; font-size: 0.9rem; text-decoration: none; }
.ai-no-markers { grid-column: 1/-1; text-align: center; padding: 30px; color: var(--success); font-weight: 600; }
.app-result-disclaimer { background: #ffffff; border: 2px solid var(--border); border-radius: 6px; padding: 12px 16px; margin: 12px 0; font-size: 12.5px; line-height: 1.5; color: var(--text); }
.app-result-disclaimer strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 13px; font-weight: 700; }
.app-result-disclaimer p { margin: 0; color: var(--text); }
.ai-no-markers.ai-no-markers-warn {
    color: #92400e;
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 6px;
    padding: 18px 22px;
    line-height: 1.5;
    font-weight: 500;
}

/* Clean result message */
.ai-clean-message {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    background: rgba(72, 187, 120, 0.08);
    border: 1px solid rgba(72, 187, 120, 0.25);
    border-radius: 10px;
    grid-column: 1 / -1;
}
.ai-clean-icon { font-size: 1.6rem; flex-shrink: 0; }
.ai-clean-text { display: flex; flex-direction: column; gap: 2px; }
.ai-clean-title { font-size: 1rem; font-weight: 700; color: #276749; }
.ai-clean-desc { font-size: 0.85rem; color: #2f855a; line-height: 1.4; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1200px) {
    .analyzer-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 12px;
        gap: 10px;
    }
    .header-row { flex-direction: column; align-items: flex-start; gap: 8px; }
    .header-controls { width: 100%; flex-wrap: wrap; gap: 6px; }
    .header-controls > * { max-width: 100%; }
    .cleaner-controls { white-space: nowrap; flex-wrap: nowrap; }
    .input-tabs { flex-wrap: wrap; row-gap: 4px; padding-bottom: 4px; }
    .tab-btn { padding: 7px 10px; font-size: 10px; }
    .tabs-meta { width: 100%; margin-left: 0 !important; justify-content: space-between; flex-wrap: wrap; gap: 6px; }
    .char-count { font-size: 11px; }
    .textarea-wrapper { height: 52vh; min-height: 340px; max-height: none; }
    .button-row { gap: 6px; }
    .action-btn { flex: 1 1 calc(50% - 6px); justify-content: center; min-height: 36px; }
    .stats-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .stat-card { min-width: 0; }
    .analyzer-row { grid-template-columns: 1fr; }
    .seo-row { grid-template-columns: 1fr; }
    .cleaner-settings-grid { grid-template-columns: repeat(2, 1fr); }

    .ai-watermark-section { width: 100%; min-width: 0; margin-top: 12px; border-radius: 6px; }
    .ai-detection-header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 14px; }
    .ai-header-left { width: 100%; min-width: 0; }
    .ai-header-icon { width: 36px; height: 36px; font-size: 20px; flex: 0 0 auto; }
    .ai-header-titles { min-width: 0; }
    .ai-header-titles h2 { font-size: 13px; line-height: 1.25; letter-spacing: 0.2px; word-break: break-word; }
    .ai-header-titles p  { font-size: 10px; }
    .ai-score-large    { width: 100%; text-align: left; }
    .ai-score-number   { font-size: 26px; }
    .ai-detection-body { padding: 12px; }
    .ai-dashboard-grid { grid-template-columns: 1fr; gap: 12px; }
    .ai-stats-panel    { gap: 8px; }
    .ai-stat-mini-card { padding: 10px 12px; }
    .ai-stat-label     { font-size: 10px; }
    .ai-stat-value     { font-size: 16px; }

    .watermark-list { grid-template-columns: 1fr; gap: 8px; max-height: none; padding-right: 0; }
    .watermark-item { min-width: 0; padding: 10px; }
    .wm-header { white-space: normal; align-items: flex-start; }
    .wm-phrase { max-width: none; word-break: break-word; overflow-wrap: anywhere; }
    .wm-meta   { flex-wrap: wrap; gap: 6px; }

    .ai-detection-header  { flex-direction: column; align-items: flex-start; gap: 10px; }
    .ai-header-left       { width: 100%; }
    .ai-score-large       { text-align: left; }
    .ai-score-number      { font-size: 28px; }
    .ai-detection-body    { padding: 12px; }
    .ai-dashboard-grid    { grid-template-columns: 1fr; gap: 12px; }
    .watermark-list       { grid-template-columns: 1fr; max-height: 320px; }
    .wm-header            { white-space: normal; gap: 8px; }
    .wm-phrase            { max-width: none; word-break: break-word; }
}

@media (max-width: 800px) {
    .container    { grid-template-columns: 1fr; }
    .analyzer-row { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    body { padding: 8px; }
    .container { padding: 10px; min-height: calc(100vh - 16px); }
    h1 { font-size: 17px; }
    .header-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .header-controls .cleaner-controls { grid-column: 1 / -1; width: 100%; justify-content: center; padding: 4px 8px; }
    .header-controls .small-btn,
    .header-controls .action-btn { width: 100%; justify-content: center; }
    .tabs-meta .char-count { width: 100%; text-align: left; }
    .textarea-wrapper { height: 44vh; min-height: 280px; }
    .action-btn { flex: 1 1 100%; }
    .client-notice,
    .seo-contact-cta { font-size: 11.5px; }
    .ai-detection-header  { padding: 10px 12px; }
    .ai-header-titles h2  { font-size: 12px; }
    .ai-score-number      { font-size: 22px; }
    .ai-score-label       { font-size: 9px; }
    .ai-detection-body    { padding: 10px; }
    .cleaner-settings-grid { grid-template-columns: 1fr; }
    .ai-rewrite-bar       { padding: 12px 14px; }
    .ai-rewrite-buttons   { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
    .ai-rewrite-btn       { padding: 8px 10px; font-size: 11.5px; }
    .ai-rewrite-title     { font-size: 12px; }
    .ai-rewrite-desc      { font-size: 11.5px; }
}

/* ================================
   Experimental: external AI rewrite bar (full-width row)
   ================================ */
.ai-rewrite-row {
    grid-column: 1 / -1;
    margin-top: 20px;
}
.ai-rewrite-bar {
    display: none;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f5f7ff 0%, #eef2ff 100%);
    border: 2px solid #d3dafe;
    border-left: 4px solid #6366f1;
    border-radius: 6px;
}
.ai-rewrite-bar.is-visible { display: block; }

.ai-rewrite-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}
.ai-rewrite-experimental {
    display: inline-block;
    padding: 3px 9px;
    background: #6366f1;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
}
.ai-rewrite-title {
    font-size: 14px;
    font-weight: 900;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.ai-rewrite-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 3px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.ai-rewrite-desc {
    font-size: 12.5px;
    line-height: 1.5;
    color: #475569;
    margin-bottom: 12px;
}
.ai-rewrite-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

/* Locked state for guest users */
.ai-rewrite-bar--locked {
    display: block !important; /* Always visible for guests as a teaser */
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-color: #cbd5e1;
    border-left-color: #94a3b8;
}
.ai-rewrite-bar--locked .ai-rewrite-experimental {
    background: #94a3b8;
}
.ai-rewrite-bar--locked .ai-rewrite-btn {
    opacity: 0.5;
    background: #f8fafc;
    color: #64748b;
    border-color: #cbd5e1;
    cursor: not-allowed;
}
.ai-rewrite-bar--locked .ai-rewrite-btn::before {
    filter: grayscale(1);
    opacity: 0.7;
}
.ai-rewrite-bar--locked .ai-rewrite-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #64748b;
    transform: none;
}
.ai-rewrite-bar--locked .ai-rewrite-btn:hover::before {
    background: inherit;
    box-shadow: none;
}
.ai-rewrite-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.ai-rewrite-btn::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex-shrink: 0;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.ai-rewrite-btn:active {
    transform: translateY(1px);
}
.ai-rewrite-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* Brand color accents per AI service */
.ai-rewrite-btn[data-service="chatgpt"]::before    { background: #10a37f; }
.ai-rewrite-btn[data-service="claude"]::before     { background: #cc785c; }
.ai-rewrite-btn[data-service="gemini"]::before     { background: #4285f4; }
.ai-rewrite-btn[data-service="perplexity"]::before { background: #20808d; }
.ai-rewrite-btn[data-service="copilot"]::before    { background: #0078d4; }
.ai-rewrite-btn[data-service="deepseek"]::before   { background: #4d6bfe; }
.ai-rewrite-btn[data-service="grok"]::before       { background: #1a1a1a; }
.ai-rewrite-btn[data-service="bggpt"]::before      { background: #d62612; }
.ai-rewrite-btn[data-service="qwen"]::before       { background: #615ced; }
.ai-rewrite-btn[data-service="meta"]::before       { background: #0866ff; }
.ai-rewrite-btn[data-service="kimi"]::before       { background: #7c3aed; }
.ai-rewrite-btn[data-service="mistral"]::before    { background: #fa7e1e; }
.ai-rewrite-btn[data-service="deepai"]::before     { background: #06b6d4; }
.ai-rewrite-btn[data-service="arena"]::before      { background: #64748b; }
/* Hover: fill button with brand color, invert dot to white */
.ai-rewrite-btn[data-service="chatgpt"]:hover    { background: #10a37f; border-color: #10a37f; color: #ffffff; }
.ai-rewrite-btn[data-service="claude"]:hover     { background: #cc785c; border-color: #cc785c; color: #ffffff; }
.ai-rewrite-btn[data-service="gemini"]:hover     { background: #4285f4; border-color: #4285f4; color: #ffffff; }
.ai-rewrite-btn[data-service="perplexity"]:hover { background: #20808d; border-color: #20808d; color: #ffffff; }
.ai-rewrite-btn[data-service="copilot"]:hover    { background: #0078d4; border-color: #0078d4; color: #ffffff; }
.ai-rewrite-btn[data-service="deepseek"]:hover   { background: #4d6bfe; border-color: #4d6bfe; color: #ffffff; }
.ai-rewrite-btn[data-service="grok"]:hover       { background: #1a1a1a; border-color: #1a1a1a; color: #ffffff; }
.ai-rewrite-btn[data-service="bggpt"]:hover      { background: #d62612; border-color: #d62612; color: #ffffff; }
.ai-rewrite-btn[data-service="qwen"]:hover       { background: #615ced; border-color: #615ced; color: #ffffff; }
.ai-rewrite-btn[data-service="meta"]:hover       { background: #0866ff; border-color: #0866ff; color: #ffffff; }
.ai-rewrite-btn[data-service="kimi"]:hover       { background: #7c3aed; border-color: #7c3aed; color: #ffffff; }
.ai-rewrite-btn[data-service="mistral"]:hover    { background: #fa7e1e; border-color: #fa7e1e; color: #ffffff; }
.ai-rewrite-btn[data-service="deepai"]:hover     { background: #06b6d4; border-color: #06b6d4; color: #ffffff; }
.ai-rewrite-btn[data-service="arena"]:hover      { background: #64748b; border-color: #64748b; color: #ffffff; }
.ai-rewrite-btn:hover::before {
    background: #ffffff;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.35);
}
.ai-rewrite-status {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 4px;
    display: none;
}
.ai-rewrite-status.is-info {
    display: block;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    font-weight: 600;
}
.ai-rewrite-status.is-success {
    display: block;
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.ai-rewrite-status.is-error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* YouTube tutorials toolbar button */
.youtube-tutorials-btn {
    background: #ff0033;
    color: #ffffff;
    border-color: #ff0033;
    font-weight: 700;
}
.youtube-tutorials-btn:hover {
    background: #cc001e;
    border-color: #cc001e;
    color: #ffffff;
}
.youtube-tutorials-btn:active {
    transform: translateY(1px);
}
