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

:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --surface2: #f0ede8;
  --border: #e2ddd6;
  --text: #1a1714;
  --text2: #6b6560;
  --text3: #a09a93;
  --accent: #1a1714;
  --green: #2a7d4f;
  --green-bg: #eaf5ee;
  --yellow: #a0720a;
  --yellow-bg: #fdf4e0;
  --blue: #1757a0;
  --blue-bg: #ebf2fc;
  --red: #b83232;
  --red-bg: #fbeaea;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(26, 23, 20, 0.08);
  --shadow-lg: 0 8px 32px rgba(26, 23, 20, 0.12);
}

body.dark {
  --bg: #141210;
  --surface: #1e1b18;
  --surface2: #2a2620;
  --border: #38332c;
  --text: #f0ede8;
  --text2: #a09a93;
  --text3: #605a52;
  --green: #4eb87a;
  --green-bg: #0f2b1d;
  --yellow: #d4a030;
  --yellow-bg: #2b2005;
  --blue: #5b9bd5;
  --blue-bg: #0d1e33;
  --red: #e06060;
  --red-bg: #2b1010;
}

body {
  font-family: "DM Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition:
    background 0.3s,
    color 0.3s;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

/* HEADER */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}
.header-title {
  font-family: "DM Serif Display", serif;
  font-size: 28px;
  letter-spacing: -0.5px;
  color: var(--text);
}
.header-title span {
  font-style: italic;
  color: var(--text2);
}
.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  cursor: pointer;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.theme-btn:hover {
  background: var(--surface2);
}

/* CARD */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* UNIT SELECTOR */
.unit-row {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
}
.unit-pill {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.unit-pill.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* INPUT GRID */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.input-full {
  grid-column: 1 / -1;
}
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 22px;
  font-weight: 300;
  padding: 0 14px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  -moz-appearance: textfield;
}
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
.field input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(26, 23, 20, 0.08);
}
.field input::placeholder {
  color: var(--text3);
  font-size: 18px;
}

/* BMI DISPLAY */
.bmi-display {
  text-align: center;
  padding: 24px 0 16px;
  position: relative;
}
.bmi-number {
  font-family: "DM Serif Display", serif;
  font-size: 72px;
  line-height: 1;
  color: var(--text);
  letter-spacing: -3px;
  transition: color 0.4s;
}
.bmi-category {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 6px;
  transition: color 0.4s;
  color: var(--text3);
}
.bmi-note {
  font-size: 13px;
  color: var(--text2);
  margin-top: 4px;
  min-height: 20px;
}

/* GAUGE */
.gauge-wrap {
  margin: 20px 0 0;
  position: relative;
}
.gauge-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    #5b9bd5 0%,
    #5b9bd5 26%,
    #4eb87a 26%,
    #4eb87a 50%,
    #d4a030 50%,
    #d4a030 68%,
    #e06060 68%,
    #e06060 100%
  );
  position: relative;
}
.gauge-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--bg);
  transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  left: 0%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}
.gauge-label {
  font-size: 10px;
  color: var(--text3);
  font-weight: 500;
}

/* ACTION BUTTONS */
.btn-primary {
  width: 100%;
  height: 52px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 12px;
  font-family: "DM Sans", sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.15s;
  letter-spacing: 0.02em;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.85;
}
.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.btn-secondary {
  height: 44px;
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--text);
}
.btn-secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* SHARE BTN */
.share-row {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.btn-share {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  font-family: "DM Sans", sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-share:hover {
  border-color: var(--text);
  color: var(--text);
}
.btn-share svg {
  width: 14px;
  height: 14px;
}

/* CATEGORY CHIP */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin: 0 auto;
}
.chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* CHART */
.chart-container {
  position: relative;
  height: 140px;
  width: 100%;
}
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 14px;
}

/* HISTORY */
.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.history-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.history-bmi {
  font-family: "DM Serif Display", serif;
  font-size: 22px;
  color: var(--text);
  letter-spacing: -0.5px;
}
.history-date {
  font-size: 12px;
  color: var(--text3);
}
.history-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  letter-spacing: 0.04em;
}
.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text3);
  font-size: 13px;
}

.btn-clear {
  background: none;
  border: none;
  color: var(--text3);
  font-family: "DM Sans", sans-serif;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-clear:hover {
  color: var(--red);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* RESULT ANIMATION */
@keyframes pop {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  60% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.bmi-number.animate {
  animation: pop 0.4s ease forwards;
}
