/* Fields, inputs, selects, switches, checkboxes and segmented controls. */

.field { margin-bottom: 16px; }
.field > label { display: block; margin-bottom: 6px; font-size: var(--fs-s); font-weight: 600; color: var(--ink); }
.field .hint { margin-top: 6px; font-size: var(--fs-xs); line-height: 1.5; color: var(--ink-4); }
.req { margin-left: 2px; color: var(--bad); font-weight: 700; }

.input, select.input, textarea.input {
  width: 100%; min-height: var(--h-md); padding: 7px 12px;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input); color: var(--ink); box-shadow: var(--sh-xs);
  font-size: var(--fs-s); line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input::placeholder { color: var(--ink-5); }
.input:hover:not(:focus):not(:disabled) { border-color: var(--line-strong); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.input:disabled { opacity: .55; cursor: not-allowed; }
.input.sm { min-height: var(--h-sm); padding: 5px 10px; font-size: var(--fs-xs); }
textarea.input { min-height: 96px; resize: vertical; }

select.input {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px; cursor: pointer; text-overflow: ellipsis;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-4) 50%),
    linear-gradient(135deg, var(--ink-4) 50%, transparent 50%);
  background-position: calc(100% - 17px) calc(50% + 1px), calc(100% - 12px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select.input option { background: var(--panel); color: var(--ink); }
select.input option:disabled { color: var(--ink-5); }
select.input optgroup { background: var(--panel); color: var(--ink-4); font-style: normal; font-weight: 600; }

/* Where the browser allows it, the open list is styled too, so every dropdown looks the same everywhere.
   Other browsers keep the closed control above with their own list. */
@supports (appearance: base-select) {
  select.input, select.input::picker(select) { appearance: base-select; }
  select.input { display: flex; align-items: center; gap: 8px; padding-right: 10px; background-image: none; }
  select.input.sm { padding-right: 8px; }
  select.input::picker-icon {
    content: ""; flex: none; width: 7px; height: 7px; margin-left: auto;
    border-right: 1.5px solid var(--ink-4); border-bottom: 1.5px solid var(--ink-4);
    transform: translateY(-2px) rotate(45deg); transition: transform .2s ease;
  }
  select.input:open::picker-icon { transform: translateY(2px) rotate(225deg); }
  select.input:open { border-color: var(--brand); box-shadow: var(--focus-ring); }

  /* The browser opens the list toward the side with the most room; ours opens below and flips only when it does not fit. */
  select.input::picker(select) {
    position-try-order: normal; position-try-fallbacks: flip-block;
    margin-top: 6px; padding: 5px; max-height: min(340px, 60vh); overflow-y: auto;
    border: 1px solid var(--line); border-radius: var(--r-m);
    background: var(--panel); color: var(--ink); box-shadow: var(--sh-float);
    opacity: 0; translate: 0 -4px;
    transition: opacity .15s ease, translate .15s ease, overlay .15s allow-discrete, display .15s allow-discrete;
  }
  select.input:open::picker(select) { opacity: 1; translate: 0 0; }
  @starting-style { select.input:open::picker(select) { opacity: 0; translate: 0 -4px; } }

  select.input option {
    display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-s);
    background: transparent; font-size: var(--fs-s); cursor: pointer;
  }
  select.input.sm option { padding: 7px 9px; font-size: var(--fs-xs); }
  select.input option:hover, select.input option:focus-visible { background: var(--panel-3); outline: none; }
  select.input option:checked { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
  select.input option::checkmark { order: 1; margin-left: auto; color: var(--brand-text); }
  select.input option:disabled { background: transparent; color: var(--ink-5); cursor: not-allowed; }
  select.input optgroup { padding-top: 4px; background: transparent; }
  select.input optgroup legend { padding: 8px 10px 4px; font-size: var(--fs-2xs); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
}

input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; }

/* A password input with a show or hide button inside its right edge (password.js). */
.pw-field { position: relative; }
.pw-field .input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 0; border-radius: var(--r-s); background: none; color: var(--brand-text); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.pw-toggle:hover { background: var(--panel-3); color: var(--brand-text-hover); }
.pw-toggle svg { width: 18px; height: 18px; }

/* A real checkbox with its label; the tick is drawn, so it takes the brand colour in both themes. */
.checkbox { display: inline-flex; align-items: center; gap: 9px; font-size: var(--fs-m); color: var(--ink-3); cursor: pointer; user-select: none; }
.checkbox input {
  appearance: none; -webkit-appearance: none; display: grid; place-items: center; flex: none;
  width: 18px; height: 18px; margin: 0; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--r-xs); background: var(--input);
  transition: background .15s ease, border-color .15s ease;
}
.checkbox input::before {
  content: ""; width: 10px; height: 10px; background: var(--on-brand);
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  transform: scale(0); transition: transform .12s ease;
}
.checkbox input:checked { background: var(--brand); border-color: var(--brand); }
.checkbox input:checked::before { transform: scale(1); }
.checkbox input:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* A wrapping list of checkboxes under one label, such as the stages a filter lets through. */
.checklist { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 12px; }

/* One-time codes */
.otp { display: flex; gap: 8px; justify-content: space-between; }
.otp input {
  width: 46px; height: 54px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--r-m); background: var(--input); color: var(--ink);
  font-family: var(--mono); font-size: 21px; font-weight: 600;
}
.otp input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
.otp-code { max-width: 180px; font-size: var(--fs-l); letter-spacing: .12em; }
.otp-code::placeholder { letter-spacing: normal; font-size: var(--fs-s); }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; font-size: var(--fs-xs); color: var(--ink-4); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- Switches ----------
   Two markups share one look: a real checkbox (.switch > input + .sl, .sw > input + .sw-track)
   and a script-toggled span (.switch.on > .track). */
.switch, .sw { position: relative; display: inline-flex; align-items: center; gap: 9px; flex: none; vertical-align: middle; cursor: pointer; }
.switch input, .sw input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .sl, .switch .track, .sw .sw-track {
  position: relative; display: block; flex: none; width: 36px; height: 20px;
  border-radius: var(--r-full); background: var(--panel-3); box-shadow: inset 0 0 0 1px var(--line);
  cursor: pointer; transition: background .15s ease, box-shadow .15s ease;
}
.switch .sl::before, .switch .track::after, .sw .sw-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--on-brand); box-shadow: var(--sh-xs);
  transition: transform .18s var(--ease);
}
.switch input:checked + .sl, .switch.on .track, .sw input:checked + .sw-track { background: var(--brand); box-shadow: none; }
.switch input:checked + .sl::before, .switch.on .track::after, .sw input:checked + .sw-track::after { transform: translateX(16px); }
.switch input:focus-visible + .sl, .sw input:focus-visible + .sw-track { box-shadow: var(--focus-ring); }
.switch input:disabled + .sl, .sw input:disabled + .sw-track { opacity: .5; cursor: not-allowed; }

/* ---------- Checkboxes and choice ticks ----------
   Every "picked" indicator in the app is the same small brand square with a white tick. */
.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: var(--fs-s); line-height: 1.5; }
.check .box, .rb {
  display: grid; place-items: center; flex: none;
  width: 18px; height: 18px; margin-top: 1px; border-radius: var(--r-xs);
  border: 1.5px solid var(--line-strong); background: var(--input);
  font-size: 11px; line-height: 1; color: transparent;
  transition: background .15s ease, border-color .15s ease;
}
.check.on .box, .rt.on .rt-h .rb {
  background: var(--brand); border-color: var(--brand); color: var(--on-brand);
}

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  border-radius: var(--r-m); background: var(--panel-3);
}
.seg button, .seg a, .seg label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--ink-3);
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg button:hover, .seg a:hover, .seg label:hover { color: var(--ink); }
.seg .on, .seg button.on, .seg label.on { background: var(--panel); color: var(--ink); font-weight: 600; box-shadow: var(--sh-xs); }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }

/* ---------- Info tip ---------- */
.itip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 6px; vertical-align: -4px;
  border-radius: 50%; background: transparent; color: var(--tip); cursor: help;
}
/* a row style that greys every span must not grey the icon */
.itip.itip.itip { color: var(--tip); }
.itip svg { width: 16px; height: 16px; }
.itip::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%); z-index: 200;
  width: max-content; max-width: 280px; padding: 8px 11px;
  border: 1px solid var(--brand-text); border-radius: var(--r-m); background: var(--panel); color: var(--ink-2); box-shadow: var(--sh-pop);
  font-size: var(--fs-xs); font-weight: 400; line-height: 1.55; text-align: left; white-space: pre-line; text-transform: none; letter-spacing: normal;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s ease;
}
.itip:hover::after, .itip:focus::after, .itip:focus-visible::after { opacity: 1; visibility: visible; }
/* with javascript the tip floats on the page (itip.js), so no card's overflow or edge can cut it off */
html.itip-js .itip::after { display: none; }
.itip-pop {
  position: fixed; z-index: 1000; max-width: 300px; padding: 10px 13px; pointer-events: none;
  border: 1px solid var(--brand-text); border-radius: var(--r-m); background: var(--panel); color: var(--ink-2, var(--ink)); box-shadow: var(--sh-pop);
  font-size: var(--fs-xs); font-weight: 400; line-height: 1.55; text-align: left; white-space: normal;
  opacity: 0; transition: opacity .12s ease;
}
.itip-pop.on { opacity: 1; }
.itip-pop ul { margin: 6px 0 0; padding-left: 16px; }
.itip-pop li + li { margin-top: 3px; }
.itip-pop li::marker { color: var(--ink-4); }

@media (max-width: 700px) {
  .otp { justify-content: flex-start; }
  .otp input { width: 42px; height: 48px; font-size: 18px; }
}

@media (max-width: 420px) {
  .otp { gap: 5px; }
  .otp input { width: 38px; height: 44px; }
}
