:root {
  --bg:        #090c12;
  --bg-1:      #0d1119;
  --bg-2:      #121824;
  --bg-3:      #18202f;
  --border:    #1f2836;
  --border-2:  #2a3547;
  --fg:        #e2e8f0;
  --fg-dim:    #8b98ad;
  --fg-faint:  #5a6779;
  --accent:    #38bdf8;
  --accent-dim:#0ea5e9;
  --green:     #34d399;
  --amber:     #fbbf24;
  --red:       #f87171;
  --violet:    #a78bfa;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); }

/* ------------------------------------------------------------- wordmark */

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.wordmark .glyph {
  width: 9px; height: 9px; border-radius: 2px;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 0 12px rgba(56, 189, 248, .55);
}
.wordmark .dim { color: var(--fg-faint); font-weight: 400; }

/* --------------------------------------------------------------- center */

.center-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(56,189,248,.10), transparent 65%),
    radial-gradient(700px 400px at 90% 110%, rgba(167,139,250,.08), transparent 60%);
}

.card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px 30px;
  box-shadow: 0 24px 60px -20px rgba(0,0,0,.8);
}

.card h1 {
  margin: 20px 0 6px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.card p.sub {
  margin: 0 0 24px;
  color: var(--fg-dim);
  font-size: 13.5px;
}

/* --------------------------------------------------------------- button */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 9px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); background: #1c2637; }
.btn:active { transform: translateY(1px); }
.btn.plain { width: auto; padding: 8px 14px; font-size: 13px; }

.legal {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--fg-faint);
  font-size: 12px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-family: var(--mono);
  border: 1px solid var(--border-2);
  color: var(--fg-dim);
  white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-faint); }
.pill.ok    { color: var(--green); border-color: #34d39944; }
.pill.ok .dot { background: var(--green); box-shadow: 0 0 7px var(--green); }
.pill.warn  { color: var(--amber); border-color: #fbbf2444; }
.pill.warn .dot { background: var(--amber); }
.pill.bad   { color: var(--red); border-color: #f8717144; }
.pill.bad .dot { background: var(--red); }

/* ---------------------------------------------------------------- avatar */

.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: #06121c;
  flex: 0 0 auto;
  text-transform: uppercase;
}
.av-rafiq    { background: linear-gradient(135deg,#38bdf8,#0ea5e9); }
.av-muhaimin { background: linear-gradient(135deg,#34d399,#059669); }
.av-suhail   { background: linear-gradient(135deg,#fbbf24,#f59e0b); }
.av-khairi   { background: linear-gradient(135deg,#a78bfa,#7c3aed); }
.av-default  { background: linear-gradient(135deg,#94a3b8,#64748b); }

/* -------------------------------------------------------------- scrollbar */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #26303f; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #33415a; }

/* ============================================================== app bar */
/* Shared header for the global pages (health / chat / tasks). */

.appbar {
  display: flex; align-items: center; gap: 8px;
  height: 46px; flex: 0 0 auto;
  padding: 0 12px 0 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.appbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; flex: 0 0 auto; }
.appbar .grow { flex: 1 1 auto; }

.gnav { display: flex; gap: 2px; flex: 0 0 auto; }
.gnav a {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: 7px;
  color: var(--fg-dim); font-size: 13px; text-decoration: none;
  position: relative;
}
.gnav a:hover { background: var(--bg-2); color: var(--fg); text-decoration: none; }
.gnav a.active { background: var(--bg-3); color: #fff; box-shadow: inset 0 0 0 1px var(--border-2); }
.gnav a svg { width: 15px; height: 15px; opacity: .85; }
.gnav a .badge {
  min-width: 7px; height: 7px; border-radius: 999px;
  background: var(--accent); box-shadow: 0 0 7px var(--accent);
}

.backlink {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px;
  border-radius: 7px; color: var(--fg-dim); font-size: 13px; text-decoration: none; flex: 0 0 auto;
}
.backlink:hover { background: var(--bg-2); color: var(--fg); text-decoration: none; }
.backlink svg { width: 15px; height: 15px; }

/* -------------------------------------------------------------- presence */

.presence { display: flex; align-items: center; gap: -6px; flex: 0 0 auto; padding-right: 4px; }
.presence .face {
  width: 24px; height: 24px; border-radius: 50%;
  margin-left: -6px; border: 2px solid var(--bg-1);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 600; color: #06121c;
  background: linear-gradient(135deg, #94a3b8, #64748b);
  overflow: hidden;
}
.presence .face img { width: 100%; height: 100%; object-fit: cover; }
.presence .count { margin-left: 8px; color: var(--fg-faint); font-size: 11.5px; white-space: nowrap; }

/* --------------------------------------------------------- account menu */

.account { position: relative; flex: 0 0 auto; }
.account > button {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px;
  background: none; border: 1px solid transparent; border-radius: 20px;
  color: var(--fg-dim); font: inherit; font-size: 12.5px; cursor: pointer;
}
.account > button:hover { border-color: var(--border-2); color: var(--fg); }
.account img.me, .account .avatar { width: 26px; height: 26px; border-radius: 50%; }
.menu {
  position: absolute; top: calc(100% + 7px); right: 0;
  width: 250px; padding: 6px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 11px; box-shadow: 0 22px 50px -14px rgba(0,0,0,.85);
  z-index: 50;
}
.menu[hidden] { display: none; }
.menu .who { padding: 10px 11px 12px; border-bottom: 1px solid var(--border); }
.menu .who .em { font-size: 12.5px; color: var(--fg-dim); word-break: break-all; }
.menu a.item {
  display: block; padding: 9px 11px; margin-top: 5px;
  border-radius: 7px; color: var(--fg); font-size: 13px; text-decoration: none;
}
.menu a.item:hover { background: var(--bg-3); text-decoration: none; }
.menu a.item.danger:hover { background: #7f1d1d40; color: #fca5a5; }

/* ------------------------------------------------------- connection pill */

.connpill { transition: opacity .2s; }
.connpill.hidden { opacity: 0; pointer-events: none; }

/* ========================================================== chat panel */
/* Docked on the right of every page. It reserves its width through
   body padding rather than floating over the content, so it never covers the
   editor or the terminal — and the terminal refits when the gutter changes. */

body { padding-right: var(--yz-chat-w, 0); transition: padding-right .18s ease; }

#yzchat {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--bg-1); border-left: 1px solid var(--border);
  transition: width .18s ease;
}

/* ------------------------------------------------------------ collapsed */
#yzchat.collapsed { width: 44px; align-items: center; }
#yzchat.collapsed > *:not(.rail) { display: none; }
#yzchat .rail {
  display: none; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0; width: 100%; height: 100%;
  background: none; border: none; color: var(--fg-dim);
  font: inherit; cursor: pointer;
}
#yzchat.collapsed .rail { display: flex; }
#yzchat .rail:hover { background: var(--bg-2); color: var(--fg); }
#yzchat .rail svg { width: 17px; height: 17px; flex: 0 0 auto; }
#yzchat .rail .vlabel {
  writing-mode: vertical-rl; letter-spacing: .14em;
  font-size: 10px; text-transform: uppercase; color: var(--fg-faint);
}
#yzchat .rail .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 7px var(--accent);
}
#yzchat .rail .dot[hidden] { display: none; }

/* --------------------------------------------------------------- header */
#yzchat .phd {
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 10px; height: 46px; flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
}
#yzchat .phd select {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  color: var(--fg); font: inherit; font-family: var(--mono); font-size: 13px;
  padding: 5px 6px; cursor: pointer; outline: none;
}
#yzchat .phd select:hover { border-color: var(--border-2); background: var(--bg-2); }
#yzchat .phd select option { background: var(--bg-2); font-family: var(--mono); }
#yzchat .phd button {
  width: 28px; height: 28px; border-radius: 7px; flex: 0 0 auto;
  background: none; border: none; color: var(--fg-faint);
  font-size: 15px; line-height: 1; cursor: pointer;
}
#yzchat .phd button:hover { background: var(--bg-3); color: var(--fg); }

/* ---------------------------------------------------------------- body */
#yzchat .plog {
  flex: 1 1 auto; overflow-y: auto; padding: 12px 10px 4px;
  display: flex; flex-direction: column;
}
#yzchat .plog::before { content: ""; flex: 1 1 auto; }
#yzchat .plog > * { flex: 0 0 auto; }
#yzchat .pday {
  display: flex; align-items: center; gap: 9px;
  margin: 12px 0 9px; color: var(--fg-faint); font-size: 10px;
}
#yzchat .pday::before, #yzchat .pday::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--border);
}

#yzchat .pmsg { display: flex; gap: 8px; padding: 3px 4px; border-radius: 6px; }
#yzchat .pmsg:hover { background: #0f141d; }
#yzchat .pmsg .pf {
  width: 24px; height: 24px; border-radius: 6px; flex: 0 0 auto; overflow: hidden;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 600; color: #06121c;
  background: linear-gradient(135deg, #94a3b8, #64748b);
}
#yzchat .pmsg .pf img { width: 100%; height: 100%; object-fit: cover; }
#yzchat .pmsg .pb { flex: 1 1 auto; min-width: 0; }
#yzchat .pmsg .ph { display: flex; align-items: baseline; gap: 6px; }
#yzchat .pmsg .pw { font-weight: 600; font-size: 12px; color: var(--fg); }
#yzchat .pmsg .pt { color: var(--fg-faint); font-size: 10px; }
#yzchat .pmsg .px {
  font-size: 12.5px; color: #cbd5e1; white-space: pre-wrap;
  overflow-wrap: anywhere; line-height: 1.45;
}
#yzchat .pmsg .px a { color: var(--accent); }
#yzchat .pmsg .px code {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px;
}
#yzchat .pmsg.pcont { margin-top: -3px; }
#yzchat .pmsg.pcont .ph { display: none; }
#yzchat .pmsg.pcont .pf { visibility: hidden; height: 0; }
#yzchat .pempty { color: var(--fg-faint); font-size: 12px; text-align: center; padding: 20px 8px; }

/* ------------------------------------------------------------ composer */
#yzchat .pcomp { flex: 0 0 auto; padding: 6px 10px 12px; }
#yzchat .pcomp .pbox {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 10px; padding: 7px 8px 7px 11px;
}
#yzchat .pcomp .pbox:focus-within { border-color: var(--accent); }
#yzchat .pcomp textarea {
  flex: 1 1 auto; resize: none; border: none; outline: none; background: transparent;
  color: var(--fg); font: inherit; font-size: 12.5px; line-height: 1.5;
  max-height: 140px; min-height: 20px;
}
#yzchat .pcomp textarea::placeholder { color: var(--fg-faint); }
#yzchat .pcomp .psend {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 7px;
  background: var(--bg-3); border: 1px solid var(--border-2);
  color: var(--fg-dim); cursor: pointer; display: grid; place-items: center;
}
#yzchat .pcomp .psend:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
#yzchat .pcomp .psend:disabled { opacity: .4; cursor: default; }
#yzchat .pcomp .psend svg { width: 13px; height: 13px; }
#yzchat .perr { color: var(--red); font-size: 11px; padding: 5px 2px 0; min-height: 6px; }

/* -------------------------------------------------------------- resizer */
#yzchat .pgrip {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; z-index: 2;
}
#yzchat .pgrip:hover, #yzchat .pgrip.dragging { background: #38bdf855; }
#yzchat.collapsed .pgrip { display: none; }
body.yz-resizing { user-select: none; }
body.yz-resizing iframe { pointer-events: none; }
