:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e3e6ee;
  --text: #1b1f2a;
  --muted: #677086;
  --accent: #d9622b;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee6;
  --ok: #1f8a4c;
  --ok-soft: #e4f5ea;
  --warn: #9a6a00;
  --warn-soft: #fbf1d6;
  --bad: #c0362c;
  --bad-soft: #fbe7e5;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1b1e26;
    --border: #2c303b;
    --text: #e9ebf1;
    --muted: #98a0b3;
    --accent: #ef7b45;
    --accent-soft: #3a2419;
    --ok: #4cc27e;
    --ok-soft: #173223;
    --warn: #e0b246;
    --warn-soft: #362c12;
    --bad: #ef6b60;
    --bad-soft: #3a1c1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
[hidden] { display: none !important; }
h1 { font-size: 1.6rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
h3 { font-size: .95rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.error { color: var(--bad); background: var(--bad-soft); padding: .55rem .75rem; border-radius: 8px; margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

label { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; font-size: .9rem; }
input, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem .85rem;
  font-weight: 400;
}
textarea { resize: vertical; min-height: 130px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  font: inherit; font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .6rem 1rem;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; border-color: var(--border); color: var(--muted); margin-top: .75rem; }
.btn.big { padding: .8rem 1.2rem; font-size: 1rem; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; }

.brand { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.logo { color: var(--accent); font-size: 1.3rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 1rem; padding: 2rem; }
.login-card p { margin: 0; }

/* Layout */
.layout { display: grid; grid-template-columns: 290px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  position: sticky; top: 0; height: 100vh;
}
.side-title { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; margin: .5rem 0 0; }
.task-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.task-list li button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  font: inherit; padding: .55rem .6rem; border-radius: 8px; cursor: pointer;
  display: flex; gap: .55rem; align-items: flex-start;
}
.task-list li button:hover, .task-list li button.active { background: var(--bg); }
.task-list .tl-text { display: flex; flex-direction: column; min-width: 0; }
.task-list .tl-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .88rem; }
.task-list .tl-sub { font-size: .75rem; color: var(--muted); }
.side-footer { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; border-top: 1px solid var(--border); padding-top: .75rem; }

.main { padding: 2.5rem; max-width: 860px; width: 100%; }
.panel { display: flex; flex-direction: column; gap: 1.25rem; }
.panel > p { margin: 0; }
#task-form { display: flex; flex-direction: column; gap: 1.1rem; }

.repo-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.repo-option {
  font: inherit; text-align: left; cursor: pointer;
  border: 1.5px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 10px; padding: .75rem .85rem; font-weight: 500;
}
.repo-option.selected { border-color: var(--accent); background: var(--accent-soft); }

.examples { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; font-size: .85rem; }
.chip {
  font: inherit; font-size: .82rem; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .3rem .75rem;
}
.chip:hover { border-color: var(--accent); }

/* Task view */
.task-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.task-head h1 { font-size: 1.3rem; white-space: pre-wrap; word-break: break-word; }
.badge { font-size: .8rem; font-weight: 600; padding: .3rem .7rem; border-radius: 999px; white-space: nowrap; }
.s-queued, .s-running { background: var(--warn-soft); color: var(--warn); }
.s-pr_opened { background: var(--ok-soft); color: var(--ok); }
.s-no_changes, .s-cancelled { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.s-failed { background: var(--bad-soft); color: var(--bad); }
.dot-status { width: 9px; height: 9px; border-radius: 50%; margin-top: .4rem; flex: none; }
.dot-status.s-running, .dot-status.s-queued { background: var(--warn); }
.dot-status.s-pr_opened { background: var(--ok); }
.dot-status.s-failed { background: var(--bad); }
.dot-status.s-no_changes, .dot-status.s-cancelled { background: var(--muted); }

.result { border-radius: 14px; padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.result.ok { background: var(--ok-soft); }
.result.neutral { background: var(--surface); border: 1px solid var(--border); }
.result.bad { background: var(--bad-soft); }
.result h3 { margin: 0; }
.result .summary { white-space: pre-wrap; margin: 0; }
.result a.btn { align-self: flex-start; text-decoration: none; }

.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.events li { display: flex; gap: .6rem; font-size: .9rem; }
.events .ic { width: 1.3rem; flex: none; text-align: center; }
.events .ev-tool { color: var(--muted); }
.events .ev-text { white-space: pre-wrap; }
.events .ev-error { color: var(--bad); }
.events .ev-status { font-weight: 500; }

.working { color: var(--muted); font-size: .9rem; margin-top: .75rem; display: flex; align-items: center; gap: 4px; }
.working .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.working .dot:nth-child(2) { animation-delay: .2s; }
.working .dot:nth-child(3) { animation-delay: .4s; margin-right: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .task-list { max-height: 220px; }
  .main { padding: 1.25rem 16px; }
}
