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%;
}

/* Footer mobile spacing. The footer is a flex child of the layout's body
   (d-flex flex-column min-vh-100 + mt-auto), so it grows when its links wrap. */
@media (max-width: 767.98px) {
  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;
}

/* 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;
}

/* Make the ongoing Box Size search visible beside already usable results. */
.box-size-search-status {
    border-inline-start: 0.25rem solid var(--bs-border-color);
}

.box-size-search-heading {
    font-size: 1.125rem;
    font-weight: 700;
}

#box-size-live-results:is([data-status="searching"], [data-status="refining"]) .box-size-search-status {
    background-color: var(--bs-primary-bg-subtle);
    background-color: color-mix(in srgb, var(--box-accent) 24%, var(--bs-body-bg));
    border-color: var(--box-accent);
    border-inline-start: 0.375rem solid var(--box-accent-deep);
}

#box-size-live-results:is([data-status="searching"], [data-status="refining"]) .box-size-search-heading {
    color: var(--bs-body-color);
    font-size: 1.25rem;
}

.box-size-search-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2rem;
}

.box-size-search-spinner[hidden] {
    display: none;
}

@media (prefers-reduced-motion: reduce) {
    .box-size-search-spinner {
        animation: none;
    }
}
