/* Shared components. Every class starts with od-. Colors, radii and fonts come
   only from the tokens in ui/theme.css. Every one is shown on .dev/ui-kit.php. */

/* ---- Icons ---------------------------------------------------------------- */

.od-icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.od-icon--sm { width: 14px; height: 14px; stroke-width: 2.2; }
.od-icon--lg { width: 22px; height: 22px; }
.od-icon--fill { fill: currentColor; }
.od-icon--accent { color: var(--color-accent-text); }

/* ---- Wordmark ------------------------------------------------------------- */

.od-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}

.od-wordmark b {
  font-weight: inherit;
  color: var(--color-accent-text);
}

/* ---- Buttons -------------------------------------------------------------- */

.od-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-raised);
  color: var(--color-text);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--speed), border-color var(--speed), color var(--speed);
}

.od-btn:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-btn:disabled,
.od-btn[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

/* The one action that matters on a screen: Publish, Save & Use, Download */
.od-btn--accent {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent);
}

.od-btn--accent:hover {
  background: color-mix(in srgb, var(--color-accent) 88%, var(--color-text));
  border-color: transparent;
  color: var(--color-on-accent);
}

/* On a panel, next to fields */
.od-btn--panel {
  background: var(--color-panel);
}

/* No box until hovered: toolbars, menus, part list */
.od-btn--quiet {
  background: transparent;
  border-color: transparent;
  font-weight: 500;
}

.od-btn--danger {
  background: var(--color-bad);
  border-color: var(--color-bad);
  color: var(--color-on-accent);
}

.od-btn--danger:hover {
  background: color-mix(in srgb, var(--color-bad) 85%, var(--color-text));
  color: var(--color-on-accent);
}

/* Text-colored link that looks like a button: "Open a saved design" */
.od-btn--link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent-text);
  font-weight: 500;
}

.od-btn--link:hover {
  background: none;
  color: var(--color-text);
  text-decoration: underline;
}

.od-btn--sm {
  height: 32px;
  padding: 0 12px;
}

.od-btn--lg {
  height: 40px;
  padding: 0 18px;
  font-size: var(--text-lg);
}

.od-btn--block {
  display: flex;
  width: 100%;
}

/* Square, icon only. Always give it an aria-label */
.od-btn--icon {
  width: var(--control-h);
  padding: 0;
}

.od-btn--icon.od-btn--sm {
  width: 32px;
}

/* ---- Fields --------------------------------------------------------------- */

.od-label {
  color: var(--color-muted);
}

.od-label--strong {
  color: var(--color-text);
  font-weight: 600;
}

.od-input,
.od-select,
.od-textarea {
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 10px;
  background: var(--color-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: border-color var(--speed);
}

.od-input::placeholder,
.od-textarea::placeholder {
  color: var(--color-faint);
}

.od-input:hover,
.od-select:hover,
.od-textarea:hover {
  border-color: color-mix(in srgb, var(--color-line) 60%, var(--color-muted));
}

.od-input:focus-visible,
.od-select:focus-visible,
.od-textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: -1px;
  border-color: transparent;
}

.od-input[readonly] {
  color: var(--color-muted);
}

.od-input:disabled,
.od-select:disabled,
.od-textarea:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.od-input[aria-invalid="true"] {
  border-color: var(--color-bad);
}

/* On a panel that is already raised: dialogs and menus */
.od-input--panel,
.od-select--panel {
  background: var(--color-panel);
}

/* The compact size used in inspector rows */
.od-input--sm,
.od-select--sm {
  height: 30px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
}

.od-select {
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-muted) 50%), linear-gradient(135deg, var(--color-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Dropdown (ui.js): a button with the select's own look, and its list */
.od-dropdown {
  display: flex;
  align-items: center;
  text-align: left;
}

.od-dropdown__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.od-dropdown[aria-expanded="true"] {
  border-color: var(--color-accent);
}

/* Fixed to the viewport and placed by ui.js; in the top layer when the
   browser has popovers, so dialogs and scrolling panels don't cut it off */
.od-dropdown__list {
  position: fixed;
  inset: auto;
  z-index: 1000;
  margin: 0;
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  padding: 6px;
  background: var(--color-panel);
  color: var(--color-text);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.od-dropdown__list[hidden] {
  display: none;
}

.od-dropdown__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 32px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.od-dropdown__option.is-active {
  background: var(--color-hover);
}

.od-dropdown__option[aria-selected="true"] {
  font-weight: 600;
}

.od-dropdown__option[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
}

.od-dropdown__check {
  flex: none;
  color: var(--color-accent-text);
  visibility: hidden;
}

.od-dropdown__option[aria-selected="true"] .od-dropdown__check {
  visibility: visible;
}

.od-textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.45;
}

/* Generated code, file paths */
.od-textarea--code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* A number, hex or other value: mono, right aligned, sized to its content */
.od-num {
  width: 44px;
  height: var(--control-h-sm);
  padding: 0 4px;
  background: var(--color-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

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

.od-num--wide {
  width: 100%;
  text-align: left;
  padding: 0 6px;
}

.od-hex {
  text-transform: uppercase;
}

.od-unit {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  color: var(--color-faint);
}

/* A group of fields, such as a star rating */
.od-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.od-fieldset > legend {
  float: none;
  width: auto;
  padding: 0;
  margin-bottom: 6px;
  font-size: inherit;
  line-height: inherit;
}

/* <input type="file" class="od-file">: the native picker with a themed button */
.od-file {
  width: 100%;
  min-width: 0;
  color: var(--color-muted);
  font-size: var(--text-md);
}

.od-file::file-selector-button {
  height: var(--control-h);
  margin-right: var(--space-3);
  padding: 0 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background: var(--color-raised);
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.od-file::file-selector-button:hover {
  background: var(--color-hover);
}

/* A stacked label, field and help text */
.od-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.od-help {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.od-error {
  font-size: var(--text-sm);
  color: var(--color-bad);
}

/* A field with a button stuck to its end: Audio Link + Record, Image + Library */
.od-input-group {
  display: flex;
  min-width: 0;
}

.od-input-group > .od-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.od-input-group > .od-btn {
  flex: none;
  height: auto;
  border-left: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ---- Switch: <input type="checkbox" role="switch" class="od-switch"> ------ */

.od-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: var(--radius-full);
  background: var(--color-line);
  cursor: pointer;
  transition: background-color var(--speed);
}

.od-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--color-muted);
  transition: transform var(--speed), background-color var(--speed);
}

.od-switch:checked {
  background: var(--color-accent);
}

.od-switch:checked::before {
  transform: translateX(14px);
  background: var(--color-on-accent);
}

.od-switch:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* A switch with its label: the whole row is the tap target */
.od-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 32px;
  color: var(--color-muted);
  cursor: pointer;
}

/* ---- Checkbox and radio --------------------------------------------------- */

.od-check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  cursor: pointer;
}

.od-check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--color-accent);
}

/* ---- Slider: <input type="range" class="od-range"> ------------------------ */
/* ui.js keeps --p (the filled part) in step with the value */

.od-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.od-range::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-accent) var(--p, 0%), var(--color-line) var(--p, 0%));
}

.od-range::-moz-range-track {
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-line);
}

.od-range::-moz-range-progress {
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
}

.od-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: var(--radius-full);
  background: var(--color-text);
  border: 2px solid var(--color-panel);
}

.od-range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--color-text);
  border: 2px solid var(--color-panel);
}

.od-range:focus-visible {
  outline: none;
}

.od-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--color-accent);
}

.od-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 3px var(--color-accent);
}

/* ---- Segmented buttons ---------------------------------------------------- */
/* <div class="od-seg" role="group"><button aria-pressed="true">Icon</button>... */

.od-seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--color-raised);
  border-radius: var(--radius-md);
}

.od-seg > button {
  flex: 1 1 0;
  min-width: 0;
  height: 30px;
  padding: 0 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.od-seg > button:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-seg > button[aria-pressed="true"] {
  background: var(--color-text);
  color: var(--color-panel);
}

/* ---- Color: swatch, hex and opacity in one row ---------------------------- */

.od-swatch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  padding: 0;
  border: 1px solid var(--color-swatch-line);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  overflow: hidden;
}

.od-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.od-swatch::-webkit-color-swatch { border: 0; border-radius: inherit; }
.od-swatch::-moz-color-swatch { border: 0; border-radius: inherit; }

.od-swatch--round {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
}

/* ---- Inspector rows ------------------------------------------------------- */
/* Label column 82px, then the control. One class per kind of row. */

.od-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.od-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
}

.od-row > .od-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Label, slider, number, unit */
.od-row--slider {
  grid-template-columns: 82px minmax(0, 1fr) 44px 14px;
}

/* Label, swatch, hex, opacity */
.od-row--color {
  grid-template-columns: 82px var(--control-h-sm) minmax(0, 1fr) auto;
}

.od-row__opacity {
  display: flex;
  align-items: center;
  gap: 4px;
}

.od-row__opacity .od-unit {
  width: 14px;
}

/* Label above, control full width: segmented buttons, text areas */
.od-row--stack {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

/* Small uppercase heading between groups of rows */
.od-section-label {
  padding-top: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-faint);
}

.od-rows > .od-section-label:first-child {
  padding-top: 0;
}

/* A part that is switched off: "Not on the player right now" */
.od-callout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-raised);
  border-radius: var(--radius-md);
  color: var(--color-muted);
}

/* ---- Gradient editor ------------------------------------------------------ */
/* The bar's background and the stops' colors are the user's colors (data) */

.od-gradbar {
  position: relative;
  height: 26px;
  margin: 0 10px;
  border-radius: var(--radius-sm);
  cursor: copy;
}

.od-gradbar__stop {
  position: absolute;
  top: 3px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-panel);
  box-shadow: 0 0 0 1px var(--color-text);
  cursor: grab;
}

.od-gradbar__stop[aria-selected="true"],
.od-gradbar__stop:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-text);
}

/* Eight directions as a 3 x 3 grid of arrows; the middle cell is empty */
.od-dir-grid {
  display: grid;
  grid-template-columns: repeat(3, 30px);
  grid-template-rows: repeat(3, 30px);
  gap: 2px;
  padding: 2px;
  background: var(--color-raised);
  border-radius: var(--radius-md);
  width: max-content;
}

.od-dir-grid > button {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
}

.od-dir-grid > button:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-dir-grid > button[aria-pressed="true"] {
  background: var(--color-text);
  color: var(--color-panel);
}

.od-dir-grid .od-icon {
  width: 15px;
  height: 15px;
  transform: rotate(var(--angle, 0deg));
}

/* ---- Position pad: drag the point; the two boxes beside it ---------------- */

/* The label above, then the pad with the two boxes to its right */
.od-pad-group {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  column-gap: var(--space-3);
  row-gap: var(--space-2);
  align-items: center;
}

.od-pad-group > .od-label {
  grid-column: 1 / -1;
}

.od-pad {
  position: relative;
  grid-row: 2 / span 2;
  width: 92px;
  height: 92px;
  /* Lines through the middle, over the raised fill */
  background:
    linear-gradient(var(--color-line), var(--color-line)) center / 1px 100% no-repeat,
    linear-gradient(var(--color-line), var(--color-line)) center / 100% 1px no-repeat,
    var(--color-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  cursor: crosshair;
  touch-action: none;
}

.od-pad:hover,
.od-pad.is-dragging {
  border-color: var(--color-accent);
}

.od-pad__dot {
  position: absolute;
  left: var(--pad-x, 50%);
  top: var(--pad-y, 50%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  background: var(--color-accent);
  border: 2px solid var(--color-panel);
  border-radius: var(--radius-full);
  pointer-events: none;
}

/* Each axis: its label, box and unit */
.od-pad-group > .od-row {
  grid-column: 2;
  grid-template-columns: 76px 52px 14px;
  justify-content: start;
}

/* ---- Cards ---------------------------------------------------------------- */

.od-card {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.od-card--raised {
  background: var(--color-raised);
}

/* A choice drawn as a card: Publish's Website / Video / Settings file */
.od-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 14px;
  background: var(--color-panel);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-lg);
  text-align: left;
  color: var(--color-text);
}

.od-choice:hover {
  background: var(--color-hover);
}

.od-choice[aria-selected="true"],
.od-choice[aria-pressed="true"] {
  border-color: var(--color-accent);
}

.od-choice__title {
  font-weight: 600;
}

.od-choice__help {
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* ---- Tabs ----------------------------------------------------------------- */
/* <div class="od-tabs" role="tablist"><button role="tab" aria-selected aria-controls>... */

.od-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  width: max-content;
  max-width: 100%;
}

.od-tabs > [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-weight: 500;
  white-space: nowrap;
}

.od-tabs > [role="tab"]:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-tabs > [role="tab"][aria-selected="true"] {
  background: var(--color-text);
  color: var(--color-panel);
}

.od-tab-count {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  opacity: .75;
}

/* ---- Chips: filters ------------------------------------------------------- */

.od-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.od-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.od-chip:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-chip[aria-pressed="true"],
.od-chip[aria-current="page"],
.od-chip[aria-current="true"] {
  background: var(--color-text);
  color: var(--color-panel);
}

/* ---- Badges and status ---------------------------------------------------- */

.od-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--color-raised);
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}

.od-badge--good {
  background: color-mix(in srgb, var(--color-good) 14%, transparent);
  color: var(--color-good);
}

.od-badge--bad {
  background: color-mix(in srgb, var(--color-bad) 14%, transparent);
  color: var(--color-bad);
}

.od-badge--accent {
  background: color-mix(in srgb, var(--color-accent) 16%, transparent);
  color: var(--color-accent-text);
}

/* Saved / Unsaved changes in the top bar */
.od-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
  white-space: nowrap;
}

.od-status--good {
  color: var(--color-good);
}

.od-status--bad {
  color: var(--color-bad);
}

/* Video export progress next to Publish. Set --value (0 to 100) for the bar */
.od-progress-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 12px;
  overflow: hidden;
  background: var(--color-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.od-progress-chip::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: calc(var(--value, 0) * 1%);
  background: var(--color-accent);
  transition: width var(--speed);
}

.od-progress-chip:hover {
  background: var(--color-hover);
  color: var(--color-text);
}

.od-progress-chip--good {
  border-color: var(--color-good);
  --value: 100;
}

.od-progress-chip--good::after {
  background: var(--color-good);
}

.od-progress-chip--bad {
  border-color: var(--color-bad);
  color: var(--color-bad);
  --value: 100;
}

.od-progress-chip--bad::after {
  background: var(--color-bad);
}

/* ---- Progress bar: <progress class="od-progress" max="100" value="42"> ---- */

.od-progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--color-line);
  overflow: hidden;
  color: var(--color-accent);
}

.od-progress::-webkit-progress-bar {
  background: var(--color-line);
  border-radius: var(--radius-full);
}

.od-progress::-webkit-progress-value {
  background: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width var(--speed);
}

.od-progress::-moz-progress-bar {
  background: var(--color-accent);
  border-radius: var(--radius-full);
}

/* Audio input level while recording */
.od-meter {
  height: 8px;
}

/* ---- Spinner and busy screen ---------------------------------------------- */

.od-spinner {
  display: inline-block;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-line);
  border-top-color: var(--color-accent);
  animation: od-spin .8s linear infinite;
}

.od-spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

@keyframes od-spin {
  to { transform: rotate(360deg); }
}

/* Covers the page while a saved design or settings file is applied */
.od-busy {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: color-mix(in srgb, var(--color-panel) 92%, transparent);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
}

/* The same, inside a box rather than over the page (the kit shows it this way) */
.od-busy--inline {
  position: relative;
  inset: auto;
  z-index: auto;
  height: 120px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
}

/* ---- Dialog: <dialog class="od-dialog"> ----------------------------------- */

.od-dialog {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-xl);
  background: var(--color-panel);
  color: var(--color-text);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.od-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: od-pop var(--speed) ease-out;
}

.od-dialog::backdrop {
  background: var(--color-scrim);
}

.od-dialog--wide {
  width: min(760px, calc(100vw - 32px));
}

.od-dialog--full {
  width: min(1100px, calc(100vw - 32px));
}

.od-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 18px 18px 0 20px;
}

.od-dialog__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.od-dialog__sub {
  margin-top: 3px;
  color: var(--color-muted);
}

.od-dialog__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4) 20px 20px;
  overflow-y: auto;
}

.od-dialog__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 14px 20px;
  border-top: 1px solid var(--color-line);
  background: var(--color-panel);
}

/* Slides in from the right: the admin's feedback drawer */
.od-dialog--drawer {
  /* Pinned to the right edge; the browser's own dialog max-width would push it off screen */
  inset: 0 0 0 auto;
  width: min(480px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: none;
  margin: 0;
  border-width: 0 0 0 1px;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

.od-dialog--drawer[open] {
  animation: od-slide var(--speed) ease-out;
}

@keyframes od-pop {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
}

@keyframes od-slide {
  from { transform: translateX(40px); opacity: 0; }
}

/* ---- Menu ----------------------------------------------------------------- */
/* <div class="od-menu-wrap"><button data-od-menu="id">...</button><div class="od-menu" id="id" hidden>... */

.od-menu-wrap {
  position: relative;
}

.od-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--color-raised);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.od-menu--end {
  left: auto;
  right: 0;
}

/* A menu that holds a small form: the save menu */
.od-menu--panel {
  width: 340px;
  max-width: calc(100vw - 24px);
  gap: var(--space-3);
  padding: var(--space-4);
}

.od-menu__head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--color-line);
}

.od-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--control-h);
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.od-menu__item:hover,
.od-menu__item:focus-visible {
  background: var(--color-hover);
  color: var(--color-text);
  outline: none;
}

.od-menu__item .od-icon {
  color: var(--color-muted);
}

.od-menu__sep {
  height: 1px;
  margin: 4px 0;
  background: var(--color-line);
}

/* Theme: Light, Dark, Auto (partials/theme-choice.php) */
.od-theme-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 6px 10px;
}

.od-theme-choice > .od-seg > button {
  flex: 1 0 auto;
  padding: 0 10px;
}

/* ---- Toast ---------------------------------------------------------------- */

.od-toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  transform: translateX(-50%);
  pointer-events: none;
}

.od-toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: var(--color-panel);
  font-weight: 600;
  box-shadow: var(--shadow-pop);
  animation: od-pop var(--speed) ease-out;
}

.od-toast--bad {
  background: var(--color-bad);
  color: var(--color-on-accent);
}

.od-toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--speed), transform var(--speed);
}

/* ---- Inline confirm: "Delete this file?" in place of a browser alert ------- */

.od-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--control-h);
}

.od-confirm__text {
  color: var(--color-bad);
  font-weight: 500;
}

.od-confirm__actions {
  display: flex;
  gap: 6px;
}

/* ---- Messages on a page: login errors, "Check your email" ----------------- */

.od-message {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-raised);
  border: 1px solid var(--color-line);
}

.od-message .od-icon {
  margin-top: 1px;
}

.od-message--good {
  background: color-mix(in srgb, var(--color-good) 10%, var(--color-panel));
  border-color: color-mix(in srgb, var(--color-good) 35%, transparent);
  color: var(--color-good);
}

.od-message--bad {
  background: color-mix(in srgb, var(--color-bad) 10%, var(--color-panel));
  border-color: color-mix(in srgb, var(--color-bad) 35%, transparent);
  color: var(--color-bad);
}

/* ---- Table ---------------------------------------------------------------- */
/* Wrap it in .od-table-scroll so it scrolls sideways in a box on narrow screens */

.od-table-scroll {
  position: relative; /* keeps visually hidden headers inside the scroll box */
  overflow-x: auto;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
}

.od-table {
  width: 100%;
  border-collapse: collapse;
}

.od-table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-line);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  color: var(--color-muted);
  white-space: nowrap;
}

.od-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-line);
  vertical-align: middle;
}

.od-table tr:last-child td {
  border-bottom: 0;
}

.od-table tbody tr:hover {
  background: color-mix(in srgb, var(--color-hover) 50%, transparent);
}

.od-table__num {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* ---- Stat tile ------------------------------------------------------------ */

.od-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-4);
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
}

.od-stat__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.1;
}

.od-stat__label {
  color: var(--color-muted);
}

/* ---- Avatar --------------------------------------------------------------- */

.od-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--color-raised);
  border: 1px solid var(--color-line);
  color: var(--color-text);
  font-weight: 600;
  text-transform: uppercase;
}

button.od-avatar:hover {
  background: var(--color-hover);
}

/* ---- Star rating: radio inputs in reverse order, as trial_ended.php has --- */

.od-stars {
  display: inline-flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  gap: 2px;
}

.od-stars input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.od-stars label {
  display: grid;
  place-items: center;
  width: var(--touch-min);
  height: var(--touch-min);
  border-radius: var(--radius-md);
  color: var(--color-muted);
  cursor: pointer;
}

/* Outlined until chosen, then filled */
.od-stars .od-icon {
  width: 28px;
  height: 28px;
  fill: transparent;
  stroke-width: 1.6;
}

.od-stars label:hover,
.od-stars label:hover ~ label,
.od-stars input:checked ~ label {
  color: var(--color-accent);
}

.od-stars label:hover .od-icon,
.od-stars label:hover ~ label .od-icon,
.od-stars input:checked ~ label .od-icon {
  fill: currentColor;
}

.od-stars input:focus-visible + label {
  outline: 2px solid var(--color-accent);
}

/* ---- Small helpers -------------------------------------------------------- */

.od-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.od-divider {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--color-line);
}

.od-vr {
  width: 1px;
  height: 22px;
  flex: none;
  background: var(--color-line);
}

/* Phones: every tap target at least 44px */
@media (max-width: 1020px) {
  :root {
    --control-h-sm: 40px;
  }

  .od-range {
    height: var(--touch-min);
  }

  .od-dropdown__option {
    min-height: var(--touch-min);
  }

  .od-num {
    width: 52px;
  }

  .od-row--slider {
    grid-template-columns: 82px minmax(0, 1fr) 52px 14px;
  }

  .od-avatar {
    width: var(--touch-min);
    height: var(--touch-min);
  }

  .od-btn,
  .od-chip,
  .od-progress-chip,
  .od-tabs > [role="tab"],
  .od-menu__item,
  .od-input,
  .od-select {
    min-height: var(--touch-min);
  }

  .od-btn--icon {
    min-width: var(--touch-min);
  }

  .od-switch-row,
  .od-row {
    min-height: var(--touch-min);
  }

  .od-check {
    align-items: center;
    min-height: var(--touch-min);
  }

  .od-check input {
    margin-top: 0;
  }

  .od-seg > button,
  .od-dir-grid > button {
    min-height: 40px;
  }

  .od-dir-grid {
    grid-template-columns: repeat(3, var(--touch-min));
    grid-template-rows: repeat(3, var(--touch-min));
  }

  .od-dialog:not(.od-dialog--drawer) {
    max-height: calc(100vh - 24px);
  }
}
