:root {
  --bg: #ffffff; --fg: #242424; --muted: #616161; --line: #e0e0e0; --soft: #f5f5f5; --hover: #f0f0f0;
  --brand: #185abd; --brand-soft: #e8f0fb; --red: #c4314b; --green: #107c41; --yellow: #fff4b3;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; font-size: 13px; color: var(--fg);
       background: var(--bg); direction: rtl; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }
.ic { font-family: "Segoe Fluent Icons", "Segoe MDL2 Assets"; font-style: normal; font-size: 14px; line-height: 1; vertical-align: -2px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; }
.gap { gap: 6px; }

/* ---------- top bar ---------- */
.topbar { position: relative; display: flex; align-items: center; height: 44px; padding: 0 8px 0 4px; border-bottom: 1px solid var(--line); flex: none; }
.title-btn { display: flex; align-items: center; gap: 6px; border: none; background: none; font: inherit; font-size: 15px; font-weight: 600;
             padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--fg); }
.title-btn:hover { background: var(--hover); }
.title-btn .chev { font-size: 10px; color: var(--muted); }
.tb-actions { display: flex; gap: 2px; margin-inline-start: auto; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border: none; border-radius: 6px;
            background: none; color: var(--muted); cursor: pointer; font: inherit; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn .ic { font-size: 16px; }
.icon-btn.on { color: var(--brand); }
.icon-btn.slash { font-weight: 600; font-size: 15px; }

.menu { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 4px; min-width: 190px; }
.topbar .menu { top: 40px; right: 6px; }
.menu button { display: flex; align-items: center; gap: 8px; width: 100%; border: none; background: none; font: inherit; text-align: right;
               padding: 7px 10px; border-radius: 6px; cursor: pointer; color: var(--fg); }
.menu button:hover, .menu button.active { background: var(--hover); }
.menu .item-desc { display: block; font-size: 11px; color: var(--muted); }
.menu.up { bottom: calc(100% + 4px); right: 8px; left: 8px; max-height: 50vh; overflow-y: auto; }

/* ---------- views ---------- */
.view { flex: 1; overflow-y: auto; padding: 10px 12px 16px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.card h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 13px; }
.summary { color: var(--muted); margin-bottom: 8px; }
.btn { display: inline-flex; align-items: center; gap: 5px; font: inherit; padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
       background: #fff; cursor: pointer; color: var(--fg); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.small-btn { font-size: 12px; padding: 3px 10px; margin-bottom: 6px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; color: #fff; font-size: 11px; }

.detail { background: var(--soft); }
.detail-top { display: flex; justify-content: space-between; align-items: center; }
.change { line-height: 1.5; }
.change.big { font-size: 17px; margin: 8px 0 4px; }
.before { text-decoration: line-through; color: var(--red); }
.after { color: var(--green); font-weight: 600; }
.arrow { margin: 0 6px; color: var(--muted); font-size: 11px; }
.reason { line-height: 1.55; margin-bottom: 6px; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); text-decoration: none; margin-bottom: 8px; }
.link:hover { text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.filters button { font: inherit; font-size: 12px; padding: 2px 10px; border-radius: 12px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.filters button.on { color: #fff; border-color: transparent; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 4px; }
.list li:hover { background: var(--hover); }
.list li.current { background: var(--brand-soft); }
.bar { width: 3px; border-radius: 2px; flex: none; }
.row-main { min-width: 0; flex: 1; }
.row-change { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-reason { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doubt-word { background: var(--yellow); padding: 0 3px; border-radius: 2px; }
.diag { white-space: pre-wrap; font-size: 11px; color: var(--muted); margin: 0; font-family: inherit; }

/* ---------- settings ---------- */
.field { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; min-width: 0; }
.field-label { display: block; margin: 8px 0 3px; color: var(--muted); font-size: 12px; }
.toggle { display: flex; align-items: center; gap: 6px; padding: 4px 0; }

/* ---------- chat ---------- */
.chat-view { display: flex; flex-direction: column; padding: 0; overflow: hidden; position: relative; }
.chat { flex: 1; overflow-y: auto; padding: 12px 12px 4px; }
.empty { text-align: center; margin-top: 18vh; color: var(--muted); }
.empty h2 { font-size: 15px; color: var(--fg); font-weight: 600; margin: 8px 0 4px; }
.empty .ic.hero { font-size: 28px; color: var(--brand); }
.skill-pills { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 14px; }
.skill-pills button { font: inherit; padding: 5px 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; cursor: pointer; color: var(--fg); }
.skill-pills button:hover { background: var(--hover); }

.msg { margin: 0 0 12px; line-height: 1.6; }
.msg.user { display: flex; justify-content: flex-start; }
.msg.user .bubble { background: var(--soft); border-radius: 12px; padding: 7px 11px; max-width: 88%; white-space: pre-wrap; }
.msg.user .skill-tag { display: block; font-size: 11px; color: var(--brand); margin-bottom: 2px; }
.msg.bot .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg.bot .body p { margin: 0 0 6px; }
.msg.bot .body ul, .msg.bot .body ol { margin: 0 0 6px; padding-inline-start: 18px; }
.msg.bot .body table { border-collapse: collapse; margin: 4px 0 8px; font-size: 12px; width: 100%; }
.msg.bot .body th, .msg.bot .body td { border: 1px solid var(--line); padding: 3px 6px; text-align: right; vertical-align: top; }
.msg.bot .body th { background: var(--soft); }
.msg.bot .body code { background: var(--soft); padding: 0 3px; border-radius: 3px; }
.msg.bot .body a { color: var(--brand); text-decoration: none; }
.msg.bot .body a:hover { text-decoration: underline; }
.thinking { color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dots span { display: inline-block; width: 5px; height: 5px; margin: 0 1px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

.proposal { border: 1px solid var(--line); border-inline-start: 3px solid var(--brand); border-radius: 6px; padding: 7px 9px; margin: 6px 0; background: #fff; }
.proposal .kind { font-size: 11px; color: var(--brand); margin-bottom: 2px; }
.proposal .change { font-size: 14px; }
.proposal .row-reason { white-space: normal; margin: 2px 0 6px; }
.apply-all { margin-top: 4px; }

.overlay { position: absolute; inset: 0; background: #fff; z-index: 10; padding: 8px 12px; overflow-y: auto; }
.overlay-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

.composer { position: relative; flex: none; margin: 6px 10px 10px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 4px;
            background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.composer:focus-within { border-color: #b4b4b4; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); background: var(--soft); border-radius: 10px; padding: 2px 8px; margin-bottom: 4px; }
.chip.accent { color: var(--brand); background: var(--brand-soft); }
.chip-x { border: none; background: none; cursor: pointer; color: inherit; padding: 0; }
.chip-x .ic { font-size: 9px; }
#input { width: 100%; border: none; outline: none; resize: none; font: inherit; font-size: 13.5px; line-height: 1.5; max-height: 160px; padding: 4px 2px; background: transparent; }
.composer-row { display: flex; align-items: center; gap: 2px; }
.model-select { border: none; background: none; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; max-width: 150px; }
.model-select:hover { background: var(--hover); }
.send-btn { width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--brand); color: #fff; cursor: pointer; display: inline-flex;
            align-items: center; justify-content: center; }
.send-btn .ic { font-size: 14px; transform: scaleX(-1); }
.send-btn:disabled { background: #c8c8c8; cursor: default; }

.toast { position: fixed; bottom: 12px; left: 12px; right: 12px; padding: 8px 12px; border-radius: 8px; background: #242424; color: #fff; z-index: 50;
         box-shadow: 0 6px 18px rgba(0,0,0,.2); }
