:root {
  --paper: #ffffff; --bg: #f6f7fb; --ink: #16152e; --ink-soft: #2b2a49; --muted: #5b5a72;
  --glow: #5b4fe8; --glow-soft: #e4e1fb; --hairline: #e7e6ef; --danger: #b42318; --ok: #05603a;
  --radius: 1rem; --shadow-card: 0 16px 40px -20px rgba(22,21,46,.28);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Rubik, "Noto Sans Hebrew", system-ui, sans-serif; font-size: 15px; line-height: 1.55; }
button, input, textarea { font: inherit; color: inherit; }
code, .ltr { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Menlo, monospace; font-size: .92em; }
bdi { unicode-bidi: isolate; }
[hidden] { display: none !important; }

/* ---------- sign-in ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.card { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 28px; width: min(420px, 100%); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand img { height: 30px; }
.brand h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .85rem; color: var(--muted); }
.field input { padding: 10px 12px; border: 1px solid var(--hairline); border-radius: 10px; background: #fff; }
.field input:focus { outline: 2px solid var(--glow-soft); border-color: var(--glow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--hairline); background: #fff; cursor: pointer; }
.btn:hover { background: #fafafe; }
.btn.primary { background: var(--glow); border-color: var(--glow); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 8px; }
.btn.ghost:hover { background: var(--glow-soft); color: var(--ink); }
.btn[disabled] { opacity: .55; cursor: default; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--hairline); }
.error { color: var(--danger); font-size: .9rem; min-height: 1.2em; margin-top: 8px; }
.note { color: var(--muted); font-size: .85rem; }

/* ---------- app shell ---------- */
.app { height: 100%; display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; grid-template-rows: 56px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px; background: var(--paper); border-bottom: 1px solid var(--hairline); }
.topbar .brand { margin: 0; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: .9rem; }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--glow-soft); color: var(--glow); }
.rail { border-inline-end: 1px solid var(--hairline); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.rail .head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--hairline); font-weight: 600; }
.rail ul { list-style: none; margin: 0; padding: 8px; overflow: auto; }
.rail li { display: flex; align-items: center; gap: 6px; }
.rail li a { flex: 1; display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail li a:hover { background: var(--bg); }
.rail li.active a { background: var(--glow-soft); color: var(--glow); font-weight: 500; }
.rail li .btn.ghost { padding: 4px 6px; opacity: 0; }
.rail li:hover .btn.ghost, .rail li.active .btn.ghost { opacity: 1; }

.chat { display: flex; flex-direction: column; min-height: 0; position: relative; }
.messages { flex: 1; overflow: auto; padding: 20px clamp(12px, 4vw, 48px); display: flex; flex-direction: column; gap: 14px; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 420px; }
.empty h2 { font-weight: 600; color: var(--ink); font-size: 1.1rem; }
.row { display: flex; gap: 10px; align-items: flex-start; direction: ltr; }
.row.user { justify-content: flex-end; }
.bubble { direction: rtl; max-width: 82%; padding: 10px 14px; border-radius: 16px; background: var(--paper); border: 1px solid var(--hairline); overflow-wrap: anywhere; }
.row.user .bubble { background: var(--glow); color: #fff; border-color: var(--glow); }
.row.tool { direction: rtl; }
.row.tool details { font-size: .78rem; color: var(--muted); background: #fbfbfe; border: 1px dashed var(--hairline); border-radius: 10px; padding: 4px 10px; max-width: 82%; }
.row.tool summary { cursor: pointer; list-style: none; }
.row.tool summary.bare { cursor: default; }
.row.tool summary::-webkit-details-marker { display: none; }
.row.tool pre { direction: ltr; text-align: left; margin: 6px 0 2px; padding: 8px; background: #f3f4f8; border-radius: 8px; overflow: auto; max-height: 220px; font-size: .74rem; }
.row.sys { justify-content: center; direction: rtl; }
.sysline { font-size: .8rem; color: var(--muted); background: var(--paper); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px 12px; }
.btn.icon { padding: 6px; line-height: 0; }
.btn.icon svg, .btn.icon-text svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn.icon-text { gap: 6px; }
.bubble p { margin: .3em 0; }
.bubble pre { direction: ltr; text-align: left; background: #f3f4f8; padding: 10px; border-radius: 8px; overflow: auto; }
.bubble table { border-collapse: collapse; margin: .4em 0; }
.bubble td, .bubble th { border: 1px solid var(--hairline); padding: 4px 8px; }
.bubble a { color: inherit; text-decoration: underline; }
.row.user .bubble a { color: #fff; }
.status { padding: 4px clamp(12px, 4vw, 48px); color: var(--muted); font-size: .88rem; min-height: 1.6em; display: flex; align-items: center; gap: 8px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--glow); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .35 } to { opacity: 1 } }
.composer { display: flex; gap: 8px; padding: 12px clamp(12px, 4vw, 48px) 16px; border-top: 1px solid var(--hairline); background: var(--paper); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 200px; padding: 10px 14px; border-radius: 22px; border: 1px solid var(--hairline); background: #fff; }
.composer textarea:focus { outline: 2px solid var(--glow-soft); border-color: var(--glow); }
.composer .btn.primary { border-radius: 22px; min-width: 44px; height: 44px; padding: 0 16px; }
.dropzone { position: absolute; inset: 0; display: none; place-items: center; background: rgba(228,225,251,.85); border: 3px dashed var(--glow); border-radius: 12px; margin: 10px; font-size: 1.1rem; color: var(--ink); z-index: 5; pointer-events: none; }
.chat.dragging .dropzone { display: grid; }
.uploads { padding: 0 clamp(12px, 4vw, 48px); display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--hairline); font-size: .85rem; }
.chip.err { border-color: var(--danger); color: var(--danger); }
.chip.ok { border-color: var(--ok); color: var(--ok); }

.results { border-inline-start: 1px solid var(--hairline); background: var(--paper); display: flex; flex-direction: column; min-height: 0; }
.results .list { padding: 8px 12px; overflow: auto; display: grid; gap: 8px; }
.result { border: 1px solid var(--hairline); border-radius: 10px; padding: 8px 10px; }
.result .name { font-weight: 500; font-size: .9rem; overflow-wrap: anywhere; }
.result .meta { color: var(--muted); font-size: .8rem; }
.result a { color: var(--glow); font-size: .9rem; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px auto minmax(0, 1fr) auto; }
  .rail { border: none; border-bottom: 1px solid var(--hairline); max-height: 160px; }
  .results { border: none; border-top: 1px solid var(--hairline); max-height: 200px; }
  .bubble { max-width: 92%; }
}

/* ---- admin overview ---- */
.adminPanel { position: fixed; inset: 0; background: rgba(22,21,46,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.adminCard { background: var(--paper); border: 1px solid var(--hairline); border-radius: 14px; width: min(920px, 100%); box-shadow: 0 20px 60px rgba(22,21,46,.25); }
.adminHead { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--hairline); }
.adminHead h2 { margin: 0; font-size: 1.05rem; }
#adminBody { padding: 16px 18px; }
.adminInst { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.adminInst > div { background: var(--bg); border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; }
.adminInst span { display: block; color: var(--muted); font-size: .75rem; margin-bottom: 3px; }
.adminInst b { font-size: .9rem; font-weight: 600; }
.adminTable { width: 100%; border-collapse: collapse; font-size: .88rem; }
.adminTable th, .adminTable td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--hairline); }
.adminTable th { color: var(--muted); font-weight: 600; font-size: .78rem; }
.adminTable .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; color: var(--muted); }
.tag { font-size: .68rem; padding: 1px 7px; border-radius: 999px; background: var(--glow-soft); color: var(--glow); }

/* ------------------------------------------------------- files and artifacts -- */
/* A signed download URL inside a message renders as a compact file button. */
.filebtn { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 11px; margin: 2px 0;
  border: 1px solid var(--hairline); border-radius: 999px; background: var(--paper); color: var(--ink);
  text-decoration: none; font-size: .85rem; vertical-align: middle; overflow-wrap: anywhere;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.filebtn:hover { background: var(--glow-soft); border-color: var(--glow); color: var(--glow); transform: translateY(-1px); box-shadow: var(--shadow-card); }
.filebtn:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
.filebtn svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.row.user .filebtn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); color: #fff; }
.row.user .filebtn:hover { background: rgba(255,255,255,.28); border-color: #fff; color: #fff; }

/* The artifacts rail: the whole card is the download. */
.results .list { padding: 10px 12px; overflow: auto; display: grid; gap: 8px; align-content: start; }
.result { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--hairline);
  border-radius: 12px; background: var(--paper); color: inherit; text-decoration: none;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease, background .15s ease; }
a.result:hover { border-color: var(--glow); background: var(--glow-soft); transform: translateY(-1px); box-shadow: var(--shadow-card); }
a.result:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
.result.pending { opacity: .7; }
.result .ficon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px;
  background: var(--glow-soft); color: var(--glow); transition: background .15s ease; }
.result .ficon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a.result:hover .ficon { background: #fff; }
.result .body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.result .name { font-weight: 500; font-size: .88rem; overflow-wrap: anywhere; unicode-bidi: plaintext; text-align: start; }
/* "4 KB · 15.9.2026, 21:14" starts with Latin/digits inside an RTL column; without this the
   number is flung to the far end and reads as "KB · 15.9.2026, 21:14 4". */
.result .meta { color: var(--muted); font-size: .76rem; unicode-bidi: plaintext; text-align: start; }
.result .dl { flex: none; color: var(--muted); opacity: 0; transform: translateY(2px); transition: opacity .15s ease, transform .15s ease, color .15s ease; }
.result .dl svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a.result:hover .dl, a.result:focus-visible .dl { opacity: 1; transform: none; color: var(--glow); }
@media (prefers-reduced-motion: reduce) { .filebtn, .result, .result .dl, .result .ficon { transition: none; } .filebtn:hover, a.result:hover { transform: none; } }

/* Staff previewing the customer view. Marked amber so it never looks like the normal page. */
.btn.viewing { border-color: #b45309; color: #b45309; background: #fffbeb; }
.btn.viewing:hover { background: #fef3c7; }

