:root {
  --bg: #F3F5F8; --card: #FFFFFF; --ink: #1B2430; --muted: #5A6472; --line: #DDE2E8;
  --blue: #1272B8; --coral: #D2412A; --green: #12796B; --purple: #8A54C9; --pink: #C7327C;
  --amber: #F5B32E; --amber-ink: #3A2A05;
  --r: 14px; --bar-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 'Heebo', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif; }
body { padding-bottom: calc(var(--bar-h) + 16px); }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; }

header { background: var(--blue); color: #fff; padding: 14px 16px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20; }
header h1 { font-size: 19px; margin: 0; font-weight: 700; }
header .sub { font-size: 13px; opacity: .92; }
.iconbtn { background: transparent; border: 0; color: inherit; min-width: 44px; min-height: 44px;
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.iconbtn:hover { background: rgba(255,255,255,.15); }
.iconbtn svg { width: 22px; height: 22px; }

main { max-width: 860px; margin: 0 auto; padding: 16px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { border-radius: var(--r); padding: 12px; color: #fff; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { font-size: 13px; }
.s-open { background: var(--coral); } .s-auto { background: var(--green); } .s-learn { background: var(--purple); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px; margin-bottom: 12px; }
.card.open { border-inline-start: 5px solid var(--coral); }
.card.answered { border-inline-start: 5px solid var(--green); }
.card.resolved { border-inline-start: 5px solid var(--purple); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: #fff; background: var(--blue); }
.chip.coral { background: var(--coral); } .chip.green { background: var(--green); }
.chip.purple { background: var(--purple); } .chip.pink { background: var(--pink); }
.chip.amber { background: var(--amber); color: var(--amber-ink); }
.q { font-size: 17px; font-weight: 700; margin: 8px 0 4px; }
.orig { white-space: pre-wrap; color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.draft { background: var(--bg); border-radius: 10px; padding: 10px; white-space: pre-wrap; font-size: 15px; margin: 8px 0; }
.draft .lbl { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.ts { direction: ltr; unicode-bidi: isolate; }

textarea, input[type=text], input[type=tel], input[type=password] { width: 100%; border: 1px solid #B9C1CB;
  border-radius: 10px; padding: 10px 12px; background: #fff; }
textarea { min-height: 96px; resize: vertical; }
textarea:focus, input:focus { outline: 3px solid rgba(18,114,184,.35); border-color: var(--blue); }
label.field { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 8px; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn { border: 0; border-radius: 10px; min-height: 44px; padding: 0 16px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; color: #fff; background: var(--blue); }
.btn svg { width: 18px; height: 18px; }
.btn.green { background: var(--green); } .btn.coral { background: var(--coral); }
.btn.purple { background: var(--purple); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid #B9C1CB; }
.btn:disabled { opacity: .55; cursor: default; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--green); }
.hint { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
h2 { font-size: 18px; margin: 4px 0 12px; }

nav.bar { position: fixed; bottom: 0; inset-inline: 0; height: var(--bar-h); background: var(--card);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); z-index: 30; }
nav.bar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); cursor: pointer; position: relative; }
nav.bar button svg { width: 22px; height: 22px; }
nav.bar button.on { color: var(--blue); font-weight: 700; }
nav.bar .badge { position: absolute; top: 6px; inset-inline-start: calc(50% + 6px); background: var(--coral);
  color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }
nav.bar .badge[hidden] { display: none; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
td, th { text-align: start; padding: 10px 6px; border-bottom: 1px solid var(--line); }
@media (max-width: 600px) {
  table.cards thead { display: none; }
  table.cards tr { display: block; border: 1px solid var(--line); border-radius: 12px; padding: 8px; margin-bottom: 8px; background: var(--card); }
  table.cards td { display: flex; justify-content: space-between; border: 0; padding: 4px 6px; }
  table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 13px; }
}

.toast { position: fixed; bottom: calc(var(--bar-h) + 12px); inset-inline: 16px; margin: 0 auto; max-width: 480px;
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; z-index: 60; font-size: 15px; }
.toast[hidden] { display: none; }
.toast.err { background: var(--coral); }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.55); z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px; }
.modal-bg[hidden] { display: none; }
.modal { background: var(--card); border-radius: var(--r); padding: 18px; width: 100%; max-width: 440px; }
.modal > * { max-width: 100%; }
.modal h3 { margin: 0 0 8px; font-size: 18px; }

.wtip { position: relative; }
.wtip:hover::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); inset-inline-end: 0;
  background: var(--ink); color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 40; }
@media (hover: none) { .wtip:hover::after { display: none; } }

.login { max-width: 380px; margin: 12vh auto 0; padding: 16px; }
.login .card { padding: 22px; }
.err-text { color: var(--coral); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* ── תרגול ── */
#chat { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.bubble { border-radius: var(--r); padding: 12px; max-width: 92%; }
.bubble.me { align-self: flex-start; background: var(--blue); color: #fff; white-space: pre-wrap; }
.bubble.bot { align-self: flex-end; background: var(--card); border: 1px solid var(--line); width: 92%; }
.srcs { font-size: 13px; color: var(--muted); margin: 4px 0; }
.srcs summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.srcs ul { margin: 4px 0; padding-inline-start: 18px; }
.composer { position: sticky; bottom: calc(var(--bar-h) + 8px); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px; box-shadow: 0 4px 16px rgba(15,23,32,.08); }
.composer textarea { min-height: 56px; }
.composer .row { margin-top: 8px; }
