:root {
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 57px;
  --header-height: 58px;

  /* Exact Cloudflare Kumo Light Theme Tokens */
  --kumo-canvas: #ffffff;
  --kumo-base: #ffffff;
  --kumo-elevated: #f5f5f5;
  --kumo-recessed: #f3f3f3;
  --kumo-tint: #f5f5f5;
  --kumo-illustration-bg: #fdfdfc;

  --kumo-line: #e5e5e5;
  --kumo-hairline: #efefef;

  --kumo-default: #171717;
  --kumo-strong: #0a0a0a;
  --kumo-subtle: #737373;

  --kumo-orange: #ff5e1f;
  --kumo-orange-accent: #fd6a2b;
  --kumo-blue: #0051c3;
  --kumo-focus: #086fff;

  --font-sans: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* 테마별로 바뀌는 보조 색상 */
  --kumo-placeholder: #a3a3a3;
  --kumo-badge-border: #d4d4d4;
  --kumo-kbd-bg: #fafafa;
  --kumo-kbd-border: #e5e5e5;
  --kumo-kbd-text: #525252;
  --step-empty: #e5e5e5;
  --toast-bg: #171717;
  --toast-text: #ffffff;
  --toast-border: transparent;

  /* 포인트 색상 (Google Blue / Red) */
  --accent-blue: #4285f4;
  --accent-blue-glow: rgba(66, 133, 244, 0.55);
  --accent-blue-glow-0: rgba(66, 133, 244, 0);
  --accent-red: #ea4335;
  --accent-red-tint: rgba(234, 67, 53, 0.08);

  color-scheme: light;
}

/* =========================================================
   Dark Theme (html[data-theme="dark"])
   ========================================================= */
:root[data-theme='dark'] {
  --kumo-canvas: #0f0f0f;
  --kumo-base: #171717;
  --kumo-elevated: #141414;
  --kumo-recessed: #262626;
  --kumo-tint: #222222;
  --kumo-illustration-bg: #1c1c1c;

  --kumo-line: #2e2e2e;
  --kumo-hairline: #262626;

  --kumo-default: #ededed;
  --kumo-strong: #fafafa;
  --kumo-subtle: #a1a1a1;

  --kumo-blue: #6ea8ff;
  --kumo-focus: #4c8dff;

  --kumo-placeholder: #6b6b6b;
  --kumo-badge-border: #3a3a3a;
  --kumo-kbd-bg: #1f1f1f;
  --kumo-kbd-border: #333333;
  --kumo-kbd-text: #a1a1a1;
  --step-empty: #2e2e2e;
  --toast-bg: #262626;
  --toast-text: #ededed;
  --toast-border: #3a3a3a;

  /* 다크 배경에서 눈부심 없이 대비가 맞도록 한 톤 밝고 부드러운 색 (Google Blue 400 / Red 400) */
  --accent-blue: #669df6;
  --accent-blue-glow: rgba(102, 157, 246, 0.5);
  --accent-blue-glow-0: rgba(102, 157, 246, 0);
  --accent-red: #ee675c;
  --accent-red-tint: rgba(238, 103, 92, 0.14);

  color-scheme: dark;
}

/* 테마 전환 순간에는 transition 을 꺼서 버튼 등이 이전 색에서 늦게 바뀌며 반짝이지 않도록 함 */
:root.theme-switching *,
:root.theme-switching *::before,
:root.theme-switching *::after {
  transition: none !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100vh;
  background-color: var(--kumo-canvas);
  color: var(--kumo-default);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================
   Main Grid Layout (260px Sidebar + 1fr Content)
   ========================================================= */
.cf-app-grid {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.25s cubic-bezier(0.77, 0, 0.175, 1);
}

.cf-app-grid.collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

/* =========================================================
   Left Sidebar (Exact SidebarNav.tsx)
   ========================================================= */
.cf-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background-color: var(--kumo-canvas);
  border-right: 1px solid var(--kumo-line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
}

/* Sidebar Scroll Viewport */
.cf-sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px;
  scrollbar-width: none;
}

.cf-sidebar-body::-webkit-scrollbar {
  display: none;
}

/* Sidebar Menu List */
.cf-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cf-nav-item {
  width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--kumo-default);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s;
}

.cf-nav-item:hover {
  background-color: var(--kumo-recessed);
}

.cf-nav-item.active {
  background-color: var(--kumo-recessed);
}

.cf-nav-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.cf-nav-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-nav-chevron {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.4;
}

.cf-nav-item:hover .cf-nav-chevron {
  opacity: 0.85;
}

.cf-badge-dashed {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 9999px;
  border: 1px solid var(--kumo-badge-border);
  font-size: 11px;
  line-height: 1;
  font-weight: 500;
  color: var(--kumo-strong);
  flex-shrink: 0;
}

.cf-nav-separator {
  margin: 12px 8px;
  border-bottom: 1px solid var(--kumo-line);
}

/* Sidebar Footer */
.cf-sidebar-footer {
  height: 48px;
  padding: 0 14px;
  border-top: 1px solid var(--kumo-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cf-collapse-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--kumo-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.cf-collapse-btn:hover {
  background-color: var(--kumo-recessed);
  color: var(--kumo-default);
}

/* Collapsed Sidebar State */
.cf-app-grid.collapsed .cf-nav-text,
.cf-app-grid.collapsed .cf-nav-chevron,
.cf-app-grid.collapsed .cf-badge-dashed {
  display: none;
}

/* 최소화 시 57px 폭 안에 아이콘/버튼이 가운데 정렬되도록 여백 조정 */
.cf-app-grid.collapsed .cf-sidebar-body {
  padding: 12px 8px;
}

.cf-app-grid.collapsed .cf-nav-item {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.cf-app-grid.collapsed .cf-nav-separator {
  margin: 12px 4px;
}

.cf-app-grid.collapsed .cf-sidebar-footer {
  padding: 0;
  justify-content: center;
}

/* =========================================================
   Right Main Column & Top Header (58px)
   ========================================================= */
.cf-main-column {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--kumo-canvas);
}

.cf-topbar {
  height: var(--header-height);
  background-color: var(--kumo-canvas);
  border-bottom: 1px solid var(--kumo-line);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.cf-topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 라이트/다크 모드 전환 버튼 */
.cf-theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--kumo-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.cf-theme-toggle:hover {
  background-color: var(--kumo-recessed);
  color: var(--kumo-default);
}

/* 라이트 모드: 달 아이콘(다크로 전환) / 다크 모드: 해 아이콘(라이트로 전환) */
.cf-theme-icon-sun {
  display: none;
}

:root[data-theme='dark'] .cf-theme-icon-sun {
  display: block;
}

:root[data-theme='dark'] .cf-theme-icon-moon {
  display: none;
}

/* =========================================================
   Center Page Body (AccountHome.tsx 1000px Grid Track)
   ========================================================= */
.cf-page-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(32px, 1fr) minmax(0, 1000px) minmax(32px, 1fr);
  padding-top: 56px;
  padding-bottom: 48px;
}

.cf-home-stack {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
}

/* Home view: 제목 + 검색창만 화면 가운데 배치 */
.cf-page-body.is-home {
  padding-top: 0;
  padding-bottom: 0;
}

.cf-page-body.is-home .cf-home-stack {
  align-self: center;
  margin-top: -8vh;
}

.cf-list-stack {
  grid-column: 2;
  width: 100%;
  align-self: start;
}

.cf-view[hidden],
.cf-kumo-btn[hidden] {
  display: none !important;
}

/* 1. Top Pill Button ("Onboard your agent to Cloudflare") */
.cf-pill-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-agent-pill {
  height: 36px;
  padding: 0 14px;
  border-radius: 9999px;
  background-color: var(--kumo-base);
  border: 1px solid var(--kumo-line);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color: var(--kumo-default);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.cf-agent-pill:hover {
  background-color: var(--kumo-tint);
}

.cf-agent-icons {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cf-agent-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.cf-agent-svg-opencode {
  height: 17px;
  width: auto;
  flex-shrink: 0;
}

/* 2. Hero Heading ("What are we building today?") */
.cf-hero-heading-wrap {
  text-align: center;
}

.cf-hero-heading {
  font-size: 30px;
  font-weight: 600;
  color: var(--kumo-default);
  letter-spacing: -0.015em;
  line-height: 1.25;
}

/* 3. Recessed Search Bar (AccountHomeSearch.tsx) */
.cf-search-outer {
  width: 100%;
  background-color: var(--kumo-elevated);
  border: 1px solid var(--kumo-hairline);
  border-radius: 16px;
  overflow: hidden;
}

.cf-search-inner-frame {
  padding: 6px;
  background-color: var(--kumo-elevated);
  border-radius: 16px;
}

.cf-search-input-group {
  width: 100%;
  height: 40px;
  background-color: var(--kumo-base);
  border: 1px solid var(--kumo-line);
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  cursor: text;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.cf-search-input-group:focus-within {
  border-color: var(--kumo-focus);
  box-shadow: 0 0 0 2px rgba(8, 111, 255, 0.2), 0 4px 6px -1px rgba(0, 0, 0, 0.06);
}

.cf-search-addon-start {
  padding-left: 12px;
  color: var(--kumo-subtle);
  display: flex;
  align-items: center;
}

.cf-search-main-input {
  flex: 1;
  height: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 0 12px;
  font-family: inherit;
  font-size: 15px;
  color: var(--kumo-default);
}

.cf-search-main-input::placeholder {
  color: var(--kumo-placeholder);
}

.cf-search-addon-end {
  padding-right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cf-kbd-box {
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background-color: var(--kumo-kbd-bg);
  border: 1px solid var(--kumo-kbd-border);
  color: var(--kumo-kbd-text);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Kumo Standard Buttons & Inputs */
.cf-kumo-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--kumo-line);
  background-color: var(--kumo-base);
  color: var(--kumo-default);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s;
}

.cf-kumo-btn:hover:not(:disabled) {
  background-color: var(--kumo-tint);
}

.cf-kumo-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cf-kumo-btn-sm {
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

/* 버튼 안 아이콘 (사이드바 아이콘과 동일 톤) */
.cf-btn-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.cf-kumo-btn:hover:not(:disabled) .cf-btn-icon {
  opacity: 1;
}

/* 아이콘만 있는 정사각형 버튼 */
.cf-kumo-btn-icon {
  width: 32px;
  padding: 0;
}

/* 삭제 버튼: 호버 시 #EA4335 */
.cf-btn-delete {
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.cf-btn-delete:hover:not(:disabled) {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background-color: var(--accent-red-tint);
}

/* 버튼 로딩 상태: 아이콘 자리에 스피너 표시 */
.cf-kumo-btn.is-loading,
.cf-kumo-btn.is-loading:disabled {
  opacity: 1;
  cursor: progress;
}

.cf-kumo-btn.is-loading .cf-btn-icon {
  display: none;
}

.cf-kumo-btn.is-loading::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.7;
  animation: cfSpin 0.7s linear infinite;
}

.cf-btn-delete.is-loading {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background-color: var(--accent-red-tint);
}

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

.cf-kumo-btn-dark {
  background-color: #171717;
  border-color: #171717;
  color: #ffffff;
}

.cf-kumo-btn-dark:hover:not(:disabled) {
  background-color: #333333;
}

.cf-kumo-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--kumo-line);
  background-color: var(--kumo-canvas);
  color: var(--kumo-default);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}

.cf-kumo-input::placeholder {
  color: var(--kumo-placeholder);
}

.cf-kumo-input:focus {
  border-color: var(--kumo-focus);
  box-shadow: 0 0 0 2px rgba(8, 111, 255, 0.18);
}

/* =========================================================
   5. Sandbox List Section (Matching Kumo LayerCard Style)
   ========================================================= */
.cf-sandbox-panel {
  width: 100%;
  background-color: var(--kumo-base);
  border: 1px solid var(--kumo-line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cf-sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--kumo-hairline);
}

.cf-sandbox-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.cf-sandbox-heading {
  font-size: 16px;
  font-weight: 600;
  color: var(--kumo-default);
}

.cf-subtle-meta {
  font-size: 12.5px;
  color: var(--kumo-subtle);
}

.cf-subtle-meta code {
  font-family: var(--font-mono);
  background: var(--kumo-recessed);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--kumo-default);
}

.cf-sandbox-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cf-sandbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cf-sandbox-row {
  padding: 12px 14px;
  border-radius: 8px;
  background-color: var(--kumo-illustration-bg);
  border: 1px solid var(--kumo-line);
  display: grid;
  grid-template-columns: 1.4fr 1.2fr auto;
  align-items: center;
  gap: 16px;
}

/* 진단 보고서(완료) 항목: 저장소 이름 + 버튼만 */
.cf-sandbox-row.cf-sandbox-row--simple {
  grid-template-columns: 1fr auto;
}

.cf-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* GitHub 저장소 소유자 프로필 이미지 */
.cf-repo-avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--kumo-line);
  background-color: var(--kumo-recessed);
  object-fit: cover;
}

.cf-repo-avatar--empty {
  display: inline-block;
}

.cf-row-repo {
  font-size: 14px;
  font-weight: 500;
  color: var(--kumo-default);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-row-repo:hover {
  text-decoration: underline;
  color: var(--kumo-blue);
}

.cf-row-status-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cf-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
}

.cf-step-track {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cf-step-bar {
  height: 5px;
  border-radius: 99px;
  background-color: var(--step-empty);
}

/* 진단 중 / 완료 상태바: #4285F4 통일 */
.cf-step-bar.done {
  background-color: var(--accent-blue);
}

.cf-step-bar.all-done {
  background-color: var(--accent-blue);
}

.cf-step-bar.current {
  background-color: var(--accent-blue);
}

/* 새로 불이 들어온 칸: 회색 -> 현재 색으로 부드럽게 켜짐 */
.cf-step-bar.lighting {
  animation: cfLightUp 0.9s ease-out both;
}

@keyframes cfLightUp {
  from {
    background-color: var(--step-empty);
    box-shadow: 0 0 0 var(--accent-blue-glow-0);
  }

  60% {
    box-shadow: 0 0 6px var(--accent-blue-glow);
  }

  to {
    box-shadow: 0 0 0 var(--accent-blue-glow-0);
  }
}

/* 실패 항목 상태바: 실패 전 단계는 파란색, 실패한 단계는 삭제 버튼과 같은 #EA4335 */
.cf-step-bar.failed-done {
  background-color: var(--accent-blue);
}

.cf-step-bar.failed {
  background-color: var(--accent-red);
}

/* 진단 중 멘트 끝 점(.) 애니메이션: . -> .. -> ... 반복 (자리 폭 고정) */
.cf-loading-dots span {
  animation-duration: 1.5s;
  animation-iteration-count: infinite;
  animation-timing-function: steps(1, end);
}

.cf-loading-dots span:nth-child(2) {
  animation-name: cfDot2;
}

.cf-loading-dots span:nth-child(3) {
  animation-name: cfDot3;
}

@keyframes cfDot2 {
  0% {
    opacity: 0;
  }

  33.333% {
    opacity: 1;
  }

  100% {
    opacity: 1;
  }
}

@keyframes cfDot3 {
  0% {
    opacity: 0;
  }

  66.666% {
    opacity: 1;
  }

  100% {
    opacity: 1;
  }
}

.cf-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-empty-box {
  padding: 28px;
  text-align: center;
  color: var(--kumo-subtle);
  font-size: 13.5px;
  border: 1px dashed var(--kumo-line);
  border-radius: 8px;
}

/* Toast */
.cf-toast-viewport {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 150;
}

.cf-toast {
  padding: 10px 14px;
  border-radius: 8px;
  background-color: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  font-size: 13px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cf-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .cf-sandbox-row {
    grid-template-columns: 1fr;
  }
}