/* LongevOS Anamnesis V3 — only presentation and responsive/touch behavior. */
html {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 100%;
  overflow-x: hidden;
}

.layout,
.layout > *,
.layout main,
.card,
.account,
#fields,
.field {
  min-width: 0;
  max-width: 100%;
}

.field label,
.field .help,
.field .hint,
.account p,
.check,
.notice,
#saveStatus,
#accountStatus,
#backupList,
h1,
h2,
h3 {
  overflow-wrap: anywhere;
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

/* Change from sidebar to a single-column form before the desktop layout gets narrow. */
@media (max-width: 1050px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 24px clamp(14px, 3vw, 30px);
  }

  aside .intro,
  aside .stats {
    display: none;
  }

  aside h1 {
    font-size: clamp(26px, 4vw, 34px);
    margin: 10px 0 16px;
  }

  aside h1 br {
    display: none;
  }

  #stages {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 4px 0 12px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  #stages button {
    flex: 0 0 auto;
    max-width: 200px;
    min-height: 44px;
    white-space: normal;
    scroll-snap-align: start;
  }
}

@media (max-width: 600px) {
  header {
    padding: 12px 14px;
    gap: 10px;
  }

  header img {
    width: 122px;
    height: 43px;
    max-width: 52vw;
  }

  .tag {
    padding: 7px 10px;
    white-space: nowrap;
  }

  .notice {
    padding: 11px 14px;
    font-size: 12px;
    line-height: 1.5;
  }

  .layout {
    gap: 16px;
    padding: 18px 12px 32px;
  }

  aside h1 {
    font-size: clamp(24px, 6vw, 30px);
    letter-spacing: -0.8px;
    line-height: 1.17;
    margin: 6px 0 14px;
  }

  aside h1 em {
    display: inline;
  }

  #stages button {
    max-width: min(70vw, 200px);
    font-size: 13px;
    line-height: 1.35;
    padding: 10px 12px;
    touch-action: manipulation;
  }

  .card,
  .account {
    padding: 18px 15px;
    border-radius: 12px;
    margin-bottom: 18px;
  }

  .access-gate {
    width: calc(100% - 24px);
    margin: 16px auto;
  }

  h2 {
    font-size: clamp(23px, 6vw, 27px);
    line-height: 1.2;
  }

  .hint {
    margin-bottom: 20px;
    line-height: 1.55;
  }

  .field {
    margin-bottom: 26px;
  }

  .field label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    margin-bottom: 9px;
  }

  .number {
    display: inline-block;
    min-width: 25px;
    margin-right: 7px;
    font-size: 12px;
    vertical-align: baseline;
  }

  .help {
    font-size: 14px;
    line-height: 1.55;
  }

  .field input:not([type="checkbox"]):not([type="radio"]),
  .field textarea,
  .field select {
    min-height: 48px;
    padding: 12px 13px;
    border-radius: 9px;
    font-size: 16px; /* iOS Safari should not zoom automatically while typing. */
    line-height: 1.45;
  }

  .field textarea {
    min-height: 112px;
  }

  .check {
    display: block;
    min-height: 48px;
    font-size: 14px;
    line-height: 1.6;
    margin: 16px 0;
    cursor: pointer;
  }

  .check input[type="checkbox"] {
    float: left;
    width: 22px;
    height: 22px;
    margin: 1px 10px 0 0;
    touch-action: manipulation;
  }

  button,
  .login-action {
    min-height: 48px;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    touch-action: manipulation;
  }

  .tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .tools button,
  .account > button,
  #finished > button,
  #backupList button {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 18px;
    margin-top: 24px;
  }

  .actions button {
    width: 100%;
    padding: 12px 8px;
  }

  .progress-label {
    flex-wrap: wrap;
    gap: 6px 12px;
    line-height: 1.5;
  }

  footer {
    line-height: 1.8;
    padding: 0 6px;
  }
}
