@font-face { font-family: Vazir; src: url("../fonts/Vazir-Light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: Vazir; src: url("../fonts/Vazir.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazir; src: url("../fonts/Vazir-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazir; src: url("../fonts/Vazir-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
    --bg: #f3f5fb;
    --bg-grad: radial-gradient(1200px 500px at 85% -10%, #e4e2ff 0%, transparent 60%), radial-gradient(900px 400px at 0% 0%, #dff4ff 0%, transparent 55%);
    --surface: #ffffff;
    --surface-2: #f6f7fc;
    --border: #e4e7f1;
    --text: #1b1f33;
    --text-2: #5b6280;
    --muted: #8a90aa;
    --primary: #5b4cf0;
    --primary-2: #7c3aed;
    --primary-soft: #eeebff;
    --success: #10b981;
    --success-soft: #e3f8f0;
    --warning: #f59e0b;
    --warning-soft: #fff4dc;
    --danger: #ef4444;
    --danger-soft: #fde8e8;
    --h1: #db2777; --h2: #5b4cf0; --h3: #0891b2; --h4: #64748b;
    --shadow: 0 1px 2px rgba(20, 24, 60, .04), 0 6px 24px rgba(20, 24, 60, .06);
    --shadow-lg: 0 12px 40px rgba(20, 24, 60, .16);
    --radius: 14px;
    --radius-sm: 9px;
    --topbar-h: 62px;
    --sidebar-w: 290px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0d0f1a;
    --bg-grad: radial-gradient(1200px 500px at 85% -10%, #231d52 0%, transparent 60%), radial-gradient(900px 400px at 0% 0%, #0c2a3b 0%, transparent 55%);
    --surface: #151829;
    --surface-2: #1b1f34;
    --border: #262b45;
    --text: #e8eaf6;
    --text-2: #a5abc8;
    --muted: #7a809e;
    --primary: #8b7dff;
    --primary-2: #a78bfa;
    --primary-soft: #262252;
    --success-soft: #0f2e27;
    --warning-soft: #33280f;
    --danger-soft: #3a1717;
    --h2: #8b7dff; --h3: #22d3ee; --h4: #94a3b8; --h1: #f472b6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: Vazir, Tahoma, sans-serif;
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg-grad), var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
svg { width: 18px; height: 18px; flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.5; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
small { color: var(--muted); font-weight: 400; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 20px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--border);
}
.topbar__end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand--center { justify-content: center; margin-bottom: 26px; }
.brand__logo {
    width: 38px; height: 38px; border-radius: 11px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 40%, transparent);
}
.brand__name { font-weight: 700; font-size: 16px; }
.brand__sub { font-size: 11.5px; color: var(--muted); margin-top: -3px; }

.provider-pills { display: flex; gap: 6px; }
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; padding: 4px 11px; border-radius: 99px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
    white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill--ok .dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }
.pill--off .dot { background: var(--danger); }
.pill--warn .dot { background: var(--warning); }

.icon-btn {
    position: relative;
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-grid; place-items: center;
    background: transparent; border: 1px solid transparent; color: var(--text-2);
    cursor: pointer; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn--light { color: #fff; }
.icon-btn--light:hover { background: rgba(255,255,255,.15); border-color: transparent; color: #fff; }
.badge {
    position: absolute; top: 2px; inset-inline-end: 2px;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    font-size: 10.5px; line-height: 17px; font-weight: 700; color: #fff;
}
.badge--danger { background: var(--danger); }
.only-mobile { display: none; }

/* ---------- Layout ---------- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
    position: sticky; top: var(--topbar-h);
    width: var(--sidebar-w); flex-shrink: 0;
    height: calc(100vh - var(--topbar-h));
    display: flex; flex-direction: column;
    border-inline-end: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 60%, transparent);
}
.sidebar__head { padding: 16px 16px 10px; display: grid; gap: 10px; }
.sidebar__title { font-size: 13.5px; display: flex; align-items: center; gap: 7px; color: var(--text-2); }
.sidebar-backdrop { display: none; }
.history { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.history__item {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-radius: 9px; cursor: pointer;
    transition: background .12s;
}
.history__item:hover { background: var(--surface-2); }
.history__item.is-active { background: var(--primary-soft); color: var(--primary); }
.history__text { flex: 1; min-width: 0; }
.history__kw { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history__time { display: block; font-size: 11px; color: var(--muted); }
.history__del { opacity: 0; width: 28px; height: 28px; border-radius: 7px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.history__del svg { width: 15px; height: 15px; }
.history__item:hover .history__del { opacity: 1; }
.history__del:hover { color: var(--danger); background: var(--danger-soft); }
.history__empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

.main { flex: 1; min-width: 0; padding: 24px 28px 140px; max-width: 1280px; margin: 0 auto; }

/* ---------- Components ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px;
}
.card__title { font-size: 14.5px; font-weight: 700; margin-bottom: 12px; }
.count {
    display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 99px;
    font-size: 11px; line-height: 19px; text-align: center; font-weight: 500;
    background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 40px; padding: 0 16px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-weight: 500; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn--primary {
    border: 0; color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 35%, transparent);
}
.btn--primary:hover { color: #fff; filter: brightness(1.08); transform: translateY(-1px); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { color: #fff; filter: brightness(1.1); }
.btn--ghost { background: transparent; }
.btn--light { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.25); color: #fff; }
.btn--light:hover { background: rgba(255,255,255,.28); color: #fff; border-color: rgba(255,255,255,.4); }
.btn--lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn--sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn--sm svg { width: 15px; height: 15px; }
.btn--block { width: 100%; }
.btn-row { display: flex; gap: 6px; align-items: center; }

.input, .select {
    width: 100%; height: 40px; padding: 0 12px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
    outline: none; transition: border .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.8; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.input--sm { height: 34px; font-size: 13px; }
.select { width: auto; cursor: pointer; padding-inline-end: 8px; }
.select--block { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field__label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.check, .radio { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); user-select: none; }
.radio { display: flex; padding: 3px 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; margin: 0; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg--block { display: flex; }
.seg--block .seg__btn { flex: 1; }
.seg__btn {
    border: 0; background: none; padding: 4px 12px; border-radius: 7px;
    font-size: 12.5px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg__btn.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }
.seg__btn:disabled { opacity: .45; cursor: not-allowed; }
.seg__btn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.seg__btn .dot.ok { background: var(--success); }
.seg__btn .dot.off { background: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; padding: 1px 9px; border-radius: 99px;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
}
.chip--ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip--warn { background: var(--warning-soft); color: #b45309; border-color: transparent; }
:root[data-theme="dark"] .chip--warn { color: var(--warning); }
.chip--err { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip--primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert--error { background: var(--danger-soft); color: var(--danger); }
.alert--info { background: var(--primary-soft); color: var(--primary); }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }

/* ---------- Hero / search ---------- */
.hero { padding: 16px; }
.search { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search__box { position: relative; flex: 1 1 340px; }
.search__icon { position: absolute; inset-inline-start: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.search__input {
    width: 100%; height: 52px; padding: 0 46px; font-size: 15.5px;
    border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2);
    outline: none; transition: .15s;
}
.search__input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.search__kbd {
    position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%);
    font-family: inherit; font-size: 11px; padding: 0 7px; border-radius: 6px;
    border: 1px solid var(--border); color: var(--muted); background: var(--surface);
}
.search .select { height: 52px; border-radius: 12px; }
.search .btn--lg { height: 52px; border-radius: 12px; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.progress__bar { flex: 1; height: 7px; border-radius: 9px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress__bar span {
    display: block; height: 100%; width: 0; border-radius: 9px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width .35s ease;
}
.progress.is-indeterminate .progress__bar span { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(100%); } 100% { transform: translateX(-300%); } }
.progress__text { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }

/* ---------- Empty state ---------- */
.empty { margin-top: 28px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { padding: 22px; border-radius: var(--radius); border: 1px dashed var(--border); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.step__num {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary); font-weight: 700; margin-bottom: 10px;
}
.step h3 { font-size: 15px; }
.step p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }

/* ---------- Results ---------- */
#results { margin-top: 22px; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.results-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.results-head__title { font-size: 21px; font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px; background: var(--accent, var(--primary)); }
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 23px; font-weight: 700; line-height: 1.4; }
.stat__value small { font-size: 13px; }
.stat__note { font-size: 11.5px; color: var(--text-2); }

.tabs {
    display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px;
    border-bottom: 1px solid var(--border); scrollbar-width: none;
}
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    border: 0; background: none; padding: 10px 14px; cursor: pointer;
    color: var(--text-2); font-weight: 500; white-space: nowrap;
    border-bottom: 2.5px solid transparent; margin-bottom: -1px; transition: .15s;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab--accent svg { color: var(--primary-2); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadein .2s ease; }

/* SERP */
.serp { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.serp__item {
    display: grid; grid-template-columns: 40px 1fr auto; gap: 14px; align-items: start;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; box-shadow: var(--shadow); transition: border-color .15s;
}
.serp__item:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.serp__rank {
    width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
    font-weight: 700; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.serp__item:nth-child(-n+3) .serp__rank { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.serp__title { font-weight: 600; font-size: 15px; color: var(--text); display: block; }
.serp__title:hover { color: var(--primary); }
.serp__domain { font-size: 12px; color: var(--success); direction: ltr; text-align: right; display: block; }
.serp__snippet { margin: 4px 0 6px; color: var(--text-2); font-size: 13px; }
.serp__actions { display: flex; gap: 4px; }
.serp__error { font-size: 12px; color: var(--danger); margin-top: 4px; word-break: break-word; }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Outline / competitors */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 12px; position: sticky; top: calc(var(--topbar-h) + 8px); z-index: 5; }
.toolbar .input { width: 240px; }
.toolbar__spacer { flex: 1; }
.competitors { display: grid; gap: 10px; }
.comp { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.comp__head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; user-select: none; }
.comp__head:hover { background: var(--surface-2); }
.comp__rank { font-weight: 700; color: var(--primary); min-width: 26px; }
.comp__info { flex: 1; min-width: 0; }
.comp__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp__caret { transition: transform .2s; color: var(--muted); }
.comp.is-open .comp__caret { transform: rotate(180deg); }
.comp__body { display: none; border-top: 1px solid var(--border); padding: 6px 8px 10px; }
.comp.is-open .comp__body { display: block; }
.comp__tools { display: flex; justify-content: flex-end; gap: 6px; padding: 4px 8px 6px; }
.hlist { list-style: none; margin: 0; padding: 0; }
.h-item { display: flex; align-items: flex-start; gap: 9px; padding: 5px 8px; border-radius: 8px; cursor: pointer; }
.h-item:hover { background: var(--surface-2); }
.h-item input { margin-top: 5px; }
.h-item.is-selected { background: var(--primary-soft); }
.h-item[data-level="h3"] { padding-inline-start: 30px; }
.h-item[data-level="h4"], .h-item[data-level="h5"], .h-item[data-level="h6"] { padding-inline-start: 52px; font-size: 13px; }
.h-item[data-level="h1"], .h-item[data-level="h2"] { font-weight: 600; }
.lvl {
    font-size: 10.5px; font-weight: 700; padding: 0 6px; border-radius: 5px; line-height: 19px; margin-top: 3px;
    color: #fff; background: var(--h4); flex-shrink: 0; direction: ltr;
}
.lvl--h1 { background: var(--h1); } .lvl--h2 { background: var(--h2); } .lvl--h3 { background: var(--h3); }
.no-data { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

/* Terms */
.terms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.term-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; }
.term {
    position: relative; display: flex; justify-content: space-between; gap: 8px;
    padding: 4px 10px; border-radius: 7px; cursor: pointer; font-size: 13.5px; overflow: hidden;
}
.term::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w, 0%); background: var(--primary-soft); border-radius: 7px; z-index: 0; }
.term > * { position: relative; z-index: 1; }
.term:hover { outline: 1px solid var(--primary); }
.term__n { font-size: 12px; color: var(--text-2); white-space: nowrap; direction: ltr; }

/* Questions */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.qa, .related { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.qa details { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: var(--surface-2); }
.qa summary { cursor: pointer; font-weight: 500; }
.qa p { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.related button {
    width: 100%; text-align: right; border: 1px solid var(--border); background: var(--surface-2);
    padding: 8px 12px; border-radius: 10px; cursor: pointer; display: flex; align-items: center; gap: 8px;
}
.related button:hover { border-color: var(--primary); color: var(--primary); }
.related svg { width: 15px; height: 15px; color: var(--muted); }

/* AI */
.ai-grid { display: grid; grid-template-columns: 340px 1fr; gap: 14px; align-items: start; }
.ai-settings { position: sticky; top: calc(var(--topbar-h) + 12px); }
.ai-output { min-height: 420px; }
.ai-output__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ai-output__head .card__title { margin: 0; }
.md { font-size: 14.5px; line-height: 2; }
.md h1 { font-size: 20px; margin: 4px 0 10px; color: var(--h1); }
.md h2 { font-size: 17px; margin: 18px 0 6px; color: var(--h2); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.md h3 { font-size: 15px; margin: 12px 0 4px; color: var(--h3); }
.md h4, .md h5, .md h6 { font-size: 14px; margin: 10px 0 2px; }
.md ul, .md ol { margin: 4px 0; padding-inline-start: 22px; }
.md p { margin: 4px 0; }
.md code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.md .cursor { display: inline-block; width: 8px; height: 17px; background: var(--primary); vertical-align: middle; animation: blink 1s steps(1) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.md-editor { min-height: 420px; font-size: 14px; }

/* Selection bar */
.selection-bar {
    position: fixed; z-index: 40; bottom: 18px; right: calc(var(--sidebar-w) + 28px);
    display: flex; align-items: center; gap: 18px;
    padding: 9px 10px 9px 18px; padding-inline-start: 18px; border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
    box-shadow: var(--shadow-lg); animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Live log ---------- */
.log {
    --log-green: #3dff8f;
    position: fixed; z-index: 50; bottom: 16px; left: 16px;
    width: min(460px, calc(100vw - 32px));
    background: #070b09; color: var(--log-green);
    border: 1px solid #1d3b2a; border-radius: 12px;
    box-shadow: 0 14px 44px rgba(0, 0, 0, .45), 0 0 0 1px rgba(61, 255, 143, .06), inset 0 0 40px rgba(61, 255, 143, .03);
    font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, Vazir, monospace;
    direction: rtl; overflow: hidden;
    transition: width .2s ease;
}
.log__head {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 6px;
    background: #0c1510; border-bottom: 1px solid #16301f; cursor: pointer; user-select: none;
    font-family: Vazir, sans-serif; font-size: 12.5px;
}
.log__dot { width: 9px; height: 9px; border-radius: 50%; background: #2b4a37; flex-shrink: 0; }
.log.is-busy .log__dot { background: var(--log-green); box-shadow: 0 0 10px var(--log-green); animation: pulse 1s ease-in-out infinite; }
.log.has-error .log__dot { background: #ff5f5f; box-shadow: 0 0 10px #ff5f5f; }
@keyframes pulse { 50% { opacity: .35; } }
.log__title { font-weight: 700; color: var(--log-green); }
.log__status { color: #7fbf98; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.log__errors { background: #4a1515; color: #ff8a8a; font-size: 11px; padding: 0 8px; border-radius: 99px; line-height: 19px; white-space: nowrap; }
.log__actions { display: flex; gap: 2px; }
.log__btn { width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; color: #6fa585; cursor: pointer; display: grid; place-items: center; }
.log__btn svg { width: 15px; height: 15px; }
.log__btn:hover { background: #163021; color: var(--log-green); }
.log__body {
    height: 230px; overflow-y: auto; padding: 8px 12px 10px;
    font-size: 12.3px; line-height: 1.85;
    background-image: repeating-linear-gradient(0deg, rgba(61,255,143,.018) 0 1px, transparent 1px 3px);
}
.log__body::-webkit-scrollbar-thumb { background: #1d3b2a; }
.log[data-state="min"] { width: 290px; }
.log[data-state="min"] .log__body { display: none; }
.log[data-state="min"] .log__head { border-bottom: 0; }
.log[data-state="min"] #log-copy, .log[data-state="min"] #log-clear { display: none; }
.log__line { display: flex; gap: 8px; white-space: pre-wrap; word-break: break-word; text-shadow: 0 0 6px rgba(61,255,143,.25); }
.log__time { color: #3f7a57; flex-shrink: 0; direction: ltr; font-size: 11.5px; }
.log__msg { flex: 1; }
.log__line--success .log__msg { color: #7dffb5; }
.log__line--success .log__msg::before { content: "✓ "; }
.log__line--warning .log__msg { color: #ffd166; text-shadow: none; }
.log__line--warning .log__msg::before { content: "⚠ "; }
.log__line--error { background: rgba(255, 70, 70, .08); border-radius: 5px; margin: 2px -6px; padding: 1px 6px; }
.log__line--error .log__msg { color: #ff7b7b; text-shadow: none; }
.log__line--error .log__msg::before { content: "✗ "; }
.log__line--muted .log__msg { color: #4f8a67; }
.log__empty { color: #3f7a57; }
.log__cursor::after { content: "▌"; animation: blink 1s steps(1) infinite; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 60; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast {
    pointer-events: auto; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
    background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg);
    animation: fadein .2s ease; max-width: 90vw;
}
.toast--error { background: var(--danger); color: #fff; }
.toast--success { background: var(--success); color: #fff; }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 400px; padding: 34px 30px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.login-form { display: grid; gap: 4px; }
.login-form .btn { margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .ai-grid { grid-template-columns: 1fr; }
    .ai-settings { position: static; }
    .terms { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .only-mobile { display: inline-grid; }
    .provider-pills { display: none; }
    .sidebar {
        position: fixed; z-index: 45; top: 0; bottom: 0; right: 0; height: 100vh;
        background: var(--surface); transform: translateX(100%); transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.is-open { transform: none; }
    .sidebar.is-open + .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(0,0,0,.35); }
    .main { padding: 16px 14px 160px; }
    .steps, .two-col, .terms { grid-template-columns: 1fr; }
    .serp__item { grid-template-columns: 34px 1fr; }
    .serp__rank { width: 34px; height: 34px; }
    .serp__actions { grid-column: 2; }
    .toolbar { position: static; }
    .toolbar .input { width: 100%; }
    .selection-bar { right: 12px; width: calc(100vw - 24px); justify-content: space-between; gap: 8px; bottom: 70px; }
    .selection-bar .btn span { display: none; }
    .log { left: 8px; bottom: 8px; width: calc(100vw - 16px); }
    .log[data-state="min"] { width: 220px; }
    .log__body { height: 180px; }
    .brand__sub { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
