:root {
    --blue: #1267f4;
    --navy: #071b3a;
    --text: #445573;
    --bg: #f5f9ff;
    --line: #dce7f5;
    --icon: #eef5ff;
    --shadow: 0 8px 24px rgba(22, 71, 130, 0.07);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; overflow-x: hidden; background: #fff; color: var(--navy); font-family: Inter, Arial, sans-serif; }
button, input, textarea { font: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.site-header { position: sticky; z-index: 20; top: 0; height: 80px; padding: 0 max(36px, calc((100% - 1180px) / 2)); display: flex; align-items: center; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--navy); font-size: 27px; font-weight: 750; text-decoration: none; }
.brand b { color: var(--blue); }
.brand-logo { display: grid; place-items: center; width: 41px; height: 41px; border-radius: 7px; background: var(--blue); color: #fff; font-size: 25px; font-weight: 500; box-shadow: 0 5px 14px rgba(18, 103, 244, 0.22); }
.site-header nav { margin-left: auto; display: flex; align-items: center; gap: 42px; }
.site-header nav a { color: var(--navy); font-size: 14px; text-decoration: none; }
.theme-toggle, .menu-toggle { display: grid; place-items: center; border: 0; background: none; color: var(--navy); cursor: pointer; }
.theme-toggle svg { width: 23px; }
.grammar-button { display: flex; align-items: center; gap: 9px !important; padding: 13px 18px; border-radius: 8px; background: var(--blue); color: #fff !important; box-shadow: 0 5px 14px rgba(18, 103, 244, 0.18); }
.grammar-button svg { width: 18px; }
.menu-toggle { display: none; margin-left: auto; }
.menu-toggle svg { width: 25px; }
.hero { position: relative; overflow: hidden; padding: 47px 20px 31px; text-align: center; background: radial-gradient(circle at 8% 0, #e9f1ff 0 10%, transparent 22%), radial-gradient(circle at 100% 85%, #edf4ff 0 13%, transparent 26%), linear-gradient(180deg, #f8fbff, #fff); }
.hero h1 { margin: 0; font-size: 54px; line-height: 1.15; letter-spacing: -2px; }
.hero p { margin: 13px 0 0; color: var(--text); font-size: 20px; line-height: 1.45; }
.dots { position: absolute; width: 90px; height: 90px; opacity: 0.35; background-image: radial-gradient(#1267f4 1.3px, transparent 1.3px); background-size: 14px 14px; }
.dots-a { top: 20px; left: 10px; }
.dots-b { right: 10px; bottom: 2px; }
.page-shell { width: min(1180px, calc(100% - 48px)); margin: auto; }
.top-stats, .secondary-stats, .keyword-card, .benefits, .utility-card { border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.top-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 0; padding: 27px 30px; }
.stat { display: flex; align-items: center; gap: 20px; padding: 0 27px; border-right: 1px solid var(--line); }
.stat:first-child { padding-left: 0; }
.stat:last-child { padding-right: 0; border: 0; }
.icon-box { display: grid; place-items: center; flex: 0 0 66px; height: 66px; border-radius: 14px; background: var(--icon); color: var(--blue); }
.icon-box svg { width: 33px; }
.stat p { margin: 0; font-size: 14px; font-weight: 650; }
.stat strong { display: block; margin-top: 8px; color: var(--blue); font-size: 27px; white-space: nowrap; }
.editor-layout { display: grid; grid-template-columns: 110px 1fr; gap: 18px; margin-top: 26px; }
.tool-rail { display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.tool-rail button { position: relative; display: grid; place-items: center; align-content: center; gap: 6px; min-height: 79px; border: 0; background: #fff; color: var(--navy); font-size: 14px; cursor: pointer; }
.tool-rail button.active, .tool-rail button:hover { color: var(--blue); background: #f8fbff; }
.tool-rail button.active::before { content: " "; position: absolute; left: 0; top: 27px; width: 3px; height: 28px; border-radius: 0 3px 3px 0; background: var(--blue); }
.tool-rail svg { width: 24px; height: 24px; }
.editor-main { min-width: 0; }
.textarea-card { position: relative; height: 460px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
textarea { width: 100%; height: 100%; padding: 27px 25px 47px; resize: none; border: 0; outline: 0; border-radius: inherit; background: transparent; color: var(--navy); font-size: 16px; line-height: 1.7; }
textarea:focus { box-shadow: inset 0 0 0 2px rgba(18, 103, 244, 0.25); }
textarea::placeholder { color: #667792; }
.char-limit { position: absolute; right: 22px; bottom: 18px; color: #405375; font-size: 14px; }
.char-limit b { font-weight: 500; }
.action-bar { display: grid; grid-template-columns: 1.05fr 0.8fr 1.15fr 1.12fr 1.05fr 1.08fr; gap: 14px; margin-top: 24px; }
.action-bar button { display: flex; align-items: center; justify-content: center; gap: 10px; height: 58px; border: 1px solid #a9c8ff; border-radius: 8px; background: #fff; color: #064bbd; font-size: 14px; font-weight: 650; cursor: pointer; }
.action-bar button.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.action-bar svg { width: 21px; }
.action-bar b { font-size: 16px; font-weight: 500; }
.secondary-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 26px; padding: 28px 0; }
.secondary-stats > div { display: grid; place-items: center; gap: 9px; border-right: 1px solid var(--line); text-align: center; }
.secondary-stats > div:last-child { border: 0; }
.secondary-stats svg { width: 28px; color: var(--blue); }
.secondary-stats span { min-height: 32px; font-size: 14px; line-height: 1.35; }
.secondary-stats strong { font-size: 16px; }
.utility-card { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; margin-top: 22px; padding: 22px 26px; }
.goal-heading, .goal-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.goal-heading { margin-bottom: 8px; font-size: 14px; font-weight: 650; }
.goal-heading span, .save-state { color: #7a8ba4; font-size: 14px; }
.progress-track { height: 5px; flex: 1; overflow: hidden; border-radius: 5px; background: #e7effb; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--blue); }
.goal-row input { width: 80px; height: 34px; border: 1px solid var(--line); border-radius: 7px; text-align: center; }
.save-state { margin: 6px 0 0; text-align: right; }
.save-state span { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--blue); }
.platform-limits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.limit-stat > span { color: #6b7c98; font-size: 14px; text-transform: uppercase; }
.limit-stat strong { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 16px; }
.limit-stat small { color: #7a8ba4; font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.limit-line { display: block; height: 2px; margin-top: 8px; background: #e7effb; }
.limit-line i { display: block; width: 0; height: 100%; background: var(--blue); }
.over b { color: #d5364c; }
.keyword-card { margin-top: 22px; padding: 18px 24px 16px; }
.keyword-head { display: flex; align-items: center; justify-content: space-between; }
.keyword-head h2 { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 17px; }
.keyword-head h2 svg { width: 25px; color: var(--blue); }
.tabs { display: flex; gap: 10px; }
.tabs button, .view-more { height: 39px; padding: 0 19px; border: 1px solid #b8cff5; border-radius: 7px; background: #fff; color: var(--navy); font-size: 14px; cursor: pointer; }
.tabs button[aria-selected="true"] { border-color: var(--blue); background: var(--blue); color: #fff; }
.keyword-meta { display: flex; gap: 20px; margin: 10px 0 7px; color: #70809a; font-size: 14px; }
.keyword-columns, .keyword-row { display: grid; grid-template-columns: 1fr 130px 130px 170px; gap: 20px; align-items: center; }
.keyword-columns { padding: 11px 13px; border: 1px solid var(--line); background: #f8fbff; color: #405272; font-size: 14px; }
.keyword-row { padding: 11px 13px; border: 1px solid var(--line); border-top: 0; font-size: 14px; }
.keyword-row strong { font-weight: 650; }
.keyword-row span { text-align: left !important; color: #344765; }
.keyword-row::after { content: " "; height: 3px; width: var(--density, 30%); background: var(--blue); }
.empty-state { padding: 32px; text-align: center; color: #667792; }
.empty-state small { display: block; margin-top: 6px; }
.view-more { display: block; margin: 15px auto 0; color: #0754cc; font-weight: 600; }
.benefits { display: grid; grid-template-columns: repeat(4, 1fr); margin: 24px 0; padding: 27px 28px; background: #f8fbff; }
.benefits > div { display: flex; align-items: flex-start; gap: 18px; padding: 0 26px; border-right: 1px solid var(--line); }
.benefits > div:first-child { padding-left: 0; }
.benefits > div:last-child { padding-right: 0; border: 0; }
.benefits svg { width: 35px; flex: 0 0 auto; color: var(--blue); }
.benefits p { margin: 0; color: var(--text); font-size: 14px; line-height: 1.7; }
.benefits strong { display: block; color: #063e9f; font-size: 14px; }
footer { width: min(1180px, calc(100% - 48px)); margin: auto; padding: 0 0 31px; display: flex; justify-content: space-between; color: var(--text); font-size: 14px; }
footer a { color: inherit; text-decoration: none; }
footer p a { color: var(--blue); }
footer nav { display: flex; gap: 42px; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 25px; padding: 11px 18px; border-radius: 7px; background: var(--navy); color: #fff; font-size: 14px; opacity: 0; transform: translate(-50%, 15px); transition: 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid rgba(18, 103, 244, 0.3); outline-offset: 3px; }
@media (max-width: 980px) {
    .site-header { padding: 0 24px; }
    .site-header nav { gap: 24px; }
    .page-shell { width: calc(100% - 32px); }
    .top-stats { grid-template-columns: repeat(2, 1fr); gap: 24px 0; }
    .stat:nth-child(2) { border: 0; }
    .stat:nth-child(n + 3) { padding-top: 22px; border-top: 1px solid var(--line); }
    .editor-layout { grid-template-columns: 92px 1fr; }
    .action-bar { grid-template-columns: repeat(3, 1fr); }
    .secondary-stats { grid-template-columns: repeat(3, 1fr); gap: 22px 0; }
    .secondary-stats > div:nth-child(3) { border: 0; }
    .secondary-stats > div:nth-child(n + 4) { padding-top: 20px; border-top: 1px solid var(--line); }
    .keyword-columns, .keyword-row { grid-template-columns: 1fr 70px 90px 110px; }
    .benefits { grid-template-columns: repeat(2, 1fr); gap: 28px 0; }
    .benefits > div:nth-child(2) { border: 0; }
}
@media (max-width: 700px) {
    .site-header { height: 68px; }
    .brand { font-size: 21px; }
    .brand-logo { width: 36px; height: 36px; font-size: 21px; }
    .menu-toggle { display: grid; }
    .site-header nav { position: absolute; top: 68px; right: 0; left: 0; display: none; flex-direction: column; align-items: stretch; gap: 0; padding: 12px 20px 20px; background: #fff; border-bottom: 1px solid var(--line); }
    .site-header.open nav { display: flex; }
    .site-header nav > a:not(.grammar-button) { padding: 12px; }
    .theme-toggle { position: absolute; right: 70px; top: -48px; }
    .grammar-button { justify-content: center; margin-top: 8px; }
    .hero { padding: 34px 16px 25px; }
    .hero h1 { font-size: 38px; }
    .hero p { font-size: 16px; }
    .page-shell { width: calc(100% - 24px); }
    .top-stats { padding: 20px 16px; }
    .stat { gap: 12px; padding: 0 12px; }
    .stat:first-child { padding-left: 0; }
    .icon-box { flex-basis: 46px; height: 46px; border-radius: 10px; }
    .icon-box svg { width: 25px; }
    .stat strong { font-size: 21px; }
    .editor-layout { display: flex; flex-direction: column; }
    .tool-rail { flex-direction: row; overflow-x: auto; }
    .tool-rail button { flex: 0 0 75px; min-height: 68px; }
    .tool-rail button.active::before { top: auto; right: 22px; bottom: 0; left: 22px; width: auto; height: 3px; }
    .textarea-card { height: 390px; }
    .action-bar { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .action-bar button { height: 50px; }
    .secondary-stats { grid-template-columns: repeat(2, 1fr); }
    .secondary-stats > div { padding: 12px; border-top: 1px solid var(--line) !important; }
    .secondary-stats > div:nth-child(2n) { border-right: 0; }
    .secondary-stats > div:last-child { grid-column: span 2; }
    .utility-card { grid-template-columns: 1fr; padding: 18px; }
    .platform-limits { gap: 10px; }
    .keyword-head { align-items: flex-start; flex-direction: column; }
    .tabs { width: 100%; overflow-x: auto; }
    .tabs button { flex: 1; min-width: max-content; padding-inline: 12px; }
    .keyword-columns, .keyword-row { grid-template-columns: minmax(110px, 1fr) 50px 75px; }
    .keyword-columns span:last-child, .keyword-row::after { display: none; }
    .keyword-card { padding: 16px 12px; }
    .benefits { grid-template-columns: 1fr; padding: 22px; }
    .benefits > div { padding: 18px 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .benefits > div:last-child { border: 0; }
    footer { width: calc(100% - 32px); flex-direction: column; gap: 14px; text-align: center; }
    footer nav { justify-content: center; gap: 20px; }
}
@media (max-width: 430px) {
    .top-stats { gap: 18px 0; }
    .stat { display: block; }
    .icon-box { margin-bottom: 10px; }
    .stat p { font-size: 14px; }
    .stat strong { font-size: 19px; }
    .platform-limits { grid-template-columns: 1fr; }
    .hero p br { display: none; }
}
.theme-picker { position: relative; }
.theme-menu { position: absolute; z-index: 30; top: calc(100% + 14px); right: -8px; display: none; width: 150px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 12px 30px rgba(7, 27, 58, 0.15); }
.theme-picker.open .theme-menu { display: block; }
.theme-menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 40px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--navy); font-size: 14px; cursor: pointer; }
.theme-menu button:hover { background: var(--icon); color: var(--blue); }
.theme-menu svg { width: 18px; }
.theme-menu span { margin-left: auto; visibility: hidden; color: var(--blue); }
.theme-menu button[aria-checked="true"] span { visibility: visible; }
body.dark { --navy: #eef5ff; --text: #aebdd3; --line: #263a58; --icon: #172d4c; --shadow: 0 8px 24px rgba(0, 0, 0, 0.2); background: #081426; color: var(--navy); }
body.dark .site-header, body.dark .site-header nav, body.dark .top-stats, body.dark .tool-rail, body.dark .tool-rail button, body.dark .textarea-card, body.dark .action-bar button:not(.primary), body.dark .secondary-stats, body.dark .utility-card, body.dark .keyword-card, body.dark .theme-menu { background: #0d1c31; }
body.dark .hero { background: radial-gradient(circle at 8% 0, #122b50 0 10%, transparent 22%), radial-gradient(circle at 100% 85%, #10274a 0 13%, transparent 26%), linear-gradient(180deg, #0b1a30, #081426); }
body.dark .tool-rail button.active, body.dark .tool-rail button:hover, body.dark .keyword-columns, body.dark .benefits { background: #102440; }
body.dark textarea, body.dark .goal-row input { color: var(--navy); background: #0d1c31; }
body.dark .keyword-row span, body.dark .char-limit, body.dark footer, body.dark footer a { color: #aebdd3; }
body.dark .theme-toggle, body.dark .menu-toggle { color: #eef5ff; }
@media (max-width: 700px) {
    .theme-picker { position: absolute; right: 68px; top: -49px; }
    .theme-toggle { position: static; }
    .theme-menu { top: 43px; right: -34px; }
    .site-header.open .theme-menu { display: none; }
    .site-header.open .theme-picker.open .theme-menu { display: block; }
}

/* RTL Overrides for Arabic */
html[dir="rtl"] .stat { border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] .stat:first-child { padding-left: 27px; padding-right: 0; }
html[dir="rtl"] .stat:last-child { padding-right: 27px; padding-left: 0; border: 0; }
html[dir="rtl"] .tool-rail button.active::before { left: auto; right: 0; border-radius: 3px 0 0 3px; }
html[dir="rtl"] .char-limit { right: auto; left: 22px; }
html[dir="rtl"] .save-state { text-align: left; }
html[dir="rtl"] .theme-menu { right: auto; left: -8px; }
html[dir="rtl"] .keyword-row span { text-align: right !important; }
html[dir="rtl"] .secondary-stats > div { border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] .secondary-stats > div:last-child { border: 0; }
html[dir="rtl"] .benefits > div { border-right: 0; border-left: 1px solid var(--line); }
html[dir="rtl"] .benefits > div:first-child { padding-left: 26px; padding-right: 0; }
html[dir="rtl"] .benefits > div:last-child { padding-right: 26px; padding-left: 0; border: 0; }
html[dir="rtl"] .toast { left: auto; right: 50%; transform: translate(50%, 15px); }
html[dir="rtl"] .toast.show { transform: translate(50%, 0); }
html[dir="rtl"] .tool-rail button.active::before { right: auto; left: 0; border-radius: 0 3px 3px 0; } /* Keep on left for RTL rail */