@font-face { font-family: "Overpass"; src: url("fonts/overpass-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Readex Pro"; src: url("fonts/readex-pro-arabic-wght-normal.woff2") format("woff2"); font-weight: 160 700; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Overpass Mono"; src: url("fonts/overpass-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Overpass Mono"; src: url("fonts/overpass-mono-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --sign: #f7f7f2;
  --panel: #ffffff;
  --ink: #111317;
  --muted: #666c75;
  --line: #e2e2dc;
  --c-text: #0072ce;
  --c-class: #00a651;
  --c-group: #f7941d;
  --c-look: #8e44ad;
  --c-repeat: #e4002b;
  --c-anchor: #111317;
  --ui: "Overpass", "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Overpass Mono", "Readex Pro", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sign: #121417; --panel: #1b1e23; --ink: #eef0f3; --muted: #99a0aa; --line: #2c3037;
    --c-text: #4da3ff; --c-class: #3dd68c; --c-group: #ffb347; --c-look: #c38be0; --c-repeat: #ff5a6e; --c-anchor: #eef0f3;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --sign: #121417; --panel: #1b1e23; --ink: #eef0f3; --muted: #99a0aa; --line: #2c3037;
    --c-text: #4da3ff; --c-class: #3dd68c; --c-group: #ffb347; --c-look: #c38be0; --c-repeat: #ff5a6e; --c-anchor: #eef0f3;
    color-scheme: dark;
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--sign); color: var(--ink); font: 400 15px/1.45 var(--ui); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-underline-offset: 3px; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-text); outline-offset: 2px; border-radius: 6px; }

.app { display: flex; flex-direction: column; min-height: 100dvh; }
.bar { display: flex; align-items: baseline; gap: 6px 20px; flex-wrap: wrap; padding: 16px 28px 8px; }
.brand { margin: 0; font: 900 26px/1 var(--ui); letter-spacing: -0.02em; }
.brand i { font-style: normal; color: var(--c-repeat); }
.purpose { flex: 1; margin: 0; color: var(--muted); }
.bar-meta { color: var(--muted); font-size: 12.5px; }

/* The pattern, big */
.input { display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap; padding: 6px 28px; }
/* A regex reads left to right on the Arabic page too */
.pattern { direction: ltr; flex: 1; min-width: min(560px, 100%); display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--panel); }
.slash { color: var(--muted); font: 700 22px var(--mono); }
.pattern input { flex: 1; min-width: 0; border: 0; background: none; font: 700 clamp(18px, 2vw, 24px) var(--mono); }
.pattern input:focus { outline: none; }
/* The settings letters sit after the last slash, as they are written in code */
.flag-text { color: var(--c-repeat); font: 700 clamp(18px, 2vw, 24px) var(--mono); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.quiet { border-color: var(--line); color: var(--muted); }
.btn { padding: 9px 16px; border: 2px solid var(--ink); border-radius: 999px; background: var(--panel); font: 700 14px var(--ui); cursor: pointer; }
.btn:hover, .btn[aria-expanded="true"] { background: var(--ink); color: var(--panel); }
.btn.ink { background: var(--ink); color: var(--panel); }
.btn.ink:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: default; }
.menu { position: relative; }
/* Menus open toward the page, from the button's outer edge, so they never leave the screen */
.pop { position: absolute; z-index: 20; top: calc(100% + 8px); inset-inline-end: 0; width: min(420px, 90vw); max-height: 60vh; overflow: auto; padding: 6px; border: 2px solid var(--ink); border-radius: 14px; background: var(--panel); box-shadow: 0 16px 40px rgb(17 19 23 / 0.18); }
.pop button { display: grid; gap: 2px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: start; cursor: pointer; }
.pop button:hover, .pop button:focus-visible { background: var(--sign); }
.pop b { font-size: 14px; }
.pop code { direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font: 400 12.5px var(--mono); }

.error { margin: 6px 28px 0; padding: 10px 14px; border-left: 0; border-radius: 10px; background: var(--c-repeat); color: #fff; font-weight: 700; }

/* Explanation: a one-line summary, then numbered steps down a single rail */
.explain, .test { display: flex; flex-direction: column; min-height: 0; gap: 8px; }
.summary { margin: 0; padding: 14px 16px; border: 2.5px solid var(--ink); border-radius: 14px; background: var(--panel); font: 600 16px/1.55 var(--ui); }
.summary:empty { display: none; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.steps:empty::before { content: "Paste a regex above, press Sample, or pick one of the Ready patterns."; color: var(--muted); }
:lang(ar) .steps:empty::before { content: "الصق regex في الأعلى، أو اضغط «مثال»، أو اختر من «أنماط جاهزة»."; }
.step { position: relative; display: grid; grid-template-columns: 34px minmax(0, auto) minmax(0, 1fr); align-items: start; gap: 4px 12px; padding: 8px 0; }
/* the rail joining the step numbers */
.step::before { content: ""; position: absolute; inset-inline-start: 16px; top: 0; bottom: 0; width: 3px; background: var(--line); }
.step .num { position: relative; z-index: 1; display: grid; place-items: center; width: 34px; height: 34px; border: 3px solid var(--ink); border-radius: 50%; background: var(--panel); font: 800 13px var(--ui); font-variant-numeric: tabular-nums; }
.step .tok { align-self: center; padding: 3px 8px; border-radius: 8px; background: var(--panel); border: 1.5px solid var(--line); font: 700 14px var(--mono); white-space: pre; unicode-bidi: isolate; }
.step .say { margin: 0; align-self: center; font-size: 15px; line-height: 1.45; }
.step.danger .num { border-color: var(--c-repeat); color: var(--c-repeat); }
.step .sub { grid-column: 2 / -1; padding-inline-start: 6px; border-inline-start: 2px dashed var(--line); }
.sub .step .num { width: 28px; height: 28px; font-size: 11px; border-width: 2px; }
.sub .step { grid-template-columns: 34px minmax(0, auto) minmax(0, 1fr); }
.sub .step::before { display: none; }

/* Each line of the test text: matches or not, and where it stopped */
.verdicts { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.verdicts li { display: grid; grid-template-columns: 22px minmax(0, auto) minmax(0, 1fr); align-items: baseline; gap: 4px 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1.5px solid var(--line); }
.verdicts .mark { font-weight: 900; }
.verdicts .ok .mark { color: var(--c-class); }
.verdicts .no .mark { color: var(--c-repeat); }
.verdicts .line { font: 700 14px var(--mono); unicode-bidi: plaintext; overflow-wrap: anywhere; }
.verdicts .why { color: var(--muted); font-size: 13.5px; }
.verdicts .note { display: block; color: var(--muted); }
.verdicts .whole { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); }
.more summary { cursor: pointer; color: var(--muted); font: 700 13px var(--ui); }
.more .matches { margin-top: 8px; max-height: 260px; }
.more .hint { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

/* Test text and matches */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; padding: 12px 28px 22px; }
.head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
h2 { margin: 0; font: 800 12px/1 var(--ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.count { font: 700 14px var(--ui); }
.count.none { color: var(--c-repeat); }
.field { position: relative; flex: none; height: 170px; border: 2px solid var(--line); border-radius: 12px; background: var(--panel); }
.mirror, .field textarea { position: absolute; inset: 0; margin: 0; padding: 12px 14px; border: 0; font: 400 15px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.mirror { overflow: hidden; color: transparent; pointer-events: none; }
.mirror mark { border-radius: 4px; background: color-mix(in srgb, var(--c-text) 22%, transparent); box-shadow: inset 0 -2px 0 var(--c-text); color: transparent; }
.mirror mark:nth-of-type(even) { background: color-mix(in srgb, var(--c-group) 26%, transparent); box-shadow: inset 0 -2px 0 var(--c-group); }
.field textarea { width: 100%; height: 100%; resize: none; background: transparent; caret-color: var(--ink); }
.field textarea:focus { outline: none; }
.field:focus-within { border-color: var(--ink); }

.warnings { display: grid; gap: 8px; margin-bottom: 10px; }
.warn { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--c-repeat) 10%, var(--panel)); border: 2px solid var(--c-repeat); font-size: 14px; }
.warn b { color: var(--c-repeat); }
.matches { flex: 1; min-height: 0; overflow: auto; list-style: none; margin: 0; padding: 0; display: grid; align-content: start; gap: 6px; }
.matches li { padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1.5px solid var(--line); font: 400 13.5px var(--mono); }
.matches li b { color: var(--c-text); }
.matches .at { float: inline-end; color: var(--muted); font-family: var(--ui); font-size: 12px; }
.matches .g { display: block; color: var(--muted); font-size: 12.5px; }
.matches .g span { color: var(--c-group); font-weight: 700; }
.matches .note { color: var(--muted); font-family: var(--ui); border: 0; background: none; }

.toast { position: fixed; left: 50%; bottom: 24px; margin: 0; padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--panel); font: 700 14px var(--ui); transform: translate(-50%, 14px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .bar, .input, .work { padding-inline: 16px; }
  .purpose { flex-basis: 100%; order: 3; }
  .work { grid-template-columns: 1fr; }
  .matches { max-height: 320px; }
}

.lang { margin-inline-start: 10px; font-weight: 600; unicode-bidi: isolate; }
.matches li b, .matches .g { unicode-bidi: plaintext; }
:lang(ar) :is(h2, .brand, .faq h2) { letter-spacing: 0; }

/* Questions under the tool: for people who scroll, and for search engines */
.faq { max-width: 920px; margin: 0 auto; padding: 56px 20px 64px; }
.faq h2 { margin: 0 0 20px; font: 700 22px/1.2 var(--display); letter-spacing: -0.02em; }
.faq-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px 32px; }
.faq h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.faq p { margin: 0; color: var(--muted); line-height: 1.6; }

/* For someone who has never seen a regex */
.intro { margin: 0 0 6px; padding: 14px 16px; border-radius: 14px; background: color-mix(in srgb, var(--c-text) 10%, var(--panel)); font-size: 15.5px; line-height: 1.55; }

/* Settings: the letters in use, each explained, with Add or Remove */
.settings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.settings li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1.5px solid var(--line); font-size: 14px; line-height: 1.45; }
.settings .letter { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--panel); font: 700 14px var(--mono); }
#settings-off .letter { background: var(--line); color: var(--ink); }
.settings .none { display: block; color: var(--muted); }
.mini { padding: 5px 12px; border: 1.5px solid var(--ink); border-radius: 999px; background: var(--panel); font: 700 12.5px var(--ui); cursor: pointer; white-space: nowrap; }
.mini:hover { background: var(--ink); color: var(--panel); }

/* Light/dark button in the top bar, round like the station numbers */
.theme { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-inline-start: 8px; padding: 0; border: 1.5px solid var(--line); border-radius: 999px; background: none; color: var(--ink); cursor: pointer; vertical-align: middle; }
.theme:hover { border-color: var(--c-repeat); color: var(--c-repeat); }
.theme svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme .sun, .theme[data-dark="true"] .moon { display: none; }
.theme[data-dark="true"] .sun { display: block; }
