@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #0f1119;
  --panel: #181c28;
  --panel-strong: #202537;
  --stroke: #30364c;
  --text: #f4f4fa;
  --muted: #a7aec6;
  --accent: #bbb1ff;
  --mint: #76dfbf;
  font-family: "IBM Plex Sans Arabic", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .62; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }

.topbar { min-height: 4.7rem; padding: .8rem max(1.5rem, calc((100vw - 90rem) / 2)); display: flex; align-items: center; justify-content: space-between; gap: 1.15rem; border-bottom: 1px solid #242838; background: #121520; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-size: 1.1rem; font-weight: 700; text-decoration: none; white-space: nowrap; }
.brand-logo { display: block; flex: none; width: clamp(4.9rem, 9vw, 7.25rem); height: auto; }
nav { display: flex; gap: .25rem; padding: .25rem; background: #1b1e2c; border-radius: .7rem; }
.nav-button { border: 0; border-radius: .5rem; background: transparent; color: var(--muted); padding: .43rem .95rem; min-height: 2.4rem; white-space: nowrap; }
.nav-button:hover, .nav-button.current { background: #2a2941; color: #e5dcff; }
.connection-panel { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .5rem .65rem; }
.connection { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .86rem; }
.connection i, .indicator { width: .45rem; height: .45rem; border-radius: 50%; flex: none; background: #e4b67d; }
.connection.live i { background: var(--mint); }
.owner-signin { padding: .3rem .65rem; border: 1px solid var(--stroke); border-radius: .55rem; background: var(--panel); color: var(--text); text-decoration: none; white-space: nowrap; font-size: .86rem; }
.owner-signin:hover { background: var(--panel-strong); }

.layout { width: min(90rem, calc(100% - 3rem)); margin: 1.65rem auto 2rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(17.5rem, 20rem); gap: 1.1rem; align-items: start; }
.layout[data-page="chat"] { display: block; }
.layout[data-page="chat"] .side { display: none; }
.topbar > nav { max-width: 100%; overflow-x: auto; }
.workspace { min-width: 0; }
.workspace-intro { display: flex; align-items: center; justify-content: space-between; gap: .9rem; margin-bottom: 1rem; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); line-height: 1.3; letter-spacing: -.025em; }
.workspace-intro p, .team-header p { color: var(--muted); font-size: .94rem; margin-top: .2rem; }
.primary, .secondary { font-weight: 600; border-radius: .6rem; border: 1px solid transparent; padding: .57rem .95rem; min-height: 2.6rem; transition: background 120ms linear; }
.primary { color: #17132c; background: #b8aafa; }
.primary:hover { background: #d0c5ff; }
.secondary { background: #1a1e2c; color: var(--text); border-color: var(--stroke); }
.secondary:hover { background: #292e43; }

.scene { position: relative; height: clamp(25rem, 60vh, 42rem); isolation: isolate; border: 1px solid #363953; border-radius: .95rem; overflow: hidden; background: radial-gradient(ellipse at 50% 50%, #242a47, #10131f 78%); }
.scene-canvas { position: absolute; inset: 0; min-height: 0; overflow: hidden; direction: ltr; }
.scene-canvas canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.team-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1rem 0 .6rem; }
.team-header h2, .workspace-card h2 { font-size: 1.1rem; }
.roster { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .55rem; }
.employee { min-width: 0; text-align: start; display: flex; align-items: center; gap: .6rem; color: var(--text); padding: .55rem; border: 1px solid #2c3145; border-radius: .65rem; background: #171a26; }
.employee[aria-pressed="true"], .employee:hover { border-color: #9b8ee6; background: #252439; }
.employee span:last-child { min-width: 0; }
.employee strong, .employee small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.employee strong { font-size: .91rem; }
.employee small { color: var(--muted); font-size: .78rem; }
.employee .avatar { width: 2rem; height: 2rem; border-radius: .52rem; font-size: .75rem; }

.side { position: sticky; top: 1rem; min-width: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid #30354a; border-radius: .95rem; padding: 1.15rem; }
.side-label { color: var(--muted); font-size: .87rem; display: flex; align-items: center; gap: .55rem; margin-bottom: 1.05rem; }
.indicator { background: var(--accent); }
.person { display: flex; align-items: center; gap: .85rem; }
.avatar { display: inline-grid; place-items: center; border: 1px solid color-mix(in srgb, var(--avatar-color, #b8aafa) 56%, transparent); background: color-mix(in srgb, var(--avatar-color, #b8aafa) 23%, #12151f); color: var(--avatar-color, #b8aafa); border-radius: .85rem; width: 3.55rem; height: 3.55rem; flex: none; font-size: 1rem; font-weight: 700; }
.person h2 { font-size: 1.35rem; line-height: 1.25; }
.person p { font-size: .9rem; color: #c5bae9; }
.agent-description { margin: 1rem 0; color: var(--muted); line-height: 1.65; }
.rule { height: 1px; background: var(--stroke); margin-bottom: .85rem; }
.side h3 { font-size: 1rem; }
.jobs { padding-inline-start: 1.15rem; margin: .45rem 0 1.05rem; color: #d8daea; line-height: 1.7; }
.jobs li::marker { color: #ac9af7; }
.side-bottom { display: grid; gap: .55rem; margin-top: auto; }
.task-status { justify-self: start; color: var(--mint); font-size: .88rem; }
.task-detail { color: var(--muted); font-size: .87rem; min-height: 1.35rem; }

.workspace-card, .delivery-card, .empty { padding: 1.15rem; background: var(--panel); border: 1px solid #30354a; border-radius: .85rem; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .9rem; }
.fields label { display: grid; gap: .36rem; align-content: start; font-weight: 600; }
.fields .full { grid-column: 1/-1; }
.fields input, .fields textarea { width: 100%; min-width: 0; color: var(--text); padding: .6rem .75rem; background: #121520; border: 1px solid var(--stroke); border-radius: .55rem; font-weight: 400; }
.fields textarea { resize: vertical; min-height: 6rem; }
.fields input::placeholder, .fields textarea::placeholder { color: #969db6; }
.form-actions { margin-top: .9rem; display: flex; align-items: center; gap: .65rem; }
.form-actions span { color: var(--mint); }
.campaign-flow { margin-top: .8rem; }
.campaign-flow p, .empty { color: var(--muted); }
.team-checks { display: flex; gap: .5rem; flex-wrap: wrap; margin: .7rem 0 .9rem; }
.team-checks label { display: flex; align-items: center; gap: .45rem; background: #222639; border-radius: .45rem; padding: .43rem .6rem; }
.team-checks input { accent-color: var(--accent); }
.deliverables { display: grid; gap: .7rem; }
.delivery-meta { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.delivery-meta span { font-size: .82rem; color: var(--mint); }
.delivery-card p { white-space: pre-wrap; overflow-wrap: anywhere; color: #dcdff1; margin: .7rem 0 .9rem; line-height: 1.75; }
.delivery-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.delivery-summary { display: grid; gap: .75rem; margin-bottom: .85rem; }
.delivery-summary p { color: var(--muted); }
.delivery-index { display: flex; flex-wrap: wrap; gap: .4rem; }
.delivery-index a { display: inline-flex; align-items: center; min-height: 2.15rem; text-decoration: none; border: 1px solid var(--stroke); padding: .2rem .55rem; border-radius: .45rem; }
.delivery-index a:hover { background: var(--panel-strong); }
.delivery-index a[data-ready="false"] { color: var(--muted); }
.design-assets { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .7rem; margin: .8rem 0 1rem; }
.design-asset { margin: 0; background: #111421; border: 1px solid var(--stroke); border-radius: .65rem; padding: .65rem; display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.design-asset figcaption { font-weight: 600; }
.design-asset canvas { display: block; width: 100%; height: clamp(10rem, 36vw, 18rem); object-fit: contain; background: #0f1119; border-radius: .4rem; }
.design-asset button { margin-top: auto; align-self: flex-start; }
footer { display: flex; justify-content: space-between; gap: .6rem; width: min(90rem, calc(100% - 3rem)); margin: 1.75rem auto 1rem; padding-top: .8rem; color: var(--muted); border-top: 1px solid #272b3d; font-size: .83rem; }

@media (max-width: 61rem) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(14rem, 17rem); width: calc(100% - 2rem); }
  .roster { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 46rem) {
  .topbar { padding: .6rem .85rem; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .55rem; }
  .topbar nav { grid-column: 1/-1; grid-row: 2; width: fit-content; }
  .connection, .owner-signin { font-size: .73rem; }
  .layout { grid-template-columns: minmax(0,1fr); width: calc(100% - 1.5rem); margin: 1rem auto; }
  .scene { height: min(59vh, 30rem); min-height: 20rem; }
  .side { position: static; }
  .workspace-intro { align-items: start; }
  .workspace-intro button { flex: none; }
  footer { width: calc(100% - 1.5rem); }
}
@media (max-width: 28rem) {
  .fields { grid-template-columns: minmax(0,1fr); }
  .workspace-intro p { font-size: .83rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
