/* Lightweight app UI primitives (editor + viz) — replaces @astryxdesign. */
.ui-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    opacity 140ms ease;
}

.ui-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ui-btn--sm {
  min-height: 2rem;
  padding: 0.35rem 0.7rem;
}

.ui-btn--md {
  min-height: 2.25rem;
  padding: 0.45rem 0.85rem;
}

.ui-btn--icon {
  width: 2rem;
  padding-inline: 0;
}

.ui-btn--primary {
  color: #fff;
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
}

.ui-btn--primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.ui-btn--secondary {
  color: var(--foreground, #111827);
  background: var(--card, #fff);
  border-color: var(--border, #e5e7eb);
}

.ui-btn--secondary:hover:not(:disabled) {
  background: var(--muted, #f3f4f6);
}

.ui-btn--ghost {
  color: var(--foreground, #111827);
  background: transparent;
}

.ui-btn--ghost:hover:not(:disabled) {
  background: var(--muted, #f3f4f6);
}

.ui-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.5rem;
  background: var(--card, #fff);
  color: var(--foreground, #111827);
}

.ui-input-wrap:focus-within {
  border-color: var(--primary, #2563eb);
  box-shadow: 0 0 0 3px
    color-mix(in oklab, var(--primary, #2563eb) 20%, transparent);
}

.ui-input {
  appearance: none;
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: inherit;
  outline: none;
}

.ui-input::placeholder {
  color: var(--muted-foreground, #6b7280);
}

.ui-input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.ui-select {
  appearance: none;
  min-height: 2rem;
  padding: 0.25rem 1.6rem 0.25rem 0.5rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.45rem;
  background: var(--card, #fff)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5 10 12.5 15 7.5' stroke='%236b7280' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    no-repeat right 0.45rem center;
  font: inherit;
  font-size: 0.75rem;
  color: var(--foreground, #111827);
}

.ui-slider {
  width: 100%;
  accent-color: var(--primary, #2563eb);
}

.ui-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 650;
  background: var(--muted, #f3f4f6);
  color: var(--muted-foreground, #6b7280);
}

.ui-badge--blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.ui-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.55rem;
  background: var(--muted, #f3f4f6);
}

.ui-segmented__item {
  appearance: none;
  border: 0;
  border-radius: 0.4rem;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted-foreground, #6b7280);
  background: transparent;
  cursor: pointer;
}

.ui-segmented__item.is-active {
  color: var(--foreground, #111827);
  background: var(--card, #fff);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.ui-dropdown {
  position: relative;
  display: inline-flex;
}

.ui-dropdown__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.35rem);
  z-index: 40;
  min-width: 7rem;
  padding: 0.3rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.55rem;
  background: var(--card, #fff);
  box-shadow: 0 10px 24px -12px rgb(0 0 0 / 0.35);
}

.ui-dropdown__item {
  appearance: none;
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0.4rem;
  padding: 0.4rem 0.55rem;
  text-align: start;
  font: inherit;
  font-size: 0.78rem;
  background: transparent;
  color: var(--foreground, #111827);
  cursor: pointer;
}

.ui-dropdown__item:hover {
  background: var(--muted, #f3f4f6);
}

/* Base UI Menu (headless kernel) — positioning is owned by Menu.Positioner,
   so the static absolute placement of .ui-dropdown__menu is reset here. */
.ui-dropdown__menu--floating {
  position: static;
  right: auto;
  bottom: auto;
  z-index: auto;
}

.ui-dd-positioner {
  z-index: 40;
}

/* Keyboard highlight state emitted by Base UI (data-highlighted) */
.ui-dropdown__item[data-highlighted],
.ui-dropdown__item[data-focused] {
  background: var(--muted, #f3f4f6);
}

.ui-tooltip {
  position: relative;
  display: inline-flex;
}

.ui-tooltip__bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.4rem);
  z-index: 50;
  transform: translateX(-50%);
  max-width: 16rem;
  padding: 0.3rem 0.5rem;
  border-radius: 0.4rem;
  background: #111827;
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease;
}

.ui-tooltip:hover .ui-tooltip__bubble,
.ui-tooltip:focus-within .ui-tooltip__bubble {
  opacity: 1;
}

/* Viz shell layout — full-width resource / calculator workspace */
.geogebra-shell {
  display: flex;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
}

.geogebra-shell--resource .geogebra-shell__main {
  width: 100%;
}

.geogebra-shell__main {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.geogebra-panel {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.geogebra-panel__chrome {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--color-border, #dadde1);
  background: color-mix(
    in srgb,
    var(--color-background-surface, #fff) 96%,
    transparent
  );
}

.geogebra-panel__chrome-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.geogebra-panel__back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--color-text-secondary, #5b6472);
  text-decoration: none;
}

.geogebra-panel__back:hover {
  color: var(--primary, #2563eb);
}

.geogebra-panel__header {
  flex: none;
  border-bottom: 1px solid var(--color-border, #dadde1);
  background: color-mix(
    in srgb,
    var(--color-background-surface, #fff) 92%,
    transparent
  );
  padding: 0.75rem 1rem;
}

.geogebra-panel__toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.geogebra-panel__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.geogebra-panel__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.geogebra-panel__actions {
  display: flex;
  gap: 0.5rem;
}

.geogebra-panel__body {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow: auto;
}

.geogebra-panel__stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.geogebra-panel__empty {
  display: grid;
  place-items: center;
  height: 100%;
  text-align: center;
  gap: 0.5rem;
  padding: 2rem;
}

.geogebra-panel__empty h2 {
  margin: 0;
  font-size: 1.25rem;
}

.geogebra-panel__empty p {
  margin: 0;
  color: var(--color-text-secondary, #65676b);
}

.geogebra-card {
  border: 1px solid var(--color-border, #dadde1);
  border-radius: 0.75rem;
  background: var(--color-background-surface, #fff);
  padding: 1rem;
}

.geogebra-card--muted {
  background: color-mix(
    in srgb,
    var(--color-background-gray, #e4e6eb) 55%,
    #fff
  );
}

.geogebra-loading {
  display: grid;
  place-items: center;
  min-height: 20rem;
  color: var(--color-text-secondary, #65676b);
}
