/*
 * AppGuard palette, sampled from the app icon: a dark navy plate (#121B2F) carrying a neon mint
 * line-art shield (#6EFCDF).
 *
 * The mint is a dark-surface colour. At 1.26:1 on white it is unusable as text there, so the two
 * schemes swap which colour leads: in light mode the deep teal --brand-teal-text carries links
 * (7.07:1) and the plate navy carries body text (17.16:1); in dark mode the mint leads (13.61:1
 * against the plate). Mint as a fill always pairs with near-black plate text (14.85:1).
 */
:root {
  color-scheme: light dark;

  --brand-plate: #121b2f;
  --brand-plate-mid: #1d3448;
  --brand-plate-deep: #0b1220;
  --brand-mint: #6efcdf;
  --brand-mint-dim: #3fd9b8;
  --brand-teal-text: #0b6455;

  --bg: #f7f9fb;
  --fg: var(--brand-plate-deep);
  --muted: #5a6a80;
  --line: #dfe5ec;
  --accent: var(--brand-teal-text);
  --accent-fg: #fff;
  --card: #fff;
  --code-bg: #eef2f6;
  --ok: #1c7d47;
  --warn: #8a6410;
  --bad: #b3392f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--brand-plate-deep);
    --fg: #e7edf5;
    --muted: #8fa3bf;
    --line: #22304a;
    --accent: var(--brand-mint);
    --accent-fg: var(--brand-plate-deep);
    --card: var(--brand-plate);
    --code-bg: #101a2c;
    --ok: #5ecf9a;
    --warn: #e0ab52;
    --bad: #f0928a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 640px; }

header.site {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 10;
}
header.site .wrap { display: flex; align-items: center; gap: 1.25rem; height: 64px; }
header.site a { color: inherit; text-decoration: none; font-size: .93rem; }
header.site a:hover { color: var(--accent); }
.brand {
  font-weight: 700;
  letter-spacing: -.02em;
  margin-right: auto;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand img { width: 30px; height: 30px; border-radius: 7px; display: block; }
/* Accent on the wordmark only — large, bold, decorative type, not body copy. */
.brand span { color: var(--brand-teal-text); }

@media (prefers-color-scheme: dark) {
  .brand span { color: var(--brand-mint); }
}

.hero-mark { width: 84px; height: 84px; border-radius: 20px; display: block; margin-bottom: 1.5rem; }

/* Primary navigation. The current tab is marked with aria-current, so the styling hook and the
   thing a screen reader announces are the same attribute rather than two that can disagree. */
nav.tabs { display: flex; gap: .35rem; margin-left: auto; }
nav.tabs a {
  padding: .45rem .8rem;
  border-radius: 7px;
  font-size: .92rem;
  white-space: nowrap;
}
nav.tabs a:hover { background: var(--code-bg); color: var(--fg); }
nav.tabs a[aria-current="page"] {
  background: var(--code-bg);
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 560px) {
  header.site .wrap { height: auto; padding-top: .6rem; padding-bottom: .6rem; flex-wrap: wrap; }
  nav.tabs { margin-left: 0; width: 100%; overflow-x: auto; }
}

/* Documentation layout */
.doc-toc {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  background: var(--card);
  margin: 1.5rem 0 2.5rem;
}
.doc-toc h2 { font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; margin: 0 0 .6rem; color: var(--muted); }
.doc-toc ol { margin: 0; padding-left: 1.2rem; columns: 2; column-gap: 2rem; }
.doc-toc li { margin: .25rem 0; font-size: .92rem; break-inside: avoid; }
.doc-toc a { color: inherit; text-decoration: none; }
.doc-toc a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 560px) { .doc-toc ol { columns: 1; } }

.step { counter-increment: step; }
.step > h2::before {
  content: counter(step);
  display: inline-grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  margin-right: .55rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: .72em;
  vertical-align: .12em;
}
main.doc { counter-reset: step; }

.callout {
  border-left: 3px solid var(--accent);
  background: var(--code-bg);
  border-radius: 0 8px 8px 0;
  padding: .85rem 1.1rem;
  margin: 1.25rem 0;
  font-size: .93rem;
}
.callout strong { display: block; margin-bottom: .2rem; }
.callout.warn { border-left-color: var(--warn); }

/* Licence tier chooser */
.tier-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin: .75rem 0 0; }
.tier { position: relative; }
.tier input { position: absolute; opacity: 0; pointer-events: none; }
.tier > span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--card);
  cursor: pointer;
  height: 100%;
  transition: border-color .12s, box-shadow .12s;
}
.tier > span:hover { border-color: var(--accent); }
.tier input:checked + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.tier input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.tier-name { font-weight: 700; font-size: 1.02rem; display: block; }
.tier-price { display: block; font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; margin: .3rem 0 .1rem; }
.tier-converted { display: block; font-size: .85rem; color: var(--muted); min-height: 1.2em; }
.tier-audience { display: block; font-size: .87rem; color: var(--muted); margin: .5rem 0 .6rem; }
.tier ul { margin: 0; padding-left: 1.05rem; }
.tier li { font-size: .85rem; color: var(--muted); margin: .2rem 0; }
.tier-term { display: inline-block; margin-top: .7rem; font-size: .78rem; padding: .12rem .5rem;
             border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

.price-row { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; margin-top: 1.1rem; }
.price-row > div { flex: 0 1 220px; }
.price-row label { margin-top: 0; }

.readonly-value {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .6rem .7rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--muted);
}
.readonly-value strong { color: var(--fg); font-size: 1rem; }

h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.15; letter-spacing: -.025em; margin: 0 0 .6rem; }
h2 { font-size: 1.3rem; letter-spacing: -.015em; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1.5rem 0 .4rem; }
p.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 1.75rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }

.hero { padding: 4rem 0 2rem; }
.cta { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }

a.btn, button {
  font: inherit;
  font-weight: 500;
  padding: .6rem 1.15rem;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
a.btn.secondary, button.secondary {
  background: transparent;
  color: inherit;
  border-color: var(--line);
}
button:disabled { opacity: .55; cursor: not-allowed; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.card h3 { margin-top: 0; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }

pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: .85rem;
  line-height: 1.5;
}
code { font-size: .87em; }
p code, li code, td code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }

table { width: 100%; border-collapse: collapse; margin: .75rem 0; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { font-weight: 600; }

form { margin: 1.5rem 0; }
label { display: block; font-weight: 600; font-size: .88rem; margin: 1.1rem 0 .35rem; }
input[type=text], input[type=email], input[type=number], input[type=password], textarea, select {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: inherit;
  font: inherit;
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .85rem 1rem; margin: 1.1rem 0 0; }
legend { font-weight: 600; font-size: .88rem; padding: 0 .35rem; }
.check { display: flex; align-items: baseline; gap: .55rem; font-weight: 400; margin: .4rem 0; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: .84rem; margin: .35rem 0 0; }

.msg { padding: .7rem .9rem; border-radius: 8px; border: 1px solid var(--line); margin: 1rem 0; font-size: .92rem; }
.msg.ok { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.msg.error { border-color: color-mix(in srgb, var(--bad) 55%, transparent); background: color-mix(in srgb, var(--bad) 10%, transparent); }
.msg.info { background: var(--code-bg); }
[hidden] { display: none !important; }

.badge { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; border: 1px solid var(--line); text-transform: uppercase; letter-spacing: .04em; }
.badge.pending { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.badge.approved { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.badge.rejected { color: var(--muted); }

.req { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.15rem; margin: 1rem 0; background: var(--card); }
.req header { display: flex; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.req header strong { font-size: 1.02rem; }
.keyout { word-break: break-all; font-size: .78rem; background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: .7rem; display: block; margin: .5rem 0; }

footer.site { border-top: 1px solid var(--line); margin-top: 4rem; padding: 2rem 0 3rem; color: var(--muted); font-size: .87rem; }
