/* ============================================================
   SCIJERRY 스타일
   - 어두운 바탕 + 픽셀 게임 느낌의 버튼(두꺼운 테두리, 아래 그림자)
   - 휴대폰: 사무실 위, 패널 아래 / 넓은 화면(1000px 이상): 사무실 왼쪽, 패널 오른쪽
   ============================================================ */

:root {
  --bg: #14141c;
  --bg2: #1b1b26;
  --card: #20202d;
  --card2: #272738;
  --line: #34344a;
  --text: #ecebf3;
  --muted: #9a99b0;
  --gold: #ffd34d;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --radius: 8px;
  --topbar: 52px;
  --font: 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--blue);
}

.muted {
  color: var(--muted);
  font-size: 0.86em;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   상단 바
   ------------------------------------------------------------ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: #101018;
  border-bottom: 2px solid #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.02em;
  min-width: 0;
  flex: 1;
}

#company {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 픽셀 로고 (작은 건물 모양 — CSS 그림자로 도트 찍기) */
.logo {
  width: 4px;
  height: 4px;
  margin: 0 14px 10px 2px;
  flex: none;
  background: var(--gold);
  box-shadow:
    4px 0 var(--gold), 8px 0 var(--gold), 12px 0 var(--gold),
    0 4px #e85d5d, 4px 4px #fff, 8px 4px #e85d5d, 12px 4px #fff,
    0 8px #4f8de0, 4px 8px #fff, 8px 8px #4f8de0, 12px 8px #fff,
    0 12px #53b77a, 4px 12px #53b77a, 8px 12px #7b4a24, 12px 12px #53b77a;
}

.conn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.conn .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 2px #0006;
}

.conn[data-state='online'] .dot {
  background: var(--green);
  animation: pulse 2s infinite;
}

.conn[data-state='offline'] .dot {
  background: var(--red);
}

.conn[data-state='offline'] .conn-text {
  color: var(--red);
}

@keyframes pulse {
  50% {
    box-shadow: 0 0 0 4px #4ade8033;
  }
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  min-height: 34px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* ------------------------------------------------------------
   전체 배치
   ------------------------------------------------------------ */
.office-wrap {
  background: #1f2330;
  border-bottom: 2px solid #000;
  overflow: hidden;
}

#office {
  display: block;
  margin: 0 auto;
  touch-action: manipulation; /* 더블탭 확대 방지 → 캐릭터 탭이 즉시 반응 */
}

.panel {
  padding-bottom: env(safe-area-inset-bottom);
  scroll-margin-top: calc(var(--topbar) + env(safe-area-inset-top)); /* 고정 상단 바에 가리지 않게 */
}

/* 넓은 화면: 좌우 2단 */
@media (min-width: 1000px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    height: calc(100dvh - var(--topbar) - env(safe-area-inset-top));
  }

  .office-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 0;
    border-right: 2px solid #000;
    min-height: 0;
  }

  .panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg2);
  }

  .panel .tabs {
    position: static;
  }

  .tab-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .tab-logs {
    display: flex;
    flex-direction: column;
  }

  .tab-logs .log-list {
    flex: 1;
    height: auto;
    min-height: 0;
  }
}

/* ------------------------------------------------------------
   탭
   ------------------------------------------------------------ */
.tabs {
  position: sticky;
  top: calc(var(--topbar) + env(safe-area-inset-top));
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #101018;
  border-bottom: 2px solid #000;
}

.tabs button {
  position: relative;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 4px 10px;
  min-height: 46px;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.tabs button[aria-selected='true'] {
  color: var(--gold);
  border-bottom-color: var(--gold);
  background: #ffd34d0d;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  animation: pop 0.25s ease-out;
}

@keyframes pop {
  from {
    transform: scale(0.4);
  }
}

.tab-body {
  padding: 14px max(14px, env(safe-area-inset-right)) 24px max(14px, env(safe-area-inset-left));
}

/* ------------------------------------------------------------
   폼, 버튼
   ------------------------------------------------------------ */
.field-label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

textarea,
select,
input[type='password'],
input[type='text'] {
  width: 100%;
  background: #0f0f16;
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 16px; /* 16px 미만이면 아이폰이 입력 시 화면을 확대함 */
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 64px;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--gold);
}

.directive-form {
  display: grid;
  gap: 4px;
}

.directive-form select {
  margin-bottom: 10px;
}

.directive-form textarea {
  margin-bottom: 10px;
}

.btn {
  border: 2px solid #000;
  border-radius: 6px;
  padding: 10px 16px;
  min-height: 44px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 #000;
  transition: transform 0.05s;
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #000;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--gold);
  color: #2a1f00;
}

.btn-approve {
  background: var(--green);
  color: #052e16;
}

.btn-reject {
  background: #3a2026;
  color: #fecaca;
  border-color: #000;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.btn-back,
.link-btn {
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--blue);
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  min-height: 40px;
}

.icon-btn {
  background: var(--card2);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  flex: none;
  cursor: pointer;
  font-size: 16px;
}

.form-error {
  margin: 6px 0 0;
  color: var(--red);
  font-size: 13px;
}

/* ------------------------------------------------------------
   카드, 칩
   ------------------------------------------------------------ */
.card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 0 #0008;
}

button.card {
  cursor: pointer;
}

button.card:hover {
  border-color: #4a4a66;
  background: var(--card2);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.card-top time {
  margin-left: auto;
}

.task-directive {
  font-weight: 600;
  /* 최대 3줄까지만 보이고 나머지는 … */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.task-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.error-text {
  color: var(--red) !important;
}

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: #3a3a50;
  color: #d4d4e0;
  border: 1px solid #0006;
}

.chip-queued,
.chip-pending,
.chip-idle {
  background: #33334a;
  color: #c7c7d9;
}

.chip-planning,
.chip-thinking {
  background: #1e3a8a;
  color: #bfdbfe;
}

.chip-working,
.chip-walking {
  background: #134e4a;
  color: #99f6e4;
}

.chip-reviewing,
.chip-meeting {
  background: #4c1d95;
  color: #ddd6fe;
}

.chip-waiting_ceo {
  background: #78350f;
  color: #fde68a;
}

.chip-done {
  background: #14532d;
  color: #bbf7d0;
}

.chip-rejected {
  background: #4a2a0a;
  color: #fed7aa;
}

.chip-failed,
.chip-error {
  background: #7f1d1d;
  color: #fecaca;
}

/* 미해결: 실행은 끝났지만 검증 미통과 (자동 수정 중단) */
.chip-unresolved {
  background: #713f12;
  color: #fde68a;
}

.chip-offline,
.chip-cancelled {
  background: #27272a;
  color: #a1a1aa;
}

/* ---- 검증 결과 (실행 종료와 별개) ---- */
.chip-verify-pass {
  background: #14532d;
  color: #bbf7d0;
}

.chip-verify-fail {
  background: #b91c1c;
  color: #fff;
}

/* 검증 미통과 결과를 CEO 가 예외로 승인 */
.chip-verify-exception {
  background: #b45309;
  color: #fff;
}

/* ---- 업무 중지 ---- */
.btn-stop {
  background: #3f3f46;
  color: #fecaca;
  width: 100%;
  margin-top: 10px;
}

.stop-all-row {
  display: flex;
  justify-content: flex-end;
  margin: 8px 0;
}

.btn-stop-all {
  padding: 6px 12px;
  font-size: 13px;
  background: #3f3f46;
  color: #fecaca;
}

/* ---- Jev QA (최종 품질 검사) ---- */
.chip-qa-pass {
  background: #14532d;
  color: #bbf7d0;
}

.chip-qa-fail {
  background: #b91c1c;
  color: #fff;
}

.chip-qa-error {
  background: #b45309;
  color: #fff;
}

/* 승인 탭의 눈에 띄는 경고 칩 */
.qa-alert-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.qa-alert {
  font-size: 13px;
  padding: 3px 10px;
  border: 2px solid #000;
  box-shadow: 0 2px 0 #000;
}

.qa-card {
  margin-top: 10px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid #14b8a6;
  border-radius: var(--radius);
}

.qa-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qa-head .muted {
  margin-left: auto;
}

.qa-error {
  margin: 8px 0 0;
  color: var(--amber);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.qa-rows {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

/* 한 줄: [라벨 ........ 퍼센트] / [막대] */
.qa-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  font-size: 13px;
}

.qa-label {
  overflow-wrap: anywhere;
}

.qa-pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.qa-row.is-pass .qa-pct,
.qa-row.is-pass .qa-label {
  color: var(--green);
}

.qa-row.is-fail .qa-pct,
.qa-row.is-fail .qa-label {
  color: var(--red);
}

.qa-bar {
  grid-column: 1 / -1;
  position: relative;
  height: 8px;
  background: #0d0d13;
  border: 1px solid #000;
  border-radius: 2px;
  overflow: hidden;
}

.qa-bar-fill {
  height: 100%;
}

.is-pass .qa-bar-fill {
  background: var(--green);
}

.is-fail .qa-bar-fill {
  background: var(--red);
}

/* 합격 기준선 */
.qa-bar-mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  opacity: 0.8;
}

.team-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #d4d4e0;
}

.team-dot,
.prov-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  flex: none;
  border: 1px solid #0008;
}

.team-dot {
  border-radius: 2px;
}

.prov-dot {
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.section-title {
  margin: 18px 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.segmented {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
  scrollbar-width: none;
}

.segmented button {
  flex: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px 12px;
  min-height: 34px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.segmented button[aria-pressed='true'] {
  background: var(--gold);
  border-color: var(--gold);
  color: #2a1f00;
  font-weight: 700;
}

/* ------------------------------------------------------------
   업무 상세
   ------------------------------------------------------------ */
.detail-head {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.detail-directive {
  margin: 4px 0 8px;
  font-weight: 700;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

.meta dt {
  color: var(--muted);
}

.meta dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.callout {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border-left: 4px solid var(--blue);
  background: #1c2536;
  font-size: 14px;
}

.callout strong {
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}

.callout p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.callout-warn {
  border-color: var(--amber);
  background: #2d2313;
}

.callout-warn strong {
  color: var(--amber);
}

.callout-error {
  border-color: var(--red);
  background: #2d1717;
}

.callout-ceo {
  border-color: var(--gold);
  background: #2a2614;
}

.approval-box {
  margin-top: 12px;
  padding: 12px;
  background: #16161f;
  border: 2px dashed #4a4a2a;
  border-radius: var(--radius);
}

.approve-card .callout {
  margin-top: 8px;
}

.subtask {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.subtask summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  min-height: 44px;
}

.subtask summary::-webkit-details-marker {
  display: none;
}

.subtask summary::before {
  content: '▸';
  color: var(--muted);
  transition: transform 0.15s;
}

.subtask[open] summary::before {
  transform: rotate(90deg);
}

/* 오른쪽 끝 칩 묶음 (직원 검수 + 상태) */
.sub-chips {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  flex: none;
}

/* 펼친 하위 업무 안의 직원 검수 목록 */
.sub-qa {
  padding-bottom: 10px;
}

.sub-qa-error {
  margin: 4px 12px 0;
}

.sub-qa-list {
  list-style: none;
  margin: 4px 12px 0;
  padding: 0;
  font-size: 13px;
}

.sub-qa-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid #2a2a3a;
}

.sub-qa-list .is-pass {
  color: var(--green);
}

.sub-qa-list .is-fail {
  color: var(--red);
}

.sub-agent {
  font-weight: 700;
  white-space: nowrap;
}

.sub-title {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.sub-label {
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.pre {
  margin: 4px 12px 10px;
  padding: 10px;
  background: #0d0d13;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 360px;
  overflow-y: auto;
}

.round-label {
  margin: 10px 0 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
}

/* ---- 진행 단계 (접수 → 계획 → 작업 → 검토 → 완료) ---- */
.stepper {
  display: flex;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
}

.step {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-align: center;
  min-width: 0;
}

/* 점 사이를 잇는 선 */
.step + .step::before {
  content: '';
  position: absolute;
  top: 5px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
}

.step-dot {
  position: relative;
  z-index: 1;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--card2);
  border: 2px solid var(--line);
}

.step-done {
  color: var(--text);
}

.step-done .step-dot,
.step-done::before,
.step-now::before,
.step-wait::before,
.step-bad::before {
  background: var(--green) !important;
  border-color: var(--green);
}

.step-now {
  color: var(--gold);
}

.step-now .step-dot {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 4px #ffd34d33;
  animation: pulse 1.4s infinite;
}

.step-wait {
  color: var(--amber);
}

.step-wait .step-dot {
  background: var(--amber);
  border-color: var(--amber);
}

.step-bad {
  color: var(--red);
}

.step-bad .step-dot {
  background: var(--red);
  border-color: var(--red);
}

/* ---- 실시간 작업 출력 ---- */
.live-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s infinite;
}

.live-done summary {
  cursor: pointer;
}

.live-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.live-head .muted {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-say {
  margin-top: 4px;
  font-size: 13px;
  color: var(--gold);
  overflow-wrap: anywhere;
}

.live-say:empty {
  display: none;
}

.live-out {
  margin: 8px 0 0;
  padding: 10px;
  max-height: 50dvh;
  overflow-y: auto;
  background: #0d0d13;
  border: 1px solid #2a2a3a;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overscroll-behavior: contain;
}

/* 쓰는 중: 글 끝에 깜빡이는 커서 */
.live-out.is-writing::after {
  content: '▍';
  color: var(--gold);
  animation: pulse 1s infinite;
}

/* ---- 진행 기록 ---- */
.timeline-box summary {
  cursor: pointer;
}

.timeline {
  max-height: 260px;
}

.report {
  background: #fbfaf5;
  color: #22222c;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 0 #0008;
}

.report h4,
.report h5 {
  margin: 12px 0 4px;
}

.report h4:first-child,
.report p:first-child {
  margin-top: 0;
}

.report p {
  margin: 6px 0;
}

.report ul {
  margin: 4px 0;
  padding-left: 20px;
}

.report code {
  background: #ebe7da;
  padding: 0 4px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.9em;
}

.report .pre {
  margin: 8px 0;
  color: #e5e5ee;
}

/* 마크다운 확장: 표, 인용, 구분선, 링크 (보고서·기억 페이지 공용) */
.report hr {
  border: 0;
  border-top: 1px solid #d8d3c3;
  margin: 12px 0;
}

.report .md-quote {
  margin: 8px 0;
  padding: 4px 10px;
  border-left: 3px solid #d9a520;
  background: #f3efe2;
}

.report .md-quote p {
  margin: 2px 0;
}

.report .md-table {
  overflow-x: auto;
  margin: 8px 0;
}

.report .md-table table {
  border-collapse: collapse;
  font-size: 13px;
}

.report .md-table th,
.report .md-table td {
  border: 1px solid #d8d3c3;
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}

.report .md-table th {
  background: #efeadb;
}

.report a,
.report .wikilink {
  color: #2563eb;
  text-decoration: underline;
}

.report .wikilink.is-static {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}

/* [기억] 탭 */
.mem-counts {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text);
}

.mem-lastlog {
  margin-top: 4px;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mem-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* 결과물 파일 목록 + 선택한 파일 보기 */
.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.file-list li.is-selected {
  border-color: var(--gold);
}

.file-pick {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 8px 0 8px 12px;
  background: none;
  border: 0;
  text-align: left;
  font-weight: 600;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.file-list .muted {
  font-size: 12px;
  white-space: nowrap;
}

.file-list a {
  font-weight: 700;
  text-decoration: none;
  padding: 6px 2px;
}

/* 선택한 파일 내용 */
.file-view {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.file-view-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card2);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.file-view-head .segmented {
  margin: 0 0 0 auto;
}

.file-body {
  max-height: 60dvh;
  overflow: auto;
  background: #0d0d13;
  overscroll-behavior: contain;
}

.file-body .report {
  border-radius: 0;
  box-shadow: none;
}

.file-body > .muted,
.file-body > a {
  display: block;
  padding: 12px;
}

.code-view {
  display: flex;
  min-width: max-content;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
}

.code-view pre {
  margin: 0;
  padding: 10px;
  font: inherit;
  white-space: pre;
}

.code-gutter {
  flex: none;
  text-align: right;
  color: #5a5a72;
  border-right: 1px solid #2a2a3a;
  user-select: none;
  position: sticky;
  left: 0;
  background: #0d0d13;
}

.file-image {
  display: block;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
}

.file-frame {
  display: block;
  width: 100%;
  height: 60dvh;
  border: 0;
  background: #fff;
}

/* ------------------------------------------------------------
   예산
   ------------------------------------------------------------ */
.budget-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.budget-head .muted {
  margin-left: auto;
}

.budget-card.is-off {
  opacity: 0.6;
}

.bar {
  height: 14px;
  background: #0d0d13;
  border: 2px solid #000;
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  /* 픽셀 느낌의 줄무늬 */
  background-image: repeating-linear-gradient(90deg, #ffffff22 0 4px, transparent 4px 8px);
  transition: width 0.4s;
}

.bar-ok {
  background-color: var(--green);
}

.bar-warn {
  background-color: var(--amber);
}

.bar-danger {
  background-color: var(--red);
}

.budget-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 14px;
}

.pct {
  font-weight: 800;
}

.pct-warn {
  color: var(--amber);
}

.pct-danger {
  color: var(--red);
}

/* ------------------------------------------------------------
   로그
   ------------------------------------------------------------ */
.tab-logs {
  padding-top: 8px;
  padding-bottom: 8px;
}

.log-list {
  height: 65dvh;
  overflow-y: auto;
  font-size: 13px;
  background: #0f0f16;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 0;
  overscroll-behavior: contain;
}

.log-list.mini {
  height: auto;
  max-height: 180px;
}

.log-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  border-bottom: 1px solid #1d1d28;
}

.log-time {
  flex: none;
  color: #6b6b82;
  font-family: var(--mono);
  font-size: 11.5px;
}

.log-agent {
  flex: none;
  font-weight: 700;
}

.log-text {
  flex: 1;
  overflow-wrap: anywhere;
  min-width: 0;
}

.log-warn .log-text {
  color: var(--amber);
}

.log-error {
  background: #2a1414;
}

.log-error .log-text {
  color: var(--red);
}

.log-task {
  flex: none;
  background: none;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
}

/* ------------------------------------------------------------
   직원 상세 시트
   ------------------------------------------------------------ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #0009;
}

.sheet {
  position: fixed;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  height: 88dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg2);
  border-top: 3px solid #000;
  border-radius: 14px 14px 0 0;
  padding: 6px 16px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.2s ease-out;
  box-shadow: 0 -8px 30px #0008;
}

.sheet > * {
  flex: none;
}

.sheet.open {
  transform: none;
}

/* 넓은 화면에서는 가운데 아래쪽에 카드처럼 */
@media (min-width: 700px) {
  .sheet {
    left: 50%;
    right: auto;
    width: 500px;
    margin-left: -250px;
    bottom: 16px;
    height: min(86dvh, 820px);
    border: 3px solid #000;
    border-radius: 14px;
    transform: translateY(calc(100% + 30px));
  }
}

.sheet-grip {
  width: 40px;
  height: 4px;
  margin: 4px auto 10px;
  border-radius: 2px;
  background: var(--line);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.avatar-box {
  flex: none;
  display: grid;
  place-items: center;
  width: 72px;
  height: 92px;
  background: #2a2f3d;
  border: 2px solid #000;
  border-radius: 8px;
  background-image: linear-gradient(#0000 70%, #0003 70%);
}

.sheet-title {
  flex: 1;
  min-width: 0;
}

.sheet-title h2 {
  margin: 0;
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sheet-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.lead-tag {
  font-size: 11px;
  background: var(--gold);
  color: #2a1f00;
  border-radius: 4px;
  padding: 1px 6px;
}

.say {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #fff;
  color: #1d1d29;
  border: 2px solid #000;
  border-radius: 8px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.sheet .meta {
  margin-bottom: 10px;
}

.sheet-activity summary {
  cursor: pointer;
}

/* ---- 1:1 대화 (남은 높이를 채우고, 입력칸은 아래에 고정) ---- */
.sheet > .chat {
  flex: 1 1 0;
  min-height: 340px;
  display: flex;
  flex-direction: column;
}

.chat .section-title {
  margin-top: 12px;
}

.chat-list {
  flex: 1 1 0;
  min-height: 140px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: #0f0f16;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chat-empty {
  margin: auto;
  font-size: 13px;
}

.msg {
  max-width: 85%;
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-time {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  opacity: 0.6;
  text-align: right;
}

.msg-ceo {
  align-self: flex-end;
  background: var(--gold);
  color: #2a1f00;
  border-bottom-right-radius: 3px;
}

.msg-agent {
  align-self: flex-start;
  background: var(--card2);
  border-left: 4px solid var(--blue);
  border-bottom-left-radius: 3px;
}

.msg-system {
  align-self: center;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  padding: 2px 10px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.msg-system .link-btn {
  min-height: 30px;
  padding: 4px 0;
}

.chat-typing {
  padding: 6px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  animation: pulse 1.4s infinite;
}

.chat-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 8px;
}

.chat-input {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  resize: none;
}

.chat-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-buttons .btn {
  min-height: 38px;
  padding: 6px 12px;
  white-space: nowrap;
}

.chat-order {
  background: var(--card2);
}

/* ------------------------------------------------------------
   토스트 알림
   ------------------------------------------------------------ */
#toasts {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  border: 2px solid #000;
  border-radius: 8px;
  background: #2b2b3c;
  box-shadow: 0 3px 0 #000;
  font-size: 14px;
  font-weight: 600;
  animation: toastIn 0.18s ease-out;
  transition: opacity 0.3s, transform 0.3s;
  overflow-wrap: anywhere;
}

.toast-ok {
  background: #14532d;
}

.toast-warn {
  background: #713f12;
}

.toast-error {
  background: #7f1d1d;
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ------------------------------------------------------------
   로그인 페이지
   ------------------------------------------------------------ */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    repeating-linear-gradient(0deg, #ffffff05 0 2px, transparent 2px 16px),
    repeating-linear-gradient(90deg, #ffffff05 0 2px, transparent 2px 16px),
    var(--bg);
}

.login-box {
  width: min(100%, 360px);
  background: var(--card);
  border: 3px solid #000;
  border-radius: 12px;
  padding: 28px 22px 24px;
  box-shadow: 0 6px 0 #000;
  text-align: center;
}

.login-box h1 {
  margin: 12px 0 2px;
  font-size: 26px;
  letter-spacing: 0.06em;
}

.login-box form {
  margin-top: 20px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.login-box .btn {
  margin-top: 8px;
}

/* 로그인 화면의 픽셀 건물 그림 */
.login-logo {
  width: 8px;
  height: 8px;
  margin: 0 auto 32px;
  transform: translateX(-12px);
  background: var(--gold);
  box-shadow:
    8px 0 var(--gold), 16px 0 var(--gold), 24px 0 var(--gold),
    0 8px #e85d5d, 8px 8px #9fd3ff, 16px 8px #e85d5d, 24px 8px #9fd3ff,
    0 16px #4f8de0, 8px 16px #9fd3ff, 16px 16px #4f8de0, 24px 16px #9fd3ff,
    0 24px #53b77a, 8px 24px #53b77a, 16px 24px #7b4a24, 24px 24px #53b77a;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
