:root {
  --primary: #00897B;
  --primary-dark: #00695C;
  --hero-start: #00897B;
  --hero-end: #00695C;
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --text-primary: #1A1C1E;
  --text-secondary: #5F6368;
  --divider: #E3E7EA;
  --field-border: #C7CDD2;
  --white: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #4DB6AC;
    --primary-dark: #00695C;
    --hero-start: #00897B;
    --hero-end: #00695C;
    --bg: #11201C;
    --surface: #1A211E;
    --text-primary: #E6E9E7;
    --text-secondary: #A7B0AC;
    --divider: #2A322E;
    --field-border: #3A443F;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 24px) 16px calc(env(safe-area-inset-bottom) + 28px);
}

/* Header */
.header {
  display: flex;
  align-items: center;
  margin-bottom: 18px;
}

.subtitle {
  flex: 1;
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--primary);
  padding: 10px;
}

.icon-button:active {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Hero card */
.hero-card {
  background: linear-gradient(135deg, var(--hero-start), var(--hero-end));
  border-radius: 24px;
  padding: 24px;
  color: var(--white);
  box-shadow: 0 6px 20px rgba(0, 105, 92, 0.25);
}

.hero-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero-value {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.1;
}

.hero-hint {
  margin: 4px 0 0;
  font-size: 12px;
  opacity: 0.8;
}

/* Inputs card */
.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px;
  margin-top: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.section-label {
  margin: 0 0 14px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Field (outlined box) */
.field {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  padding: 8px 14px;
  margin-top: 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field:first-of-type {
  margin-top: 0;
}

.field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.field-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: var(--primary);
}

.field-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.field-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

.field input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 500;
  padding: 2px 0;
  width: 100%;
}

.field-suffix {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.divider {
  height: 1px;
  background: var(--divider);
  margin: 16px 0;
}

.helper-text {
  margin: 8px 4px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Formula dialog */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 100;
}

.overlay[hidden] {
  display: none;
}

.dialog {
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 20px;
  padding: 24px 24px 8px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.dialog-title {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
}

.formula {
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  padding: 14px;
  border-radius: 10px;
  color: var(--primary);
  font-size: 15px;
  font-weight: 700;
}

.formula-line {
  margin: 16px 0 0;
  font-size: 14px;
}

.formula-line:first-of-type {
  margin-top: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.text-button {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.text-button:active {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
}
