/* RR SEO Tools — the web app (app.php) */
:root {
  --bg: #0B1120; --surface: #131C2E; --surface-2: #1A2540; --line: rgba(240, 237, 230, .1); --line-2: rgba(240, 237, 230, .18);
  --text: #F0EDE6; --muted: rgba(240, 237, 230, .62); --faint: rgba(240, 237, 230, .4);
  --blue: #3B7BFF; --blue-2: #2F66E0; --mint: #6FCF97; --red: #FF7A7A;
  --top: 56px; --tabs: 62px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --r: 14px; --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; --display: 'Fraunces', Georgia, serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--blue); text-decoration: none; }
button { font: inherit; }
body { min-height: 100vh; min-height: 100dvh; padding-top: calc(var(--top) + var(--safe-t)); padding-bottom: calc(var(--tabs) + var(--safe-b)); }
body.ap-tool-screen { overflow: hidden; height: 100dvh; }

/* top bar */
.ap-top { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: calc(var(--top) + var(--safe-t)); padding: var(--safe-t) 12px 0; display: flex; align-items: center; gap: 8px;
  background: rgba(11, 17, 32, .92); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.ap-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; min-width: 0; }
.ap-brand img { border-radius: 8px; flex: none; }
.ap-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-back { display: grid; place-items: center; width: 40px; height: 40px; margin-left: -6px; color: var(--text); border-radius: 10px; flex: none; }
.ap-back:active { background: var(--surface); }
.ap-top-right { margin-left: auto; display: flex; gap: 6px; align-items: center; flex: none; }
.ap-pill { font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 99px; background: var(--surface-2); color: var(--text); border: 1px solid var(--line-2); }
.ap-saved { font-size: 13px; color: var(--mint); font-weight: 600; }
.ap-icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.ap-icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ap-icon-btn:hover, .ap-icon-btn:focus-visible { background: var(--surface); }

/* bottom tabs (phones) — a bar at the top right on wide screens */
.ap-tabs { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--tabs) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex;
  background: rgba(11, 17, 32, .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.ap-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 12px; font-weight: 600; }
.ap-tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ap-tabs a.is-on { color: var(--text); }
.ap-tabs a.is-on svg { stroke: var(--blue); }

/* content */
.ap-main { width: 100%; max-width: 1100px; margin: 0 auto; padding: 20px 16px 32px; }
.ap-center { min-height: calc(100dvh - var(--top) - var(--safe-t) - 40px); display: flex; align-items: center; justify-content: center; }
.ap-section { width: 100%; }
.ap-h1 { font: 600 28px/1.15 var(--display); margin: 4px 0 6px; letter-spacing: -.01em; }
.ap-h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 26px 0 10px; font-weight: 700; }
.ap-sub { color: var(--muted); margin: 0 0 16px; }
.ap-fine { color: var(--faint); font-size: 13px; margin: 10px 0 0; }
.ap-center-txt { text-align: center; margin-top: 26px; }
.ap-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 0 0 14px; }
.ap-card h2 { font: 600 19px/1.25 var(--display); margin: 0 0 8px; }
.ap-card ol { margin: 0; padding-left: 20px; color: var(--muted); }
.ap-card ol li { margin: 4px 0; }
.ap-cta { background: linear-gradient(135deg, #16244A, #131C2E); }
.ap-cta p { color: var(--muted); margin: 0 0 12px; }

/* forms */
.ap-label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; color: var(--text); }
.ap-label small { color: var(--faint); font-weight: 400; }
.ap-input { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; outline: none; }
.ap-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59, 123, 255, .25); }
.ap-code { font-size: 26px; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; }
.ap-search { margin: 4px 0 6px; }
.ap-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 16px 0 4px; }
.ap-check input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--blue); flex: none; }
.ap-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; cursor: pointer; text-align: center; }
.ap-btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; width: 100%; margin-top: 16px; }
.ap-btn-primary:hover { background: var(--blue-2); }
.ap-btn[disabled] { opacity: .6; cursor: wait; }
.ap-link { background: none; border: 0; padding: 0; color: var(--blue); cursor: pointer; font-size: inherit; }
.ap-danger { color: var(--red); display: block; margin: 22px auto 0; font-size: 14px; }
.ap-err { color: var(--red); font-size: 14px; margin: 10px 0 0; min-height: 1px; }
.ap-err:empty { display: none; }
#apSignout { width: 100%; margin-top: 4px; }
.ap-row-link { display: block; padding: 12px 0; color: var(--text); border-bottom: 1px solid var(--line); }
.ap-row-link:last-child { border-bottom: 0; }

/* welcome / sign-in */
.ap-welcome { width: 100%; max-width: 420px; text-align: center; }
.ap-welcome h1 { font: 600 32px/1.1 var(--display); margin: 14px 0 8px; }
.ap-welcome .ap-card { text-align: left; margin-top: 20px; }
.ap-welcome-logo { border-radius: 20px; box-shadow: 0 10px 40px rgba(59, 123, 255, .25); }
.ap-lead { color: var(--muted); margin: 0; }
.ap-points { list-style: none; padding: 0; margin: 18px 0 0; color: var(--muted); font-size: 14px; text-align: left; }
.ap-points li { padding: 5px 0 5px 26px; position: relative; }
.ap-points li::before { content: "✓"; position: absolute; left: 4px; color: var(--mint); font-weight: 700; }

/* tool grid */
.ap-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.ap-tool, .ap-list a { display: flex; gap: 14px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); transition: border-color .15s, transform .15s; }
.ap-tool:hover, .ap-list a:hover { border-color: var(--line-2); }
.ap-tool:active, .ap-list a:active { transform: scale(.99); }
.ap-tool-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 22px; background: var(--surface-2); border-radius: 12px; }
.ap-tool-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ap-tool-txt b { font-size: 16px; }
.ap-tool-txt small { color: var(--muted); font-size: 13.5px; line-height: 1.4; }
.ap-tool-txt em { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--blue); margin-top: 2px; }
.ap-grid-compact .ap-tool { align-items: center; padding: 10px 12px; }
.ap-grid-compact .ap-tool-ico { width: 36px; height: 36px; font-size: 18px; }
.ap-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.ap-list a { align-items: center; }
.ap-list .ap-tool-txt b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.ap-empty h1 { font: 600 26px var(--display); color: var(--text); }

/* tool screen: the tool fills the space between the bars */
.ap-main.ap-main-frame { max-width: none; padding: 0; position: fixed; left: 0; right: 0; top: calc(var(--top) + var(--safe-t)); bottom: calc(var(--tabs) + var(--safe-b)); display: flex; flex-direction: column; }
body.ap-tool-screen:not(:has(.ap-tabs)) .ap-main-frame { bottom: 0; }
.ap-frame-wrap { position: relative; flex: 1; min-height: 0; }
.ap-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }
.ap-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); z-index: 1; background: var(--bg); }
.ap-loading.is-done { display: none; }
.ap-spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--blue); animation: apspin .8s linear infinite; }
@keyframes apspin { to { transform: rotate(360deg); } }
.ap-report-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; background: var(--surface); }
.ap-report-head b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-report-head small { color: var(--faint); font-size: 12.5px; }

.ap-toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabs) + var(--safe-b) + 14px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 14px; transition: .25s; max-width: calc(100% - 32px); }
.ap-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.ap-install-now { margin: 10px 0 16px; }

@media (min-width: 700px) {
  .ap-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .ap-grid-compact { grid-template-columns: repeat(3, 1fr); }
  .ap-main { padding: 28px 24px 40px; }
  .ap-h1 { font-size: 34px; }
}
@media (min-width: 1000px) {
  :root { --tabs: 0px; }
  body { padding-bottom: 0; }
  .ap-tabs { top: var(--safe-t); bottom: auto; left: auto; right: 12px; height: var(--top); width: auto; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; gap: 4px; padding: 0; }
  .ap-tabs a { flex-direction: row; gap: 8px; padding: 0 14px; font-size: 14px; }
  .ap-tabs svg { width: 20px; height: 20px; }
  .ap-top-right { margin-right: 330px; }
  body:not(:has(.ap-tabs)) .ap-top-right { margin-right: 0; }
  .ap-grid { grid-template-columns: repeat(3, 1fr); }
  .ap-toast { bottom: 24px; }
}
@media print {
  body { padding: 0; }
  .ap-top, .ap-tabs, .ap-toast { display: none !important; }
}

/* account: usage & credits */
.ap-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.ap-meter { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.ap-meter b { font: 700 24px/1.1 var(--font); color: var(--mint); }
.ap-meter b small { font-size: 14px; color: var(--faint); font-weight: 600; }
.ap-meter span { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.ap-fine a { color: var(--mint); }
.ap-mini-list { list-style: none; margin: 12px 0 0; padding: 0; border-top: 1px solid var(--line); }
.ap-mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.ap-mini-list li span { display: flex; flex-direction: column; min-width: 0; }
.ap-mini-list li small { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-mini-list li em { font-style: normal; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
