:root {
  --ink: #12262c;
  --ink-2: #44595f;
  --ink-3: #7a8c91;
  --paper: #f4f7f6;
  --surface: #ffffff;
  --line: #dde6e5;
  --teal: #0f4c5c;
  --teal-2: #16707f;
  --teal-soft: #e3eff1;
  --coral: #d9622b;
  --coral-soft: #fdeee5;
  --amber: #b7791f;
  --amber-soft: #fdf4e1;
  --green: #2f7d5b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 38, 44, .06), 0 6px 24px rgba(18, 38, 44, .06);
  --font: 'Heebo', system-ui, sans-serif;
  --serif: 'Frank Ruhl Libre', 'David', serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--paper);
  background-image: radial-gradient(circle at 100% 0, #e6f1f0 0, transparent 40%);
  line-height: 1.6; font-size: 15px;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal-2) 55%, transparent); outline-offset: 2px; }

/* כותרת */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.5rem; background: var(--teal); color: #fff;
}
.brand { display: flex; align-items: center; gap: .85rem; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: #fff; color: var(--teal); font-size: 1.5rem; font-weight: 800;
}
.brand h1 { margin: 0; font-family: var(--serif); font-size: 1.55rem; letter-spacing: .01em; line-height: 1.1; }
.brand p { margin: 0; font-size: .85rem; opacity: .8; }
.disclaimer-pill {
  font-size: .8rem; font-weight: 600; padding: .35rem .8rem; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); white-space: nowrap;
}

/* פריסה */
.layout {
  display: grid; grid-template-columns: 340px 1fr; gap: 1rem; padding: 1rem;
  height: calc(100vh - 74px); min-height: 600px;
}
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.setup { background: transparent; border: 0; box-shadow: none; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; padding-inline-end: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; gap: .55rem; margin: 0 0 .8rem; font-size: 1.02rem; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--teal-soft); color: var(--teal); font-size: .8rem; font-weight: 700;
}

.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field > span { font-weight: 600; font-size: .88rem; color: var(--ink-2); }
.field select, .field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; background: #fbfdfd;
}
.field textarea { resize: vertical; }
.hint { color: var(--ink-3); font-size: .78rem; line-height: 1.45; }

.switch { display: flex; align-items: center; gap: .7rem; cursor: pointer; padding: .65rem .75rem; border-radius: 10px; background: var(--teal-soft); margin-bottom: .8rem; }
.switch input { position: absolute; opacity: 0; }
.switch .slider { flex: none; width: 40px; height: 22px; border-radius: 999px; background: #b9cacc; position: relative; transition: background .2s; }
.switch .slider::after { content: ''; position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .slider { background: var(--teal-2); }
.switch input:checked + .slider::after { transform: translateX(-18px); }
.switch input:focus-visible + .slider { outline: 3px solid color-mix(in srgb, var(--teal-2) 55%, transparent); outline-offset: 2px; }
.switch small { display: block; color: var(--ink-2); font-size: .78rem; }
.more summary { cursor: pointer; font-weight: 600; color: var(--teal-2); font-size: .9rem; margin-bottom: .6rem; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .25rem;
  border: 2px dashed #b8cfd1; border-radius: 12px; padding: 1.2rem .8rem; cursor: pointer;
  color: var(--ink-2); transition: background .15s, border-color .15s;
}
.dropzone svg { width: 38px; height: 38px; color: var(--teal-2); }
.dropzone strong { color: var(--ink); }
.dropzone span { font-size: .8rem; }
.dropzone.over, .dropzone:hover { background: var(--teal-soft); border-color: var(--teal-2); }

.file-list { list-style: none; padding: 0; margin: .7rem 0 0; display: flex; flex-direction: column; gap: .4rem; }
.file-list li {
  display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; align-items: center;
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; background: #fbfdfd;
}
.file-list .fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.file-list .fname:hover { color: var(--teal-2); }
.file-list .fstatus { grid-column: 1 / -1; color: var(--ink-3); font-size: .76rem; }
.file-list .fstatus.ok { color: var(--green); }
.file-list .fstatus.warn { color: var(--amber); }
.file-list .fstatus.err { color: var(--coral); }
.file-list .remove { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 1.1rem; line-height: 1; }
.file-list progress { grid-column: 1 / -1; width: 100%; height: 4px; accent-color: var(--teal-2); }

.btn { border: 1px solid transparent; border-radius: 10px; padding: .55rem 1rem; font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--coral); color: #fff; }
.btn.primary:not([disabled]):hover { background: #c4521f; }
.btn.big { padding: .85rem 1rem; font-size: 1.05rem; box-shadow: 0 6px 18px rgba(217, 98, 43, .25); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--teal); }
.btn.ghost:not([disabled]):hover { background: var(--teal-soft); }
.run-status { margin: 0; font-size: .85rem; color: var(--ink-2); min-height: 1.4em; }
.run-status.err { color: var(--coral); }

/* מסך מפוצל */
.workspace { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .9fr); gap: 1rem; min-height: 0; }
.results { overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; }
.result-columns { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.result-columns.compare { grid-template-columns: 1fr 1fr; }

.empty-state { margin: auto; max-width: 520px; text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.empty-state h2 { font-family: var(--serif); color: var(--ink); font-size: 1.6rem; margin: .8rem 0 .4rem; }
.empty-art { display: flex; justify-content: center; gap: 8px; }
.empty-art span { width: 54px; height: 70px; border-radius: 8px; background: var(--teal-soft); border: 1px solid #cfe1e3; }
.empty-art span:nth-child(2) { transform: translateY(-10px); background: #fff; box-shadow: var(--shadow); }
.how { text-align: right; display: inline-block; margin-top: .6rem; }
.how li { margin-bottom: .3rem; }

.anon-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .8rem; font-size: .85rem;
  background: #edf7f2; border: 1px solid #cde7da; color: #23573f; padding: .55rem .8rem; border-radius: 10px;
}
.anon-banner b { font-weight: 700; }
.anon-banner .warn { color: var(--amber); }

.result { border: 1px solid var(--line); border-radius: 12px; background: #fff; display: flex; flex-direction: column; min-width: 0; }
.result-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.model-badge { font-weight: 700; color: var(--teal); background: var(--teal-soft); padding: .2rem .65rem; border-radius: 999px; font-size: .85rem; }
.result-meta { color: var(--ink-3); font-size: .78rem; margin-inline-start: .4rem; }
.tabs { display: flex; gap: .2rem; padding: .4rem .6rem 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .5rem .7rem; cursor: pointer; font-weight: 600; color: var(--ink-3); border-bottom: 3px solid transparent; white-space: nowrap; font-size: .9rem; }
.tabs button[aria-selected="true"] { color: var(--teal); border-bottom-color: var(--coral); }
.tabs .count { font-style: normal; background: var(--coral-soft); color: var(--coral); border-radius: 999px; padding: 0 .45rem; font-size: .75rem; }
.tabs .count:empty { display: none; }
.tab-body { padding: 1rem 1.1rem 1.3rem; }

.loading { text-align: center; padding: 2.5rem 1rem; color: var(--ink-2); }
.loading p { margin: .8rem 0 .1rem; font-weight: 600; }
.loading small { color: var(--ink-3); }
.pulse { display: inline-block; width: 46px; height: 46px; border-radius: 50%; background: var(--teal-soft); position: relative; }
.pulse::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--teal-2); border-top-color: transparent; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(-360deg); } }
.error-box { background: var(--coral-soft); color: #8a3412; border-radius: 10px; padding: .9rem 1rem; }

.draft-disclaimer { font-size: .8rem; font-weight: 600; color: var(--coral); background: var(--coral-soft); border-radius: 8px; padding: .4rem .7rem; margin-bottom: .8rem; }
.opinion {
  font-family: var(--serif); font-size: 1.08rem; line-height: 1.9; white-space: pre-wrap;
  border: 1px dashed transparent; border-radius: 8px; padding: .3rem .4rem; min-height: 6rem;
}
.opinion:hover { border-color: var(--line); }
.opinion:focus { outline: none; border-color: var(--teal-2); background: #fcfefe; }
.edit-hint { font-size: .75rem; color: var(--ink-3); margin: .4rem 0 0; }
.cite {
  display: inline; font-family: var(--font); font-size: .78em; font-weight: 600; color: var(--teal-2);
  background: var(--teal-soft); border-radius: 6px; padding: .05rem .35rem; cursor: pointer; white-space: nowrap; border: 0;
}
.cite:hover { background: var(--teal-2); color: #fff; }
.cite.missing { color: var(--ink-3); background: #eef1f1; cursor: default; }
.cite.demo { cursor: default; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; top: .5rem; bottom: .5rem; right: 7px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 1.8rem 1rem 0; }
.timeline li::before { content: ''; position: absolute; right: 0; top: .45rem; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--teal-2); }
.timeline .when { font-weight: 700; color: var(--teal); }
.timeline .where { color: var(--ink-2); font-size: .85rem; margin-inline-start: .4rem; }
.timeline p { margin: .15rem 0 0; }

.gaps { display: flex; flex-direction: column; gap: .6rem; }
.gap { border: 1px solid var(--line); border-inline-start: 4px solid var(--amber); border-radius: 10px; padding: .6rem .8rem; }
.gap.high { border-inline-start-color: var(--coral); }
.gap.low { border-inline-start-color: var(--green); }
.gap .gap-head { display: flex; gap: .5rem; align-items: center; font-weight: 700; font-size: .9rem; }
.sev { font-size: .72rem; padding: .05rem .5rem; border-radius: 999px; background: var(--amber-soft); color: var(--amber); }
.gap.high .sev { background: var(--coral-soft); color: var(--coral); }
.gap.low .sev { background: #e6f3ec; color: var(--green); }
.gap p { margin: .25rem 0 0; }
.muted { color: var(--ink-3); }
.background-text { white-space: pre-wrap; }

/* מציג */
.viewer { display: flex; flex-direction: column; overflow: hidden; }
.viewer-bar { display: flex; align-items: center; gap: .5rem; padding: .55rem .7rem; border-bottom: 1px solid var(--line); background: #fbfdfd; }
.viewer-bar select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .5rem; background: #fff; }
.pager { display: flex; align-items: center; gap: .3rem; font-size: .85rem; }
.pager input { width: 3.4rem; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: .15rem; }
.zoom { display: flex; gap: .2rem; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover { background: var(--teal-soft); }
.viewer-stage { flex: 1; overflow: auto; background: #e9eeee; display: flex; justify-content: center; align-items: flex-start; padding: 1rem; position: relative; }
.viewer-stage canvas { background: #fff; box-shadow: 0 4px 18px rgba(0,0,0,.15); max-width: none; }
.viewer-stage canvas.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 5px var(--coral); } 100% { box-shadow: 0 4px 18px rgba(0,0,0,.15); } }
.viewer-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); margin: 0; }

@media (max-width: 1200px) {
  .result-columns.compare { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .results { max-height: none; }
  .viewer { height: 75vh; position: sticky; bottom: 0; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
@media print {
  .topbar, .setup, .viewer, .tabs, .result-actions { display: none !important; }
  .layout, .workspace { display: block; height: auto; }
}

/* תיק דמו */
.demo-cta { margin-top: .85rem; padding-top: .85rem; border-top: 1px dashed var(--line); display: grid; gap: .35rem; }
.btn.demo { width: 100%; display: flex; align-items: center; justify-content: center; gap: .45rem; border-style: dashed; border-color: var(--teal-2); }
.demo-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(640px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(18, 38, 44, .3); color: var(--ink); }
.demo-dialog::backdrop { background: rgba(18, 38, 44, .45); }
.demo-inner { padding: 1.2rem 1.4rem; display: grid; gap: .6rem; }
.demo-inner header { display: flex; justify-content: space-between; align-items: center; }
.demo-inner h2 { margin: 0; font-size: 1.15rem; font-family: var(--serif); color: var(--teal); }
.demo-inner p { margin: 0; }
.small { font-size: .85rem; }
.demo-list { margin: 0; padding: .6rem 1.6rem .6rem .6rem; max-height: 34vh; overflow-y: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; font-size: .85rem; columns: 2; column-gap: 1.4rem; }
.demo-list li { break-inside: avoid; padding: .1rem 0; }
.demo-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.demo-actions .btn { flex: 1 1 auto; }
.result-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
@media (max-width: 640px) { .demo-list { columns: 1; } }
