:root {
  --brand: #7C5CFC;
  --brand-2: #2BD9C4;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --text: #1b1d28;
  --text-soft: #5b6072;
  --border: #e3e6ef;
  --danger: #e5484d;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(20, 24, 48, 0.08);
  --maxw: 960px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2330;
  --text: #eef1f8;
  --text-soft: #a3a9bd;
  --border: #2a2f3d;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.visually-hidden, .skip-link {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 1000;
}

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-logo { border-radius: 8px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .2px; }
.brand-sub { color: var(--text-soft); font-size: 13px; font-weight: 600; }
.top-nav { display: flex; align-items: center; gap: 8px; }
.lang-picker select {
  appearance: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 7px 28px 7px 12px; border-radius: 10px; font-size: 14px;
  cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%), linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
  background-position: calc(100% - 16px) center, calc(100% - 11px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.ghost-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 12px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.ghost-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ---------- hero ---------- */
main { flex: 1; padding: 22px 16px 40px; }
.hero { text-align: center; padding: 14px 0 20px; }
.hero-title {
  font-size: clamp(28px, 5vw, 42px); margin: 0 0 8px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-tagline { color: var(--text-soft); font-size: clamp(15px, 2.4vw, 18px); margin: 0; }

/* ---------- editor ---------- */
.editor-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
  padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.tool-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tool-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
  transition: transform .04s ease, background .15s ease, border-color .15s ease;
}
.tool-btn:hover { border-color: var(--brand); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn.primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; border: none; }
.tool-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.tool-btn.icon { padding: 8px 10px; font-weight: 800; }
.font-ctl { display: inline-flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 13px; }

.search-panel {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  padding: 12px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.search-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-soft); }
.search-panel input {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; min-width: 160px;
}

.editor {
  width: 100%; min-height: 52vh; flex: 1; resize: vertical;
  border: none; outline: none; padding: 18px; font-size: 16px; line-height: 1.7;
  font-family: "SFMono-Regular", "JetBrains Mono", "Consolas", "Noto Sans Mono", monospace;
  background: var(--surface); color: var(--text); tab-size: 4;
}

.status-bar {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; color: var(--text-soft);
}
.stats { display: flex; flex-wrap: wrap; gap: 16px; }
.stats b { color: var(--text); }
.save-state b, .save-state { color: var(--text-soft); }

.privacy-note {
  text-align: center; color: var(--text-soft); font-size: 13px; margin: 14px 0 0;
}

/* ---------- info sections ---------- */
.info-section { margin-top: 40px; }
.info-section h2 { font-size: 22px; margin: 0 0 16px; }
.seo-intro { color: var(--text-soft); font-size: 16px; max-width: 70ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 6px; font-size: 17px; }
.card-desc { margin: 0; color: var(--text-soft); font-size: 14px; }
.steps .card { position: relative; }
.steps .card::before {
  content: attr(data-step); position: absolute; top: -10px; left: 14px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff;
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}

/* ---------- faq ---------- */
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 16px;
}
.faq-item summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--brand); font-size: 20px; line-height: 1; }
.faq-item[open] summary::after { content: "−"; }
.faq-body { color: var(--text-soft); padding: 0 0 14px; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0 36px; margin-top: 50px; }
.friend-links h2 { font-size: 16px; margin: 0 0 12px; color: var(--text-soft); }
.friend-links ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.friend-links a { color: var(--text-soft); font-size: 14px; }
.friend-links a:hover { color: var(--brand); }
.footer-tagline { color: var(--text-soft); font-size: 14px; margin: 18px 0 6px; }
.copyright { color: var(--text-soft); font-size: 13px; margin: 0; }

/* ---------- focus ---------- */
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 600px) {
  .header-inner { height: auto; padding: 10px 0; flex-wrap: wrap; }
  .brand-sub { display: none; }
  .top-nav { flex: 1; justify-content: flex-end; }
  .toolbar { gap: 8px; }
  .tool-btn { padding: 8px 10px; font-size: 13px; }
  .editor { min-height: 46vh; }
  .stats { gap: 10px; font-size: 12px; }
}

/* ---------- RTL (Arabic) ---------- */
[dir="rtl"] .brand-sub { margin-right: 0; }
[dir="rtl"] .faq-item summary::after { float: left; }
[dir="rtl"] .steps .card::before { left: auto; right: 14px; }
[dir="rtl"] .skip-link:focus { left: auto; right: 8px; }
