:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-light: #fed7aa;
  --secondary: #8b5cf6;
  --secondary-light: #ddd6fe;
  --bg: #fdf6ee;
  --bg-card: #ffffff;
  --bg-section: #fef3e2;
  --text: #3f3424;
  --text-light: #8b7355;
  --text-muted: #b8a68e;
  --border: #e8ddd0;
  --border-light: #f0e8dc;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(139, 92, 246, 0.08);
  --shadow-lg: 0 8px 40px rgba(139, 92, 246, 0.12);
  --font-main: 'Nunito', sans-serif;
  --font-display: 'Quicksand', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.paw-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 20%, var(--primary-light) 0%, transparent 50%),
    radial-gradient(circle at 90% 80%, var(--secondary-light) 0%, transparent 50%),
    var(--bg);
  opacity: 0.5;
}

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.9);
}

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

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

.logo-icon {
  font-size: 2rem;
  line-height: 1;
}

.app-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--primary-dark);
  line-height: 1.2;
}

.app-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.main-content {
  max-width: 800px;
  margin: 32px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.calculator-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border-light);
}

.card-header {
  text-align: center;
  margin-bottom: 28px;
}

.card-header h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 6px;
}

.card-header p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.calc-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row.two-col > .form-group {
  flex: 1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-group label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-section);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.input-icon {
  font-size: 1.1rem;
  margin-right: 10px;
  flex-shrink: 0;
}

.input-wrap input,
.input-wrap select {
  border: none;
  background: transparent;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  padding: 12px 0;
  width: 100%;
  outline: none;
}

.input-wrap select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.select-wrap::after {
  content: '▾';
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-left: 8px;
}

.size-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.chip {
  background: var(--bg-section);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: all 0.2s;
}

.chip span {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.chip:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.chip-active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2);
}

.calc-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
  margin-top: 8px;
}

.calc-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(249, 115, 22, 0.4);
}

.calc-btn:active:not(:disabled) {
  transform: translateY(0);
}

.calc-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.result-area {
  animation: fadeSlideUp 0.4s ease;
}

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

.result-burst {
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, var(--bg-section), var(--primary-light));
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.result-icon {
  font-size: 3.5rem;
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.result-label {
  font-size: 0.85rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.result-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 2px 0;
}

.result-age-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.result-age {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.result-unit {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 600;
}

.result-note {
  text-align: center;
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 20px;
  padding: 12px;
  background: var(--bg-section);
  border-radius: var(--radius-xs);
}

.result-actions {
  display: flex;
  gap: 12px;
}

.save-btn,
.new-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.save-btn {
  background: linear-gradient(135deg, var(--secondary), #7c3aed);
  color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.4);
}

.new-btn {
  background: var(--bg-section);
  color: var(--text);
  border: 2px solid var(--border);
}

.new-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.history-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--border-light);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.history-header h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
}

.history-count {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-illustration {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
  font-weight: 600;
}

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

.dog-card {
  background: var(--bg-section);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: fadeSlideUp 0.3s ease;
}

.dog-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.dog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.dog-card-emoji {
  font-size: 2rem;
}

.dog-card-remove {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  transition: color 0.2s, background 0.2s;
  line-height: 1;
}

.dog-card-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.dog-card-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dog-card-age {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.dog-card-dog-age {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--primary-dark);
  line-height: 1;
}

.dog-card-unit {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
}

.dog-card-details {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.dog-card-actual,
.dog-card-size {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-light);
  text-transform: capitalize;
}

.dog-card-stage {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--secondary);
}

@media (max-width: 600px) {
  .main-content {
    padding: 0 12px;
    margin: 20px auto;
    gap: 24px;
  }

  .calculator-card,
  .history-section {
    padding: 20px;
  }

  .form-row.two-col {
    flex-direction: column;
  }

  .size-chips {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-burst {
    flex-direction: column;
    text-align: center;
    padding: 20px;
  }

  .result-age-wrap {
    justify-content: center;
  }

  .result-actions {
    flex-direction: column;
  }

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