/* The app's own pickers (pick.js), and its checkboxes, radios and
 * switches. Every colour is a design.css token, so one set of rules is
 * right in light and in dark. A page that links this file gets the
 * custom checkboxes, radios and switches at once, and its selects and
 * date and time inputs as soon as it calls SonalinePick.upgrade(). */

/* The native control a picker wraps stays in the page for the app's
   code to read; it is never seen. */
.pk-native { display: none !important; }
.pk-trigger, .pk-pop, .pk-sheet, .pk-pop *, .pk-sheet * { box-sizing: border-box; }

/* ---------- the button that stands where the native control was ---------- */
.pk-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 200px; max-width: 100%; padding: 0 10px 0 14px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--glass); color: var(--text);
  font: inherit; font-size: 16px; text-align: left; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.pk-trigger.short { min-width: 136px; }
.pk-trigger:hover { background: var(--hover); }
.pk-trigger[aria-expanded="true"] { border-color: var(--primary); }
.pk-trigger:disabled { opacity: .5; cursor: default; }
.pk-trigger:disabled:hover { background: var(--glass); }
.pk-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The inbox's app.css has an empty state called .empty too (a padded,
   centred block); a placeholder here is only its colour. */
.pk-trigger .pk-value.empty { color: var(--text-2); padding: 0; text-align: left; }
.pk-icon { display: grid; place-items: center; }
.pk-icon svg { width: 20px; height: 20px; fill: var(--text-2); }

/* ---------- a popover on a desktop ---------- */
.pk-pop {
  position: fixed; inset: auto; margin: 0; z-index: 1000;
  max-width: min(420px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto;
  padding: 0; background: var(--sheet); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .32), 0 2px 6px rgba(0, 0, 0, .18);
  opacity: 0; transform: translateY(-4px) scale(.98);
  transition: opacity .16s ease-out, transform .16s ease-out;
}
.pk-pop.up { transform: translateY(4px) scale(.98); }
.pk-pop.in { opacity: 1; transform: none; }
.pk-pop.wide { max-width: min(620px, calc(100vw - 16px)); }
.pk-pop .pk-body { padding: 8px; }

/* ---------- a bottom sheet on a phone: the app's GlassSheet ---------- */
dialog.pk-sheet {
  position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: 100%;
  max-height: 88dvh; display: flex; flex-direction: column;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  border: 0; border-radius: 28px 28px 0 0;
  background: var(--sheet); color: var(--text);
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
dialog.pk-sheet.in { transform: none; }
dialog.pk-sheet.searching { height: 72dvh; }
dialog.pk-sheet::backdrop { background: rgba(0, 0, 0, .45); }
.pk-sheet .pk-body { overflow: auto; min-height: 0; flex: 1; display: flex; flex-direction: column; }
.pk-grip { display: block; flex: none; width: 42px; height: 4px; border-radius: 2px; margin: 0 auto 12px; background: var(--faint); }
.pk-sheet-title { margin: 0 4px 10px; font-size: 17px; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .pk-pop, dialog.pk-sheet, .pk-trigger, .pk-day, input[type="checkbox"], input[type="radio"], .switch, .switch::after, input[role="switch"]::after { transition: none !important; }
}

/* ---------- search and options ---------- */
.pk-search {
  display: flex; align-items: center; gap: 8px; margin: 4px 4px 8px; padding: 0 12px;
  height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--glass);
}
.pk-search:focus-within { border-color: var(--primary); }
.pk-search svg { width: 20px; height: 20px; fill: var(--text-2); flex: none; }
.pk-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text);
  font: inherit; font-size: 16px; appearance: none;
}
.pk-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.pk-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; outline: none; }
.pk-sheet .pk-list { max-height: none; }
.pk-group { padding: 12px 12px 4px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); }
.pk-opt { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.pk-opt.active { background: var(--hover); }
.pk-list:focus-visible .pk-opt.active, .pk-search:focus-within + .pk-list .pk-opt.active { box-shadow: inset 0 0 0 2px var(--primary); }
.pk-opt[aria-selected="true"] { background: var(--selected); color: var(--selected-text); }
.pk-opt[aria-disabled="true"] { opacity: .45; cursor: default; }
.pk-opt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pk-opt-text small { color: var(--text-2); font-size: 13px; }
.pk-tick svg { width: 20px; height: 20px; fill: var(--primary); visibility: hidden; }
/* A row's own action (pick.js opts.action): a round 44px button. */
.pk-opt-act { flex: none; width: 44px; height: 44px; margin: -8px 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; padding: 0; }
.pk-opt-act svg { width: 24px; height: 24px; fill: currentColor; }
.pk-opt-act:hover { background: var(--surface-2); color: var(--text); }
.pk-opt[aria-selected="true"] .pk-tick svg { visibility: visible; }
.pk-none { margin: 12px; color: var(--text-2); font-size: 15px; }

/* ---------- the calendar ---------- */
.pk-cal-head { display: flex; align-items: center; gap: 4px; padding: 4px 4px 6px 12px; }
.pk-cal-title { flex: 1; font-weight: 500; font-size: 16px; }
.pk-nav { width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--text); cursor: pointer; display: grid; place-items: center; }
.pk-nav svg { width: 24px; height: 24px; fill: currentColor; }
.pk-nav:hover { background: var(--hover); }
.pk-grid { border-collapse: collapse; margin: 0 auto; }
.pk-grid th { width: 44px; height: 28px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.pk-grid td { padding: 0; }
.pk-day {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--text);
  font: inherit; font-size: 15px; font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color .15s;
}
.pk-day:hover { background: var(--hover); }
.pk-day.out { color: var(--faint); }
.pk-day.today { box-shadow: inset 0 0 0 1px var(--primary); }
.pk-day.on { background: var(--primary); color: var(--on-primary); font-weight: 500; }
.pk-day:disabled { opacity: .3; cursor: default; }
.pk-day:disabled:hover { background: none; }

/* ---------- months ---------- */
.pk-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; }
.pk-month { min-height: 48px; border: 0; border-radius: 12px; background: var(--glass); color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.pk-month:hover { background: var(--hover); }
.pk-month.today { box-shadow: inset 0 0 0 1px var(--primary); }
.pk-month.on { background: var(--primary); color: var(--on-primary); font-weight: 500; }

/* ---------- the wheels: the inbox line menu's, at 44px a row ---------- */
.pk-wheels { position: relative; display: flex; align-items: center; justify-content: center; gap: 2px;
  height: 132px; margin: 4px; border-radius: 16px; background: var(--glass-2); overflow: hidden; }
.pk-band { position: absolute; left: 10px; right: 10px; top: 44px; height: 44px; border-radius: 12px;
  background: var(--primary-soft); pointer-events: none; }
.pk-wheel { position: relative; width: 66px; height: 132px; overflow-y: auto; border-radius: 12px;
  scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; outline: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent); }
.pk-wheel::-webkit-scrollbar { display: none; }
.pk-wheel:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.pk-ampm { width: 60px; }
.pk-pad { height: 44px; }
.pk-wi { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 22px;
  color: var(--text-2); scroll-snap-align: center; cursor: pointer; font-variant-numeric: tabular-nums; }
.pk-ampm .pk-wi { font-size: 17px; }
.pk-wi.on { color: var(--text); font-weight: 500; }
.pk-colon { position: relative; font-size: 22px; font-weight: 500; }

/* ---------- a day and a time together ---------- */
.pk-dt { display: flex; gap: 12px; align-items: flex-start; }
.pk-dt-time { padding-top: 4px; }
.pk-dt-label { padding: 12px 8px 10px; font-weight: 500; font-size: 16px; }
.pk-sheet .pk-dt { flex-direction: column; align-items: stretch; gap: 4px; }
.pk-sheet .pk-dt-label { padding: 8px 8px 0; }

.pk-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 4px 2px; }
.pk-btn { min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; }
.pk-btn.text { background: none; color: var(--primary); }
.pk-btn.text:hover { background: var(--hover); }
.pk-btn.fill { background: var(--primary); color: var(--on-primary); }

/* ---------- checkboxes, radios and switches ----------
   Still the browser's own inputs, so the keyboard, forms and screen
   readers work as they always did: only how they look changes. The box
   is 22px; the row it sits in gives the 44px to touch. */
input[type="checkbox"]:not([role="switch"]), input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 22px; height: 22px; margin: 0; flex: none; cursor: pointer;
  border: 2px solid var(--text-2); border-radius: 6px; background: none;
  display: inline-grid; place-items: center; vertical-align: middle;
  transition: background-color .15s, border-color .15s;
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:not([role="switch"]):checked { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:not([role="switch"]):checked::after {
  content: ""; width: 6px; height: 11px; border: solid var(--on-primary); border-width: 0 2.5px 2.5px 0;
  transform: translateY(-1px) rotate(45deg);
}
input[type="checkbox"]:indeterminate { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"]:indeterminate::after { content: ""; width: 10px; height: 2.5px; background: var(--on-primary); border-radius: 1px; }
input[type="radio"]:checked { border-color: var(--primary); }
input[type="radio"]:checked::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .45; cursor: default; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* The app's switch, at the size Android's is: 52 by 32. The inbox draws
   it as a button with role="switch", the console as a checkbox with
   role="switch"; both look the same. */
input[type="checkbox"][role="switch"] {
  appearance: none; -webkit-appearance: none; margin: 0; display: inline-block; vertical-align: middle;
}
.switch, input[type="checkbox"][role="switch"] {
  position: relative; width: 52px; height: 32px; flex: none; padding: 0; border: 0;
  border-radius: 16px; background: var(--border); cursor: pointer; transition: background-color .15s;
}
.switch::after, input[type="checkbox"][role="switch"]::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--text-2); box-shadow: none; transition: transform .18s, background-color .15s;
}
.switch[aria-checked="true"], input[type="checkbox"][role="switch"]:checked { background: var(--primary); }
.switch[aria-checked="true"]::after, input[type="checkbox"][role="switch"]:checked::after { left: 4px; transform: translateX(20px); background: var(--on-primary); }
.switch:disabled, input[type="checkbox"][role="switch"]:disabled { opacity: .5; cursor: default; }
/* A settings page (app.css .settings .switch) keeps its 44px-high switch
   for the tap target and moves the knob with left; here the knob moves
   with the transform above, so left stays put or it would move twice. */
.settings .switch[aria-checked="true"]::after { left: 4px; }
input[type="checkbox"][role="switch"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
