:root {
  color-scheme: dark;
  --espresso: #1c1712;
  --ink: #241c16;
  --cream: #f3e6d2;
  --buttermilk: #f7ecda;
  --muted: #7a6a58;
  --line: #e2d2b8;
  --copper: #d86a32;
  --copper-deep: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  padding:
    0
    calc(14px + env(safe-area-inset-right))
    calc(20px + env(safe-area-inset-bottom))
    calc(14px + env(safe-area-inset-left));
  font-family: Outfit, system-ui, sans-serif;
  color: var(--cream);
  background:
    radial-gradient(720px 380px at 12% -10%, rgba(216, 106, 50, 0.22), transparent 55%),
    var(--espresso);
}

.glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(243, 230, 210, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 230, 210, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at top, black 30%, transparent 78%);
}

.bar,
.intro,
.tabs,
.grid {
  position: relative;
  width: min(1040px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: linear-gradient(to bottom, var(--espresso) 72%, transparent);
}

.mark {
  display: none;
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--copper);
}

.home {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: #cbb79a;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 650;
}

.mark {
  margin: 0;
  justify-self: center;
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--copper);
}

.langs {
  display: flex;
  padding: 3px;
  border: 1px solid rgba(243, 230, 210, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.lang {
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #cbb79a;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.lang[aria-pressed="true"] {
  background: var(--copper);
  color: #fff7ed;
}

.intro {
  margin-bottom: 14px;
}

h1 {
  margin: 0 0 6px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 560;
  letter-spacing: -0.04em;
  line-height: 1;
}

.lead {
  margin: 0;
  color: #cbb79a;
  line-height: 1.45;
  font-size: 0.95rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.28);
}

.tab {
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #cbb79a;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--buttermilk);
  color: var(--ink);
}

.grid {
  display: grid;
  gap: 16px;
}

.card {
  display: none;
  flex-direction: column;
  padding: 18px 16px 16px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 28%),
    var(--buttermilk);
  border-radius: 20px;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.24);
}

.card.is-active {
  display: flex;
}

.card-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.badge {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #2b241c;
  color: var(--cream);
  font-family: Fraunces, Georgia, serif;
  font-size: 0.9rem;
  font-weight: 720;
}

h2 {
  margin: 2px 0 4px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.35rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 0.92rem;
}

.fields {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffaf2;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

input:focus {
  outline: 2px solid var(--copper);
  outline-offset: 1px;
}

.output {
  margin-top: 14px;
  padding: 14px 16px 12px;
  border-radius: 16px;
  background: #2b241c;
  color: var(--cream);
}

.result-label {
  margin: 0 0 2px;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #cbb79a;
  font-weight: 650;
}

.result {
  margin: 0;
  min-height: 1.05em;
  font-family: Outfit, system-ui, sans-serif;
  font-size: clamp(2.4rem, 11vw, 3.2rem);
  font-weight: 650;
  color: #f6e7d4;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.result:not(.is-ready) {
  font-size: 2rem;
  opacity: 0.45;
}

.result.is-ready {
  font-family: Fraunces, Georgia, serif;
  font-weight: 720;
  font-style: italic;
  color: var(--copper);
}

.error {
  margin: 10px 0 0;
  color: #fdba74;
  font-size: 0.92rem;
}

.formula {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 27px,
      rgba(216, 106, 50, 0.12) 27px,
      rgba(216, 106, 50, 0.12) 28px
    ),
    #fff8ec;
  border: 1px dashed #d8c3a4;
}

.formula-label {
  margin: 0 0 8px;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--copper-deep);
  font-weight: 700;
}

.formula-line {
  margin: 0 0 4px;
  font-size: 0.92rem;
  line-height: 1.45;
  color: #4a3b2d;
  overflow-wrap: anywhere;
}

.formula-line.filled {
  color: var(--ink);
  font-weight: 600;
}

.formula-line.filled:empty {
  display: none;
}

details {
  margin-top: 12px;
}

summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 650;
  color: var(--copper-deep);
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "+";
  display: inline-block;
  width: 1.2em;
  color: var(--copper);
}

details[open] summary::before {
  content: "–";
}

ol {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.5;
}

@media (min-width: 860px) {
  .bar {
    position: relative;
    background: none;
    margin-bottom: 20px;
  }

  .mark {
    display: block;
  }

  h1 {
    font-size: 3.2rem;
  }

  .tabs {
    display: none;
  }

  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 22px;
  }

  .card,
  .card.is-active {
    display: flex;
    padding: 28px 24px 22px;
  }

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

  h2 {
    font-size: 1.7rem;
  }
}
