:root {
  --color-bg-main: #050810;
  --color-bg-elevated: #0b0f1a;
  --color-bg-muted: #101522;

  --color-text-primary: #f5f5f7;
  --color-text-secondary: #a3a8b8;
  --color-text-muted: #6d7385;
  --color-text-danger: #ff6b6b;
  --color-text-accent: #7cffb2;

  --color-accent-primary: #16f29a;
  --color-accent-soft: #1e9c74;

  --color-border-subtle: #1b2235;
  --color-border-strong: #2f3b5c;

  --shadow-card: 0 18px 45px rgba(0, 0, 0, 0.55);
  --radius-card: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #0b0f1a 0, #050810 55%);
  color: var(--color-text-primary);
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}

/* ===== Header (centered) ===== */

.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.app-title {
  margin: 0;
  font-size: 1.8rem;
}

.app-subtitle {
  margin: 0.4rem auto 0;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 40rem;
}

.app-meta {
  display: flex;
  justify-content: center;
  margin-top: 0.6rem;
}

.app-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(22, 242, 154, 0.5);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-accent);
}

/* ===== Main layout ===== */

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 1.25rem;
  align-items: flex-start;
}

@media (max-width: 900px) {
  .app-main {
    grid-template-columns: 1fr;
  }
}

/* ===== Cards ===== */

.card {
  background: linear-gradient(
      135deg,
      rgba(22, 242, 154, 0.06),
      transparent 60%
    ),
    var(--color-bg-elevated);
  border-radius: var(--radius-card);
  border: 1px solid var(--color-border-subtle);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem 1.25rem;
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

/* ===== Form ===== */

.form-grid {
  display: grid;
  gap: 0.85rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.field-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

.field-input {
  border-radius: 8px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-muted);
  color: var(--color-text-primary);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
}

.field-input:focus {
  outline: none;
  border-color: var(--color-accent-primary);
  box-shadow: 0 0 0 1px rgba(22, 242, 154, 0.45);
}

.field-help {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.btn-primary {
  margin-top: 0.5rem;
  align-self: flex-start;
  border-radius: 999px;
  border: none;
  background-image: linear-gradient(135deg, #16f29a, #4da3ff);
  color: #050810;
  padding: 0.55rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    filter 0.12s ease;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.03);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.7);
}

/* ===== Results / Flags ===== */

.results-body,
.flags-body {
  font-size: 0.95rem;
}

.results-placeholder {
  margin: 0;
  color: var(--color-text-muted);
}

.results-section h3 {
  margin: 0.75rem 0 0.4rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
}

.results-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.results-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(27, 34, 53, 0.7);
}

.results-label {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

.results-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.results-value--danger {
  color: var(--color-text-danger);
  font-weight: 600;
}

.results-value--warning {
  color: #ffc857;
  font-weight: 600;
}

/* Flag pills */

.flag-pill {
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.15rem 0.25rem 0.15rem 0;
}

.flag-pill--warning {
  background: rgba(255, 200, 87, 0.1);
  color: #ffc857;
  border-left: 3px solid #ffc857;
}

.flag-pill--danger {
  background: rgba(255, 107, 107, 0.08);
  color: #ff6b6b;
  border-left: 3px solid #ff6b6b;
}

.flag-pill--info {
  background: rgba(77, 163, 255, 0.06);
  color: #4da3ff;
  border-left: 3px solid #4da3ff;
}

/* ===== Footer (centered) ===== */

.app-footer {
  margin-top: 1.75rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
}

.disclaimer {
  margin: 0;
}

/* ===== Wide-only behaviour ===== */

.wide-only {
  display: none;
}

.wide-mode .wide-only {
  display: flex;
}

.field-radio-row {
  display: flex;
  gap: 0.75rem;
}

.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
}

/* Validation errors */

.results-errors h3 {
  margin: 0 0 0.4rem;
  color: var(--color-text-danger);
  font-size: 0.95rem;
}

.results-errors ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.results-note {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Collapsibles ===== */

.collapsible {
  margin-top: 0.9rem;
  border-top: 1px solid var(--color-border-subtle);
  padding-top: 0.6rem;
}

.collapsible-summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.collapsible-summary::before {
  content: "▸";
  font-size: 0.75rem;
  transform-origin: center;
  transition: transform 0.15s ease;
}

details[open] .collapsible-summary::before {
  transform: rotate(90deg);
}

.collapsible-body {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.collapsible-intro {
  margin: 0 0 0.4rem;
}

.formula-list,
.references-list {
  margin: 0;
  padding-left: 1.1rem;
}

.formula-list li {
  margin-bottom: 0.35rem;
}

.references-list li {
  margin-bottom: 0.4rem;
}

/* ===== Number input tweaks ===== */

/* Remove number input up/down arrows (Chrome, Edge, Safari) */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Remove number input arrows (Firefox) */
input[type=number] {
  -moz-appearance: textfield;
}

/* === iOS Install Hint Banner === */

.ios-install-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.95);
  border-top: 1px solid rgba(0, 255, 102, 0.5);
  box-shadow: 0 -0.4rem 1rem rgba(0, 255, 102, 0.25);
  color: #e0ffe6;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ios-install-hint-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.ios-install-hint-text {
  flex: 1;
}

.ios-install-hint-text strong {
  color: #00ff66;
}

.ios-install-hint-close {
  border: 1px solid rgba(0, 255, 102, 0.6);
  background: transparent;
  color: #e0ffe6;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 999px;
  cursor: pointer;
}

.ios-install-hint-hidden {
  display: none !important;
}
