/* Shared styles for every tool page. Tool-specific styles live inside each tool file. */
:root {
  --bg: #121b29;
  --panel: #172234;
  --panel-2: #1d2a3f;
  --raised: #26364f;
  --raised-2: #2e4161;
  --line: rgba(148, 172, 214, 0.15);
  --line-strong: rgba(148, 172, 214, 0.28);
  --text: #e8eef8;
  --text-2: #aab9ce;
  --text-3: #7487a1;
  --accent: #47c6e8;
  --accent-ink: #052330;
  --pass: #45d49a;
  --pass-bg: rgba(69, 212, 154, 0.14);
  --warn: #f3b94d;
  --warn-bg: rgba(243, 185, 77, 0.13);
  --fail: #f2706d;
  --fail-bg: rgba(242, 112, 109, 0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans Hebrew", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --hover: rgba(255, 255, 255, 0.07);
  --primary-hover: #72d5ef;
  --msg-error: #ffb3b1;
  --msg-warn: #ffd99a;
  --msg-info: #b8ecfa;
  --info-bg: rgba(71, 198, 232, 0.1);
  --bar-bg: #0d1522;
  --stage: #0e1623;
  color-scheme: dark;
}

/* Light theme (set by the desktop, or by the switch on a tool opened on its own) */
:root[data-theme="light"] {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --raised: #e7ecf3;
  --raised-2: #d5dde8;
  --line: rgba(20, 40, 80, 0.12);
  --line-strong: rgba(20, 40, 80, 0.22);
  --text: #152033;
  --text-2: #46566d;
  --text-3: #6d7c92;
  --accent: #0b7ea3;
  --accent-ink: #ffffff;
  --pass: #13845a;
  --pass-bg: rgba(19, 132, 90, 0.11);
  --warn: #9a6200;
  --warn-bg: rgba(200, 130, 0, 0.12);
  --fail: #c3322d;
  --fail-bg: rgba(195, 50, 45, 0.1);
  --hover: rgba(20, 40, 80, 0.06);
  --primary-hover: #0a6f90;
  --msg-error: #8f1d1a;
  --msg-warn: #6e4500;
  --msg-info: #075a73;
  --info-bg: rgba(11, 126, 163, 0.08);
  --bar-bg: #e9eef5;
  --stage: #eef2f7;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex: none; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }
code, kbd, .mono { font-family: var(--mono); font-size: 0.92em; }

/* ---------- layout ---------- */
.tk-app { display: flex; flex-direction: column; height: 100%; min-height: 0; }
/* A tool opened on its own: the top bar (header) sits above the tool, so the page stacks the two */
.tk-has-bar body { display: flex; flex-direction: column; }
.tk-has-bar .tk-app { flex: 1; height: auto; }
/* For screen readers only (the tool name as the page's h1, added by routes.py) */
.tk-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* "Skip to the tool": the first stop of the Tab key, shown only while it has focus */
.tk-skip {
  position: fixed;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 1000;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.tk-skip:focus { transform: none; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6); }
.tk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tk-main { flex: 1; min-height: 0; overflow: auto; padding: 14px; }
.tk-spacer { flex: 1; }
.tk-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tk-h { margin: 0 0 10px; font-size: 13.5px; font-weight: 650; color: var(--text); }
.tk-sub { margin: -6px 0 12px; font-size: 12.5px; color: var(--text-3); }

/* ---------- controls ---------- */
.tk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s, transform 0.06s;
}
.tk-btn:hover { background: var(--raised-2); }
.tk-btn:active { transform: translateY(1px); }
.tk-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.tk-btn svg { width: 17px; height: 17px; }
.tk-btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.tk-btn.primary:hover { background: var(--primary-hover); }
.tk-btn.pass { background: var(--pass-bg); border-color: rgba(69, 212, 154, 0.4); color: var(--pass); }
.tk-btn.pass:hover { background: rgba(69, 212, 154, 0.24); }
.tk-btn.fail { background: var(--fail-bg); border-color: rgba(242, 112, 109, 0.4); color: var(--fail); }
.tk-btn.fail:hover { background: rgba(242, 112, 109, 0.22); }
.tk-btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.tk-btn.ghost:hover { background: var(--hover); color: var(--text); }
.tk-btn.lg { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.tk-btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.tk-btn.is-on { background: rgba(71, 198, 232, 0.16); border-color: rgba(71, 198, 232, 0.5); color: var(--accent); }

.tk-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.tk-select {
  height: 34px;
  max-width: 260px;
  padding: 0 32px 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aab9ce' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 16px;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis;
}
[dir="rtl"] .tk-select { padding: 0 10px 0 32px; background-position: left 9px center; }
.tk-select:disabled { opacity: 0.5; }

.tk-check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.tk-check input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 10px;
  background: var(--raised-2);
  cursor: pointer;
  transition: background-color 0.15s;
}
.tk-check input::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: inset-inline-start 0.15s;
}
.tk-check input:checked { background: var(--accent); }
.tk-check input:checked::after { inset-inline-start: 17px; }

.tk-range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
.tk-range::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: var(--raised-2); }
.tk-range::-moz-range-track { height: 5px; border-radius: 3px; background: var(--raised-2); }
.tk-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--accent); }
.tk-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); }

.tk-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); }
.tk-seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.tk-seg button.is-on { background: var(--raised-2); color: var(--text); }

/* ---------- data display ---------- */
.tk-stat { display: flex; flex-direction: column; gap: 1px; min-width: 80px; }
.tk-stat-k { font-size: 11.5px; color: var(--text-3); }
.tk-stat-v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tk-kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 7px 16px; margin: 0; font-size: 13px; }
.tk-kv dt { color: var(--text-3); }
.tk-kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tk-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--raised);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tk-pill svg { width: 13px; height: 13px; }
.tk-pill.pass { background: var(--pass-bg); color: var(--pass); }
.tk-pill.warn { background: var(--warn-bg); color: var(--warn); }
.tk-pill.fail { background: var(--fail-bg); color: var(--fail); }
.tk-pill.accent { background: rgba(71, 198, 232, 0.14); color: var(--accent); }
.tk-note { font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.tk-msg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.45; }
.tk-msg.error { background: var(--fail-bg); color: var(--msg-error); border: 1px solid rgba(242, 112, 109, 0.3); }
.tk-msg.warn { background: var(--warn-bg); color: var(--msg-warn); border: 1px solid rgba(243, 185, 77, 0.35); }
.tk-msg.info { background: var(--info-bg); color: var(--msg-info); border: 1px solid rgba(71, 198, 232, 0.28); }

.tk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 20px;
  text-align: center;
  color: var(--text-2);
}
.tk-empty-icon { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 20px; background: var(--panel-2); color: var(--accent); }
.tk-empty-icon svg { width: 34px; height: 34px; }
.tk-empty h2 { margin: 0; font-size: 19px; color: var(--text); }
.tk-empty p { margin: 0; max-width: 46ch; font-size: 13.5px; line-height: 1.55; }

/* ---------- verdict bar ---------- */
.tk-verdict {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 9px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.tk-verdict-q { font-size: 13px; color: var(--text-2); font-weight: 600; }
.tk-verdict-state { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.tk-verdict-state svg { width: 17px; height: 17px; }
.tk-verdict-state.pass { color: var(--pass); }
.tk-verdict-state.fail { color: var(--fail); }

/* ---------- standalone page bar ---------- */
.tk-standalone {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--line);
}
.tk-sa-home { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 13px; }
.tk-sa-home img { width: 26px; height: 26px; }
.tk-sa-home:hover span { text-decoration: underline; }
.tk-sa-home { min-width: 0; }
.tk-sa-home span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-sa-theme {
  display: grid;
  place-items: center;
  width: 32px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.tk-sa-theme:hover { background: var(--hover); color: var(--text); }
.tk-sa-theme svg { width: 18px; height: 18px; }
/* the "i" in the top bar and its list of terms and policies (the links come in the page HTML, routes.py) */
.tk-sa-info { display: grid; place-items: center; width: 32px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--text-2); cursor: pointer; }
.tk-sa-info:hover, .tk-sa-info[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.tk-sa-info svg { width: 18px; height: 18px; }
.tk-legal { position: fixed; top: 52px; inset-inline-end: 12px; z-index: 60; display: grid; min-width: 230px; padding: 6px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--panel); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.5); }
.tk-legal a { padding: 9px 12px; border-radius: 7px; color: var(--text); font-size: 13.5px; text-decoration: none; }
.tk-legal a:hover, .tk-legal a:focus-visible { background: var(--hover); }
.tk-sa-lang {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding-inline: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text-2);
  cursor: pointer;
}
.tk-sa-lang:hover { background: var(--hover); color: var(--text); }
.tk-sa-lang:focus-within { border-color: var(--accent); }
.tk-sa-lang img { width: 20px; height: 14px; border-radius: 2px; object-fit: cover; }
.tk-sa-lang select {
  height: 100%;
  padding: 0 18px 0 0;
  border: 0;
  outline: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aab9ce' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0 center / 14px;
  color: inherit;
  font-size: 12.5px;
  font-weight: 650;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
[dir="rtl"] .tk-sa-lang select { padding: 0 0 0 18px; background-position: left 0 center; }
.tk-sa-lang option { background: var(--panel); color: var(--text); }

/* ---------- app tiles (same look as the desktop) ---------- */
.tile {
  --tile: #47c6e8;
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 30% 0%, color-mix(in oklab, var(--tile) 55%, white) 0%, transparent 60%),
    linear-gradient(160deg, var(--tile), color-mix(in oklab, var(--tile) 62%, #061020));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 6px 14px -8px rgba(0, 0, 0, 0.7);
}
.tile .ic { width: 22px; height: 22px; }
.ic { width: 20px; height: 20px; }

/* ---------- scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--raised-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--raised-2); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 480px) {
  .tk-verdict-q { flex-basis: 100%; }
  .tk-verdict .tk-spacer { display: none; }
  .tk-verdict .tk-btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:root[data-theme="light"] .tk-seg button.is-on { background: #fff; box-shadow: 0 1px 2px rgba(10, 20, 40, 0.14); }
:root[data-theme="light"] .tile { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 6px 14px -8px rgba(10, 20, 40, 0.45); }

/* ---------- dialog (TK.ask and TK.tell in tool-kit.js, in place of alert and confirm) ---------- */
.tk-dlg { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 10, 18, 0.55); animation: tk-dlg-fade 0.14s ease-out; }
.tk-dlg-box { width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 22px 18px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.65); animation: tk-dlg-in 0.18s cubic-bezier(0.2, 0.8, 0.3, 1); }
.tk-dlg-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 12px; background: var(--info-bg); color: var(--accent); }
.tk-dlg-icon.is-warn { background: var(--fail-bg); color: var(--fail); }
.tk-dlg-icon svg { width: 22px; height: 22px; }
.tk-dlg-text { margin: 0; font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; }
.tk-dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.tk-dlg-btns .tk-btn { min-width: 100px; height: 40px; padding: 0 18px; font-size: 14px; }
.tk-btn.danger { background: var(--fail); border-color: transparent; color: #1c0505; }
.tk-btn.danger:hover { filter: brightness(1.08); }
:root[data-theme="light"] .tk-btn.danger { background: #c4302b; color: #ffffff; }
:root[data-theme="light"] .tk-dlg { background: rgba(10, 20, 40, 0.38); }
@keyframes tk-dlg-fade { from { opacity: 0; } }
@keyframes tk-dlg-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
html.a11y-still .tk-dlg, html.a11y-still .tk-dlg-box { animation: none; }
