/* Polaris — form controls use the shared dark surfaces and focus ring. */
.duo { display: flex; gap: var(--s-3); }
.duo .field { flex: 1; min-width: 0; }

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  font-size: 12px;
  color: var(--text-muted);
}

.field input[type="number"],
.field input[type="time"],
.opt-row input[type="time"] {
  height: 36px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  color-scheme: dark;
  font: 13px var(--font-ui);
  padding: 0 10px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.field input:focus, .opt-row input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input::placeholder { color: var(--text-muted); opacity: 1; }

.stepper {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}

.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stepper button {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.stepper button:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.stepper button:active:not(:disabled) { background: var(--surface-3); }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }

.field .stepper input {
  flex: 1;
  width: 0;
  min-width: 0;
  height: 34px;
  text-align: center;
  padding: 0;
  font-size: 14px;
  border: none;
  border-radius: var(--r-sm);
  appearance: textfield;
  -moz-appearance: textfield;
  box-shadow: none;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.opt-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 36px;
  color: var(--text);
  font-size: 13px;
}

.opt-row > span:first-child, .opt-row > label:first-child { flex: 1; }
label.opt-row { cursor: pointer; }
.opt-row input[type="time"] { width: 112px; }

/* The native checkbox remains focusable and operates the visual switch. */
.opt-row input[type="checkbox"] {
  position: absolute;
  right: 0;
  width: 40px;
  height: 32px;
  opacity: 0;
  cursor: pointer;
}

.switch {
  width: 40px;
  height: 24px;
  flex-shrink: 0;
  position: relative;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-3);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  pointer-events: none;
}

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
}

.opt-row input:checked + .switch { background: var(--accent); border-color: var(--accent); }
.opt-row input:checked + .switch::before { transform: translateX(16px); background: #fff; }
.opt-row input:focus-visible + .switch { outline: var(--ring); outline-offset: 3px; }
.opt-row input:disabled + .switch { opacity: 0.4; }

/* An inset active pill makes the selected segment read as a movable control. */
.segmented {
  display: flex;
  gap: 3px;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.segmented button {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: 12px var(--font-ui);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.segmented button:hover:not(:disabled) { color: var(--text); background: var(--surface-hover); }
.segmented button.active {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--accent-text);
  box-shadow: var(--shadow-1), inset 0 1px 0 var(--accent-soft);
}
.segmented button:disabled { opacity: 0.35; cursor: not-allowed; }
.segmented.mini { width: 112px; flex-shrink: 0; }

/* One field surface, with the search action inset at its trailing edge. */
.search {
  display: flex;
  align-items: center;
  height: 36px;
  padding-right: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input {
  flex: 1;
  min-width: 0;
  height: 34px;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--text);
  font: 12px var(--font-ui);
  padding: 0 10px;
}
.search input:focus { outline: none; }
.search input::placeholder { color: var(--text-muted); opacity: 1; }

.search button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--accent-text);
  cursor: pointer;
}
.search button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.search button:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.search button:disabled { opacity: 0.4; cursor: wait; }

/* Darken the blue token enough to keep the white primary label readable. */
#calculate, #demo-primary {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent) 65%, #000);
  color: #fff;
  font: 600 13px var(--font-ui);
  cursor: pointer;
  transition: background var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

#calculate {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 12px;
}
#demo-primary { min-height: 38px; padding: 10px 8px; }

#calculate:hover:not(:disabled), #demo-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 72%, #000);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#calculate:active:not(:disabled), #demo-primary:active:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 58%, #000);
  transform: translateY(1px);
}
#calculate:disabled, #demo-primary:disabled {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text-muted);
  cursor: not-allowed;
}

.btn-star { width: 15px; height: 15px; fill: currentColor; }
#calculate.loading { background: var(--accent-soft); color: var(--accent-text); cursor: wait; }
#calculate.loading .btn-label { visibility: hidden; }
#calculate.loading .btn-star { position: absolute; width: 20px; height: 20px; animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(0.8) rotate(0deg); opacity: 0.5; }
  50% { transform: scale(1.25) rotate(45deg); opacity: 1; filter: drop-shadow(0 0 10px var(--star-glow)); }
}

.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  padding: 5px 7px;
  min-height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font: 11px var(--font-ui);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.ghost:active:not(:disabled) { background: var(--surface-3); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.panel-actions .ghost { min-height: 32px; }
#eta-note { margin-top: 2px; }
