/* -------- Buttons --------------------------------------------------- */
button {
  font: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
button:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
  box-shadow: 0 1px 0 rgba(180, 90, 59, 0.18) inset, var(--shadow-xs);
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.primary-ghost {
  background: var(--bg-panel);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}
button.primary-ghost:hover:not(:disabled) { background: var(--accent-tint); }

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
button.ghost:hover:not(:disabled) { background: var(--bg-subtle); border-color: var(--border-strong); }
/*
 * Transient success state for ghost buttons. Used by the Media
 * Providers "Reload from daemon" button after a successful reload —
 * the button briefly turns green with a check icon for ~2s then snaps
 * back to its idle treatment, replacing what used to be a permanent
 * success paragraph under the section header. Reusable on any
 * ghost button that wants the same "did it" pulse.
 */
button.ghost.is-success-flash {
  border-color: var(--green-border, color-mix(in srgb, #1f9d55 32%, var(--border)));
  background: var(--green-bg, color-mix(in srgb, #1f9d55 8%, transparent));
  color: var(--green, #137a3d);
}
button.ghost.is-success-flash:hover:not(:disabled) {
  background: var(--green-bg, color-mix(in srgb, #1f9d55 14%, transparent));
}
button.ghost.is-success-flash svg {
  color: currentColor;
}

/*
 * Visually-hidden but assistive-tech accessible. We use it to keep
 * a `role="status"` live-region for actions whose visible feedback
 * is too transient (e.g. a 2s button-label flash) for a screen
 * reader to catch reliably. Borrowed from Tailwind's `sr-only` so
 * it reads as the same primitive everyone already knows.
 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button.subtle {
  background: var(--bg-subtle);
  border-color: transparent;
  color: var(--text);
}
button.subtle:hover:not(:disabled) { background: var(--bg-muted); }

button.icon-btn { padding: 6px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* -------- Inputs ---------------------------------------------------- */
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  width: 100%;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--selected);
  box-shadow: 0 0 0 3px var(--selected-soft);
}
/* Entry sidebar form fields keep a quieter, neutral focus so the orange
   "Create" CTA stays the loudest thing in the panel. A low-opacity black
   halo reads as "focused" without re-introducing the global blue/accent
   ring. Using rgba directly because the Next CSS pipeline collapses
   `color-mix(in srgb, var(--text) 8%, transparent)` to a solid var(--text)
   ring (would render a 3px black band — too loud). */
.entry-side input:focus,
.entry-side textarea:focus,
.entry-side select:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(28, 27, 26, 0.08);
}
/* Native <select> on macOS uses its own intrinsic min-height that ends up
   shorter than <input> at the same `padding: 7px 10px` rule above, so any
   form that flex-aligns an input next to a select (e.g. the memory editor's
   Title + Type row) renders with mismatched heights. Stripping the native
   chrome lets the shared padding and inherited line-height compute the
   same box dimensions as the input, then we paint our own chevron via a
   background SVG. The chevron color is a per-theme override so it stays
   readable against the panel in both light and dark. */
select {
  padding-right: 32px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%2374716b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 6 8 9 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
select::-ms-expand { display: none; }
[data-theme='dark'] select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%239a9690' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 6 8 9 5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 12px;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%239a9690' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='3 5 6 8 9 5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px 12px;
  }
}
textarea { resize: vertical; font-family: inherit; }

.od-select {
  position: relative;
  width: 100%;
  min-width: 0;
}
.od-select-trigger {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font: inherit;
  color: var(--text);
  text-align: left;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.od-select-trigger:hover:not(:disabled),
.od-select-trigger[aria-expanded='true'] {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}
.od-select-trigger:focus-visible,
.od-select-trigger[aria-expanded='true'] {
  outline: none;
  border-color: var(--selected);
  box-shadow: 0 0 0 3px var(--selected-soft);
}
.od-select-trigger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.od-select-trigger svg {
  color: var(--text-muted);
  transition: transform 120ms ease;
}
.od-select-trigger[aria-expanded='true'] svg {
  transform: rotate(180deg);
}
.od-select-value,
.od-select-option-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.od-select-menu {
  z-index: 9000;
  padding: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  max-width: calc(100vw - 24px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
}
.od-select-menu.portal {
  position: fixed;
}
.od-select-menu.inline {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: min(280px, 48vh);
}
.od-select-option {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
}
.od-select-option:hover:not(:disabled),
.od-select-option.active:not(:disabled) {
  background: var(--bg-subtle);
}
.od-select-option.selected {
  color: var(--text);
  background: color-mix(in srgb, var(--selected) 9%, var(--bg-subtle));
  font-weight: 600;
}
.od-select-option.selected:hover:not(:disabled),
.od-select-option.selected.active:not(:disabled) {
  background: color-mix(in srgb, var(--selected) 13%, var(--bg-subtle));
}
.od-select-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.od-select-option-check {
  display: inline-flex;
  justify-content: center;
  color: var(--selected);
  opacity: 0;
}
.od-select-option.selected .od-select-option-check {
  opacity: 1;
}
.od-select-group + .od-select-group {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-soft);
}
.od-select-group-label {
  padding: 6px 8px 4px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
}
