/* ============================================================
   XBoard Meeting — مجلس — design system
   Dark executive boardroom (default) + warm light theme.
   Full RTL support. */

:root {
  --font-body: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', 'Amiri', Georgia, serif;

  --bg: #0b0d12;
  --bg-grad: radial-gradient(1200px 700px at 70% -10%, rgba(212, 175, 106, .07), transparent 60%),
             radial-gradient(900px 600px at 0% 100%, rgba(90, 110, 160, .06), transparent 60%);
  --surface: #12151c;
  --card: #161a23;
  --card-2: #1b202c;
  --border: #262d3b;
  --border-soft: #1f2531;
  --text: #eae8e3;
  --muted: #97a0b3;
  --accent: #d4af6a;
  --accent-2: #e8c988;
  --accent-ink: #241c0c;
  --ok: #6fbf8f;
  --warn: #e0b46a;
  --bad: #e07a6a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .25);
}

[data-theme='light'] {
  --bg: #f5f3ed;
  --bg-grad: radial-gradient(1200px 700px at 70% -10%, rgba(168, 129, 58, .08), transparent 60%),
             radial-gradient(900px 600px at 0% 100%, rgba(90, 110, 160, .05), transparent 60%);
  --surface: #fdfcf9;
  --card: #ffffff;
  --card-2: #faf8f3;
  --border: #e3ddcf;
  --border-soft: #ece7db;
  --text: #24262e;
  --muted: #6d7482;
  --accent: #a8813a;
  --accent-2: #8d6a2b;
  --accent-ink: #fff;
  --ok: #3d8f63;
  --warn: #a87f2e;
  --bad: #bf5a4a;
  --shadow: 0 10px 30px rgba(80, 70, 40, .12);
  --shadow-sm: 0 2px 10px rgba(80, 70, 40, .08);
}

html[dir='rtl'] {
  --font-body: 'Cairo', 'Inter', -apple-system, sans-serif;
  --font-display: 'Amiri', 'Playfair Display', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(212, 175, 106, .3); }
a { color: var(--accent); }

.icon { display: inline-flex; width: 18px; height: 18px; vertical-align: -3px; }
.icon svg { width: 100%; height: 100%; }
.crown { width: 13px; height: 13px; color: var(--accent); margin-inline-start: 6px; }

/* ------------------------------- top bar ------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.brand-icon { width: 26px; height: 26px; color: var(--accent); }
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand-sub { color: var(--accent); font-size: 15px; opacity: .85; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; transition: all .18s;
}
.iconbtn:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-1px); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px;
  background: var(--card); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.chip-credits { color: var(--ok); font-weight: 600; }
.chip.flash { animation: flash .5s ease 2; }
@keyframes flash { 50% { border-color: var(--bad); color: var(--bad); } }

/* ------------------------------- gate ------------------------------- */
.gate { min-height: calc(100vh - 0px); display: grid; place-items: center; padding: 24px; }
.gate-card {
  width: min(430px, 100%);
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 44px 36px; text-align: center; box-shadow: var(--shadow);
  animation: rise .5s ease both;
}
.gate-logo { width: 54px; height: 54px; margin: 0 auto 18px; color: var(--accent); }
.gate-logo .icon, .gate-logo svg { width: 100%; height: 100%; }
.gate-title { font-family: var(--font-display); font-size: 30px; margin-bottom: 4px; }
.gate-title-ar { color: var(--accent); }
.gate-tag { color: var(--muted); font-size: 14px; margin: 10px 0 26px; }
.gate-input { text-align: center; letter-spacing: 2px; }
.gate-btn { width: 100%; margin-top: 14px; }
.gate-err { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* ------------------------------ inputs ------------------------------ */
.input {
  width: 100%; padding: 12px 16px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--border);
  color: var(--text); font: inherit; transition: border .18s, box-shadow .18s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212, 175, 106, .15); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
textarea.input { resize: vertical; min-height: 130px; line-height: 1.7; }
select.input { max-width: 420px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); border: none;
}
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
.btn-ghost { background: transparent; color: var(--muted); }

/* ------------------------------ lobby ------------------------------ */
.container { max-width: 1060px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; }
.panel {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 18px;
  padding: 26px 28px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
  animation: rise .45s ease both;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin-bottom: 4px; }
.page-title { font-size: 26px; margin: 6px 0 18px; }
.panel-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; max-width: 720px; }

.depth-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.depth-btn {
  display: flex; flex-direction: column; gap: 4px; text-align: start;
  padding: 14px 18px; border-radius: 14px; cursor: pointer; font: inherit;
  background: var(--card-2); border: 1.5px solid var(--border); color: var(--text);
  transition: all .18s;
}
.depth-btn:hover { border-color: var(--accent); }
.depth-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card-2)); box-shadow: 0 0 0 3px rgba(212, 175, 106, .12); }
.depth-name { font-weight: 700; font-size: 15px; }
.depth-desc { color: var(--muted); font-size: 12px; }

.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 12px; margin-top: 6px; }
.mcard {
  background: var(--card-2); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 14px 15px; cursor: pointer; transition: all .16s; position: relative;
}
.mcard:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.mcard.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card-2)); box-shadow: 0 0 0 3px rgba(212, 175, 106, .1); }
.mcard-top { display: flex; align-items: center; gap: 10px; }
.mcard-names { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mcard-persona { font-weight: 700; font-size: 14.5px; }
.mcard-brand { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard-check { color: var(--accent); font-weight: 800; font-size: 16px; width: 18px; }
.mcard-tag { color: var(--muted); font-size: 12px; margin-top: 9px; min-height: 32px; }
.mcard-price { color: var(--accent); font-size: 11.5px; font-weight: 600; margin-top: 4px; }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  font-family: var(--font-display); font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #8a744d, #5c4d33);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .18);
}
.avatar.sm { width: 30px; height: 30px; font-size: 15px; }
[data-m='opus']    .avatar, .avatar[data-m='opus']    { background: linear-gradient(135deg, #c9a35c, #8a6a2e); }
[data-m='gpt']     .avatar, .avatar[data-m='gpt']     { background: linear-gradient(135deg, #3fa08c, #1f6f5f); }
[data-m='gemini']  .avatar, .avatar[data-m='gemini']  { background: linear-gradient(135deg, #5a8ede, #3660a8); }
[data-m='grok']    .avatar, .avatar[data-m='grok']    { background: linear-gradient(135deg, #d06a5a, #9c4436); }
.avatar[data-m='deepseek'] { background: linear-gradient(135deg, #6a74d9, #434da3); }
.avatar[data-m='kimi']     { background: linear-gradient(135deg, #9a68c9, #6a4293); }
.avatar[data-m='qwen']     { background: linear-gradient(135deg, #d98e4a, #a3611f); }
.avatar[data-m='mimo']     { background: linear-gradient(135deg, #48a8bf, #26768a); }
.avatar[data-m='glm']      { background: linear-gradient(135deg, #5cae72, #37804c); }
.avatar[data-m='minimax']  { background: linear-gradient(135deg, #cf6d96, #9c4168); }
.avatar[data-m='fable']    { background: linear-gradient(135deg, #e0b45c, #a97c1e); }
.avatar[data-m='sonnet']   { background: linear-gradient(135deg, #7e8ba3, #55617a); }
.avatar[data-m='mistral']  { background: linear-gradient(135deg, #d9a23f, #a0731a); }
.avatar[data-m='llama']    { background: linear-gradient(135deg, #6d8bb5, #46618a); }
.avatar[data-m='command']  { background: linear-gradient(135deg, #4aa88a, #2c7a60); }
.avatar[data-m='sonar']    { background: linear-gradient(135deg, #52a3d9, #2f74a8); }
.avatar[data-m='nova']     { background: linear-gradient(135deg, #5c6db5, #3a4787); }
.avatar[data-m='nemotron'] { background: linear-gradient(135deg, #8fae4a, #647f27); }
.avatar[data-m='seed']     { background: linear-gradient(135deg, #d97b6a, #a34e3e); }
.avatar[data-m='hunyuan']  { background: linear-gradient(135deg, #8a6dd9, #5c43a3); }
.avatar[data-m='jamba']    { background: linear-gradient(135deg, #b58a5c, #85603a); }

.chair-select { margin-top: 4px; }

.convene-panel { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.est { font-size: 14px; color: var(--muted); flex: 1; min-width: 220px; }
.est strong { color: var(--accent); font-size: 16px; }
.est-note { display: block; font-size: 11.5px; opacity: .75; }
.warn { color: var(--bad); font-size: 13px; font-weight: 600; }
.btn-convene { font-size: 16px; padding: 14px 30px; border-radius: 14px; }

.loading { text-align: center; color: var(--muted); padding: 60px; font-size: 24px; }
.empty { color: var(--muted); padding: 20px 0; }

/* ------------------------------ meeting ------------------------------ */
.meet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.meet-brief {
  font-family: var(--font-display); font-size: 18px; line-height: 1.5; max-width: 700px;
  border-inline-start: 3px solid var(--accent); padding-inline-start: 14px;
}
.meet-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meet-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s ease infinite; }
.dot-done { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.chip-cost { color: var(--accent); }

.stepper {
  position: sticky; top: 61px; z-index: 40;
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px; margin-bottom: 18px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  scrollbar-width: none;
}
.stepper::-webkit-scrollbar { display: none; }
.step {
  flex: none; padding: 6px 15px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); color: var(--muted); background: var(--card);
  transition: all .25s;
}
.step.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.step.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }

.phase-sec { margin-bottom: 34px; animation: rise .4s ease both; }
.phase-head { margin-bottom: 14px; }
.phase-title { font-family: var(--font-display); font-size: 22px; }
.phase-note { color: var(--muted); font-size: 13px; margin-top: 2px; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(370px, 100%), 1fr)); gap: 14px; }

.speak-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  overflow: hidden; box-shadow: var(--shadow-sm); animation: rise .35s ease both;
  transition: border-color .3s;
}
.speak-card.speaking { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.speak-card.speaking .card-head::after {
  content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sweep 1.6s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.speak-card.absent { opacity: .55; }

.card-head {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--card-2); border-bottom: 1px solid var(--border-soft);
}
.card-names { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.card-persona { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; }
.card-brand { color: var(--muted); font-size: 11.5px; }
.mstatus { font-size: 11.5px; color: var(--muted); font-style: italic; white-space: nowrap; }
.mstatus.ok { color: var(--ok); font-style: normal; }
.cross-target { font-size: 11.5px; color: var(--accent); font-weight: 600; }

.card-body { padding: 14px 18px; max-height: 460px; overflow-y: auto; }
.card-stream { white-space: pre-wrap; font-size: 14px; }
.card-stream p, .card-stream li { white-space: normal; }
.card-stream h2, .card-stream h3, .card-stream h4, .card-stream h5 { font-family: var(--font-body); font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent); margin: 14px 0 6px; white-space: normal; }
.card-stream ul, .card-stream ol { padding-inline-start: 20px; margin: 6px 0; }
.card-stream li { margin: 3px 0; }
.card-stream p { margin: 7px 0; }
.card-stream blockquote { border-inline-start: 3px solid var(--accent); padding-inline-start: 12px; color: var(--muted); margin: 8px 0; }
.card-stream code { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }
.card-stream pre { background: var(--card-2); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 12.5px; margin: 8px 0; }
.card-stream hr { border: none; border-top: 1px solid var(--border-soft); margin: 12px 0; }
.tblwrap { overflow-x: auto; margin: 10px 0; }
.card-stream table { border-collapse: collapse; font-size: 13px; min-width: 60%; }
.card-stream th, .card-stream td { border: 1px solid var(--border); padding: 6px 10px; text-align: start; }
.card-stream th { background: var(--card-2); }

/* verdict */
.verdict-card { grid-column: 1 / -1; border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.verdict-card .card-body { max-height: none; padding: 20px 28px; }
.verdict-card .card-stream { font-size: 15px; }
.verdict-card .card-stream h1 { font-family: var(--font-display); font-size: 26px; margin: 6px 0 14px; color: var(--text); white-space: normal; }
.verdict-card .card-stream h2 { font-family: var(--font-display); font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--accent); margin: 20px 0 8px; }

/* agreement meter */
.agree { margin-top: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px 18px; }
.agree-row { display: flex; align-items: center; gap: 14px; }
.agree-label { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; white-space: nowrap; }
.agree-bar { flex: 1; height: 9px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border-soft); overflow: hidden; }
.agree-fill { height: 100%; border-radius: 999px; transition: width 1s ease; }
.agree-fill.high { background: linear-gradient(90deg, #4d9d72, #6fbf8f); }
.agree-fill.mid { background: linear-gradient(90deg, #c9a35c, #e0b46a); }
.agree-fill.low { background: linear-gradient(90deg, #c96a5a, #e07a6a); }
.agree-pct { font-weight: 800; font-size: 15px; color: var(--accent); min-width: 44px; text-align: end; }
.agree-crux { margin-top: 8px; font-size: 13px; color: var(--muted); }

.converged {
  margin: -14px 0 30px; padding: 12px 18px; border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--ok) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--border));
  color: var(--ok); animation: rise .4s ease both;
}
.meet-error {
  margin: 10px 0; padding: 12px 18px; border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--bad) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--border));
  color: var(--bad);
}

/* votes */
.vote-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.vote-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 18px; box-shadow: var(--shadow-sm); animation: rise .35s ease both;
}
.vote-card .card-head { background: none; border: none; padding: 0 0 10px; }
.vote-conf { font-weight: 800; color: var(--accent); font-size: 15px; }
.vote-stance { font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.conf-bar { height: 7px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border-soft); overflow: hidden; }
.conf-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .8s ease; }
.vote-rationale { color: var(--muted); font-size: 12.5px; margin-top: 9px; }

/* footer: follow-up + actions */
.meet-footer { margin-top: 10px; animation: rise .4s ease both; }
.followup { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 18px; padding: 22px 26px; margin-bottom: 18px; }
.fu-title { font-family: var(--font-display); font-size: 18px; margin-bottom: 12px; }
.fu-chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.fu-q {
  align-self: flex-end; max-width: 85%;
  background: color-mix(in srgb, var(--accent) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  padding: 9px 15px; border-radius: 14px 14px 4px 14px; font-size: 14px;
}
html[dir='rtl'] .fu-q { border-radius: 14px 14px 14px 4px; }
.fu-a { align-self: flex-start; max-width: 92%; background: var(--card); border: 1px solid var(--border); padding: 10px 16px; border-radius: 14px 14px 14px 4px; font-size: 14px; }
html[dir='rtl'] .fu-a { border-radius: 14px 14px 4px 14px; }
.fu-row { display: flex; gap: 10px; }
.fu-input { flex: 1; }
.meet-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------ history ------------------------------ */
.hist-item {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 15px 20px; margin-bottom: 10px; transition: border-color .18s;
}
.hist-item:hover { border-color: var(--accent); }
.hist-main { flex: 1; min-width: 0; cursor: pointer; }
.hist-brief { font-weight: 600; font-size: 14.5px; }
.hist-meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.hist-actions { display: flex; gap: 8px; flex: none; }

/* ------------------------------ misc ------------------------------ */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 720px) {
  body { font-size: 15px; }
  .depth-row { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .panel { padding: 20px 18px; }
  .verdict-card .card-body { padding: 16px; }
  .meet-actions { justify-content: stretch; }
  .meet-actions .btn { flex: 1; }
  .hist-item { flex-direction: column; align-items: stretch; }
  .hist-actions { justify-content: flex-end; }
  .stepper { top: 57px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}
