/* Buttons, inputs, controls — every state in 5c, light and dark.
 * One primary per screen, and it says the verb. Hover darkens one step; pressed darkens two and
 * shrinks 3 %; disabled is quiet, not ghostly. */

.btn {
  --focus-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--hit);
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: var(--t-button);
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--d-micro) var(--ease-enter),
    border-color var(--d-micro) var(--ease-enter),
    color var(--d-micro) var(--ease-enter),
    transform var(--d-press) var(--ease-enter);
  user-select: none;
}
.btn:hover {
  text-decoration: none;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn > svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
:root[data-theme='dark'] .btn-primary,
:root[data-theme='dark'] .btn-danger {
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: var(--on-accent);
}
.btn-primary:active:not(:disabled) {
  background: var(--accent-pressed);
}
.btn-primary:disabled {
  background: var(--surface-selected);
  color: var(--ink-placeholder);
}
:root[data-theme='dark'] .btn-primary:disabled,
:root[data-theme='dark'] .btn-danger:disabled {
  background: var(--line-soft);
  color: var(--ink-quiet);
}

.btn-secondary {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--ground-sunken);
  border-color: var(--line-strong);
  color: var(--ink);
}
:root[data-theme='dark'] .btn-secondary:hover:not(:disabled) {
  background: var(--surface-you);
}
.btn-secondary:active:not(:disabled) {
  background: var(--surface-selected);
}
.btn-secondary:disabled {
  background: var(--ground);
  border-color: var(--line-soft);
  color: var(--ink-placeholder);
}

.btn-quiet {
  color: var(--ink-soft);
}
.btn-quiet:hover:not(:disabled) {
  background: var(--ground-sunken);
  color: var(--ink);
}
:root[data-theme='dark'] .btn-quiet:hover:not(:disabled) {
  background: var(--surface-raised);
}
.btn-quiet:active:not(:disabled) {
  background: var(--surface-selected);
}
:root[data-theme='dark'] .btn-quiet:active:not(:disabled) {
  background: var(--line-soft);
}
.btn-quiet:disabled {
  color: var(--ink-disabled);
}

.btn-danger {
  background: var(--danger);
  color: var(--on-danger);
  --focus-ring: var(--danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  color: var(--on-danger);
}
.btn-danger:active:not(:disabled) {
  background: var(--danger-pressed);
}
.btn-danger:disabled {
  background: var(--surface-selected);
  color: var(--ink-placeholder);
}
.btn-danger:focus-visible {
  box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--danger);
}

/* Full-width, larger: first run and the phone's sheets. */
.btn-block {
  width: 100%;
  min-height: 48px;
  padding: 13px 20px;
  font-size: calc(16px * var(--ts));
  font-weight: 600;
}

/* Working: a spinner and the verb in its -ing form ("Sending"). */
.btn.is-working {
  pointer-events: none;
}
.spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid color-mix(in oklch, currentColor 40%, transparent);
  border-top-color: currentColor;
  animation: mx-spin 800ms linear infinite;
  flex: none;
}

/* Hold to confirm: the fill grows while held. Irreversible verbs only. */
.btn-hold {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--surface-selected);
  color: var(--ink);
  --hold: 0;
}
:root[data-theme='dark'] .btn-hold {
  background: var(--line);
}
.btn-hold::before {
  content: '';
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(var(--hold));
  background: var(--hold-fill, var(--danger));
  z-index: -1;
}
.btn-hold.is-accent {
  --hold-fill: var(--accent);
}
.btn-hold.is-done {
  color: var(--on-danger);
}
.btn-hold.is-accent.is-done {
  color: var(--on-accent);
}

/* A verb in running text: "Change the ceiling", "Ask me again", "Show". */
.link {
  display: inline;
  color: var(--accent-text);
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border-radius: 4px;
}
.link:hover {
  color: var(--accent-text-hover);
  text-decoration: underline;
}
.link.is-quiet {
  color: var(--ink-quiet);
  font-weight: 400;
}
.link.is-quiet:hover {
  color: var(--ink);
}
.link.is-danger {
  color: var(--danger);
}
.link:disabled {
  color: var(--ink-disabled);
  text-decoration: none;
}

/* Icon buttons: 38 px, 44 on the phone. */
.icon-btn {
  --focus-radius: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  flex: none;
  transition:
    background-color var(--d-micro) var(--ease-enter),
    color var(--d-micro) var(--ease-enter),
    transform var(--d-press) var(--ease-enter);
}
.icon-btn:hover:not(:disabled) {
  background: var(--ground-sunken);
  color: var(--ink);
}
:root[data-theme='dark'] .icon-btn:hover:not(:disabled) {
  background: var(--surface-raised);
}
.icon-btn:active:not(:disabled) {
  background: var(--surface-selected);
  transform: scale(0.94);
}
.icon-btn:disabled {
  color: var(--ink-disabled);
}
.icon-btn.is-small {
  width: 32px;
  height: 32px;
}
.icon-btn.is-quiet {
  color: var(--ink-quiet);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn.is-small svg {
  width: 16px;
  height: 16px;
}

/* The send button: an accent circle; dims to surface.selected when there is nothing to send;
 * becomes Stop (a square) while Motrix is replying. */
.send-btn {
  --focus-radius: 50%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--accent);
  color: var(--on-accent);
  transition:
    background-color var(--d-micro) var(--ease-enter),
    color var(--d-micro) var(--ease-enter),
    transform var(--d-press) var(--ease-enter);
}
.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.send-btn:active:not(:disabled) {
  background: var(--accent-pressed);
  transform: scale(0.94);
}
.send-btn:disabled {
  background: var(--surface-selected);
  color: var(--ink-placeholder);
}
:root[data-theme='dark'] .send-btn:disabled {
  background: var(--line-soft);
  color: var(--ink-quiet);
}
.send-btn svg {
  width: 16px;
  height: 16px;
}
.send-btn .stop-square {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: currentColor;
}

/* ------------------------------------------------------------------------------------------ */
/* Text fields */

.field {
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  font-size: calc(16px * var(--ts));
  line-height: 1.35;
  color: var(--ink);
  transition: border-color var(--d-micro) var(--ease-enter);
  resize: none;
}
:root[data-theme='dark'] .field {
  border-color: var(--line-soft);
}
.field::placeholder {
  color: var(--ink-placeholder);
}
.field:focus,
.field:focus-visible {
  border: 1.5px solid var(--accent);
  padding: 12.5px 15.5px;
  box-shadow: none;
  caret-color: var(--accent);
}
.field.is-error,
.field[aria-invalid='true'] {
  border: 1.5px solid var(--danger);
  padding: 12.5px 15.5px;
}
.field-error {
  font-size: var(--t-small);
  color: var(--danger);
  padding: 6px 4px 0;
}
.field-hint {
  font-size: var(--t-small);
  color: var(--ink-quiet);
  padding: 6px 4px 0;
}
.field-label {
  display: block;
  font-size: var(--t-small);
  color: var(--ink-quiet);
  padding: 0 0 6px;
}

/* Search: the same shell with the magnifier inside. */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search > svg {
  position: absolute;
  left: 16px;
  width: 17px;
  height: 17px;
  color: var(--ink-quiet);
  pointer-events: none;
}
.search .field {
  padding-left: 45px;
}
.search .field:focus {
  padding-left: 44.5px;
}
.search .field::-webkit-search-cancel-button {
  -webkit-appearance: none;
}
.search .search-count {
  position: absolute;
  right: 16px;
  font-size: var(--t-small);
  color: var(--ink-quiet);
  pointer-events: none;
}

/* ------------------------------------------------------------------------------------------ */
/* Switch: the knob is geometry and may overshoot; the track colour is appearance and never does. */

.switch {
  --focus-radius: 14px;
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: 14px;
  background: var(--switch-off);
  flex: none;
  transition: background-color var(--d-micro) var(--ease-enter);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--knob-off);
  transition:
    transform var(--d-micro) var(--ease-spring),
    background-color var(--d-micro) var(--ease-enter);
}
.switch[aria-checked='true'] {
  background: var(--accent);
}
.switch[aria-checked='true']::after {
  transform: translateX(18px);
  background: var(--knob);
}
.switch:disabled {
  background: color-mix(in oklch, var(--switch-off) 55%, var(--ground));
  cursor: default;
}
.switch:disabled::after {
  background: var(--ground);
}
:root[data-theme='dark'] .switch:disabled {
  background: #2A2521;
}
:root[data-theme='dark'] .switch:disabled::after {
  background: #3F332B;
}

/* Radio and checkbox, drawn. */
.radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-disabled);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition:
    background-color var(--d-micro) var(--ease-enter),
    border-color var(--d-micro) var(--ease-enter);
}
:root[data-theme='dark'] .radio {
  border-color: var(--line-strong);
}
.radio.is-on {
  border-color: var(--accent);
  background: var(--accent);
}
.radio.is-on::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--on-accent);
}
:root[data-theme='light'] .radio.is-on::after {
  background: #fff;
}

.check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid var(--ink-disabled);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: #fff;
}
:root[data-theme='dark'] .check {
  color: var(--on-accent);
  border-color: var(--line-strong);
}
.check.is-on {
  background: var(--accent);
  border-color: var(--accent);
}
.check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
}
.check.is-on svg {
  opacity: 1;
}

/* Segmented: Light · Dark · Match. */
.segmented {
  display: inline-flex;
  background: var(--ground-sunken);
  border-radius: 12px;
  padding: 4px;
  gap: 2px;
}
.segmented button {
  --focus-radius: 9px;
  flex: 1 1 auto;
  white-space: nowrap;
  padding: 7px 14px;
  min-height: 34px;
  border-radius: 9px;
  font-size: var(--t-button);
  color: var(--ink-soft);
  transition:
    background-color var(--d-micro) var(--ease-enter),
    color var(--d-micro) var(--ease-enter);
}
.segmented button:hover {
  color: var(--ink);
}
.segmented button[aria-checked='true'] {
  background: var(--surface-raised);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(30, 26, 22, 0.12);
}
:root[data-theme='dark'] .segmented button[aria-checked='true'] {
  background: var(--line);
  box-shadow: none;
}

/* Slider: a native range input, drawn as the design draws it. `--fill` is set from the value. */
.slider {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  background: transparent;
  cursor: pointer;
}
.slider:focus-visible {
  box-shadow: none;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-selected) var(--fill));
}
:root[data-theme='dark'] .slider::-webkit-slider-runnable-track {
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line-soft) var(--fill));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1.5px solid var(--accent);
  box-shadow: 0 2px 8px rgba(30, 26, 22, 0.15);
  transition: transform var(--d-press) var(--ease-enter);
}
.slider:active::-webkit-slider-thumb {
  transform: scale(1.08);
}
.slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--ground), 0 0 0 4px var(--accent);
}
.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--surface-selected);
}
.slider::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1.5px solid var(--accent);
  box-shadow: 0 2px 8px rgba(30, 26, 22, 0.15);
}

/* ------------------------------------------------------------------------------------------ */
/* Chips: starting points, name suggestions. */

.chip {
  --focus-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-raised);
  font-size: calc(14.5px * var(--ts));
  color: var(--ink-soft);
  transition:
    background-color var(--d-micro) var(--ease-enter),
    border-color var(--d-micro) var(--ease-enter),
    color var(--d-micro) var(--ease-enter),
    transform var(--d-press) var(--ease-enter);
}
.chip:hover {
  background: var(--ground-sunken);
  color: var(--ink);
}
:root[data-theme='dark'] .chip:hover {
  background: var(--surface-you);
}
.chip:active {
  transform: scale(0.97);
}
.chip[aria-pressed='true'],
.chip.is-on {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ground);
  font-weight: 600;
}

/* Badges say a state, never a count of things a person can't act on. The only number is
 * "needs you". */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: var(--t-label);
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}
.badge-count {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: calc(12.5px * var(--ts));
}
.badge-needs {
  background: var(--accent-wash);
  color: var(--accent-pressed);
}
:root[data-theme='dark'] .badge-needs {
  color: var(--accent-text);
}
.badge-state {
  background: var(--surface-selected);
  color: var(--ink-soft);
}
.badge-new {
  border: 1px solid var(--line);
  color: var(--ink-quiet);
}
.badge-good {
  padding: 0;
  font-size: var(--t-small);
  font-weight: 400;
  color: var(--success);
}
.badge-good::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Avatars. You: initials on avatar.you. Motrix: the mark, never a face. */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--avatar-you);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: calc(13px * var(--ts));
  font-weight: 600;
  flex: none;
  letter-spacing: 0.01em;
}
.avatar.is-small {
  width: 26px;
  height: 26px;
  font-size: 10.5px;
}
.avatar.is-large {
  width: 44px;
  height: 44px;
  font-size: 15px;
}
.avatar.is-xl {
  width: 64px;
  height: 64px;
  font-size: 21px;
}

/* The mark: the app icon, the assistant's avatar, the thinking and offline indicator. A ring and
 * a breathing dot while working; still, without the ring, while waiting; a tick when done. */
.mark {
  --mark: 22px;
  position: relative;
  width: var(--mark);
  height: var(--mark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: var(--accent);
}
.mark .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0;
}
.mark .dot {
  width: calc(var(--mark) * 0.45);
  height: calc(var(--mark) * 0.45);
  border-radius: 50%;
  background: currentColor;
}
.mark.is-working .ring {
  animation: mx-ring var(--breath) var(--ease-enter) infinite;
}
.mark.is-working .dot {
  animation: mx-breathe var(--breath) var(--ease-move) infinite;
}
.mark.is-done {
  border-radius: 50%;
  background: currentColor;
}
.mark.is-done .dot {
  display: none;
}
.mark .tick {
  display: none;
  width: 11px;
  height: 11px;
  color: var(--on-accent);
}
:root[data-theme='light'] .mark .tick {
  color: #fff;
}
.mark.is-done .tick {
  display: block;
}
/* The app mark: a solid circle with a light dot, as on Start something and first run. */
.mark-solid {
  --mark: 44px;
  width: var(--mark);
  height: var(--mark);
  border-radius: 50%;
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.mark-solid::after {
  content: '';
  width: calc(var(--mark) * 0.32);
  height: calc(var(--mark) * 0.32);
  border-radius: 50%;
  background: var(--surface-raised);
}
:root[data-theme='dark'] .mark-solid::after {
  background: var(--ground);
}

/* A status dot: connected, off, needs you. */
.dot-state {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-disabled);
  flex: none;
}
.dot-state.is-good {
  background: var(--success);
}
.dot-state.is-accent {
  background: var(--accent);
}
.dot-state.is-bad {
  background: var(--danger);
}

/* An "!" in a circle: risk lines, failed tool lines, error toasts. */
.alert-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  flex: none;
}
:root[data-theme='light'] .alert-dot {
  color: #fff;
}
.alert-dot.is-danger {
  background: var(--danger);
}
.tick-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
:root[data-theme='dark'] .tick-dot {
  color: var(--on-accent);
}
.tick-dot.is-good {
  background: var(--success);
}
.tick-dot svg {
  width: 11px;
  height: 11px;
}

/* A link that reads as text until pointed at: a conversation's title in a list, quiet hours. */
.link-plain {
  --focus-radius: 4px;
  color: inherit;
  text-align: left;
  text-decoration: none;
}
.link-plain:hover {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
