@font-face {
  font-family: "Archivo";
  src: url("fonts/Archivo-500-latin.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Archivo";
  src: url("fonts/Archivo-700-latin.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Archivo";
  src: url("fonts/Archivo-800-latin.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bench: #f4f7f7;
  --paper: #ffffff;
  --ink: #182126;
  --muted: #667278;
  --line: #ccd5d5;
  --line-strong: #aebbbb;
  --violet: #705c86;
  --violet-dark: #4f3f62;
  --violet-soft: #e8e1ee;
  --aqua: #87cdc7;
  --aqua-dark: #276d68;
  --aqua-soft: #dff3f1;
  --stone: #d9d8d2;
  --amber: #b96b35;
  --amber-soft: #f7e9df;
  --danger: #a44343;
  --ad-pad: 0px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "Archivo", "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bench);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--bench);
  background-image:
    linear-gradient(rgba(112, 92, 134, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(112, 92, 134, 0.045) 1px, transparent 1px);
  background-size: 24px 24px;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: var(--ad-pad);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(39, 109, 104, 0.34);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  min-height: calc(100vh - var(--ad-pad));
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.side-rail {
  position: sticky;
  top: 0;
  height: calc(100vh - var(--ad-pad));
  padding: calc(24px + var(--safe-top)) 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(16px);
  z-index: 10;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-lockup img {
  width: 56px;
  height: 56px;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 16px 5px 16px 5px;
  object-fit: cover;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup strong {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-lockup span {
  color: var(--violet);
  font-size: 0.86rem;
  font-weight: 700;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  appearance: none;
  min-height: 48px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 9px 3px 9px 3px;
  color: var(--muted);
  background: transparent;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
}

.nav-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button.active {
  color: var(--violet-dark);
  border-color: #d8cfdf;
  background: var(--violet-soft);
}

.local-note {
  margin-top: auto;
  padding: 13px 12px;
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 9px;
  align-items: start;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.local-note strong,
.local-note span {
  display: block;
}

.local-note strong {
  color: var(--ink);
  font-size: 0.76rem;
}

.local-note span {
  margin-top: 2px;
  font-size: 0.69rem;
}

.local-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--aqua-dark);
  box-shadow: 0 0 0 3px var(--aqua-soft);
}

#main {
  min-width: 0;
  padding: calc(38px + var(--safe-top)) clamp(24px, 4vw, 68px) 64px;
}

.page {
  width: min(1230px, 100%);
  margin: 0 auto;
}

.mobile-brand {
  display: none;
}

.page-head {
  margin-bottom: 26px;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
}

.page-head h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.15rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 800;
}

.page-head p {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--aqua-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.planner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(350px, 0.92fr);
  gap: clamp(20px, 3vw, 38px);
  align-items: start;
}

.input-stack {
  display: grid;
  gap: 18px;
}

.sheet {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px 5px 16px 5px;
  background: rgba(255, 255, 255, 0.96);
}

.sheet-head {
  min-height: 66px;
  padding: 16px 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2,
.sheet-head h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sheet-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.sheet-body {
  padding: 19px;
}

.section-rule {
  height: 1px;
  margin: 20px -19px;
  border: 0;
  background: var(--line);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field > span,
.field-label {
  color: #465258;
  font-size: 0.74rem;
  font-weight: 700;
}

.field small,
.helper {
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.4;
}

.input-wrap {
  position: relative;
  min-width: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--line-strong);
  border-radius: 7px 2px 7px 2px;
  color: var(--ink);
  background: #fbfcfc;
  font-variant-numeric: tabular-nums;
}

input,
textarea {
  padding: 10px 12px;
}

select {
  padding: 9px 34px 9px 11px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #879797;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--aqua-dark);
  background: white;
}

.unit-suffix {
  position: absolute;
  right: 11px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
  font-size: 0.74rem;
  pointer-events: none;
}

.input-wrap input.has-unit {
  padding-right: 52px;
}

.shape-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.shape-button {
  min-width: 0;
  min-height: 76px;
  padding: 9px 5px 8px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 9px 3px 9px 3px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 0.67rem;
  font-weight: 700;
}

.shape-button svg {
  width: 34px;
  height: 28px;
  fill: rgba(112, 92, 134, 0.08);
  stroke: currentColor;
  stroke-width: 1.6;
}

.shape-button.active {
  color: var(--violet-dark);
  border-color: var(--violet);
  background: var(--violet-soft);
  box-shadow: inset 0 -3px 0 rgba(112, 92, 134, 0.22);
}

.inline-row {
  display: flex;
  gap: 9px;
  align-items: end;
}

.inline-row > :first-child {
  flex: 1;
}

.segment {
  padding: 4px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 9px 3px 9px 3px;
  background: #edf1f1;
}

.segment button {
  min-height: 39px;
  border: 0;
  border-radius: 6px 2px 6px 2px;
  color: var(--muted);
  background: transparent;
  font-size: 0.76rem;
  font-weight: 700;
}

.segment button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 1px 5px rgba(24, 33, 38, 0.1);
}

.ratio-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
  align-items: end;
  gap: 9px;
}

.ratio-colon {
  min-height: 45px;
  display: grid;
  place-items: center;
  color: var(--violet);
  font-size: 1.3rem;
  font-weight: 800;
}

.basis-note,
.source-note,
.warning-note {
  padding: 12px 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-left: 3px solid var(--aqua-dark);
  background: var(--aqua-soft);
  color: #315855;
  font-size: 0.73rem;
  line-height: 1.45;
}

.source-note {
  margin-top: 14px;
  border-left-color: var(--violet);
  background: var(--violet-soft);
  color: var(--violet-dark);
}

.source-note a {
  color: inherit;
  font-weight: 700;
}

.warning-note {
  border-left-color: var(--amber);
  background: var(--amber-soft);
  color: #704323;
}

.price-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.price-panel summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--violet-dark);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.price-panel summary::-webkit-details-marker {
  display: none;
}

.price-panel summary::after {
  content: "+";
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.price-panel[open] summary::after {
  content: "−";
}

.price-grid {
  padding: 3px 0 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.price-component {
  padding: 13px;
  border: 1px solid var(--line);
  background: #f8fafa;
}

.price-component strong {
  display: block;
  margin-bottom: 10px;
  font-size: 0.78rem;
}

.price-fields {
  display: grid;
  grid-template-columns: 0.85fr 1fr 0.78fr;
  gap: 7px;
}

.price-fields input,
.price-fields select {
  min-height: 41px;
  font-size: 0.78rem;
}

.button {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px 3px 8px 3px;
  color: var(--ink);
  background: white;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.button:hover {
  border-color: var(--ink);
}

.button.primary {
  border-color: var(--violet-dark);
  color: white;
  background: var(--violet-dark);
}

.button.aqua {
  border-color: #1f625e;
  color: white;
  background: #276d68;
}

.button.ghost {
  color: var(--violet-dark);
  border-color: transparent;
  background: transparent;
}

.button.danger {
  color: var(--danger);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: white;
  font-size: 1.3rem;
}

.result-column {
  position: sticky;
  top: 28px;
  display: grid;
  gap: 14px;
}

.result-card {
  overflow: hidden;
  border: 1px solid #b6a6c3;
  border-radius: 25px 7px 25px 7px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(232, 225, 238, 0.88)),
    var(--violet-soft);
  box-shadow: 0 20px 50px rgba(66, 50, 79, 0.12);
}

.result-top {
  padding: 21px 22px 18px;
  border-bottom: 1px solid rgba(112, 92, 134, 0.24);
}

.result-top > span {
  color: var(--violet-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.result-total {
  margin-top: 5px;
  display: flex;
  gap: 9px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}

.result-total strong {
  font-size: clamp(2.45rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.065em;
}

.result-total b {
  color: var(--violet-dark);
  font-size: 1.1rem;
}

.result-subline {
  margin: 8px 0 0;
  color: #5b4a6a;
  font-size: 0.73rem;
}

.ratio-result {
  padding: 20px 22px 22px;
}

.ratio-bar {
  height: 12px;
  display: flex;
  overflow: hidden;
  border: 1px solid rgba(24, 33, 38, 0.18);
  border-radius: 999px;
  background: white;
}

.ratio-bar-a {
  background: var(--violet);
}

.ratio-bar-b {
  background: var(--aqua);
}

.part-results {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.part-result {
  min-width: 0;
}

.part-result::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-right: 6px;
  display: inline-block;
  border-radius: 50%;
  background: var(--violet);
}

.part-result.part-b::before {
  background: var(--aqua-dark);
}

.part-result > span {
  color: #4f5960;
  font-size: 0.7rem;
  font-weight: 700;
}

.part-result strong,
.part-result small {
  display: block;
  font-variant-numeric: tabular-nums;
}

.part-result strong {
  margin-top: 5px;
  font-size: 1.28rem;
  letter-spacing: -0.035em;
}

.part-result small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.35;
}

.cost-strip {
  margin: 0 22px 22px;
  padding: 13px 0 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 14px;
  border-top: 1px solid rgba(112, 92, 134, 0.25);
}

.cost-strip span {
  color: #5b4a6a;
  font-size: 0.72rem;
}

.cost-strip strong {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  padding: 0 22px 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.error-card {
  padding: 20px;
  border: 1px solid #ddb9b9;
  border-radius: 18px 5px 18px 5px;
  background: #fff5f5;
  color: #713c3c;
}

.error-card strong,
.error-card span {
  display: block;
}

.error-card span {
  margin-top: 5px;
  font-size: 0.78rem;
}

.worked-card {
  border: 1px solid var(--line);
  border-radius: 12px 4px 12px 4px;
  background: rgba(255, 255, 255, 0.94);
}

.worked-card summary {
  min-height: 56px;
  padding: 15px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.worked-card summary::-webkit-details-marker {
  display: none;
}

.worked-card summary span {
  color: var(--aqua-dark);
  font-size: 0.68rem;
  font-weight: 700;
}

.steps {
  margin: 0;
  padding: 0 17px 17px;
  list-style: none;
  counter-reset: steps;
}

.step {
  position: relative;
  min-height: 58px;
  padding: 11px 0 11px 37px;
  border-top: 1px solid var(--line);
  counter-increment: steps;
}

.step::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 12px;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.step strong,
.step span {
  display: block;
}

.step strong {
  font-size: 0.75rem;
}

.step span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.safety-card {
  padding: 14px 15px;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  border: 1px solid #e2cbb9;
  border-radius: 10px 3px 10px 3px;
  background: rgba(255, 249, 244, 0.95);
  color: #6d4b34;
}

.safety-card svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.7;
}

.safety-card strong,
.safety-card span {
  display: block;
}

.safety-card strong {
  font-size: 0.74rem;
}

.safety-card span {
  margin-top: 3px;
  font-size: 0.67rem;
  line-height: 1.45;
}

.library-tabs {
  width: min(380px, 100%);
  margin-bottom: 19px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.library-card {
  position: relative;
  min-height: 176px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px 4px 14px 4px;
  background: rgba(255, 255, 255, 0.96);
}

.library-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 4px;
  background: var(--aqua);
}

.library-card.mixture-card::after {
  background: var(--violet);
}

.library-card h3 {
  margin: 0 0 7px;
  font-size: 1rem;
  letter-spacing: -0.025em;
}

.library-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.library-card .basis-chip {
  width: max-content;
  margin-top: 12px;
}

.card-actions {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.basis-chip,
.history-chip {
  padding: 5px 8px;
  border: 1px solid #cfc4d7;
  border-radius: 999px;
  color: var(--violet-dark);
  background: var(--violet-soft);
  font-size: 0.64rem;
  font-weight: 700;
}

.empty-state {
  min-height: 290px;
  padding: 42px 24px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px 5px 18px 5px;
  background: rgba(255, 255, 255, 0.72);
}

.empty-state svg {
  width: 58px;
  height: 58px;
  margin-bottom: 15px;
  fill: rgba(112, 92, 134, 0.08);
  stroke: var(--violet);
  stroke-width: 1.4;
}

.empty-state h2 {
  margin: 0;
  font-size: 1.2rem;
}

.empty-state p {
  max-width: 430px;
  margin: 7px 0 17px;
  color: var(--muted);
  font-size: 0.8rem;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-row {
  padding: 16px 17px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 11px 3px 11px 3px;
  background: rgba(255, 255, 255, 0.96);
}

.history-row h3 {
  margin: 0;
  font-size: 0.9rem;
}

.history-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.history-amount {
  text-align: right;
}

.history-amount strong,
.history-amount span {
  display: block;
  font-variant-numeric: tabular-nums;
}

.history-amount strong {
  font-size: 1.05rem;
}

.history-amount span {
  color: var(--muted);
  font-size: 0.67rem;
}

.history-buttons {
  display: flex;
  gap: 6px;
}

.backup-bar {
  margin-top: 28px;
  padding-top: 19px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.backup-bar strong,
.backup-bar span {
  display: block;
}

.backup-bar strong {
  font-size: 0.82rem;
}

.backup-bar span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.advertising-card {
  margin-top: 18px;
  padding: 17px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border: 1px solid #cfc4d7;
  border-left: 5px solid var(--violet);
  border-radius: 5px 13px 5px 13px;
  background: rgba(255, 255, 255, 0.94);
}

.advertising-card strong,
.advertising-card span {
  display: block;
}

.advertising-card strong {
  font-size: 0.82rem;
}

.advertising-card span {
  max-width: 630px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
}

.advertising-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.app-dialog {
  width: min(540px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 20px 6px 20px 6px;
  color: var(--ink);
  background: white;
  box-shadow: 0 30px 90px rgba(24, 33, 38, 0.24);
}

.app-dialog::backdrop {
  background: rgba(24, 33, 38, 0.46);
  backdrop-filter: blur(3px);
}

.app-dialog header {
  padding: 19px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.app-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}

.dialog-kicker {
  margin: 0 0 3px;
  color: var(--aqua-dark);
  font-size: 0.7rem;
  font-weight: 700;
}

.dialog-body {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.dialog-actions {
  padding: 14px 20px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom) + var(--ad-pad));
  z-index: 100;
  max-width: min(440px, calc(100vw - 30px));
  padding: 11px 15px;
  border: 1px solid #314346;
  border-radius: 9px 3px 9px 3px;
  color: white;
  background: #253438;
  box-shadow: 0 12px 34px rgba(24, 33, 38, 0.2);
  font-size: 0.77rem;
  opacity: 0;
  pointer-events: none;
  translate: -50% 12px;
  transition: opacity 140ms ease, translate 140ms ease;
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
}

.bottom-nav {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .side-rail {
    display: none;
  }

  #main {
    padding: calc(24px + var(--safe-top)) 18px calc(92px + var(--safe-bottom) + var(--ad-pad));
  }

  .mobile-brand {
    width: max-content;
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: 46px auto;
    gap: 10px;
    align-items: center;
  }

  .mobile-brand img {
    width: 46px;
    height: 46px;
    display: block;
    object-fit: cover;
    border: 1px solid var(--line-strong);
    border-radius: 13px 4px 13px 4px;
  }

  .mobile-brand strong,
  .mobile-brand span {
    display: block;
    line-height: 1.1;
  }

  .mobile-brand strong {
    font-size: 0.84rem;
    font-weight: 800;
  }

  .mobile-brand span {
    margin-top: 3px;
    color: var(--violet);
    font-size: 0.72rem;
    font-weight: 700;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--ad-pad);
    z-index: 20;
    min-height: calc(68px + var(--safe-bottom));
    padding: 7px 13px calc(7px + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(18px);
  }

  .bottom-nav .nav-button {
    min-height: 52px;
    padding: 5px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    text-align: center;
    font-size: 0.65rem;
  }

  .bottom-nav .nav-button svg {
    width: 22px;
    height: 22px;
  }

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

  .result-column {
    position: static;
  }
}

@media (max-width: 640px) {
  .page-head {
    margin-bottom: 20px;
    align-items: flex-start;
    flex-direction: column;
  }

  .page-head h1 {
    font-size: 2.18rem;
  }

  .page-head-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-head-actions .button {
    flex: 1;
  }

  .sheet-head,
  .sheet-body {
    padding-left: 15px;
    padding-right: 15px;
  }

  .section-rule {
    margin-left: -15px;
    margin-right: -15px;
  }

  .shape-picker {
    grid-template-columns: repeat(4, minmax(68px, 1fr));
    overflow-x: auto;
    padding-bottom: 5px;
    scroll-snap-type: x mandatory;
  }

  .shape-button {
    scroll-snap-align: start;
  }

  .field-grid.three,
  .price-grid {
    grid-template-columns: 1fr;
  }

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

  .result-card {
    border-radius: 20px 6px 20px 6px;
  }

  .result-total strong {
    font-size: 3.15rem;
  }

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

  .history-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .history-buttons {
    grid-column: 1 / -1;
  }

  .history-buttons .button {
    flex: 1;
  }

  .backup-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .backup-actions {
    width: 100%;
  }

  .backup-actions .button {
    flex: 1;
  }

  .advertising-card {
    align-items: stretch;
    flex-direction: column;
  }

  .advertising-actions {
    justify-content: flex-start;
  }

  .advertising-actions .button {
    flex: 1 1 150px;
  }
}

.legal-page {
  width: min(780px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.legal-page header {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.legal-page .legal-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.legal-page .legal-brand img {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line-strong);
  border-radius: 14px 4px 14px 4px;
}

.legal-page h1 {
  margin: 34px 0 8px;
  font-size: clamp(2rem, 7vw, 3.5rem);
  letter-spacing: -0.055em;
  line-height: 0.96;
}

.legal-page h2 {
  margin: 30px 0 8px;
  font-size: 1.1rem;
}

.legal-page p,
.legal-page li {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.legal-page a {
  color: var(--aqua-dark);
}

.legal-page .button {
  margin-top: 22px;
  color: white;
}

@media (max-width: 390px) {
  #main {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  .ratio-editor {
    grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr);
  }

  .part-results {
    gap: 8px;
  }

  .result-top,
  .ratio-result {
    padding-left: 17px;
    padding-right: 17px;
  }

  .cost-strip,
  .result-actions {
    margin-left: 17px;
    margin-right: 17px;
  }

  .result-actions {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
