/* Showgram LIVE lab — shared styles. RTL-first, mobile-first (375px), light + dark. */

:root {
  color-scheme: light dark;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15181e;
  --muted: #5b6472;
  --border: #dfe3ea;
  --accent: #2c56d8;
  --accent-hover: #2349bd;
  --accent-text: #ffffff;
  --accent-soft: #e7edfd;
  --track: #e3e7ee;
  --ok: #157046;
  --ok-bg: #e6f4ec;
  --warn: #8f5500;
  --warn-bg: #fdf1dc;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --focus: #2c56d8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.05);

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  --gutter: 16px;

  --font: system-ui, -apple-system, 'SF Arabic', 'Segoe UI', 'Noto Sans Arabic', 'Noto Naskh Arabic',
    'Geeza Pro', Tahoma, Roboto, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Roboto Mono', 'Liberation Mono',
    'DejaVu Sans Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #171a20;
    --surface-2: #1f232b;
    --text: #e8ebf0;
    --muted: #9aa3b0;
    --border: #2b303a;
    --accent: #7c9bff;
    --accent-hover: #93adff;
    --accent-text: #0b0e14;
    --accent-soft: #1e2740;
    --track: #2a2f39;
    --ok: #5fcf95;
    --ok-bg: #13281e;
    --warn: #f2b65e;
    --warn-bg: #2d2412;
    --bad: #ff8a80;
    --bad-bg: #321816;
    --focus: #9db4ff;
    --shadow: none;
  }
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
  font-weight: 700;
}
h1 {
  font-size: 1.6rem;
}
h2 {
  font-size: 1.25rem;
}
h3 {
  font-size: 1.05rem;
}

p {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

ol,
ul {
  margin: 0;
  padding-inline-start: 1.4em;
}
li + li {
  margin-top: 6px;
}

code,
kbd,
samp {
  font-family: var(--mono);
  font-size: 0.92em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

img,
video,
canvas {
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- layout ---------- */

.wrap {
  width: 100%;
  max-width: 720px;
  margin-inline: auto;
  padding: 20px var(--gutter) 40px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.row > .btn {
  flex: 1 1 140px;
}
.row > a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding-inline: 6px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px var(--gutter);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

header,
footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.ok {
  color: var(--ok);
}
.warn {
  color: var(--warn);
}
.bad {
  color: var(--bad);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: scale(0.985);
}
.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.btn-ghost:hover {
  background: var(--accent-soft);
}

.stack > .btn,
nav > .btn {
  width: 100%;
  min-height: 56px;
  font-size: 1.08rem;
}

/* ---------- forms ---------- */

label {
  display: block;
  font-weight: 600;
}
label > input:not([type='radio']):not([type='checkbox']),
label > select,
label > textarea {
  margin-top: 6px;
}
label:has(> input[type='radio']),
label:has(> input[type='checkbox']) {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-weight: 500;
  cursor: pointer;
}

input[type='text'],
input[type='number'],
input[type='search'],
input[type='tel'],
input:not([type]),
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
textarea {
  min-height: 96px;
  resize: vertical;
}
input[type='number'],
input[dir='ltr'] {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

input[type='radio'],
input[type='checkbox'] {
  accent-color: var(--accent);
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
legend {
  padding: 0;
  margin-bottom: 8px;
  font-weight: 700;
}

/* Radio group of carriers, built by carrierPicker() in common.js */
.carrier-picker {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.carrier-picker > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.carrier-picker label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.carrier-picker label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
}
.carrier-picker label:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
.carrier-picker input:focus-visible {
  outline: none;
}
@media (max-width: 340px) {
  .carrier-picker > div {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (min-width: 560px) {
  .carrier-picker > div {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---------- messages ---------- */

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.97rem;
}
.notice.ok {
  border-color: var(--ok-bg);
  border-inline-start-color: var(--ok);
  background: var(--ok-bg);
  color: var(--text);
}
.notice.warn {
  border-color: var(--warn-bg);
  border-inline-start-color: var(--warn);
  background: var(--warn-bg);
  color: var(--text);
}
.notice.bad {
  border-color: var(--bad-bg);
  border-inline-start-color: var(--bad);
  background: var(--bad-bg);
  color: var(--text);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  unicode-bidi: plaintext;
  font-variant-numeric: tabular-nums;
}
.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}
.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

/* ---------- numbers ---------- */

.big-number {
  display: block;
  font-size: clamp(2rem, 11vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  unicode-bidi: plaintext;
  text-align: right;
}

.stats {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
  align-items: baseline;
}
.stats dt {
  color: var(--muted);
  font-size: 0.92rem;
}
.stats dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  unicode-bidi: plaintext;
  text-align: right;
}
@media (min-width: 600px) {
  .stats {
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr);
    column-gap: 20px;
  }
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.progress > .bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ---------- tables ---------- */

table.results {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
table.results caption {
  text-align: right;
  padding: 10px 12px 6px;
  font-weight: 700;
}
table.results th,
table.results td {
  padding: 9px 12px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
table.results td {
  unicode-bidi: plaintext;
}
table.results thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  position: sticky;
  top: 0;
}
table.results tbody th {
  font-weight: 600;
  position: sticky;
  right: 0;
  background: var(--surface);
}
table.results tr:last-child > * {
  border-bottom: 0;
}

/* ---------- video ---------- */

.video-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  max-height: 72vh;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.video-box video,
.video-box canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #000;
}
/* ---------- clock ---------- */

.clock-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 100vh;
  min-height: 100svh;
  padding: 16px 8px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: min(12.5vw, 26vh);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'zero' 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: center;
}
.clock-face .muted,
.clock-face .badge,
.clock-face .btn,
.clock-face p {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.5;
  white-space: normal;
  direction: rtl;
}
.clock-face .btn {
  font-weight: 600;
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
