:root {
  --bg: #f7f7f5; --panel: #ffffff; --text: #1f2328; --muted: #6b6f76; --line: #e3e3de;
  --accent: #1f5fbf; --red: #c62828; --orange: #d9730d; --grey: #8a8f98; --green: #2e7d32; --yellow: #b8860b;
  --sel: #eef3fb; --news: #fbfaf4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Naskh Arabic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --panel: #1f2328; --text: #e6e6e3; --muted: #9aa0a8; --line: #30353c;
          --accent: #6ea8fe; --sel: #243049; --news: #23262b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.link { background: none; border: 0; color: var(--accent); padding: 0; }

.login { max-width: 420px; margin: 18vh auto; padding: 0 16px; text-align: center; }

#status { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 16px; border-bottom: 1px solid var(--line);
          background: var(--panel); font-size: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }
.dot.rare, .dot.unknown { background: var(--grey); }
.alert-line { color: var(--red); }

.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) minmax(0, 440px); height: calc(100vh - 38px); }
.sidebar { padding: 12px 16px; border-right: 1px solid var(--line); overflow-y: auto; }
.tabs { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.tabs button { text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.tabs button.active { background: var(--sel); font-weight: 600; }
.filters label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.filters select, .filters input { display: block; width: 100%; margin-top: 3px; padding: 5px 6px; font: inherit;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }

.feed { overflow-y: auto; padding: 8px 16px; }
#feed { list-style: none; margin: 0; padding: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.card.selected { outline: 2px solid var(--accent); }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.score { font-weight: 700; padding: 0 6px; border-radius: 4px; color: #fff; background: var(--grey); }
.score.s-red { background: var(--red); } .score.s-orange { background: var(--orange); }
.card .slug { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card h3 { font-size: 15px; margin: 4px 0; font-weight: 600; cursor: pointer; }
.card ul { margin: 4px 0; padding-left: 18px; }
.card .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.card .actions button { font-size: 13px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); }
.card .actions button.on { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.why { font-size: 13px; background: var(--bg); border-left: 3px solid var(--line); padding: 6px 8px; margin-top: 6px; white-space: pre-wrap; }
.new-pill { position: sticky; top: 0; z-index: 2; text-align: center; background: var(--accent); color: #fff;
  padding: 4px 10px; border-radius: 12px; margin: 0 auto 8px; width: fit-content; cursor: pointer; font-size: 13px; }
[dir="rtl"], .rtl { direction: rtl; text-align: right; }

.work { border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 14px; }
.close-work { display: none; }
.work h2 { font-size: 15px; margin: 0 0 6px; }
details summary { cursor: pointer; color: var(--accent); }
.original { white-space: pre-wrap; font-size: 14px; max-height: 40vh; overflow-y: auto; }
.news-block { background: var(--news); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; position: relative; }
.copy { position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); }
#chat-log { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; font-size: 14px; }
.msg.user { background: var(--sel); align-self: flex-end; max-width: 90%; }
.msg.model { background: var(--panel); border: 1px solid var(--line); }
#chat-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
#chat-form textarea { font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); resize: vertical; }
#chat-form button[type=submit], .primary { align-self: flex-start; padding: 6px 14px; border-radius: 6px; border: 0;
  background: var(--accent); color: #fff; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .tabs { flex-direction: row; overflow-x: auto; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .work { position: fixed; inset: 0; background: var(--bg); z-index: 10; border: 0; display: none; }
  .work.open { display: flex; }
  .close-work { display: block; align-self: flex-end; background: none; border: 0; font-size: 20px; color: var(--text); }
}
