/* =============================================
   Unit Converter All — Styles
   ============================================= */

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

:root {
  --bg: #0B0E14;
  --bg-card: #12161F;
  --bg-input: #0D1018;
  --bg-hover: #1A1F2E;
  --border: rgba(99, 110, 130, 0.2);
  --border-focus: rgba(99, 102, 241, 0.5);
  --primary: #6366F1;
  --primary-dim: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.3);
  --accent: #22D3EE;
  --text: #E8ECF0;
  --text-dim: #8B95A8;
  --text-muted: #5A6478;
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg: #F4F6F9;
  --bg-card: #FFFFFF;
  --bg-input: #F0F2F5;
  --bg-hover: #E8EBF0;
  --border: rgba(0, 0, 0, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);
  --text: #1A1D26;
  --text-dim: #5A6478;
  --text-muted: #8B95A8;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* Header */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 1.5rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  border-radius: var(--radius);
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--primary);
  background: var(--primary-dim);
}

/* Main */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* Categories */
.categories {
  margin-bottom: 24px;
}

.categories-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.categories-scroll::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  flex-shrink: 0;
}

.cat-btn:hover {
  color: var(--text);
  border-color: var(--primary);
}

.cat-btn.active {
  color: var(--primary);
  background: var(--primary-dim);
  border-color: rgba(99, 102, 241, 0.3);
}

.cat-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.cat-icon {
  font-size: 1rem;
}

/* Converter Card */
.converter-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 32px;
}

.converter-inputs {
  display: flex;
  align-items: flex-end;
  gap: 16px;
}

.converter-side {
  flex: 1;
  min-width: 0;
}

.converter-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.converter-input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: all var(--transition);
  -moz-appearance: textfield;
}

.converter-input::-webkit-outer-spin-button,
.converter-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.converter-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.converter-input.result {
  color: var(--primary);
  background: var(--primary-dim);
  border-color: rgba(99, 102, 241, 0.2);
}

.converter-select {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%238B95A5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  transition: all var(--transition);
}

.converter-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

/* Swap Button */
.swap-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-dim);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  color: var(--primary);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  margin-bottom: 24px;
}

.swap-btn:hover {
  transform: rotate(180deg);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 16px var(--primary-glow);
}

.swap-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Formula Bar */
.formula-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.formula-bar svg {
  flex-shrink: 0;
  color: var(--primary);
}

/* Common Conversions */
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.common-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}

.common-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.85rem;
}

.common-item:hover {
  border-color: var(--primary);
  background: var(--primary-dim);
  transform: translateY(-1px);
}

.common-from {
  color: var(--text);
  font-weight: 500;
}

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

.common-to {
  color: var(--primary);
  font-weight: 600;
}

/* Responsive */
@media (max-width: 640px) {
  .converter-inputs {
    flex-direction: column;
    align-items: stretch;
  }

  .swap-btn {
    align-self: center;
    margin-bottom: 0;
    transform: rotate(90deg);
  }

  .swap-btn:hover {
    transform: rotate(270deg);
  }

  .converter-input {
    font-size: 1.2rem;
    padding: 12px 14px;
  }

  .converter-card {
    padding: 20px;
  }

  .common-grid {
    grid-template-columns: 1fr;
  }
}
