* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, "Noto Sans KR", sans-serif;
       background: #0d1117; color: #e6edf3; }
.view { max-width: 880px; margin: 0 auto; padding: 24px; }
.hidden { display: none !important; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 1.4rem; }
button { background: #238636; color: #fff; border: 0; border-radius: 6px;
         padding: 8px 14px; cursor: pointer; font-size: .95rem; }
button:hover { opacity: 0.9; }
button.secondary { background: #30363d; }
input, textarea, select { width: 100%; padding: 8px; margin: 4px 0 12px;
         background: #161b22; border: 1px solid #30363d; border-radius: 6px;
         color: #e6edf3; }
input:focus, textarea:focus, select:focus { outline: 2px solid #58a6ff; outline-offset: 2px; }
#login-form { max-width: 320px; margin: 12vh auto; text-align: center; }
.error { color: #f85149; min-height: 1.2em; }
.task-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px;
             padding: 14px; margin: 10px 0; cursor: pointer; }
.task-card:hover { border-color: #58a6ff; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px;
         font-size: .8rem; margin-left: 8px; }
.progress { display: flex; gap: 4px; margin-top: 8px; }
.progress span { flex: 1; height: 6px; border-radius: 3px; background: #30363d; }
.progress span.completed { background: #238636; }
.progress span.working { background: #d29922; }
.progress span.failed { background: #f85149; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6);
         display: flex; align-items: center; justify-content: center; }
.modal-box { background: #161b22; padding: 24px; border-radius: 10px;
             width: 92%; max-width: 480px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
label { display: block; font-size: .9rem; }
#detail-body pre { white-space: pre-wrap; background: #161b22; padding: 16px;
                   border-radius: 8px; overflow-x: auto; }
.gate-actions { display: flex; gap: 8px; margin: 16px 0; }
.task-meta { font-size: .8rem; color: #8b949e; margin: 4px 0; }
.stage-pipeline { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.stage-badge { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px;
               border-radius: 4px; font-size: .75rem; background: #21262d;
               border: 1px solid #30363d; color: #8b949e; }
.stage-badge.state-completed { background: #0f2d12; border-color: #238636; color: #3fb950; }
.stage-badge.state-working   { background: #2d1f00; border-color: #9e6a03; color: #e3b341; }
.stage-badge.state-failed    { background: #2d0f0f; border-color: #da3633; color: #f85149; }
.stage-badge.state-timeout   { background: #2d1f00; border-color: #9e6a03; color: #e3b341; }
.next-action { font-size: .85rem; color: #8b949e; margin: 10px 0; padding: 8px 12px;
               background: #161b22; border-left: 3px solid #58a6ff; border-radius: 4px; }
.plan-box { background: #0d1117; border: 1px solid #30363d; border-radius: 8px;
            padding: 16px; margin: 12px 0; max-height: 420px; overflow-y: auto; }
.plan-box pre { white-space: pre-wrap; margin: 0; font-size: .83rem; color: #c9d1d9; }
.refs-list { list-style: none; padding: 0; margin: 4px 0 8px; }
.refs-list li { display: flex; justify-content: space-between; align-items: center;
                padding: 4px 8px; background: #0d1117; border-radius: 4px;
                margin-bottom: 3px; font-size: .82rem; color: #c9d1d9; }
.refs-list li button { background: none; border: none; color: #f85149; cursor: pointer;
                       padding: 0 4px; font-size: .9rem; }
.output-header { display: flex; align-items: center; justify-content: space-between;
                 margin: 16px 0 8px; }
.output-header h3 { margin: 0; }
.dl-btn { display: inline-block; padding: 7px 14px; background: #1f6feb;
          color: #fff; border-radius: 6px; text-decoration: none; font-size: .9rem; }
.dl-btn:hover { background: #388bfd; }
.file-list { list-style: none; padding: 0; margin: 4px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.file-list li a { display: inline-block; padding: 4px 10px; background: #21262d;
                  border: 1px solid #30363d; border-radius: 4px; color: #58a6ff;
                  text-decoration: none; font-size: .82rem; }
.file-list li a:hover { border-color: #58a6ff; background: #1f2937; }

/* ── 프롬프트 로그 탭 ─────────────────────── */
.prompt-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: #1a2744;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #718096;
}
.prompt-summary strong { color: #90cdf4; }
.prompt-expand-all {
  margin-left: auto;
  background: none;
  border: none;
  color: #805ad5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}
.prompt-expand-all:hover { color: #d6bcfa; }

.accordion-item {
  background: #161b22;
  border-radius: 6px;
  margin-bottom: 4px;
  overflow: hidden;
}
.accordion-item.open {
  border: 1px solid #553c9a;
  background: #1a1a2e;
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.accordion-header:hover { background: rgba(255,255,255,0.03); }
.accordion-label {
  font-weight: bold;
  color: #a0aec0;
  margin-right: 8px;
}
.accordion-item.open .accordion-label { color: #d6bcfa; }
.accordion-role { color: #4a5568; font-size: 12px; }
.accordion-meta { color: #4a5568; font-size: 12px; }
.accordion-rc-fail { color: #fc8181; font-size: 12px; margin-left: 4px; }
.accordion-arrow { color: #4a5568; font-size: 11px; transition: transform 0.15s; }
.accordion-item.open .accordion-arrow { color: #805ad5; }

.accordion-body { display: none; padding: 0 12px 12px; }
.accordion-item.open .accordion-body { display: block; }

.prompt-inner-tabs {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #2d3748;
  margin-bottom: 8px;
}
.prompt-inner-tab {
  padding: 4px 12px;
  font-size: 12px;
  color: #4a5568;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.prompt-inner-tab.active { color: #90cdf4; border-bottom-color: #4299e1; }
.prompt-copy-btn {
  margin-left: auto;
  background: none;
  border: 1px solid #2d3748;
  color: #718096;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.prompt-copy-btn:hover { color: #e2e8f0; border-color: #4a5568; }

.prompt-pre {
  background: #0d1117;
  border-radius: 4px;
  padding: 10px;
  color: #a0aec0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  height: 320px;
  overflow-y: auto;
  font-family: "Consolas", "Monaco", monospace;
}
.prompt-size-hint {
  color: #4a5568;
  font-size: 11px;
  margin-top: 4px;
  text-align: right;
}

/* ── 마크다운 렌더링 ───────────────────────── */
.md-body {
  line-height: 1.75;
  color: #c9d1d9;
  font-size: .93rem;
  padding: 16px 0;
}
.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 {
  color: #e6edf3;
  margin: 1.2em 0 .5em;
  line-height: 1.3;
}
.md-body h1 { font-size: 1.6rem; border-bottom: 1px solid #30363d; padding-bottom: .3em; }
.md-body h2 { font-size: 1.3rem; border-bottom: 1px solid #21262d; padding-bottom: .2em; }
.md-body h3 { font-size: 1.1rem; }
.md-body p  { margin: .7em 0; }
.md-body a  { color: #58a6ff; text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body ul, .md-body ol { padding-left: 1.8em; margin: .6em 0; }
.md-body li { margin: .3em 0; }
.md-body blockquote {
  border-left: 4px solid #30363d;
  margin: .8em 0;
  padding: .4em 1em;
  color: #8b949e;
  background: #161b22;
  border-radius: 0 4px 4px 0;
}
.md-body code {
  background: #21262d;
  padding: .15em .4em;
  border-radius: 4px;
  font-size: .88em;
  font-family: "Consolas", "Monaco", monospace;
  color: #f0883e;
}
.md-body pre {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: .8em 0;
}
.md-body pre code {
  background: none;
  padding: 0;
  color: #c9d1d9;
  font-size: .88em;
}
.md-body table {
  border-collapse: collapse;
  width: 100%;
  margin: .8em 0;
  font-size: .88rem;
}
.md-body th {
  background: #21262d;
  color: #e6edf3;
  padding: 7px 12px;
  border: 1px solid #30363d;
  text-align: left;
}
.md-body td {
  padding: 6px 12px;
  border: 1px solid #21262d;
  vertical-align: top;
}
.md-body tr:nth-child(even) td { background: #0d1117; }
.md-body hr {
  border: none;
  border-top: 1px solid #30363d;
  margin: 1.2em 0;
}
.md-body img { max-width: 100%; border-radius: 6px; }

/* plan-box 내 md-body 조정 */
.plan-box .md-body { padding: 0; font-size: .83rem; }

/* 상세 화면 탭 바 */
.detail-tabs {
  display: flex;
  border-bottom: 2px solid #1a2744;
  margin-bottom: 12px;
}
.detail-tab {
  padding: 8px 16px;
  font-size: 13px;
  color: #718096;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.detail-tab:hover { color: #a0aec0; }
.detail-tab.active { color: #d6bcfa; border-bottom-color: #805ad5; }
