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

:root {
  --teal: #00897b;
  --teal-light: #e0f2f0;
  --teal-dark: #00695c;
  --accent: #26a69a;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1a2b27;
  --text-muted: #6b8278;
  --border: #d9e4e1;
  --result-value: #00897b;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* NAV */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 2rem;
}

.nav-logo {
  color: var(--teal);
  font-size: 1.3rem;
}

.nav-links {
  display: flex;
  gap: 0;
  flex: 1;
}

.nav-link {
  padding: 0 1.2rem;
  height: 60px;
  display: flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  text-decoration: none;
}

.nav-link.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

.nav-link:hover:not(.active) {
  color: var(--text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switcher {
  display: flex;
  gap: 0.4rem;
}

.lang-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.lang-btn.active {
  background: var(--teal);
  color: white;
}

/* MAIN */
main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.main-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
}

.main-title::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* FORM ROW */
.converter-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field label span {
  color: var(--teal);
}

.field input, .field select {
  border: none;
  border-bottom: 2px solid var(--border);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  padding: 0.4rem 0;
  outline: none;
  transition: border-color 0.2s;
  width: 200px;
}

.field input:focus, .field select:focus {
  border-bottom-color: var(--teal);
}

.field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b8278' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  transition: background 0.2s, border-color 0.2s, transform 0.3s;
  flex-shrink: 0;
  margin-bottom: 0.3rem;
}

.swap-btn:hover {
  background: var(--teal-light);
  border-color: var(--teal);
  transform: rotate(180deg);
}

.convert-btn {
  background: var(--teal);
  color: white;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.75rem 1.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  margin-bottom: 0.25rem;
}

.convert-btn:hover { background: var(--teal-dark); }
.convert-btn:active { transform: scale(0.97); }

/* RESULT */
.result-section {
  margin-top: 3rem;
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.result-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.result-main {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 300;
  color: var(--text);
  line-height: 1.2;
}

.result-main .result-value {
  color: var(--result-value);
  font-weight: 600;
}

.result-rates {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

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

/* HISTORY */
.history-section {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.4s ease 0.15s, transform 0.4s ease 0.15s;
}

.history-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.history-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.duration-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1.5rem;
}

.duration-field label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.duration-field select {
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  padding: 0.3rem 0;
  width: 160px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

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

@media (max-width: 600px) {
  .history-grid { grid-template-columns: 1fr; }
  .converter-row { gap: 0.75rem; }
  .field input, .field select { width: 150px; }
}

.card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 0.8rem 1.2rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table td {
  padding: 0.75rem 1.2rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.history-table tr:last-child td { border-bottom: none; }

.history-table .rate-cell {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.stats-table td {
  padding: 0.75rem 1.2rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.stats-table tr:last-child td { border-bottom: none; }

.stats-table .stat-value {
  text-align: right;
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.empty-state {
  padding: 2rem 1.2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.loading-indicator {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.5rem;
}

.convert-btn.loading .btn-text { display: none; }
.convert-btn.loading .loading-indicator { display: inline-block; }

.convert-btn-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

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