html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem var(--box-bg), 0 0 0 0.25rem var(--box-accent);
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 120px;
}

footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}

/* Footer mobile spacing */
@media (max-width: 767.98px) {
  body {
    margin-bottom: 140px;
  }

  footer .row > div:first-child {
    margin-bottom: 0.75rem;
  }
}

.ts-wrapper.single .ts-control {
  overflow: hidden;
}

.ts-wrapper.single .ts-control > .item {
  max-width: calc(100% - 3rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* Prevent CLS - Reserve space for 3D visualization */
#visualization-container {
    width: 100%;
    height: 400px;
    min-height: 400px;
    background-color: #f8f9fa;
}

@media (max-width: 768px) {
    #visualization-container {
        height: 300px;
        min-height: 300px;
    }
}

/* Touch-friendly button targets */
@media (hover: none) and (pointer: coarse) {
    .btn-group .btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Prevent iOS zoom on input focus */
@media (max-width: 767.98px) {
    input[type="number"],
    .form-control,
    .form-select {
        font-size: 16px;
    }
}

/* Privacy Policy and Terms of Service pages */
.privacy-policy,
.terms-of-service {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
    line-height: 1.8;
}

.privacy-policy h1,
.terms-of-service h1 {
    margin-bottom: 0.5rem;
}

.privacy-policy h2,
.terms-of-service h2 {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bs-border-color);
}

.privacy-policy h2:first-of-type,
.terms-of-service h2:first-of-type {
    margin-top: 1.5rem;
    padding-top: 0;
    border-top: none;
}

.privacy-policy h3,
.terms-of-service h3 {
    margin-top: 1.5rem;
}

.privacy-policy ul,
.terms-of-service ul {
    padding-left: 1.5rem;
    margin: 1rem 0;
}

.privacy-policy li,
.terms-of-service li {
    margin-bottom: 0.5rem;
    color: var(--bs-secondary-color);
}

.privacy-policy p,
.terms-of-service p {
    color: var(--bs-secondary-color);
    margin-bottom: 1rem;
}

.privacy-policy .last-updated,
.terms-of-service .last-updated {
    font-size: 0.875rem;
    color: var(--bs-tertiary-color);
    margin-bottom: 2rem;
}

.privacy-table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
}

.privacy-table th,
.privacy-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bs-border-color);
}

.privacy-table th {
    font-weight: 600;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

.privacy-resources {
    list-style: none;
    padding: 0;
}

.privacy-resources li {
    margin-bottom: 0.75rem;
}

/* Calculator advertising */
.calculator-native-ad-slot,
.calculator-inline-banner-slot {
    width: 100%;
    min-width: 0;
    margin-top: 1rem;
}

.calculator-top-banner-slot {
    width: 100%;
    min-width: 0;
    margin: 0 0 2rem;
    overflow: hidden;
}

.calculator-ad-frame {
    box-sizing: border-box;
    background: var(--box-surface-alt, #f8f9fa);
    border: 2px solid var(--box-stroke-strong, #cbd5e1);
    border-radius: var(--box-r-lg, 14px);
    box-shadow: 0 2px 8px rgba(31, 27, 22, 0.08);
}

.calculator-native-ad-frame {
    width: 100%;
    min-width: 0;
    min-height: 100px;
    padding: 0.75rem;
    overflow: hidden;
}

.calculator-top-banner-shell {
    padding: 1rem;
}

.calculator-top-banner-frame {
    display: flex;
    width: 100%;
    min-height: 50px;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
}

.calculator-top-banner-frame[data-banner-size="desktop"] {
    min-height: 90px;
}

.calculator-inline-banner-shell {
    padding: 1rem;
}

.calculator-inline-banner-frame {
    display: flex;
    width: 100%;
    min-height: 60px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.calculator-inline-banner-frame iframe {
    max-width: 100%;
}

.calculator-sponsored-label {
    display: block;
    margin: 0 0 0.5rem;
    margin-inline-start: 0.25rem;
    color: var(--box-ink-dim, #777);
    font-family: var(--box-font-mono, monospace);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

@media (max-width: 767.98px) {
    .calculator-top-banner-slot,
    .calculator-inline-banner-slot {
        width: calc(100% + 1.5rem);
        margin-inline: -0.75rem;
        margin-bottom: 1.5rem;
    }

    .calculator-top-banner-slot .calculator-sponsored-label,
    .calculator-inline-banner-slot .calculator-sponsored-label {
        margin-inline: 0.75rem;
    }

    .calculator-top-banner-shell,
    .calculator-inline-banner-shell {
        padding: 0.75rem 0;
        border-inline: 0;
        border-radius: 0;
    }
}

/* RTL support for privacy and terms pages */
[dir="rtl"] .privacy-policy ul,
[dir="rtl"] .terms-of-service ul {
    padding-left: 0;
    padding-right: 1.5rem;
}

[dir="rtl"] .privacy-table th,
[dir="rtl"] .privacy-table td {
    text-align: right;
}

/* Language selector: the dropdown lists 30+ languages, so cap its height
   and make it scrollable instead of overflowing small viewports. */
.lang-selector-menu {
    max-height: 70vh;
    overflow-y: auto;
}
