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

:root {
  --bg:          #ffffff;
  --surface:     #f9fafb;
  --border:      #e5e7eb;
  --border-dash: #d1d5db;
  --text:        #111827;
  --text-sub:    #374151;
  --text-muted:  #6b7280;
  --btn-bg:      #404040;
  --btn-hover:   #2d2d2d;
  --accent:      #404040;
  --radius-card: 12px;
  --radius-btn:  8px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  --max-w:       780px;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ── Header ─────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.logo svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

nav {
  display: flex;
  gap: 28px;
  font-size: 0.875rem;
  color: var(--text-sub);
}

nav a:hover { color: var(--text); }

/* ── Language switcher ───────────────────── */
.lang-switcher {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 1px solid var(--border);
  min-width: 34px;
}

.lang-btn:first-child { border-left: none; }

.lang-btn:hover { background: var(--surface); color: var(--text); }

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

/* ── Main layout ─────────────────────────── */
main {
  flex: 1;
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  padding: 64px 24px 80px;
}

/* ── Hero ────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 48px;
}

.hero h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 16px;
  color: var(--text);
}

.hero p {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── Cards ───────────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 32px;
  margin-bottom: 16px;
}

/* ── Mode selector ───────────────────────── */
.mode-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

.mode-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mode-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 0;
  cursor: pointer;
  border-top: 1px solid var(--border);
}

.mode-item:first-child { border-top: none; }

.mode-item input[type="radio"] { display: none; }

.mode-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--border-dash);
  flex-shrink: 0;
  margin-top: 5px;
  transition: background 0.15s, border-color 0.15s;
}

.mode-item.selected .mode-dot {
  background: var(--text);
  border-color: var(--text);
}

.mode-text strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.mode-item.selected .mode-text strong::after {
  content: none;
}

.mode-bullet {
  width: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  padding-top: 4px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--text);
  opacity: 0;
}

.mode-item.selected .mode-bullet { opacity: 1; }

.mode-text p {
  font-size: 0.8375rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Drop zone ───────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border-dash);
  border-radius: 10px;
  padding: 56px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #9ca3af;
  background: var(--surface);
}

.drop-zone.has-file {
  border-color: #6b7280;
  background: var(--surface);
}

.drop-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  color: var(--text-muted);
}

.drop-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.drop-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-selected {
  display: none;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
  margin-top: 12px;
}

.drop-zone.has-file .file-selected { display: block; }
.drop-zone.has-file .drop-label,
.drop-zone.has-file .drop-hint { display: none; }

/* ── Convert button ──────────────────────── */
.convert-btn {
  width: 100%;
  padding: 16px;
  background: var(--btn-bg);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.convert-btn:hover:not(:disabled) { background: var(--btn-hover); }

.convert-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.convert-btn.loading .spinner { display: block; }
.convert-btn.loading .btn-text::after { content: '...'; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── SEO block ───────────────────────────── */
.seo-block {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.seo-block h2 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.seo-block p {
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.7;
  margin-bottom: 10px;
}

/* ── Ad units ────────────────────────────── */
.ad-container {
  margin: 32px 0;
  min-height: 90px;
  text-align: center;
  overflow: hidden;
}

.ad-container.ad-end {
  margin: 40px 0 8px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

/* ── Privacy note ────────────────────────── */
.privacy-note {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 32px 0 0;
  line-height: 1.65;
}

/* ── Results ─────────────────────────────── */
#results {
  margin-top: 24px;
}

.token-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 16px;
}

.token-summary h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.token-badges {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.badge {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 150px;
}

.badge-model {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-pct {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.badge-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.token-counts {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-secondary {
  padding: 9px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: #9ca3af;
}

.markdown-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  font-family: 'Courier New', 'Menlo', monospace;
  font-size: 0.8125rem;
  line-height: 1.65;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-sub);
}

/* ── Error ───────────────────────────────── */
.error-msg {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 0.875rem;
  color: #dc2626;
  margin-top: 16px;
}

.error-msg.visible { display: block; }

/* ── Footer ──────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 48px 24px 32px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 40px;
}

.footer-brand strong {
  font-size: 0.9rem;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.footer-brand p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-col h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.footer-col ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-col ul li a {
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: color 0.15s;
}

.footer-col ul li a:hover { color: var(--text); }

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

/* ── About / Privacy pages ───────────────── */
.page-header {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 48px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-content h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 36px 0 12px;
  color: var(--text);
}

.page-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 24px 0 8px;
}

.page-content p,
.page-content li {
  font-size: 0.9rem;
  color: var(--text-sub);
  line-height: 1.75;
}

.page-content ul, .page-content ol {
  padding-left: 24px;
  margin: 8px 0;
}

.page-content li { margin-bottom: 4px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 20px 0;
}

.feature-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.feature-item h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.feature-item p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 720px) {
  header { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px 0; padding-top: 8px; padding-bottom: 8px; }
  .header-right { gap: 12px; width: 100%; justify-content: space-between; }
  nav { gap: 14px; font-size: 0.8125rem; }
  .lang-btn { padding: 5px 8px; min-width: 30px; font-size: 0.75rem; }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 1.6rem; }
  .card { padding: 20px; }
  .drop-zone { padding: 40px 20px; }
  nav { gap: 12px; font-size: 0.75rem; }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
  .token-badges { flex-direction: column; }
  .badge { min-width: unset; }
  .feature-grid { grid-template-columns: 1fr; }
}
