:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --border: #e9ecef;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-light: #eef2ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 12px;
  --code-bg: #f1f3f5;
  --pre-bg: #1a1a2e;
  --pre-text: #e8e8f0;
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --border: #2a2a3e;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --accent-light: #1e1e3a;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
  --code-bg: #2a2a3e;
  --pre-bg: #0a0a14;
  --pre-text: #c8c8e0;
}

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

html { font-size: 16px; }

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

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

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

.header-logo {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.header-logo small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.7rem;
  margin-left: 0.3rem;
}

.header-nav { display: flex; gap: 1.5rem; align-items: center; }

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: border-color 0.2s, color 0.2s;
  padding: 0;
  line-height: 1;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.header-nav a:hover { color: var(--accent); }
.header-nav a.active { color: var(--accent); }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 4rem 1.5rem 2rem;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ── Search ── */
.search-wrap {
  max-width: 500px;
  margin: 1.5rem auto 2rem;
  padding: 0 1.5rem;
}

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

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* ── App Grid ── */
.app-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.app-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.app-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.app-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}

.app-card-info { flex: 1; min-width: 0; }

.app-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
  font-weight: 500;
}

.app-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.75rem;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-download:hover { background: var(--accent-hover); }

/* ── App Detail Page ── */
.detail {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.detail-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.detail-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
  flex-shrink: 0;
}

.detail-title { margin-bottom: 0.25rem; font-size: 1.6rem; }
.detail-subtitle { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-meta dt { font-weight: 600; color: var(--text); }
.detail-meta dd { margin: 0; }

.detail-section { margin-bottom: 2rem; }

.detail-section h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.detail-section ul {
  padding-left: 1.2rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.detail-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.detail-downloads .btn-download {
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}

.detail-cta {
  background: var(--accent-light);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.detail-cta p { margin-bottom: 0.75rem; color: var(--text-muted); }

.btn-outline {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.btn-outline:hover { background: var(--accent); color: #fff; }

/* ── Request Page ── */
.request-wrap {
  max-width: 700px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.request-wrap h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.request-wrap > p { color: var(--text-muted); margin-bottom: 2rem; }

.request-cards {
  display: grid;
  gap: 1rem;
  margin-bottom: 2rem;
}

.request-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.request-card h3 { font-size: 1rem; margin-bottom: 0.3rem; }
.request-card p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.request-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.request-link:hover { text-decoration: underline; }

.formspree-link {
  text-align: center;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.formspree-link p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.75rem; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .app-grid { grid-template-columns: 1fr; }
  .detail-header { flex-direction: column; }
  .hero h1 { font-size: 1.6rem; }
}
