/* ===== متغيرات الألوان: استبدلها بهويتك من هنا فقط ===== */
/* ===== متغيرات الألوان: هوية murtada.net (داكن افتراضيًا) ===== */
:root {
  --bg: #05070f;
  --surface: #0b1128;
  --surface-2: #121a38;
  --text: #e9efff;
  --muted: #9aa8c7;
  --border: #222c55;
  --accent: #63ddff;
  --accent-text: #031018;
  --accent-soft: #0e2a44;
  --ok: #5be39a;
  --ok-soft: #0a2a1f;
  --warn: #f2c14e;
  --warn-soft: #2a2010;
  --danger: #ff8f8f;
  --danger-soft: #2d1218;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  --radius: 12px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f7fc;
  --surface: #ffffff;
  --surface-2: #e8eef9;
  --text: #0e1730;
  --muted: #4a5878;
  --border: #cdd7ea;
  --accent: #2457d6;
  --accent-text: #ffffff;
  --accent-soft: #dde8ff;
  --ok: #1b7443;
  --ok-soft: #dbf0e4;
  --warn: #7f5200;
  --warn-soft: #faedcb;
  --danger: #a82820;
  --danger-soft: #f7dedb;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.1);
  color-scheme: light;
}

/* ===== الأساس ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}

[hidden] {
  display: none !important;
}

h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 1.2rem 0 0.6rem;
}

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.6rem;
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
}

p {
  margin: 0 0 0.8rem;
}

a {
  color: var(--accent);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.offscreen {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
}

.skip {
  position: absolute;
  inset-inline-start: 8px;
  top: -60px;
  background: var(--accent);
  color: var(--accent-text);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 50;
}

.skip:focus {
  top: 8px;
}

/* ===== هيكل التطبيق (شاشة كمبيوتر بلا تمرير) ===== */
body.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  flex: 1 1 auto;
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.back:hover {
  filter: brightness(1.08);
}

.stage-area {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 14px 16px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

.split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
}

.split-main,
.split-side {
  min-height: 0;
  min-width: 0;
  overflow: auto;
}

.split-main {
  display: flex;
  flex-direction: column;
}

.split-main > .screen {
  flex: 1 1 auto;
}

.stage-area > .screen {
  flex: 1 1 auto;
  min-height: 0;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.screen > .display {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.btn-wide {
  width: 100%;
  margin: 0 0 10px;
}

/* ===== الصفحة الرئيسية: مربعات في الوسط ===== */
.hub {
  margin: auto;
  width: 100%;
  max-width: 940px;
  text-align: center;
}

.tiles {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.tile {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.12s, border-color 0.12s, background-color 0.12s;
}

.tile:hover,
.tile:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-3px);
}

.tile-icon {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1;
}

.tile-name {
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
}

.tile-desc {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.hub-note {
  max-width: 640px;
  margin-inline: auto;
}

@media (max-width: 899px) {
  body.app {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .stage-area {
    overflow: visible;
  }

  .split {
    display: block;
  }

  .split-main,
  .split-side {
    overflow: visible;
  }

  .screen > .display {
    min-height: 40vh;
  }

  .topbar {
    flex-wrap: wrap;
  }

  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

/* ===== المكوّنات ===== */
.lead {
  color: var(--muted);
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.card-link {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.card-link h2 {
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.card-link p {
  margin: 0;
  color: var(--muted);
}

.card-link:hover {
  border-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin: 0 0 10px;
}

.row.tight {
  gap: 6px;
  margin: 0;
}

.row-between {
  justify-content: space-between;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field.grow {
  flex: 1 1 160px;
}

.field.narrow {
  flex: 0 0 96px;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

input[type="range"] {
  width: 100%;
  min-height: 32px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 0.6rem;
}

.btn {
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-small {
  min-height: 36px;
  min-width: 36px;
  padding: 4px 10px;
  font-size: 0.9rem;
}

.btn.toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.chip-btn {
  min-height: 40px;
  padding: 4px 14px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.chip-btn.selected,
.chip-btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  min-height: 36px;
}

.check input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 12px;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.plain-list li:last-child {
  border-bottom: 0;
}

ol.plain-list {
  list-style: decimal;
  padding-inline-start: 1.4rem;
}

.notice {
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 14px;
  font-size: 0.95rem;
}

.notice-info {
  background: var(--accent-soft);
  color: var(--text);
}

.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: 16px;
  max-width: 420px;
  margin-inline: auto;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 60;
}

.toast.show {
  opacity: 1;
}

/* ===== شاشات العرض الكبيرة ===== */
.screen {
  margin: 0 0 14px;
}

.screen:fullscreen {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  overflow: auto;
}

.display {
  border-radius: var(--radius);
  border: 2px solid var(--border);
  padding: 18px 12px 12px;
  text-align: center;
  transition: background-color 0.3s, color 0.3s;
}

.display.state-ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.display.state-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.display.state-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.meter-fill.state-ok {
  background: var(--ok);
}

.meter-fill.state-warn {
  background: var(--warn);
}

.meter-fill.state-danger {
  background: var(--danger);
}

.big-time {
  direction: ltr;
  font-size: clamp(3.4rem, min(16vw, 30vh), 12rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.big-name {
  font-size: clamp(2.2rem, min(9vw, 18vh), 7rem);
  font-weight: 700;
  line-height: 1.25;
  min-height: 1.4em;
  overflow-wrap: anywhere;
}

.status {
  min-height: 1.6em;
  margin: 6px 0 0;
  font-weight: 600;
}

.progress {
  height: 10px;
  margin: 10px 0 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: currentColor;
  transition: width 0.2s linear;
}

.controls {
  margin: 12px 0 0;
  justify-content: center;
  align-items: center;
}

.phase-name {
  font-size: clamp(1.6rem, 7vw, 3rem);
  font-weight: 700;
  margin: 0 0 4px;
}

.phase-time {
  direction: ltr;
  font-size: clamp(3rem, min(14vw, 24vh), 9rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ===== مخطط الحصة ===== */
.phase-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  font-size: 0.9rem;
}

.chips li {
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.chips li.done {
  text-decoration: line-through;
}

.chips li.current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 700;
}

/* ===== المجموعات ===== */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
  margin: 0 0 12px;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.role {
  font-size: 0.85rem;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
}

/* ===== المقاعد ===== */
.board-label {
  text-align: center;
  padding: 6px;
  margin: 0 0 10px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-weight: 700;
}

.seat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 6px;
}

.seat-grid {
  display: grid;
  gap: 8px;
  min-height: 100%;
  grid-auto-rows: minmax(48px, 1fr);
}

.seat {
  min-height: 48px;
  padding: 4px 6px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.seat.empty {
  color: var(--muted);
  border-style: dashed;
  background: var(--surface-2);
}

.seat.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.unseated-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== عدّاد الضجيج ===== */
.meter {
  position: relative;
  direction: ltr;
  height: 56px;
  margin: 10px 0;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  transition: width 0.08s linear;
}

.meter-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  margin-left: -2px;
  background: var(--text);
}

.level-value {
  font-size: clamp(2.5rem, min(12vw, 22vh), 7rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* ===== لوحة التعليمات ===== */
.board-view {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0 0 14px;
  position: relative;
  flex: 1 1 auto;
  overflow: auto;
}

.board-title {
  font-size: 2em;
  margin: 0 0 0.4em;
  line-height: 1.25;
}

.board-list {
  font-size: 1.5em;
  padding-inline-start: 1.5em;
  margin: 0 0 0.6em;
}

.board-list li {
  margin: 0 0 0.4em;
}

.board-note {
  font-size: 1.3em;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  margin: 0 0 0.6em;
  white-space: pre-line;
}

.level-chip {
  display: inline-block;
  font-size: 1.3em;
  font-weight: 700;
  padding: 4px 18px;
  border-radius: 999px;
  margin: 0 0 0.4em;
}

.level-chip.lvl-0 {
  background: var(--danger-soft);
  color: var(--danger);
}

.level-chip.lvl-1 {
  background: var(--warn-soft);
  color: var(--warn);
}

.level-chip.lvl-2 {
  background: var(--accent-soft);
  color: var(--text);
}

.level-chip.lvl-3 {
  background: var(--ok-soft);
  color: var(--ok);
}

.clock {
  direction: ltr;
  text-align: start;
  font-size: 1.4em;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 0.3em;
}

/* ===== وضع العرض ===== */
.present-only {
  display: none;
}

body.present .no-present {
  display: none !important;
}

body.present .present-only {
  display: block;
  position: fixed;
  inset-block-end: 16px;
  inset-inline-start: 16px;
  z-index: 40;
}

body.present .board-view {
  border: 0;
}

body.present .split {
  display: block;
}

body.present .stage-area {
  max-width: none;
  padding: 0;
}

/* ===== الطباعة ===== */
@media print {
  body {
    background: Canvas;
    color: CanvasText;
  }

  body.app {
    height: auto;
    overflow: visible;
    display: block;
  }

  .stage-area,
  .split-main,
  .split-side {
    overflow: visible;
    display: block;
  }

  .split {
    display: block;
  }

  .no-print,
  .topbar,
  .toast,
  .controls {
    display: none !important;
  }

  .panel,
  .card,
  .group-card {
    box-shadow: none;
    break-inside: avoid;
  }

  .seat.selected {
    background: transparent;
    border-color: CanvasText;
  }
}

/* ===== تقليل الحركة ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


/* ===== هوية الموقع: ترويسة وخلفية وتذييل ===== */
:root:not([data-theme="light"]) body.app {
  background:
    radial-gradient(900px 480px at 88% -80px, rgba(132, 85, 255, .18), transparent 70%),
    radial-gradient(760px 420px at 4% 60px, rgba(99, 221, 255, .11), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
:root:not([data-theme="light"]) .topbar {
  background: linear-gradient(120deg, #0b1736 0%, #171446 58%, #0b2038 100%);
  border-bottom-color: transparent;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  position: relative;
}
:root:not([data-theme="light"]) .topbar::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, #63ddff, #4d8cff, #8455ff, transparent);
}
.brand-mini { flex: none; width: 32px; height: 32px; border-radius: 9px; overflow: hidden; box-shadow: 0 0 0 1px rgba(99, 221, 255, .38); }
.brand-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rights { flex: none; padding: 14px 16px 18px; text-align: center; font-size: .78rem; color: var(--muted); }
.mn-link { color: inherit; text-decoration: none; display: inline-flex; }
