/* 디자인 토큰
   - 구조, 색: 사용자 제공 design.md (강조색 #0052ff 1색)
   - 글꼴: SUIT, 본문 12px, 페이지 제목 28px, 절 제목 16px */
:root {
  --primary: #0052ff;
  --primary-active: #003ecc;
  --primary-disabled: #a8b8cc;
  --canvas: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-strong: #eef0f3;
  --surface-dark: #0a0b0d;
  --surface-dark-elevated: #16181c;
  --hairline: #dee1e6;
  --ink: #0a0b0d;
  --body: #5b616e;
  --muted: #7c828a;
  --on-dark: #ffffff;
  --on-dark-soft: #a8acb3;
  --up: #05b169;
  --down: #cf202f;
  --r-sm: 8px;
  --r-md: 12px;
  --r-xl: 24px;
  --r-pill: 100px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  --font: 'SUIT Variable', -apple-system, system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --nav-h: 64px;
  --side-w: 208px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 12px/1.5 var(--font);
  color: var(--body);
  background: var(--canvas);
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }
[hidden] { display: none !important; }

.display, .page-title { font-size: 28px; font-weight: 400; line-height: 1.2; letter-spacing: -0.5px; }
.page-title { margin-bottom: 32px; }
h2 { font-size: 16px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 12px; font-weight: 600; line-height: 1.5; }
.muted { color: var(--muted); }
.strong { color: var(--ink); font-weight: 600; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.error { color: var(--down); }

/* 상단 바 */
.topnav {
  position: sticky; top: 0; z-index: 20;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
}
.wordmark { font-size: 16px; font-weight: 800; letter-spacing: -0.3px; color: var(--primary); }
.wordmark span { margin-left: 4px; font-weight: 400; color: var(--ink); }
.wordmark:hover { text-decoration: none; }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.me-link { color: var(--ink); font-weight: 600; }
.topnav .menu-toggle { display: none; }

/* 사이드 메뉴 */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: calc(100vh - var(--nav-h)); }
.sidenav {
  position: sticky; top: var(--nav-h);
  align-self: start;
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 24px 12px;
  border-right: 1px solid var(--hairline);
  background: var(--canvas);
}
.nav-group { padding: 16px 12px 6px; color: var(--muted); font-weight: 600; }
.nav-group:first-child { padding-top: 0; }
.sidenav a {
  display: flex; align-items: center;
  min-height: 36px; padding: 0 12px;
  border-radius: var(--r-pill);
  color: var(--ink); font-weight: 500;
}
.sidenav a:hover { background: var(--surface-soft); text-decoration: none; }
.sidenav a.active { background: var(--surface-strong); font-weight: 700; }

/* 띠와 컨테이너 */
.band { padding: 48px 0; }
.band-soft { background: var(--surface-soft); }
.band-dark { background: var(--surface-dark); color: var(--on-dark); }
.band-dark h1, .band-dark h2, .band-dark h3 { color: var(--on-dark); }
.container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.stack > * + * { margin-top: 24px; }

.grid-2, .grid-3 { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 20px;
  border: 0; border-radius: var(--r-pill);
  font-weight: 600; line-height: 1; white-space: nowrap;
  cursor: pointer;
}
.btn:hover { text-decoration: none; }
.btn-sm { height: 32px; padding: 0 14px; }
.btn-primary { background: var(--primary); color: var(--canvas); }
.btn-primary:active { background: var(--primary-active); }
.btn-primary:disabled { background: var(--primary-disabled); cursor: not-allowed; }
.btn-secondary { background: var(--surface-strong); color: var(--ink); }
.btn-dark { background: var(--surface-dark-elevated); color: var(--on-dark); }
.btn-outline-dark { background: transparent; color: var(--on-dark); box-shadow: inset 0 0 0 1px var(--on-dark); }
.btn-text { background: transparent; color: var(--primary); padding: 0; height: auto; }
.btn-danger-text { background: transparent; color: var(--down); padding: 0; height: auto; }
.btn-text, .btn-danger-text { border: 0; font-weight: 600; cursor: pointer; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* 카드 */
.card { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-xl); padding: 24px; min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.count { font-size: 16px; font-weight: 600; color: var(--ink); }
.ui-card { background: var(--surface-dark-elevated); color: var(--on-dark); border-radius: var(--r-xl); padding: 24px; }
.ui-card h2, .ui-card h3 { color: var(--on-dark); }
.ui-card .muted { color: var(--on-dark-soft); }
.tier-featured { background: var(--surface-dark); color: var(--on-dark); border-color: var(--surface-dark); }
.tier-featured h2, .tier-featured h3, .tier-featured .count { color: var(--on-dark); }
.tier-featured .muted { color: var(--on-dark-soft); }
.tier-featured .notice-body { color: var(--on-dark); }

/* 홈 히어로: 겹친 제품 화면 카드 */
.hero { padding: 64px 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.hero .btn-row { margin-top: 24px; }
.ui-stack { position: relative; min-height: 340px; }
.ui-stack .ui-card-back { position: absolute; top: 0; right: 0; width: 76%; transform: rotate(3deg); background: #1f2228; }
.ui-stack .ui-card-front { position: relative; width: 74%; margin-top: 150px; box-shadow: 0 0 0 1px #24272d; }
.metric-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 0; border-bottom: 1px solid #24272d; }
.metric-row:last-child { border-bottom: 0; }
.metric { font-size: 16px; font-weight: 600; color: var(--on-dark); }

/* 진행률 */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-strong); overflow: hidden; margin: 12px 0 8px; }
.progress span { display: block; height: 100%; background: var(--primary); border-radius: var(--r-pill); }
.ui-card .progress, .tier-featured .progress { background: #2a2d33; }

/* 목록 행 */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--hairline); }
.rows li:last-child { border-bottom: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .title { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.rows a.title:hover { color: var(--primary); }
.empty { padding: 12px 0; color: var(--muted); }

/* 배지 */
.badge {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--surface-strong); color: var(--ink);
  font-weight: 600; white-space: nowrap;
}
.badge-blue { background: var(--primary); color: var(--canvas); }
.ui-card .badge, .tier-featured .badge { background: #2a2d33; color: var(--on-dark); }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline); border-radius: var(--r-xl); }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--hairline); white-space: nowrap; background: var(--surface-soft); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--hairline); color: var(--ink); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }

pre.diagram {
  margin: 0; padding: 24px;
  background: var(--surface-dark); color: var(--on-dark);
  border-radius: var(--r-xl);
  font: 400 12px/1.6 ui-monospace, 'SFMono-Regular', Menlo, monospace;
  overflow-x: auto;
}

/* 입력 */
.field + .field { margin-top: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--ink); font-weight: 600; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  background: var(--canvas); color: var(--ink);
  font-size: 12px;
}
textarea.input { height: auto; min-height: 140px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.hint { margin-top: 6px; color: var(--muted); }
.form-actions { margin-top: 24px; }

/* 구성원 */
.avatar {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 9999px;
  background: var(--surface-strong); color: var(--ink);
  font-size: 16px; font-weight: 600;
}
.member { display: flex; gap: 12px; align-items: flex-start; }

.notice-body { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); margin-top: 12px; }

/* 로그인 화면 */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100vh; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: 48px; }
.auth-form .inner { width: 100%; max-width: 360px; margin: 0 auto; }
.auth-form .wordmark { display: inline-block; margin-bottom: 32px; }
.auth-form .page-title { margin-bottom: 24px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 24px; background: var(--surface-strong); border-radius: var(--r-pill); }
.segmented button { height: 32px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--body); font-weight: 600; cursor: pointer; }
.segmented button[aria-selected='true'] { background: var(--canvas); color: var(--ink); box-shadow: var(--shadow); }
.auth-form .btn { width: 100%; }
.auth-msg { min-height: 18px; margin-top: 16px; }
.auth-msg.ok { color: var(--up); }
.auth-hero { display: flex; flex-direction: column; justify-content: center; gap: 32px; padding: 64px; background: var(--surface-dark); color: var(--on-dark); }
.auth-hero h2.display { color: var(--on-dark); max-width: 420px; }
.auth-hero .ui-stack { max-width: 440px; width: 100%; }

.loading { padding: 48px 32px; color: var(--muted); }

/* 태블릿 */
@media (max-width: 1023px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

/* 휴대폰: 사이드 메뉴를 메뉴 버튼 시트로 전환 */
@media (max-width: 767px) {
  .topnav { padding: 0 16px; gap: 12px; }
  .topnav .menu-toggle { display: inline-flex; }
  .me-link { display: none; }
  .shell { display: block; }
  .sidenav {
    display: none;
    position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0; z-index: 19;
    height: auto; align-self: stretch; border-right: 0;
  }
  .sidenav.open { display: block; }
  .container { padding: 0 16px; }
  .band { padding: 32px 0; }
  .hero { padding: 40px 0; }
  .display, .page-title { font-size: 22px; }
  .page-title { margin-bottom: 24px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card { padding: 20px; }
  .ui-stack { min-height: 0; }
  .ui-stack .ui-card-back, .ui-stack .ui-card-front { position: static; width: 100%; transform: none; margin: 0; }
  .ui-stack .ui-card-back { margin-bottom: 12px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-form { padding: 40px 20px; }
  .auth-hero { display: none; }
}

/* 터치 기기: iOS 입력 확대 방지를 위해 입력 글자만 16px */
@media (pointer: coarse) {
  .input { font-size: 16px; }
}
