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

:root {
  --bg: #0d0d0d;
  --surface: #161616;
  --surface-2: #1e1e1e;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --text: #f0ede8;
  --text-muted: #888;
  --text-dim: #555;
  --accent: #c8f060;
  --accent-dark: #a8d040;
  --radius: 14px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Syne', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.container {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}

.header {
  margin-bottom: 1.5rem;
}

.header-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(200, 240, 96, 0.1);
  border: 1px solid rgba(200, 240, 96, 0.2);
  border-radius: 100px;
  padding: 4px 12px;
  margin-bottom: 16px;
}

.header h1 {
  font-size: clamp(36px, 8vw, 52px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1.5px;
  color: var(--text);
}

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.tab {
  flex: 1;
  padding: 9px;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* TAB CONTENT */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeUp 0.2s ease;
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.pair-row {
  display: grid;
  grid-template-columns: 1fr 44px 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

select, input {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

select:focus, input:focus {
  border-color: var(--border-hover);
}

select option {
  background: #1e1e1e;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

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

.amount-field {
  margin-bottom: 20px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-symbol {
  position: absolute;
  left: 12px;
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrap input {
  padding-left: 28px;
  font-family: 'DM Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  padding-top: 12px;
  padding-bottom: 12px;
}

.convert-btn {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #0d0d0d;
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.convert-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.convert-btn:active {
  transform: translateY(0);
}

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

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #0d0d0d;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

.spinner.active {
  display: block;
}

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

.result {
  display: none;
  margin-top: 1.25rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeUp 0.25s ease;
}

.result.show {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.result-value {
  font-family: 'DM Mono', monospace;
  font-size: 32px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.result-rate {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.error {
  display: none;
  margin-top: 1rem;
  padding: 12px;
  background: rgba(226, 75, 74, 0.1);
  border: 1px solid rgba(226, 75, 74, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #f09595;
  animation: fadeUp 0.2s ease;
}

.error.show {
  display: block;
}

/* CURRENCIES TAB */
.currencies-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}

.currencies-count {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.search-input {
  appearance: none;
  -webkit-appearance: none;
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 180px;
}

.search-input:focus {
  border-color: var(--border-hover);
}

.currencies-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

.currencies-list::-webkit-scrollbar {
  width: 4px;
}

.currencies-list::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: 4px;
}

.currency-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.currency-item:hover {
  background: var(--surface-2);
}

.currency-code {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  min-width: 44px;
}

.currency-name {
  font-size: 13px;
  color: var(--text-muted);
  text-align: right;
}

.currencies-loading {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 2rem 0;
}

/* FOOTER */
.footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

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

@media (max-width: 400px) {
  .card { padding: 1.25rem; }
  .pair-row { grid-template-columns: 1fr 38px 1fr; }
  .swap-btn { width: 38px; height: 38px; }
  .search-input { width: 140px; }
}
