* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1c1c1c;
  --bg-elevated: #242424;
  --text-primary: #fafafa;
  --text-secondary: #737373;
  --text-muted: #525252;
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-blue-glow: rgba(59, 130, 246, 0.15);
  --accent-green: #22c55e;
  --border-color: #262626;
  --border-focus: #404040;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --transition-fast: 150ms ease;
  --transition-normal: 200ms ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.container {
  width: min(100%, 620px);
  margin: auto;
  padding: clamp(16px, 4vw, 36px) clamp(14px, 3.2vw, 28px);
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.5vw, 22px);
}

main {
  display: grid;
  gap: clamp(12px, 2.3vw, 18px);
}

/* Header */
.header {
  text-align: center;
  margin-bottom: clamp(6px, 1.6vw, 12px);
}

.header-icon {
  width: clamp(44px, 7vw, 52px);
  height: clamp(44px, 7vw, 52px);
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent-blue) 0%, #1d4ed8 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.header-icon svg {
  width: 24px;
  height: 24px;
  color: white;
}

.header h1 {
  font-size: clamp(1.36rem, 4vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-bottom: 4px;
}

.header p {
  color: var(--text-secondary);
  font-size: clamp(0.8rem, 2.7vw, 0.9rem);
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3.6vw, 24px);
  border: 1px solid var(--border-color);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: clamp(14px, 2.2vw, 20px);
}

.card-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-icon svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

.card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

/* Form Fields */
.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  padding-right: 80px;
  font-size: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: textfield;
  -moz-appearance: textfield;
}

.input.recon-input {
  padding-right: 50px;
}

.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.input::placeholder {
  color: var(--text-muted);
}

.input-suffix {
  position: absolute;
  right: 12px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.unit-toggle {
  position: absolute;
  right: 8px;
  display: flex;
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.unit-btn {
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.unit-btn.active {
  background: var(--accent-blue);
  color: white;
}

.unit-btn:not(.active):hover {
  color: var(--text-primary);
}

/* Select */
.select {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  padding-right: 40px;
  font-size: 1rem;
  color: var(--text-primary);
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Results */
.results-card {
  background: var(--bg-secondary);
  border-color: var(--accent-blue);
  position: relative;
  overflow: hidden;
}

.results-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
}

.result-main {
  text-align: center;
  padding: clamp(18px, 3.8vw, 24px) 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.result-value {
  font-size: clamp(2.1rem, 8vw, 3rem);
  font-weight: 700;
  color: var(--accent-blue);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-left: 4px;
}

.result-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.result-secondary-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.result-secondary-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.result-secondary-toggle svg {
  width: 14px;
  height: 14px;
}

.result-secondary-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: none;
}

.result-secondary-value.visible {
  display: block;
}

.result-secondary-value span {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Button */
.btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-primary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-focus);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

.btn.copied {
  background: var(--accent-green);
  border-color: var(--accent-green);
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  width: min(calc(100% - 24px), 340px);
  transform: translateX(-50%) translateY(calc(100% + 24px));
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toast svg {
  width: 16px;
  height: 16px;
  color: var(--accent-green);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Footer */
.footer {
  text-align: center;
  padding: 10px 0 2px;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: auto;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.animate-in {
  animation: fadeIn 0.4s ease-out;
}

.result-value.updating {
  animation: pulse 0.2s ease;
}

@media (min-width: 768px) {
  .container {
    width: min(100%, 700px);
  }

  .footer {
    padding-bottom: 10px;
  }
}

@media (max-height: 760px) {
  .app {
    justify-content: flex-start;
  }

  .container {
    margin: 0 auto;
  }
}
