/* The wrapper occupies the field's original layout slot. Dictation fields
   retain their existing wrapper and paired microphone/clear controls. */
.textclearwrap {
  --textclear-size: 1.8rem;
  --textclear-space: 2.35rem;
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  min-width: 0;
  max-width: 100%;
}
.textclearwrap[hidden] { display: none; }
.textclearwrap > input,
.textclearwrap > textarea,
.row .textclearwrap > input,
.textclearwrap > #mailTo,
.textclearwrap > #importPrompt {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* These page-specific selectors keep the reserved control space after
   each page's field padding, including the larger mobile login inputs. */
.textclearwrap > input,
.textclearwrap > textarea,
.trans .textclearwrap > textarea,
#login .textclearwrap > input,
#clist .textclearwrap > input,
.textclearwrap > #writeText {
  padding-right: var(--textclear-space);
}
.textclearwrap > input[type="search"]::-webkit-search-cancel-button { display: none; }
.textclearwrap.multiline { display: flex; width: 100%; }
.textclearwrap.multiline[hidden] { display: none; }
.textclearwrap > .textclear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--textclear-size);
  height: var(--textclear-size);
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 4px;
  background: none;
  color: #999;
  cursor: pointer;
}
.textclearwrap.multiline > .textclear { top: 0.25rem; transform: none; }
.textclearwrap > .textclear:hover:not(:disabled) { color: #333; }
.textclearwrap > .textclear:focus-visible {
  outline: 2px solid #b5825f;
  outline-offset: -2px;
}
.textclearwrap > .textclear:disabled { opacity: 0.4; cursor: default; }
.textclear svg { width: 1.05rem; height: 1.05rem; display: block; }

/* Preserve flex proportions, full-width editors, and the contact grid. */
.row > .textclearwrap:has(> .cname) { flex: 1; min-width: 8rem; }
.row > .textclearwrap:has(> .caddr) { flex: 1.4; min-width: 11rem; }
.row > .textclearwrap:has(> #mailTo) { flex: 1; min-width: 10rem; }
#composeArea .row > .textclearwrap:has(> #mailSubject) { flex: 1; min-width: 0; }
#composeArea .textclearwrap:has(> #mailBody) { margin: 0.25rem 0; }
#composeArea .textclearwrap > #mailBody { margin: 0; }
#importArea > .textclearwrap:not([hidden]) { display: flex; width: 100%; margin-top: 0.5rem; }
#importArea .textclearwrap > #importPrompt { margin-top: 0; }
#importcard .row > .textclearwrap:has(> #importPrompt) { flex: 1; min-width: 12rem; }
#clist .textclearwrap { width: 100%; }

@media (max-width: 480px) {
  .textclearwrap { --textclear-size: 2.75rem; --textclear-space: 3rem; }
  .textclearwrap > input,
  #clist .textclearwrap > input { min-height: 2.75rem; }
  .textclearwrap > .textclear { right: 0.125rem; }
  #login .textclearwrap { width: 100%; }
  #login .textclearwrap > .textclear { padding: 0; margin: 0; }
  #importcard .row > .textclearwrap:has(> #importPrompt) { flex-basis: 100%; }
  /* Editing needs room for both text and the touch target. The normal
     contact display keeps its columns; an open editor uses the full row. */
  #clist .crow:has(> .editidentity) {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.35rem 0.45rem;
    align-items: center;
  }
  #clist .crow > .editidentity { grid-column: 1 / -1; }
}
