/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-hover: #f5f5f0;
  --text: #1a1a18;
  --text-secondary: #6b6b60;
  --text-tertiary: #9a9a8e;
  --border: #e2e2d8;
  --border-light: #ececdf;
  --accent: #3d7a5f;
  --accent-hover: #2f6149;
  --accent-light: #e8f2ec;
  --accent-subtle: #f0f7f3;
  --warm: #8b7355;
  --warm-light: #f5f0e8;
  --error: #b44040;
  --error-bg: #fdf0f0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  --max-w: 860px;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; }

/* ===== Nav ===== */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250,250,248,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.nav-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.03em;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 6px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}

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

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text);
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  margin: 4px 0;
  transition: transform var(--transition);
}

/* ===== Hero ===== */
.hero {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 80px 24px 64px;
  text-align: center;
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.04em;
  margin-bottom: 8px;
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 400;
  margin-bottom: 40px;
}

.hero-accent {
  display: block;
  width: 48px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  margin: 0 auto 32px;
  animation: accent-grow 1s ease-out forwards;
}

@keyframes accent-grow {
  from { width: 0; opacity: 0; }
  to { width: 48px; opacity: 1; }
}

.hero-descriptions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 720px;
  margin: 0 auto;
}

.hero-desc {
  flex: 1;
  min-width: 200px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.hero-desc-lang {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.hero-desc p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Sections ===== */
.section {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

/* ===== Translate Section ===== */
.translate-direction {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border-light);
}

.dir-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
}

.dir-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.dir-btn:hover:not(.active) {
  color: var(--text);
}

.translate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.translate-pane {
  display: flex;
  flex-direction: column;
}

.pane-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.translate-input,
.translate-output {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.translate-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.translate-output {
  background: var(--accent-subtle);
  border-color: var(--border-light);
  cursor: default;
  resize: none;
  overflow-y: auto;
}

.translate-output.loading {
  color: var(--text-tertiary);
  font-style: italic;
}

.translate-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.char-count {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.char-count.over {
  color: var(--error);
  font-weight: 600;
}

.latency-text {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-left: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

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

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { opacity: 0.7; }

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

/* ===== Dictionary Section ===== */
.lookup-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lookup-input {
  flex: 1;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.lookup-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.lookup-result {
  min-height: 48px;
}

.lookup-entry {
  padding: 12px 0;
}

.lookup-entry + .lookup-entry {
  border-top: 1px solid var(--border-light);
}

.lookup-entry .result-direction {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--warm-light);
  color: var(--warm);
  margin-bottom: 6px;
}

.lookup-entry .result-word {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.lookup-entry .result-translation {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.not-found {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 0.9rem;
  padding: 8px 0;
}

/* ===== Dialect Checker (Coming Soon) ===== */
.coming-soon {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--warm-light);
  border: 1px solid #e6ddd0;
  border-radius: var(--radius);
}

.coming-soon-text {
  flex: 1;
}

.coming-soon-text p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.coming-soon-text a {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.coming-soon-text a:hover {
  text-decoration: underline;
}

.coming-soon-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warm);
  white-space: nowrap;
}

/* ===== Footer ===== */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border-light);
  margin-top: 48px;
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 48px 24px 32px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.footer-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.footer-section p,
.footer-section li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.footer-section ul {
  list-style: none;
}

.footer-section li { margin-bottom: 4px; }

.footer-section a {
  color: var(--accent);
  text-decoration: none;
}

.footer-section a:hover {
  text-decoration: underline;
}

.footer-bottom {
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-bottom p {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

/* ===== Error ===== */
.error-message {
  padding: 10px 14px;
  background: var(--error-bg);
  border: 1px solid #e8c0c0;
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.85rem;
  display: none;
  margin-top: 12px;
}

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

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .hero { padding: 48px 20px 40px; }
  .hero-descriptions { flex-direction: column; gap: 12px; }
  .hero-desc { min-width: auto; }

  .translate-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .translate-input,
  .translate-output {
    min-height: 110px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .nav-links { display: none; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px;
    box-shadow: var(--shadow-md);
  }
  .nav-toggle { display: block; }

  .section { padding: 36px 20px; }
  .card { padding: 20px; }

  .coming-soon {
    flex-direction: column;
    text-align: center;
    gap: 8px;
  }
}

/* ===== Utility classes (replace inline styles) ===== */
.mt-8 { margin-top: 8px; }
.text-small { font-size: 0.8rem; }
.text-tertiary { color: var(--text-tertiary); }

/* ===== Error page (404) ===== */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
}
.error-page-code {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 8px;
}
.error-page-text {
  color: var(--text-secondary);
}
.error-page-link {
  color: var(--accent);
  text-decoration: none;
}
.error-page-link:hover {
  text-decoration: underline;
}
