/* ===== 기본 설정 ===== */
:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #212529;
  --text-muted: #6c757d;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.1);
  --border: #dee2e6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-light: rgba(129, 140, 248, 0.1);
  --border: #334155;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

/* ===== 접근성 ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s, color .3s;
}

/* ===== 헤더 ===== */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.logo span { color: var(--text); }

.nav-links {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .95rem;
  transition: color .2s;
}

.nav-links a:hover { color: var(--primary); }

#theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .4rem .7rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1rem;
  transition: all .2s;
}

#theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ===== 언어 선택기 ===== */
.lang-switcher {
  display: flex;
  gap: 2px;
  align-items: center;
}

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  padding: .3rem .5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  font-family: var(--font);
  transition: all .2s;
}

.lang-btn:first-child {
  border-radius: 6px 0 0 6px;
}

.lang-btn:last-child {
  border-radius: 0 6px 6px 0;
}

.lang-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.lang-btn:not(.active):hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

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

/* ===== 히어로 ===== */
.hero {
  text-align: center;
  padding: 3rem 1rem 2rem;
}

.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 1rem;
  font-weight: 800;
  line-height: 1.3;
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

/* ===== 검색 박스 ===== */
.search-box {
  max-width: 500px;
  margin: 0 auto;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: .9rem 1.2rem;
  border: 2px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box input:focus:not(:focus-visible) {
  box-shadow: none;
}

.search-box input:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ===== 섹션 헤더 ===== */
.section-header {
  margin-top: 3rem;
  margin-bottom: 1.2rem;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.section-header p {
  color: var(--text-muted);
  font-size: .95rem;
}

/* ===== 카드 그리드 ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card-icon {
  font-size: 2.2rem;
  margin-bottom: .8rem;
}

.card h3 {
  font-size: 1.15rem;
  margin-bottom: .4rem;
}

.card p {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: .8rem;
}

.card-tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .25rem .6rem;
  border-radius: 100px;
  background: var(--primary-light);
  color: var(--primary);
}

/* ===== 도구 페이지 ===== */
.tool-header {
  margin-bottom: 1.5rem;
}

.tool-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
}

.tool-header p {
  color: var(--text-muted);
  margin-top: .3rem;
}

.tool-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: .4rem;
  font-size: .95rem;
}

textarea, input[type="text"], input[type="number"], select {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
}

textarea {
  resize: vertical;
}

textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
  box-shadow: none;
}

textarea:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .7rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn:hover { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

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

.btn-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}

.result-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
  font-size: .9rem;
  margin-top: .5rem;
}

.options {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.options label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  cursor: pointer;
}

/* ===== 인포 그리드 ===== */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.info-icon {
  font-size: 2.2rem;
  margin-bottom: .8rem;
}

.info-card h3 {
  font-size: 1.1rem;
  margin-bottom: .5rem;
}

.info-card p {
  color: var(--text-muted);
  font-size: .9rem;
}

/* ===== 푸터 ===== */
footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  background: var(--surface);
}

.footer-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2rem;
}

.footer-brand p {
  color: var(--text-muted);
  margin-top: .5rem;
  font-size: .9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  align-items: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  transition: color .2s;
}

.footer-links a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

.footer-bottom a {
  color: var(--primary);
  text-decoration: none;
}

/* ===== 사용법 섹션 ===== */
.usage-section {
  margin-top: 2.5rem;
}

.usage-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.usage-steps {
  display: flex;
  flex-direction: column;
  gap: .8rem;
}

.usage-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}

.usage-step:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}

.usage-step-badge {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 700;
}

.usage-step-content {
  flex: 1;
  min-width: 0;
}

.usage-step-content strong {
  display: block;
  font-size: .95rem;
  margin-bottom: .15rem;
}

.usage-step-content p {
  color: var(--text-muted);
  font-size: .88rem;
  line-height: 1.5;
}

.usage-step-content code {
  font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
  font-size: .85rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: .1rem .35rem;
  border-radius: 4px;
}

.usage-tip {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  font-size: .88rem;
  color: var(--text);
  line-height: 1.5;
}

.usage-tip strong {
  color: var(--primary);
}

/* ===== 반응형 ===== */
@media (max-width: 640px) {
  .hero h1 { font-size: 1.7rem; }
  .card-grid { grid-template-columns: 1fr; }
  .nav-links a { display: none; }
  .nav-links a:first-child { display: inline; }
  .footer-content { flex-direction: column; text-align: center; }
  .footer-links { justify-content: center; }
}
