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

:root {
  --bg: var(--ui-bg);
  --surface: var(--ui-surface);
  --surface2: var(--ui-surface-3);
  --border: var(--ui-border);
  --text: var(--ui-text);
  --muted: var(--ui-muted);
  --accent: var(--ui-accent);
  --accent2: var(--ui-accent-2);
  --radius: var(--ui-radius);
}

body {
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--text);
  min-height: calc(100vh - var(--ui-bar-h, 0px));
  padding: 32px 16px 64px;
}

header {
  text-align: center;
  margin-bottom: 36px;
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}
.accent { color: var(--accent2); }
.subtitle { color: var(--muted); font-size: .9rem; margin-top: 6px; }

main {
  max-width: 700px;
  margin: 0 auto;
}

/* Category Bar */
.cat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 28px;
}
.cat-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cat-btn:hover { border-color: var(--accent); color: var(--text); }
.cat-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Converter Card */
.converter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field { flex: 1; min-width: 120px; }
.field label {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.field input, .field select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
}

.swap-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--accent2);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: all .2s;
}
.swap-btn:hover { background: var(--accent); color: #fff; }

/* Result */
.result-box {
  text-align: center;
  margin-top: 24px;
  padding: 20px;
  background: rgba(var(--ui-accent-rgb),.06);
  border-radius: 12px;
  border: 1px solid rgba(var(--ui-accent-rgb),.15);
}
.result-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent2);
}
.result-label {
  display: block;
  margin-top: 4px;
  font-size: .85rem;
  color: var(--muted);
}

/* All conversions */
.all-conversions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.conv-item {
  background: var(--surface2);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .82rem;
  display: flex;
  justify-content: space-between;
}
.conv-item .val { color: var(--accent2); font-weight: 600; }
.conv-item .unit { color: var(--muted); }

/* History */
.history-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.history-header h3 {
  font-size: .95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-clear {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: .75rem;
  cursor: pointer;
  transition: all .2s;
}
.btn-clear:hover { border-color: #ef4444; color: #ef4444; }

.history-list { max-height: 220px; overflow-y: auto; }
.history-list .empty { color: var(--muted); font-size: .82rem; text-align: center; padding: 20px; }
.history-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
}
.history-entry:last-child { border-bottom: none; }
.history-entry .from { color: var(--text); }
.history-entry .arrow { color: var(--muted); margin: 0 6px; }
.history-entry .to { color: var(--accent2); font-weight: 600; }
.history-entry .time { color: var(--muted); font-size: .7rem; }

@media (max-width: 600px) {
  .input-row { flex-direction: column; }
  .swap-btn { align-self: center; }
}

