/* ===========================
   공통 스타일
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: #EEF2FF;
  --text: #1E293B;
  --text-muted: #64748B;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --success: #10B981;
  --success-light: #ECFDF5;
  --warning: #F59E0B;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===========================
   네비게이션
   =========================== */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 60px;
  max-width: 1100px;
  margin: 0 auto;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem;
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem 1rem;
    gap: 0.25rem;
    box-shadow: var(--shadow-md);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
}

/* ===========================
   공통 레이아웃
   =========================== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-header {
  background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
  color: #fff;
  padding: 3rem 1.5rem 2.5rem;
  text-align: center;
}

.page-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.page-header p { font-size: 1rem; opacity: 0.85; }

.page-content {
  max-width: 760px;
  margin: 2rem auto;
  padding: 0 1.5rem 4rem;
}

/* ===========================
   카드 컴포넌트
   =========================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===========================
   폼 요소
   =========================== */
.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.form-group .hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}

.input-wrap input:focus,
.input-wrap select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.input-wrap .unit {
  position: absolute;
  right: 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  pointer-events: none;
}

.input-wrap input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

select {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text);
  background: #fff;
  outline: none;
  cursor: pointer;
}

/* ===========================
   버튼
   =========================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,0.3); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover { background: var(--primary-light); }

/* ===========================
   결과 박스
   =========================== */
.result-box {
  display: none;
  animation: fadeIn 0.3s ease;
}

.result-box.show { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-highlight {
  background: linear-gradient(135deg, var(--primary-light), #F5F3FF);
  border: 1.5px solid #C7D2FE;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}

.result-highlight .label {
  font-size: 0.875rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.result-highlight .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}

.result-highlight .value span { font-size: 1rem; font-weight: 600; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) { .result-grid { grid-template-columns: 1fr; } }

.result-item {
  background: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}

.result-item .r-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.result-item .r-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.result-item.negative .r-value { color: #EF4444; }
.result-item.positive .r-value { color: var(--success); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* ===========================
   광고 영역 플레이스홀더
   =========================== */
.ad-placeholder {
  background: #F1F5F9;
  border: 2px dashed #CBD5E1;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 1.25rem 0;
}

/* ===========================
   메인 허브 페이지
   =========================== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
  color: #fff;
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.88;
  max-width: 520px;
  margin: 0 auto;
}

@media (max-width: 600px) { .hero h1 { font-size: 1.8rem; } }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 2rem 1.5rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #C7D2FE;
}

.tool-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.tool-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.tool-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tool-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  margin-top: 0.25rem;
  align-self: flex-start;
}

/* ===========================
   표 (대출 상환 스케줄)
   =========================== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: #F1F5F9;
  padding: 0.65rem 0.9rem;
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th:first-child { text-align: center; }

td {
  padding: 0.6rem 0.9rem;
  text-align: right;
  border-bottom: 1px solid #F1F5F9;
  white-space: nowrap;
}

td:first-child { text-align: center; font-weight: 600; color: var(--text-muted); }

tr:last-child td { border-bottom: none; }
tr:hover td { background: #F8FAFC; }

/* ===========================
   BMI 게이지
   =========================== */
.bmi-gauge {
  margin: 1rem 0;
}

.bmi-bar {
  height: 18px;
  border-radius: 99px;
  background: linear-gradient(to right, #60A5FA, #34D399, #FBBF24, #F87171, #DC2626);
  position: relative;
  margin-bottom: 0.5rem;
}

.bmi-pointer {
  position: absolute;
  top: -4px;
  width: 26px;
  height: 26px;
  background: #fff;
  border: 3px solid var(--primary);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 0.5s cubic-bezier(.34,1.56,.64,1);
  box-shadow: var(--shadow-md);
}

.bmi-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.bmi-result-label {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.5rem;
  border-radius: 8px;
  margin-top: 0.75rem;
}

/* ===========================
   글자수 카운터
   =========================== */
.text-area-wrap textarea {
  width: 100%;
  min-height: 180px;
  padding: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
  outline: none;
  color: var(--text);
}

.text-area-wrap textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 480px) { .count-grid { grid-template-columns: repeat(4, 1fr); } }

.count-item {
  background: var(--primary-light);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.count-item .c-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
}

.count-item .c-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ===========================
   D-day 관련
   =========================== */
.dday-result {
  text-align: center;
  padding: 1.5rem;
}

.dday-number {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.dday-label {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ===========================
   간소화 네비 (back link)
   =========================== */
.nav-back {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}
.nav-back:hover { color: var(--primary); }

/* ===========================
   카테고리 섹션 (index)
   =========================== */
.cat-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
}
.cat-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ===========================
   푸터
   =========================== */
footer {
  background: #1E293B;
  color: #94A3B8;
  text-align: center;
  padding: 1.75rem 1.5rem;
  font-size: 0.875rem;
}

footer a { color: #94A3B8; text-decoration: none; }
footer a:hover { color: #fff; }
