@layer components {
  .form { display: flex; flex-direction: column; gap: 20px; }

  .field { display: flex; flex-direction: column; gap: 8px; }
  .field__label { font-size: 14px; font-weight: 600; }
  .field__label abbr { display: none; }

  .field__input {
    width: 100%;
    min-height: var(--control);
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-control);
    font-size: 16px;
    color: var(--ink);
    background: var(--white);
  }
  .field__input::placeholder { color: var(--placeholder); }
  .field__input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--line-faint); }
  textarea.field__input { min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
  select.field__input { appearance: none; padding-right: 40px; background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2355524C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center; }

  .field__input--error { border-color: var(--danger-fg); }
  .field__hint { font-size: 13px; color: var(--muted); }
  .field__error { font-size: 13px; font-weight: 600; color: var(--danger-fg); }

  /* Read-only data, e.g. a Pix key */
  .data-field {
    display: flex;
    align-items: center;
    min-height: var(--control);
    padding: 0 14px;
    border-radius: var(--radius-control);
    background: var(--ink);
    color: var(--white);
    font-family: var(--font-mono);
    font-size: 14px;
    overflow-wrap: anywhere;
  }

  /* Checkbox */
  .checkbox { display: flex; align-items: center; gap: 12px; min-height: var(--touch); font-size: 15px; cursor: pointer; }
  .checkbox__input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--action); }

  /* Option card (radio) */
  .option {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-option);
    cursor: pointer;
  }
  .option__radio {
    appearance: none;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex-shrink: 0;
    border: 1px solid var(--placeholder);
    border-radius: 50%;
    background: var(--white);
  }
  .option__radio:checked { border: 5px solid var(--ink); }
  .option__body { display: flex; flex-direction: column; gap: 2px; }
  .option__title { font-size: 15px; font-weight: 600; }
  .option__text { font-size: 13px; color: var(--muted); }
  .option:has(.option__radio:checked) {
    padding: 15px;
    border: 2px solid var(--ink);
    background: var(--soft);
  }

  /* Pill chips and time slots (radio inside a label) */
  .chip, .slot {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
  }
  .chip input, .slot input { position: absolute; opacity: 0; pointer-events: none; }
  .chip { border-radius: 22px; border: 1px solid var(--line-strong); }
  .chip:has(input:checked), .chip--on { background: var(--ink); border-color: var(--ink); color: var(--white); }
  .slot { border-radius: var(--radius-control); border: 1px solid var(--line); background: var(--soft); font-family: var(--font-mono); font-weight: 500; }
  .slot:has(input:checked), .slot--on { background: var(--action); border-color: var(--action); color: var(--white); }
  .chip:has(input:focus-visible), .slot:has(input:focus-visible) { outline: 2px solid var(--action); outline-offset: 2px; }
}

@layer components {
  /* Filter chips as links */
  .chip--link { position: relative; background: var(--white); color: var(--body); text-decoration: none; }
  .chip--link:hover { color: var(--ink); border-color: var(--ink); }
  .chip--link[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--white); }

  .form__footer { flex-wrap: wrap; padding-top: 18px; border-top: 1px solid var(--line); }
}

@layer components {
  .list-editor { border: 0; margin: 0; padding: 0; gap: 10px; }
  .list-editor__item { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--white); }
  .list-editor__item:focus-within { border-color: var(--ink); }
  .list-editor__grip { color: var(--placeholder); }
  .list-editor__input { flex: 1; min-width: 0; min-height: 46px; border: 0; outline: none; font-size: 15px; background: transparent; }
  .list-editor__remove { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
  .list-editor__remove:hover { background: var(--soft); color: var(--ink); }
  .list-editor__add { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); padding: 0 14px; border: 1px dashed #BDBAB4; border-radius: var(--radius-control); background: transparent; font-size: 14px; font-weight: 600; color: var(--body); cursor: pointer; }
  .list-editor__add:hover { border-color: var(--ink); color: var(--ink); }

  .upload__drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px; border: 1px dashed #BDBAB4; border-radius: var(--radius-option); text-align: center; color: var(--muted); cursor: pointer; }
  .upload__drop:hover, .upload__drop:focus-within { border-color: var(--ink); }
  .upload__title { font-size: 14px; font-weight: 600; color: var(--ink); }
  .upload__hint { font-size: 12px; }
  .upload__input { font-size: 13px; color: var(--body); max-width: 100%; }

  .file-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 6px 4px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--muted); }
  .file-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .file-row__title { font-size: 14px; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
  .file-row__title:hover { text-decoration: underline; }
  .file-row__meta { font-size: 12px; }
  .file-row form { display: contents; }

  .template-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: var(--touch); font-size: 14px; font-weight: 500; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-faint); }
  .template-row:last-child { border-bottom: 0; }
}

@layer components {
  .chip--sm { min-height: 40px; padding: 0 14px; }

  .tag-input { align-self: flex-start; min-height: 36px; width: 180px; padding: 0 12px; border: 1px dashed #BDBAB4; border-radius: 18px; font-size: 14px; background: var(--white); }
  .suggestion { min-height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 16px; background: var(--white); font-size: 13px; color: var(--body); cursor: pointer; }
  .suggestion:hover { border-color: var(--ink); color: var(--ink); }

  .kind-option { position: relative; flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px; min-height: 64px; padding: 10px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-option); cursor: pointer; }
  .kind-option input { position: absolute; opacity: 0; pointer-events: none; }
  .kind-option__title { font-size: 15px; font-weight: 600; }
  .kind-option__text { font-size: 13px; opacity: 0.8; }
  .kind-option:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--white); }
  .kind-option:has(input:focus-visible) { outline: 2px solid var(--action); outline-offset: 2px; }

  /* Profile diagnostics have no right answer: hide the markers. */
  .diag-form:has(input[name="diagnostic[graded]"][value="false"]:checked) .graded-only { display: none; }

  .question { padding: 24px 28px; gap: 14px; }
  .question[hidden] { display: none; }
  .answer-row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--soft); border-radius: var(--radius-control); background: var(--soft); }
  .answer-row:has(.answer-row__mark:checked) { background: var(--action-soft); border-color: #9BD3C8; }
  .answer-row__mark { appearance: none; width: 28px; height: 28px; flex-shrink: 0; margin: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23BDBAB4' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") no-repeat center; cursor: pointer; }
  .answer-row__mark:checked { border-color: var(--action); background: var(--action) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") no-repeat center; }
  .answer-row__letter { width: 18px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
  .answer-row__input { flex: 1; min-width: 0; min-height: 36px; border: 0; outline: none; background: transparent; font-size: 15px; }

  .add-question { min-height: 56px; border: 1px dashed #BDBAB4; border-radius: var(--radius-card); background: transparent; font-size: 15px; font-weight: 600; color: var(--body); cursor: pointer; }
  .add-question:hover { border-color: var(--ink); color: var(--ink); }
  .summary-value { color: var(--ink); font-weight: 600; }
}

@layer components {
  .module-row { display: flex; align-items: center; gap: 10px; }
  .module-row .field__input { min-height: 44px; }
  .module-row > input[type=text] { flex: 1; min-width: 0; }
  .module-row__number { width: 72px; flex-shrink: 0; font-size: 12px; color: var(--action); }
}

@layer components {
  .meeting-edit summary { list-style: none; }
  .meeting-edit summary::-webkit-details-marker { display: none; }
  .meeting-edit[open] { flex-basis: 100%; }
  .meeting-edit[open] .meeting-form { margin-top: 12px; }
  .item form.button_to { display: contents; }
}

@layer components {
  /* File field: a button (the label) plus the chosen file's name. */
  .upload-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
  .upload-field__button { position: relative; cursor: pointer; }
  .upload-field__button:focus-within { outline: 2px solid var(--action); outline-offset: 2px; }
  .upload-field__input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
  .upload-field__name { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }

  /* Two fields side by side, stacked on phones. */
  .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 24px; align-items: start; }

  .profile-form { gap: 24px; }
  .profile-form__grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; }
  .profile-form__photo { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 24px 16px; border-radius: var(--radius-option); background: var(--soft); text-align: center; }
  .profile-form__photo .field__hint { text-align: center; }
  .profile-form__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px 24px; align-content: start; }
  .profile-form__footer { display: flex; justify-content: flex-end; gap: 12px; }

  @media (max-width: 720px) {
    .profile-form__grid { grid-template-columns: 1fr; }
  }
}

@layer components {
  .upload-field__name:empty { display: none; }
  .profile-form__photo .upload-field { flex-direction: column; justify-content: center; }
}

@layer components {
  .new-cohort { padding: 18px; border-radius: var(--radius-option); background: var(--soft); }
  .new-cohort[hidden] { display: none; }
}

@layer components {
  /* Fields and the button share the bottom line (the button lines up with the inputs, not the labels). */
  .meeting-form { --gap: 12px; align-items: flex-end; }
}

@layer components {
  /* "Meu perfil" / "Editar aluno": dark band with the photo overlapping it, then settings-style sections. */
  .profile-card { padding: 0; gap: 0; overflow: hidden; }
  .profile-card__band { height: 96px; background: var(--ink); }
  .profile-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 16px 24px;
    padding: 0 32px 24px;
    margin-top: -48px;
    border-bottom: 1px solid var(--line-faint);
  }
  .profile-card__avatar { position: relative; flex-shrink: 0; border-radius: 50%; cursor: pointer; }
  .profile-card__avatar .avatar { width: 112px; height: 112px; font-size: 36px; box-shadow: 0 0 0 5px var(--white); }
  .profile-card__avatar-image { display: block; }
  .profile-card__avatar-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 50%;
    background: rgb(21 21 21 / 0.8);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.15s;
  }
  .profile-card__avatar:hover .profile-card__avatar-overlay,
  .profile-card__avatar:has(input:focus-visible) .profile-card__avatar-overlay { opacity: 1; }
  .profile-card__avatar:has(input:focus-visible) { outline: 2px solid var(--action); outline-offset: 6px; }
  /* Always visible: phones have no hover. */
  .profile-card__avatar-badge {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--white);
    color: var(--ink);
    box-shadow: 0 0 0 1px var(--line), 0 2px 6px rgb(21 21 21 / 0.15);
  }
  /* The photo overlaps the band by 48px; name and actions start 16px below the band. */
  .profile-card__who { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; margin-top: 64px; }
  .profile-card__name { font-size: 24px; line-height: 1.25; letter-spacing: -0.4px; overflow-wrap: anywhere; }
  .profile-card__upload { gap: 4px; }
  .profile-card .notice { margin: 24px 32px 0; }

  .profile-card__section {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px 40px;
    padding: 28px 32px;
  }
  .profile-card__section-intro { display: flex; flex-direction: column; gap: 6px; }
  .profile-card__footer { display: flex; justify-content: flex-end; gap: 12px; padding: 20px 32px; border-top: 1px solid var(--line-faint); background: var(--white); }

  @media (max-width: 720px) {
    .profile-card__head { padding: 0 20px 20px; }
    .profile-card__who { margin-top: 0; }
    .profile-card__section { grid-template-columns: minmax(0, 1fr); padding: 24px 20px; }
    .profile-card__footer { padding: 16px 20px; }
  }
}

@layer components {
  /* Initials would show through the overlay text. */
  .profile-card__avatar:hover .avatar:not(.avatar--photo),
  .profile-card__avatar:has(input:focus-visible) .avatar:not(.avatar--photo) { color: transparent; }
}
