/* Final consistency pass: controls, states, microinteractions, and mobile rhythm. */

:root {
  --otl-ui-rgb: 96, 165, 250;
  --otl-ui-color: #60a5fa;
}

/* --------------------------------------------------------------------------
   Selection controls
   -------------------------------------------------------------------------- */

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid rgba(148, 163, 184, 0.46);
  border-radius: 5px;
  color: #fff;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(2, 6, 23, 0.82));
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.32),
    0 1px 0 rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease,
    transform 120ms ease;
}

input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 5px;
  margin-top: -2px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0;
  transform: rotate(-45deg) scale(0.65);
  transition: opacity 120ms ease, transform 120ms ease;
}

input[type="checkbox"]:checked {
  border-color: rgba(var(--otl-ui-rgb), 0.78);
  background: linear-gradient(145deg, rgba(var(--otl-ui-rgb), 0.96), rgba(var(--otl-ui-rgb), 0.66));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.17),
    0 0 0 1px rgba(var(--otl-ui-rgb), 0.08),
    0 0 14px rgba(var(--otl-ui-rgb), 0.13);
}

input[type="checkbox"]:checked::before {
  opacity: 1;
  transform: rotate(-45deg) scale(1);
}

input[type="checkbox"]:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  filter: saturate(0.45);
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid rgba(var(--otl-ui-rgb), 0.33);
  outline-offset: 2px;
}

/* Event checks inherit their category color. */
#eventsPanel .event-category input[type="checkbox"] {
  --otl-ui-rgb: var(--category-rgb);
}

/* Yellow Light uses a true switch because it controls an entire feature layer. */
.toggle-wrap input[type="checkbox"],
.yellow-enable-label input[type="checkbox"],
.otl-fx-master input[type="checkbox"] {
  --switch-rgb: 96, 165, 250;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 7px 50%, #94a3b8 0 5px, transparent 5.5px),
    rgba(15, 23, 42, 0.92);
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, 0.42),
    0 1px 0 rgba(255, 255, 255, 0.035);
}

.toggle-wrap input[type="checkbox"]::before,
.yellow-enable-label input[type="checkbox"]::before,
.otl-fx-master input[type="checkbox"]::before {
  display: none;
}

.toggle-wrap input[type="checkbox"]:checked,
.yellow-enable-label input[type="checkbox"]:checked,
.otl-fx-master input[type="checkbox"]:checked {
  border-color: rgba(var(--switch-rgb), 0.64);
  background:
    radial-gradient(circle at calc(100% - 7px) 50%, #fff 0 5px, transparent 5.5px),
    rgba(var(--switch-rgb), 0.54);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.20),
    0 0 15px rgba(var(--switch-rgb), 0.11);
}

.yellow-enable-label input[type="checkbox"] {
  --switch-rgb: 245, 158, 11;
}

.otl-fx-master input[type="checkbox"] {
  --switch-rgb: 217, 70, 239;
}

.inline-setting,
.toggle-wrap,
.yellow-enable-label,
.otl-fx-master {
  user-select: none;
}

/* --------------------------------------------------------------------------
   Sliders
   -------------------------------------------------------------------------- */

input[type="range"] {
  --otl-range-rgb: 96, 165, 250;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--otl-range-rgb), 0.34), rgba(51, 65, 85, 0.82));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  margin-top: -7px;
  border: 2px solid rgba(var(--otl-range-rgb), 0.86);
  border-radius: 50%;
  background: #f8fafc;
  box-shadow:
    0 2px 7px rgba(0, 0, 0, 0.36),
    0 0 12px rgba(var(--otl-range-rgb), 0.13);
}

input[type="range"]::-moz-range-track {
  height: 5px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(var(--otl-range-rgb), 0.34), rgba(51, 65, 85, 0.82));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(var(--otl-range-rgb), 0.86);
  border-radius: 50%;
  background: #f8fafc;
  box-shadow:
    0 2px 7px rgba(0, 0, 0, 0.36),
    0 0 12px rgba(var(--otl-range-rgb), 0.13);
}

input[type="range"]:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.yellow-premium-feature input[type="range"] { --otl-range-rgb: 245, 158, 11; }
.trainer-card input[type="range"] { --otl-range-rgb: 56, 189, 248; }
.visual-effects-setting input[type="range"] { --otl-range-rgb: 167, 139, 250; }
.game-settings-subgroup[data-settings-group="audio"] input[type="range"] { --otl-range-rgb: 45, 212, 191; }

/* --------------------------------------------------------------------------
   Badges and state chips
   -------------------------------------------------------------------------- */

.premium-badge,
.premium-lock,
.premium-status,
.trainer-tier-badge,
.event-category-count,
.otl-training-count,
.otl-account-launcher-state,
.otl-account-verification,
.otl-premium-state,
.otl-patreon-state {
  min-height: 23px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 4px 12px rgba(0, 0, 0, 0.09);
}

.premium-badge,
.premium-lock,
.trainer-tier-badge,
.otl-account-verification {
  letter-spacing: 0.085em;
}

/* --------------------------------------------------------------------------
   Settings opening motion
   -------------------------------------------------------------------------- */

.settings-card[open] > .settings-content {
  transform-origin: top center;
  animation: otl-settings-reveal 190ms ease-out both;
}

@keyframes otl-settings-reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-summary-action {
  transition:
    color 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.settings-card[open] .settings-summary-action {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 5px 16px rgba(0, 0, 0, 0.14);
}

/* --------------------------------------------------------------------------
   Session controls and status/help area
   -------------------------------------------------------------------------- */

.controls-card {
  position: relative;
  overflow: hidden;
}

.controls-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(var(--otl-session-rgb, 96,165,250), 0.78), transparent);
  opacity: 0.46;
  transition: opacity 260ms ease, background 260ms ease;
}

body.otl-session-active .controls-card::before {
  opacity: 0.92;
}

.controls-card .controls > button {
  min-height: 43px;
  padding-inline: 15px;
  border-radius: 11px;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    0 6px 16px rgba(0, 0, 0, 0.14);
}

.controls-card .controls > button:disabled {
  box-shadow: none;
}

.status-wrap {
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(100, 116, 139, 0.18);
}

.status {
  --status-rgb: var(--otl-session-rgb, 100, 116, 139);
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  min-height: 36px;
  padding: 8px 11px;
  border: 1px solid rgba(var(--status-rgb), 0.22);
  border-radius: 10px;
  color: #cbd5e1;
  background: rgba(2, 6, 23, 0.34);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  font-size: 0.84rem;
}

.status::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(var(--status-rgb));
  box-shadow: 0 0 10px rgba(var(--status-rgb), 0.42);
}

.status.good { --status-rgb: 34, 197, 94; color: #bbf7d0; }
.status.warn { --status-rgb: 245, 158, 11; color: #fde68a; }
.status.bad { --status-rgb: 248, 113, 113; color: #fecaca; }

.status-wrap .help,
.status-wrap .shortcut-help {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(100, 116, 139, 0.14);
  border-radius: 9px;
  color: #64748b;
  background: rgba(2, 6, 23, 0.16);
  line-height: 1.48;
}

.status-wrap .help {
  font-size: 0.78rem;
}

.status-wrap .shortcut-help {
  width: fit-content;
  color: #718096;
  font-size: 0.72rem;
  letter-spacing: 0.01em;
}

/* --------------------------------------------------------------------------
   Empty states and previews
   -------------------------------------------------------------------------- */

.otl-media-preview-empty {
  gap: 10px;
  background:
    radial-gradient(circle at 50% 10%, rgba(var(--otl-preview-accent), 0.055), transparent 58%),
    rgba(2, 6, 23, 0.18);
}

.otl-media-preview-empty::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 24px;
  border-radius: 50%;
  background: rgba(var(--otl-preview-accent), 0.72);
  box-shadow:
    12px 0 0 rgba(var(--otl-preview-accent), 0.42),
    24px 0 0 rgba(var(--otl-preview-accent), 0.20),
    0 0 12px rgba(var(--otl-preview-accent), 0.16);
}

.otl-media-preview-heading span:first-child {
  color: #cbd5e1;
  letter-spacing: 0.04em;
}

.otl-media-preview-count {
  padding: 3px 7px;
  border: 1px solid rgba(var(--otl-preview-accent), 0.16);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.26);
}

.otl-media-preview-tile {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.035),
    0 5px 14px rgba(0, 0, 0, 0.13);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

@media (hover: hover) {
  .otl-media-preview-tile:hover {
    transform: translateY(-1px);
    border-color: rgba(var(--otl-preview-accent), 0.42);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.045),
      0 8px 20px rgba(0, 0, 0, 0.20);
  }
}

/* --------------------------------------------------------------------------
   Mobile and narrow-layout refinement
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  body:not(.theater-mode) {
    padding: 18px;
  }

  .app {
    gap: 16px;
  }

  .card {
    border-radius: 18px;
  }

  .settings-summary {
    min-height: 66px;
    padding: 14px 16px;
  }

  .settings-content {
    padding: 16px;
  }
}

@media (max-width: 680px) {
  body:not(.theater-mode) {
    padding: 12px;
  }

  .app {
    gap: 12px;
  }

  .card {
    border-radius: 16px;
  }

  .controls-card .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .controls-card .controls > button {
    width: 100%;
    min-width: 0;
    padding-inline: 10px;
  }

  .controls-card #startBtn,
  .controls-card .toggle-wrap {
    grid-column: 1 / -1;
  }

  .controls-card .toggle-wrap {
    justify-content: space-between;
    min-height: 43px;
    margin: 0;
    border-radius: 11px;
  }

  .status {
    width: 100%;
  }

  .status-wrap .shortcut-help {
    width: 100%;
  }

  .settings-summary-copy small {
    font-size: 0.79rem;
    line-height: 1.35;
  }

  .settings-summary-action {
    padding: 7px 9px;
    font-size: 0.76rem;
  }

  .otl-media-preview-heading {
    align-items: flex-start;
  }
}

@media (max-width: 460px) {
  .settings-summary {
    align-items: flex-start;
  }

  .settings-summary-action {
    flex: 0 0 auto;
  }

  .controls-card .controls {
    grid-template-columns: 1fr;
  }

  .controls-card #startBtn,
  .controls-card .toggle-wrap {
    grid-column: auto;
  }

  .probability-row,
  .event-range-row {
    align-items: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-card[open] > .settings-content {
    animation: none !important;
  }

  input[type="checkbox"],
  input[type="range"],
  .otl-media-preview-tile {
    transition: none !important;
  }
}
