/* ========== 공통 리셋 ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1624;
  --bg-2: #151e31;
  --surface: #1c2740;
  --border: #2a3656;
  --text: #e6ecf5;
  --text-dim: #8a95ab;
  --accent: #4fc3ff;
  --accent-2: #7c5cff;
  --success: #4ade80;
  --warn: #fbbf24;
  --error: #f87171;
  --front: #ff7aa2;
  --back: #4fc3ff;
  --db: #4ade80;
  --mono: "JetBrains Mono", "Consolas", "D2Coding", monospace;
  --sans: "Pretendard", "Noto Sans KR", -apple-system, sans-serif;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ========== 헤더 / 네비게이션 ========== */
.top-nav {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-nav .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: 0.3px;
}
.top-nav .brand span { color: var(--accent); }
.top-nav ul {
  list-style: none;
  display: flex;
  gap: 18px;
  margin-left: auto;
}
.top-nav ul a {
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 6px;
}
.top-nav ul a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.top-nav ul a.active { color: var(--text); background: var(--surface); }

/* ========== 드롭다운 서브메뉴 (팀 협업) ========== */
.top-nav .has-submenu { position: relative; }
.top-nav .has-submenu > a::after {
  content: " ▾";
  font-size: 10px;
  opacity: 0.6;
  margin-left: 2px;
}
.top-nav .submenu {
  display: none;                       /* 기본 숨김 */
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
  list-style: none;
  flex-direction: column;              /* hover 시 flex 가 되면 세로 배치 */
  gap: 2px;
  margin: 6px 0 0;                     /* 부모와 약간의 간격 */
  z-index: 200;
}
.top-nav .has-submenu:hover .submenu {
  display: flex;
}
/* 호버 끊김 방지: 부모와 submenu 사이의 invisible bridge */
.top-nav .has-submenu::before {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 200px;
  height: 10px;
}
.top-nav .submenu li { width: 100%; }
.top-nav .submenu a {
  display: block;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text-dim);
  border-radius: 6px;
  white-space: nowrap;
}
.top-nav .submenu a:hover {
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
}
.top-nav .submenu a.active {
  color: var(--accent);
  background: var(--surface);
}

/* ========== 레이아웃 ========== */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.page h1 {
  font-size: 28px;
  margin-bottom: 8px;
}
.page .subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 15px;
}
section { margin-top: 44px; }
section h2 {
  font-size: 20px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
section h3 { font-size: 16px; margin: 18px 0 10px; color: var(--accent); }
p { margin-bottom: 12px; color: #cfd6e4; }
ul.bullet { padding-left: 20px; margin-bottom: 12px; }
ul.bullet li { margin-bottom: 6px; color: #cfd6e4; }

/* ========== 카드 / 블록 ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.card.link {
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
  display: block;
  color: inherit;
}
.card.link:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  text-decoration: none;
}
.card.link h3 { margin-top: 0; }

/* ========== 가짜 브라우저 UI ========== */
.browser {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.browser .chrome {
  background: #0b1220;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.browser .dots { display: flex; gap: 6px; }
.browser .dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3a465e;
}
.browser .dots span:nth-child(1) { background: #f87171; }
.browser .dots span:nth-child(2) { background: #fbbf24; }
.browser .dots span:nth-child(3) { background: #4ade80; }
.browser .url-form {
  flex: 1;
  display: flex;
  gap: 8px;
}
.browser .url-bar {
  flex: 1;
  background: #121a2c;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 14px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
}
.browser .url-bar:focus { border-color: var(--accent); }
.browser .go-btn {
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
}
.browser .viewport {
  min-height: 260px;
  background: #ffffff;
  color: #111827;
  padding: 24px;
  font-family: var(--sans);
}
.browser .viewport.dark { background: #0b1220; color: var(--text); }

/* 렌더링되는 가짜 JSP 페이지 스타일 */
.jsp-page h1 { color: #1e40af; margin-bottom: 8px; }
.jsp-page p  { color: #4b5563; }
.jsp-page .jsp-tag {
  display: inline-block;
  background: #fde68a;
  color: #78350f;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-family: var(--mono);
  margin-bottom: 14px;
}
.jsp-page form {
  display: flex; flex-direction: column; gap: 10px; max-width: 280px; margin-top: 14px;
}
.jsp-page input, .jsp-page button {
  padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px;
}
.jsp-page button { background: #1e40af; color: white; border: none; cursor: pointer; }
.jsp-page table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.jsp-page th, .jsp-page td { padding: 8px; border-bottom: 1px solid #e5e7eb; text-align: left; font-size: 14px; }
.jsp-page th { background: #f1f5f9; }

/* 에러 페이지 */
.err-screen {
  text-align: center;
  padding: 40px 20px;
}
.err-screen .code {
  font-size: 72px;
  font-weight: 800;
  letter-spacing: -2px;
  margin-bottom: 4px;
}
.err-404 .code { color: #7c5cff; }
.err-500 .code { color: #f87171; }
.err-screen .title { font-size: 18px; margin-bottom: 8px; color: #374151; }
.err-screen .detail { font-size: 13px; color: #6b7280; font-family: var(--mono); }

/* ========== 코드 블록 ========== */
pre.code {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: #cfd6e4;
  margin: 10px 0;
}
.code .kw { color: #c084fc; }
.code .str { color: #86efac; }
.code .num { color: #fbbf24; }
.code .cmt { color: #64748b; font-style: italic; }
.code .tag { color: #4fc3ff; }
.code .attr { color: #fbbf24; }
.code .fn { color: #7dd3fc; }

/* ========== 흐름 다이어그램 (라우팅) ========== */
.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}
.flow .node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  transition: all 0.3s;
}
.flow .node.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,195,255,0.15);
  background: #152236;
}
.flow .node .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.flow .node .value { font-family: var(--mono); font-size: 14px; margin-top: 4px; color: var(--text); }
.flow .arrow { color: var(--text-dim); font-size: 22px; transition: color 0.3s; }
.flow .arrow.active { color: var(--accent); }
@media (max-width: 720px) {
  .flow { grid-template-columns: 1fr; }
  .flow .arrow { transform: rotate(90deg); }
}

/* ========== 상태 코드 표 ========== */
table.status {
  width: 100%; border-collapse: collapse; margin-top: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
table.status th, table.status td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.status th { background: #111a2d; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
table.status tr:last-child td { border-bottom: none; }
table.status .sc { font-family: var(--mono); font-weight: 700; }
.sc.s2 { color: var(--success); }
.sc.s4 { color: var(--warn); }
.sc.s5 { color: var(--error); }

/* ========== 버튼 ========== */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; }
button.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  transition: all 0.15s;
}
button.pill:hover { border-color: var(--accent); color: var(--accent); }
button.pill.danger:hover { border-color: var(--error); color: var(--error); }

/* ========== 협업 타임라인 ========== */
.roles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.role {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  position: relative;
  min-height: 180px;
  transition: border-color 0.3s;
}
.role.front { border-top: 3px solid var(--front); }
.role.back  { border-top: 3px solid var(--back); }
.role.db    { border-top: 3px solid var(--db); }
.role h3 { margin: 0 0 6px; font-size: 14px; }
.role.front h3 { color: var(--front); }
.role.back h3  { color: var(--back); }
.role.db h3    { color: var(--db); }
.role .who { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.role .state {
  font-family: var(--mono);
  font-size: 12px;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  color: var(--text-dim);
  min-height: 100px;
  white-space: pre-wrap;
  transition: color 0.3s;
}
.role.active { border-color: var(--accent); }
.role.active .state { color: var(--text); }

.timeline {
  display: flex;
  gap: 8px;
  margin-top: 22px;
  padding: 12px;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}
.timeline button {
  flex: 1;
  min-width: 120px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  text-align: left;
  transition: all 0.15s;
}
.timeline button:hover { color: var(--text); border-color: var(--accent); }
.timeline button.current {
  background: var(--accent);
  color: #0b1220;
  border-color: var(--accent);
  font-weight: 700;
}
.timeline button .day { display: block; font-size: 10px; opacity: 0.7; margin-bottom: 2px; }

.narration {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin-top: 18px;
  color: var(--text);
  font-size: 14px;
}
.narration .tag {
  display: inline-block;
  font-size: 10px;
  background: var(--accent);
  color: #0b1220;
  padding: 2px 8px;
  border-radius: 10px;
  font-family: var(--mono);
  margin-right: 8px;
  font-weight: 700;
}

/* ========== 역할별 상세 카드 (큰 사이즈) ========== */
.role-deep {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 26px;
  margin-top: 22px;
  border-top: 4px solid var(--border);
}
.role-deep.front { border-top-color: var(--front); }
.role-deep.back  { border-top-color: var(--back); }
.role-deep.db    { border-top-color: var(--db); }
.role-deep h3 {
  font-size: 20px;
  margin: 0 0 4px;
  border: none;
  padding: 0;
}
.role-deep.front h3 { color: var(--front); }
.role-deep.back  h3 { color: var(--back); }
.role-deep.db    h3 { color: var(--db); }
.role-deep .who { font-size: 12px; color: var(--text-dim); margin-bottom: 18px; text-transform: uppercase; letter-spacing: 0.5px; }
.role-deep h4 { font-size: 14px; margin: 22px 0 10px; color: var(--accent); }
.role-deep h4:first-of-type { margin-top: 0; }

/* ========== 체크리스트 (계약 항목) ========== */
ul.checklist {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}
ul.checklist li {
  padding: 12px 16px 12px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #cfd6e4;
  position: relative;
}
ul.checklist li::before {
  content: '[합의]';
  color: var(--success);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  position: absolute;
  left: 12px;
  top: 13px;
}
ul.checklist li b { color: var(--text); }
ul.checklist li code { background: #0b1220; padding: 1px 6px; border-radius: 3px; font-size: 12px; }

/* ========== 파일 트리 ========== */
pre.file-tree {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.75;
  color: #cfd6e4;
  margin: 14px 0;
  overflow-x: auto;
}
.file-tree .own-front { color: var(--front); }
.file-tree .own-back  { color: var(--back); }
.file-tree .own-db    { color: var(--db); }
.file-tree .own-share { color: var(--accent); font-weight: 700; }
.file-tree .tree-line { color: #4a5876; }
.file-tree .note { color: var(--text-dim); font-size: 11px; margin-left: 6px; }

/* ========== 책임자 표시 라벨 ========== */
.owner-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 6px;
  letter-spacing: 0.3px;
}
.owner-tag.front { background: rgba(255,122,162,0.15); color: var(--front); border: 1px solid rgba(255,122,162,0.4); }
.owner-tag.back  { background: rgba(79,195,255,0.15);  color: var(--back);  border: 1px solid rgba(79,195,255,0.4); }
.owner-tag.db    { background: rgba(74,222,128,0.15);  color: var(--db);    border: 1px solid rgba(74,222,128,0.4); }
.owner-tag.share { background: rgba(124,92,255,0.15);  color: var(--accent-2); border: 1px solid rgba(124,92,255,0.4); }

/* ========== 스크린샷 ========== */
figure.screenshot {
  margin: 18px 0;
  padding: 0;
  text-align: center;
}
figure.screenshot img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  background: #ffffff;
}
figure.screenshot figcaption {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
  letter-spacing: 0.3px;
}
figure.screenshot figcaption b {
  color: var(--accent);
}

/* ========== 데이터 흐름 스텝 ========== */
.flow-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
  margin: 18px 0;
  position: relative;
  padding-left: 72px;
}
.flow-step::before {
  content: attr(data-step);
  position: absolute;
  left: 20px;
  top: 22px;
  width: 38px;
  height: 38px;
  background: var(--accent);
  color: #0b1220;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: var(--mono);
  font-size: 16px;
}
.flow-step.err::before {
  background: var(--error);
  color: #fff;
}
.flow-step h3 {
  font-size: 17px;
  color: var(--text);
  margin: 0 0 6px;
  border: none;
  padding: 0;
}
.flow-step .who-line {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}
.flow-step .who-line .owner-tag { margin-right: 4px; }
.flow-step p { margin-bottom: 8px; }
.flow-step figure.screenshot { margin: 14px 0 6px; }

/* ========== 충돌 시나리오 박스 ========== */
.conflict {
  background: #2a1a1a;
  border: 1px solid rgba(248,113,113,0.4);
  border-radius: 10px;
  padding: 18px 22px;
  margin: 14px 0;
}
.conflict h4 {
  color: var(--error);
  margin: 0 0 8px;
  font-size: 15px;
}
.conflict .scene { color: #f0d4d4; font-size: 14px; margin-bottom: 10px; }
.conflict .fix {
  background: #1a2a1a;
  border-left: 3px solid var(--success);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  color: #d4f0d4;
  font-size: 13px;
  margin-top: 10px;
}
.conflict .fix b { color: var(--success); }

/* ========== 팁 박스 ========== */
.tip {
  background: #152236;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 14px 16px;
  color: #cfd6e4;
  font-size: 14px;
  margin: 14px 0;
}
.tip b { color: var(--accent); }
.warn-box {
  background: #2a1a1a;
  border: 1px dashed var(--error);
  border-radius: 8px;
  padding: 14px 16px;
  color: #f0d4d4;
  font-size: 14px;
  margin: 14px 0;
}
.warn-box b { color: var(--error); }
