/* Mobile-first refinements for fixed navigation and clearer settings controls. */
.app-shell {
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.bottom-nav {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: 0;
  z-index: 120;
  width: min(100vw, 430px);
  max-width: 100vw;
  margin: 0;
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
  border-right: 1px solid var(--line);
  border-bottom: 0;
  border-left: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  transform: translateX(-50%);
  box-sizing: border-box;
}

.nav-item {
  min-height: 56px;
}

.weight-row.is-hidden {
  display: none;
}

.settings-group summary {
  grid-template-columns: minmax(0, 1fr) auto 32px;
}

.settings-group summary::after {
  width: 28px;
  height: 28px;
}

.htf-settings-panel,
.settings-note-panel {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.htf-panel-head,
.htf-agreement-card,
.htf-row,
.tv-tp-row,
.settings-note-row {
  display: grid;
  gap: 8px;
}

.htf-panel-head {
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
}

.htf-panel-head h3,
.settings-note-row h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.15;
}

.htf-panel-head p,
.htf-agreement-card p,
.settings-note-row p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.htf-agreement-card {
  padding: 10px;
  border: 1px solid rgba(154, 98, 255, 0.35);
  border-radius: 8px;
  background: rgba(154, 98, 255, 0.08);
}

.htf-agreement-card strong {
  font-size: 24px;
  line-height: 1;
}

.htf-agreement-card span {
  color: var(--purple);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.htf-row {
  grid-template-columns: 26px 82px minmax(78px, 1fr) 86px 30px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.htf-row .mini-toggle-small {
  min-height: 42px;
  display: grid;
  place-items: center;
}

.htf-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple);
}

.htf-row .mini-field span,
.tv-tp-row .mini-field span,
.tp-result span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.htf-row .select-control,
.htf-row .text-control,
.tv-tp-row .text-control {
  min-height: 38px;
  padding: 0 8px;
}

.trend-readout {
  min-height: 38px;
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.trend-readout svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-readout strong {
  font-size: 12px;
  line-height: 1;
}

.trend-readout.is-up {
  color: var(--green);
  border-color: rgba(98, 227, 111, 0.36);
}

.trend-readout.is-down {
  color: var(--red);
  border-color: rgba(255, 86, 86, 0.36);
}

.trend-readout.is-sideways,
.trend-readout.is-unknown {
  color: var(--muted);
}

.icon-lite-button {
  width: 30px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 15px;
  font-weight: 900;
}

.htf-add-row {
  display: grid;
  grid-template-columns: 1fr;
}

.tv-tp-row {
  grid-template-columns: 62px 1fr 1fr 74px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.tv-tp-row .switch-line {
  grid-template-columns: 22px 1fr;
  min-height: 38px;
}

.tp-result {
  min-height: 38px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid rgba(154, 98, 255, 0.35);
  border-radius: 8px;
  background: rgba(154, 98, 255, 0.08);
}

.tp-result strong {
  color: var(--purple);
  font-size: 14px;
  line-height: 1;
}

.tp-result small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.settings-help-toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 160;
  width: min(calc(100vw - 24px), 406px);
  padding: 12px;
  border: 1px solid rgba(154, 98, 255, 0.48);
  border-radius: 8px;
  background: rgba(10, 14, 18, 0.96);
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.48);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.settings-help-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.settings-help-toast strong {
  display: block;
  margin-bottom: 4px;
  color: var(--purple);
  font-size: 12px;
  text-transform: uppercase;
}

.settings-help-toast span {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 430px) {
  .bottom-nav {
    left: 0;
    right: 0;
    width: 100vw;
    transform: none;
    border-right: 0;
    border-left: 0;
  }
}

@media (max-width: 390px) {
  .htf-row,
  .tv-tp-row {
    grid-template-columns: 1fr 1fr;
  }

  .htf-row .mini-toggle-small,
  .htf-row .icon-lite-button,
  .tv-tp-row .switch-line,
  .tp-result {
    grid-column: 1 / -1;
  }
}

@media (min-width: 720px) {
  .bottom-nav {
    width: min(100vw, 460px);
  }
}
