:root {
  --bg: #0b1020;
  --bg-soft: #0e1528;
  --panel: #101a31;
  --panel-2: #0c1426;
  --line: #1e2b48;
  --line-soft: #16213a;
  --text: #e7eefb;
  --muted: #8fa2c0;
  --muted-2: #6d7f9d;
  --accent: #6ea8fe;
  --accent-soft: rgba(110, 168, 254, 0.14);
  --green: #7ee787;
  --green-soft: rgba(126, 231, 135, 0.12);
  --red: #ff8f87;
  --red-soft: rgba(255, 143, 135, 0.12);
  --yellow: #f2cc60;
  --code-bg: #080d19;
  --hl: rgba(110, 168, 254, 0.16);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

html { scroll-padding-top: 92px; }

body {
  background:
    radial-gradient(1100px 500px at 15% -10%, rgba(110, 168, 254, 0.10), transparent 60%),
    radial-gradient(900px 450px at 100% 0%, rgba(126, 231, 135, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

/* ---------- header ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  background: rgba(11, 16, 32, 0.82);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #8bbcff, #5b8def);
  color: #06101f;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 8px 24px rgba(91, 141, 239, 0.35);
  flex: none;
}

.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 17px; letter-spacing: 0.2px; }
.brand-text p { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; }

.top-actions { display: flex; align-items: center; gap: 12px; flex: none; }

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(242, 204, 96, 0.14);
}
.dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgba(126, 231, 135, 0.14); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px rgba(255, 143, 135, 0.14); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(140deg, #7db4ff, #5b8def);
  color: #07101f;
  box-shadow: 0 10px 26px rgba(91, 141, 239, 0.28);
}
.btn.primary:hover { background: linear-gradient(140deg, #8dbfff, #6a99f4); }

.btn.ghost {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}
.btn.ghost:hover { border-color: #2c4069; background: #101c34; }

.btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn.primary.running .run-icon {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(7, 16, 31, 0.35);
  border-top-color: #07101f;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  font-size: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.mini-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.mini-btn:hover { color: var(--text); border-color: #2c4069; background: #101c34; text-decoration: none; }

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 22px 26px 40px;
  align-items: start;
}

.sidebar { position: sticky; top: 86px; min-width: 0; }

.side-label {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 4px 0 10px 4px;
}

.task-list { display: grid; gap: 10px; }

.task-card {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease;
}
.task-card:hover { border-color: #2c4069; background: #101c34; }
.task-card:active { transform: translateY(1px); }

.task-card.active {
  border-color: rgba(110, 168, 254, 0.65);
  background: linear-gradient(150deg, rgba(110, 168, 254, 0.14), rgba(110, 168, 254, 0.04));
  box-shadow: 0 0 0 1px rgba(110, 168, 254, 0.25) inset;
}
.task-card.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 16px;
  bottom: 16px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.task-week { font-size: 11.5px; color: var(--accent); letter-spacing: 0.04em; }
.task-name { font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.task-files { font-size: 11.5px; color: var(--muted-2); font-family: var(--mono); }

.side-note {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(16, 26, 49, 0.5);
  color: var(--muted);
  font-size: 12.5px;
}
.side-note strong { color: var(--text); font-size: 13px; }
.side-note p { margin: 6px 0 0; }
.side-small { color: var(--muted-2); font-family: var(--mono); font-size: 11px; }

/* ---------- main ---------- */

.main { min-width: 0; }

.task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(110, 168, 254, 0.08), rgba(16, 26, 49, 0.75) 45%);
  margin-bottom: 14px;
}

.task-head-text { min-width: 0; }

.crumbs {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.task-head h2 { margin: 0 0 6px; font-size: 23px; line-height: 1.2; letter-spacing: -0.2px; }
.task-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 780px; }

.task-actions { display: flex; gap: 9px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

.file-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.file-chip::before { content: "◇"; color: var(--muted-2); font-size: 10px; }
.file-chip:hover { color: var(--text); border-color: #2c4069; }
.file-chip.active {
  color: var(--accent);
  border-color: rgba(110, 168, 254, 0.55);
  background: var(--accent-soft);
}
.file-chip.active::before { content: "◆"; color: var(--accent); }

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}

.tab {
  position: relative;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 9px 9px 0 0;
}
.tab:hover { color: var(--text); background: rgba(110, 168, 254, 0.06); }
.tab.active { color: var(--text); }
.tab.active::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.tab-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--muted);
  font-size: 10.5px;
  font-family: var(--mono);
  text-align: center;
}
.tab-badge.ok { background: var(--green-soft); color: var(--green); }
.tab-badge.bad { background: var(--red-soft); color: var(--red); }

/* ---------- panels ---------- */

.panel {
  display: none;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--panel-2);
  overflow: hidden;
}
.panel.active { display: block; }

/* code */

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  background: #0b1324;
  border-bottom: 1px solid var(--line-soft);
}

.file-name { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.code-tools { display: flex; gap: 7px; }

.code-scroll {
  max-height: 62vh;
  overflow: auto;
  background: var(--code-bg);
  scrollbar-color: #223252 transparent;
}

.code {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.62;
  padding: 8px 0 14px;
  min-width: max-content;
}

.line {
  display: flex;
  min-height: 21px;
  transition: background 0.2s ease;
}
.line:hover { background: rgba(110, 168, 254, 0.05); }
.line.hl { background: var(--hl); }

.ln {
  flex: none;
  width: 54px;
  padding-right: 14px;
  text-align: right;
  color: #42536f;
  user-select: none;
  position: sticky;
  left: 0;
  background: var(--code-bg);
}
.line:hover .ln { background: #0a1222; }
.line.hl .ln { background: #101c36; color: var(--accent); }

.src {
  flex: 1;
  padding-right: 24px;
  white-space: pre;
  color: #d7e2f3;
  tab-size: 4;
}

.tok-kw { color: #c792ea; }
.tok-str { color: #a5e6a0; }
.tok-com { color: #61748f; font-style: italic; }
.tok-num { color: #f2cc60; }
.tok-bi { color: #82aaff; }
.tok-fn { color: #ffcb6b; }
.tok-cls { color: #7ee787; }

/* explanation */

.explain-wrap { padding: 8px 22px 28px; max-width: 900px; }

.explain {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line-soft);
}
.explain:last-child { border-bottom: 0; }

.explain h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  font-size: 16.5px;
  letter-spacing: -0.1px;
}

.explain p { margin: 0 0 9px; color: #c6d3e8; font-size: 14.2px; }
.explain p:last-child { margin-bottom: 0; }

.explain code {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(110, 168, 254, 0.12);
  color: #a8c7ff;
  white-space: pre-wrap;
}

.lines-chip {
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(110, 168, 254, 0.4);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
}
.lines-chip:hover { background: rgba(110, 168, 254, 0.24); }

.explain pre {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: var(--code-bg);
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #d7e2f3;
}

/* result */

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #0b1324;
  border-bottom: 1px solid var(--line-soft);
}

.result-status { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }

.status-badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--line-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
}
.status-badge.ok { background: var(--green-soft); color: var(--green); }
.status-badge.bad { background: var(--red-soft); color: var(--red); }
.status-badge.run { background: var(--accent-soft); color: var(--accent); }

.result-meta { color: var(--muted-2); font-size: 12px; font-family: var(--mono); }

.result-body { padding: 14px; }

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 17px;
}
.empty-state p { margin: 0; max-width: 520px; }

.terminal {
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: #05090f;
  color: #cfe0d4;
  font-family: var(--mono);
  font-size: 12.8px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 52vh;
  overflow-y: auto;
}
.terminal.stderr { margin-top: 10px; color: #ffb4ab; background: #120a0c; border-color: #3a1d22; }

.artifacts { display: grid; gap: 10px; margin-top: 12px; }

.artifact {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  overflow: hidden;
}
.artifact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.artifact-name { font-family: var(--mono); color: var(--text); }
.artifact-size { color: var(--muted-2); font-family: var(--mono); font-size: 11.5px; margin-left: 8px; }
.artifact pre {
  margin: 0;
  padding: 10px 12px;
  background: var(--code-bg);
  color: #b9c8de;
  font-family: var(--mono);
  font-size: 11.5px;
  overflow-x: auto;
  white-space: pre;
}

/* footer */

.foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 4px 0;
  color: var(--muted-2);
  font-size: 11.5px;
}

/* toast */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid rgba(110, 168, 254, 0.4);
  background: #13203a;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 32px; }
  .sidebar { position: static; }
  .task-list { grid-template-columns: 1fr 1fr; }
  .side-note { display: none; }
  .task-head { flex-direction: column; }
  .task-actions { justify-content: flex-start; }
  .code-scroll { max-height: 58vh; }
}

@media (max-width: 640px) {
  .topbar { padding: 11px 14px; gap: 10px; flex-wrap: wrap; }
  .brand-text p { display: none; }
  .top-actions { gap: 8px; }
  .server-pill { display: none; }
  .task-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .task-list::-webkit-scrollbar { display: none; }
  .task-card { flex: 0 0 auto; width: auto; min-width: 240px; max-width: 300px; }
  .task-head { padding: 16px; }
  .task-head h2 { font-size: 19px; }
  .task-actions { width: 100%; }
  .task-actions .btn { flex: 1; }
  .explain-wrap { padding: 6px 15px 22px; }
  .explain p { font-size: 13.6px; }
  .foot { flex-direction: column; gap: 4px; }
  .ln { width: 42px; padding-right: 10px; }
  .code { font-size: 12.2px; }
}
