/* ===== Navigation ===== */
.nav {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding-top: var(--space-s);
  padding-bottom: var(--space-s);
}

.nav__inner {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  padding-inline: var(--space-m);
  gap: var(--space-m);
}

.nav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.nav__logo:hover { text-decoration: none; }

.nav__panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: var(--space-m);
}

.nav__primary {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: var(--space-s);
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: color 0.15s, background-color 0.15s;
}

.nav__link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.nav__link.active {
  color: var(--color-primary);
  font-weight: var(--font-medium);
}

.nav__link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Dropdown */
.nav__dropdown {
  position: relative;
}

.nav__dropdown-panel {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 12rem;
  padding: var(--space-3xs) 0;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

.nav__dropdown-panel--end {
  left: auto;
  right: 0;
  min-width: 8rem;
}

.nav__dropdown[data-open] > .nav__dropdown-panel {
  display: block;
}

.nav__dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  text-align: left;
  transition: background-color 0.1s, color 0.1s;
}

.nav__dropdown-item:hover,
.nav__dropdown-item:focus-visible {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
  text-decoration: none;
  outline: none;
}

.nav__dropdown-item.active {
  color: var(--color-primary);
  font-weight: var(--font-medium);
}

.nav__dropdown-header {
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.nav__dropdown-divider {
  border-bottom: 1px solid var(--color-border);
  margin: var(--space-3xs) 0;
}

/* Chevron icon */
.nav__chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
}

.nav__dropdown[data-open] > [data-dropdown-trigger] .nav__chevron {
  transform: rotate(180deg);
}

/* User trigger */
.nav__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  padding: var(--space-3xs);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: background-color 0.15s;
}

.nav__user:hover {
  background-color: var(--color-bg-muted);
}

.nav__user:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  flex-shrink: 0;
}

/* Locale trigger — icon-only button */
.nav__locale-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xs);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: color 0.15s, background-color 0.15s;
}

.nav__locale-trigger:hover {
  color: var(--color-text);
  background-color: var(--color-bg-muted);
}

.nav__locale-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav__locale-trigger .nav__icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* Hamburger toggle — hidden on desktop, pushed to end on mobile */
.nav__toggle {
  display: none;
  margin-inline-start: auto;
  padding: var(--space-3xs);
}

.nav__toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.nav__toggle-icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 1.25rem;
  height: 1.25rem;
}

.nav__toggle-icon > span {
  display: block;
  height: 2px;
  background-color: var(--color-text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* Animated hamburger → X */
.nav[data-open] .nav__toggle-icon > span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav[data-open] .nav__toggle-icon > span:nth-child(2) {
  opacity: 0;
}

.nav[data-open] .nav__toggle-icon > span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ===== Button ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s;
}

.button[data-variant="primary"] {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.button[data-variant="primary"]:hover {
  background-color: var(--color-primary-dark);
}

.button[data-variant="secondary"] {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.button[data-variant="secondary"]:hover {
  background-color: var(--color-bg-muted);
}

.button[data-variant="danger"] {
  background-color: var(--color-error);
  color: var(--color-text-inverse);
}

.button[data-variant="danger"]:hover {
  background-color: var(--color-error-dark);
}

.button[data-variant="ghost"] {
  background-color: transparent;
  color: var(--color-text-muted);
}

.button[data-variant="ghost"]:hover {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
}

.button[data-variant="ghost-danger"] {
  background-color: transparent;
  color: var(--color-error);
  border-color: var(--color-border);
}

.button[data-variant="ghost-danger"]:hover {
  background-color: var(--color-error-light);
  color: var(--color-error-dark);
}

.button[data-size="sm"] {
  padding: var(--space-3xs) var(--space-xs);
  font-size: var(--text-xs);
}

.button[data-size="md"] {
  padding: var(--space-3xs) var(--space-xs);
  font-size: var(--text-sm);
}

.button[data-size="lg"] {
  padding: var(--space-xs) var(--space-m);
  font-size: var(--text-base);
}

.button:disabled,
.button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Card ===== */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  box-shadow: var(--shadow-sm);
}

.card__header {
  margin-bottom: var(--space-s);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

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

/* ===== Skill card ===== */
.skill-card {
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-s);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  text-decoration: none;
  color: inherit;
}

.skill-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  text-decoration: none;
  z-index: 10;
}

.skill-card__name {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-3xs);
}

.skill-card__summary {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2xs);
}

.skill-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3xs);
}

/* ===== Floating tooltip (cursor-follow, driven by JS) ===== */
.floating-tooltip {
  display: none;
  position: fixed;
  z-index: 200;
  max-width: 20rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  pointer-events: none;
}

/* ===== Tab nav ===== */
.tab-nav {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.tab-nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3xs) var(--space-2xs);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab-nav__link:hover {
  color: var(--color-text);
  text-decoration: none;
}

.tab-nav__link[data-active] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ===== Catalog toolbar (positioning anchor for filter panel) ===== */
.catalog-toolbar {
  position: relative;
  margin-block: var(--space-m);
}

/* ===== Sort segmented control ===== */
.sort-control {
  display: inline-flex;
  align-items: center;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.sort-control__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xs) var(--space-2xs);
  color: var(--color-text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.sort-control__option:hover {
  color: var(--color-text);
  text-decoration: none;
}

.sort-control__option[data-active] {
  background-color: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.sort-control__option svg {
  flex-shrink: 0;
}

/* ===== Filter toggle (icon-only) ===== */

.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--space-2xs);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.filter-toggle:hover {
  color: var(--color-text);
  background-color: var(--color-bg-muted);
}

.filter-toggle[aria-expanded="true"] {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.filter-toggle svg {
  flex-shrink: 0;
}

.filter-toggle__count {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 var(--space-3xs);
  font-size: 0.625rem;
  font-weight: var(--font-bold);
  line-height: 1;
  color: var(--color-text-inverse);
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  transform: translate(25%, -25%);
}

/* ===== Filter panel (floating, full toolbar width) ===== */
.filter-panel {
  position: absolute;
  top: calc(100% + var(--space-2xs));
  inset-inline: 0;
  z-index: 100;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-s);
}

.filter-panel:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
}

.filter-panel__section {
  flex: 1;
  min-width: 12rem;
  border: none;
  padding: 0;
}

.filter-panel__section + .filter-panel__section {
  border-inline-start: 1px solid var(--color-border);
  padding-inline-start: var(--space-s);
}

.filter-panel__heading {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2xs);
}

.filter-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: var(--space-3xs) var(--space-m);
}

.filter-panel__option {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) 0;
  font-size: var(--text-sm);
  cursor: pointer;
}

.filter-panel__option:hover {
  color: var(--color-primary);
}

.filter-panel__option input[type="checkbox"] {
  accent-color: var(--color-primary);
}

.filter-panel__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2xs);
  width: 100%;
  padding-top: var(--space-xs);
  border-top: 1px solid var(--color-border);
}

/* ===== Plans grid ===== */
.plans-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-m);
}

/* ===== Plan card ===== */
.plan-card {
  flex: 0 1 16rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.plan-card__name {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-2xs);
}

.plan-card__price {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  margin-bottom: var(--space-2xs);
}

.plan-card__period {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-m);
}

.plan-card__features {
  text-align: left;
  margin-bottom: var(--space-m);
}

.plan-card__feature {
  padding: var(--space-2xs) 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-bg-muted);
}

.plan-card__specs {
  text-align: start;
  margin-bottom: var(--space-m);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xs);
}

.plan-card__specs-label {
  grid-column: 1 / -1;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding-bottom: var(--space-2xs);
  border-bottom: 1px solid var(--color-bg-muted);
}

.plan-card__spec {
  text-align: center;
  padding: var(--space-2xs);
}

.plan-card__spec-value {
  display: block;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-text);
}

.plan-card__spec-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.plan-card__models {
  text-align: start;
  margin-bottom: var(--space-m);
}

/* ===== Form ===== */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.form-field label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-text);
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background-color: var(--color-surface);
  transition: border-color 0.15s;
}

.form-field select {
  appearance: none;
  padding-inline-end: var(--space-xl);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-xs) center;
  background-size: 12px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ===== Table ===== */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: var(--space-xs) var(--space-s);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.table th {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  background-color: var(--color-bg-alt);
}

.table td {
  font-size: var(--text-sm);
}

.table tbody tr:hover {
  background-color: var(--color-bg-alt);
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3xs) var(--space-2xs);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  line-height: 1;
}

.badge[data-variant="success"] {
  background-color: var(--color-success-light);
  color: var(--color-success);
}

.badge[data-variant="warning"] {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
}

.badge[data-variant="error"] {
  background-color: var(--color-error-light);
  color: var(--color-error);
}

.badge[data-variant="info"] {
  background-color: var(--color-info-light);
  color: var(--color-info);
}

.badge[data-variant="neutral"] {
  background-color: var(--color-bg-muted);
  color: var(--color-text-muted);
}

a.badge {
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

a.badge:hover {
  background-color: var(--color-border);
  text-decoration: none;
}

a.badge.active {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ===== Alert ===== */
.alert {
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

.alert[data-variant="success"] {
  background-color: var(--color-success-light);
  color: var(--color-success);
  border-color: var(--color-success);
}

.alert[data-variant="error"] {
  background-color: var(--color-error-light);
  color: var(--color-error);
  border-color: var(--color-error);
}

.alert[data-variant="info"] {
  background-color: var(--color-info-light);
  color: var(--color-info);
  border-color: var(--color-info);
}

.alert[data-variant="warning"] {
  background-color: var(--color-warning-light);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

/* ===== Hero ===== */
.hero {
  padding: var(--space-3xl) 0;
  text-align: center;
}

.hero__title {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-s);
}

.hero__subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 36rem;
  margin-inline: auto;
  margin-bottom: var(--space-l);
}

.hero__actions {
  display: flex;
  justify-content: center;
  gap: var(--space-s);
  flex-wrap: wrap;
}

/* ===== Stat card ===== */
.stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  text-align: center;
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--color-primary);
}

.stat-card__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-3xs);
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3xs);
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: var(--space-3xs) var(--space-2xs);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background-color 0.15s;
}

.pagination__link:hover {
  background-color: var(--color-bg-muted);
  text-decoration: none;
}

.pagination__link.active {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

/* ===== Search bar (Google-style) ===== */
.search-bar {
  display: flex;
  align-items: center;
  max-width: 860px;
  margin-inline: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-bar:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.search-bar__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: var(--space-xs) var(--space-s);
  font-size: var(--text-base);
  color: var(--color-text);
  min-width: 0;
}

.search-bar__input::placeholder {
  color: var(--color-text-muted);
}

/* Hide the browser's default clear button on search inputs */
.search-bar__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-bar__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xs) var(--space-xs);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}

.search-bar__clear[hidden] {
  display: none;
}

.search-bar__clear:hover {
  color: var(--color-text);
}

.search-bar__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xs) var(--space-s);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-inline-start: 1px solid var(--color-border);
  cursor: pointer;
  transition: color 0.15s;
}

.search-bar__icon:hover {
  color: var(--color-text);
}

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-l) var(--space-m);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: auto;
}

/* ===== Auth form ===== */
.auth-form {
  width: 100%;
  max-width: 24rem;
  margin-inline: auto;
  margin-block: auto;
  padding: var(--space-l);
  gap: var(--space-l);
}

/* ===== Narrow form page ===== */
.form-narrow {
  max-width: 40rem;
  margin-inline: auto;
}

.auth-form__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  text-align: center;
  margin-bottom: var(--space-xs);
}

.auth-form__subtitle {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-l);
}

.auth-form__error {
  display: none;
  margin-bottom: var(--space-s);
}

.auth-form__footer {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-m);
}

.code-input {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  letter-spacing: 0.5em;
  font-family: var(--font-mono, monospace);
}

/* ===== Section heading ===== */
.section-heading {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-m);
}

.section-subheading {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-s);
}

/* ===== Inline form ===== */
.inline-form {
  display: inline;
}

/* ===== API key display ===== */
.api-key-display {
  margin-top: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
}

/* ===== Chat nav (sidebar) ===== */
.workspace-nav {
  overflow-y: auto;
  border-inline-end: 1px solid var(--color-border);
  padding: var(--space-s);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  background-color: var(--color-bg-alt);
}

.workspace-nav__item {
  display: block;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  transition: background-color 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-nav__item:hover,
.workspace-nav__item[data-active] {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
  text-decoration: none;
}

/* ===== Topbar: edit-title button ===== */
.topbar__edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-3xs);
  border-radius: var(--radius-sm);
}

.topbar__edit-btn[hidden] {
  display: none;
}

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

.topbar__title[contenteditable="true"] {
  cursor: text;
  outline: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-3xs);
}

/* ===== Chat messages ===== */
.workspace-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-m) 0;
  max-width: 48rem;
  width: 100%;
  margin-inline: auto;
}

.workspace-bubble {
  padding: var(--space-xs) var(--space-s);
  border-radius: var(--radius-md);
  max-width: 80%;
}

.workspace-bubble[data-role="user"] {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  margin-inline-start: auto;
}

.workspace-bubble + .workspace-bubble[data-role="user"] {
  margin-block-start: var(--space-xl);
}

.workspace-bubble[data-role="assistant"] {
  background-color: var(--color-surface);
  margin-block-end: var(--space-2xs);
}

.workspace-bubble[data-loading] {
  background-color: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.workspace-bubble[data-role="system"],
.workspace-bubble[data-role="tool"] {
  background-color: var(--color-bg-muted);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.workspace-bubble__content {
  word-break: break-word;
}

.workspace-bubble[data-role="user"] .workspace-bubble__content {
  white-space: pre-wrap;
}

/* ── Markdown content in assistant bubbles ─────────────────────────────────── */

.workspace-bubble[data-role="assistant"] .workspace-bubble__content p + p {
  margin-block-start: var(--space-xs);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content h1,
.workspace-bubble[data-role="assistant"] .workspace-bubble__content h2,
.workspace-bubble[data-role="assistant"] .workspace-bubble__content h3 {
  margin-block-start: var(--space-s);
  margin-block-end: var(--space-2xs);
  font-weight: var(--font-semibold);
  line-height: 1.3;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content h1 { font-size: var(--text-xl); }
.workspace-bubble[data-role="assistant"] .workspace-bubble__content h2 { font-size: var(--text-lg); }
.workspace-bubble[data-role="assistant"] .workspace-bubble__content h3 { font-size: var(--text-base); }

.workspace-bubble[data-role="assistant"] .workspace-bubble__content ul,
.workspace-bubble[data-role="assistant"] .workspace-bubble__content ol {
  padding-inline-start: var(--space-m);
  margin-block: var(--space-2xs);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content ul {
  list-style: disc;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content ol {
  list-style: decimal;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content li + li {
  margin-block-start: var(--space-3xs);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content strong {
  font-weight: var(--font-semibold);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content code {
  font-family: var(--font-mono, ui-monospace, "SFMono-Regular", "SF Mono", Menlo, monospace);
  font-size: 0.875em;
  background-color: var(--color-bg-alt);
  padding: 0.125em 0.375em;
  border-radius: var(--radius-sm);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content pre {
  position: relative;
  background-color: var(--color-bg-alt);
  padding: var(--space-s);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-block: var(--space-xs);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: var(--text-sm);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content blockquote {
  border-inline-start: 3px solid var(--color-border);
  padding-inline-start: var(--space-s);
  color: var(--color-text-muted);
  margin-block: var(--space-xs);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content table {
  border-collapse: collapse;
  margin-block: var(--space-xs);
  font-size: var(--text-sm);
  width: 100%;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content th,
.workspace-bubble[data-role="assistant"] .workspace-bubble__content td {
  border: 1px solid var(--color-border);
  padding: var(--space-3xs) var(--space-xs);
  text-align: start;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content th {
  background-color: var(--color-bg-alt);
  font-weight: var(--font-semibold);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content hr {
  border: none;
  border-block-start: 1px solid var(--color-border);
  margin-block: var(--space-s);
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content a {
  color: var(--color-primary);
  text-decoration: underline;
}

.workspace-bubble[data-role="assistant"] .workspace-bubble__content a:hover {
  color: var(--color-primary-dark);
}

/* ── Code block copy button ─────────────────────────────────────────────── */

.code-copy {
  position: absolute;
  inset-block-start: var(--space-3xs);
  inset-inline-end: var(--space-3xs);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
  padding: var(--space-3xs);
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}

pre:hover .code-copy {
  opacity: 1;
}

.code-copy:hover {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

.workspace-bubble__footer {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding-block-start: var(--space-s);
  color: var(--color-text-muted);
}

.workspace-bubble__copy,
.workspace-bubble__info {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--color-text-muted);
}

.workspace-bubble__copy::after,
.workspace-bubble__info::after {
  white-space: pre;
  text-align: center;
  position: absolute;
  inset-block-start: calc(100% + var(--space-3xs));
  inset-inline-start: 0;
  background-color: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  padding: var(--space-3xs) var(--space-2xs);
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}

.workspace-bubble__copy:hover::after,
.workspace-bubble__info:hover::after {
  opacity: 1;
}

.workspace-bubble__info {
  cursor: default;
}

.workspace-bubble__info::after {
  content: attr(data-model) "\A" attr(data-created);
}

.workspace-bubble__copy {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-3xs);
  border-radius: var(--radius-sm);
}

.workspace-bubble__copy::after {
  content: "Copy";
}

.workspace-bubble__copy:hover {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

/* ===== Tool steps group (inline in assistant bubble) ===== */
/* Borderless, muted — secondary to the message text. */
.workspace-tool-group {
  margin-block: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.workspace-tool-group__header {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) 0;
  cursor: pointer;
  user-select: none;
}

.workspace-tool-group__header:hover {
  color: var(--color-text);
}

.workspace-tool-group__icon {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  transition: transform 0.15s ease;
}

.workspace-tool-group[data-expanded] .workspace-tool-group__icon {
  transform: rotate(180deg);
}

.workspace-tool-group__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  height: 1.4em;
  padding: 0 0.3em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  line-height: 1;
}

.workspace-tool-group__label {
  font-weight: var(--font-medium);
}

.workspace-tool-group__body {
  display: none;
  padding-inline-start: var(--space-s);
  border-inline-start: 2px solid var(--color-border);
  margin-inline-start: 0.45em;
  margin-block: var(--space-3xs);
}

.workspace-tool-group[data-expanded] .workspace-tool-group__body {
  display: block;
}

/* Individual tool step inside the group */
.workspace-tool-card {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.workspace-tool-card__row {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) 0;
  cursor: pointer;
  user-select: none;
}

.workspace-tool-card__row:hover {
  color: var(--color-text);
}

.workspace-tool-card__name {
  font-weight: var(--font-medium);
}

.workspace-tool-card__status-icon {
  flex-shrink: 0;
  opacity: 0.6;
}

.workspace-tool-card__status-icon[data-status="done"] {
  color: var(--color-success);
}

.workspace-tool-card__status-icon[data-status="error"] {
  color: var(--color-error);
}

.workspace-tool-card__status-icon[data-status="running"] {
  color: var(--color-warning);
}

.workspace-tool-card__body {
  display: none;
  padding-inline-start: var(--space-s);
  margin-block: var(--space-3xs);
  max-height: 20rem;
  overflow-y: auto;
}

.workspace-tool-card[data-expanded] .workspace-tool-card__body {
  display: block;
}

.workspace-tool-card__output {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--color-text-muted);
}

/* Tool card INPUT/OUTPUT sections (persist view) */
.workspace-tool-card__section {
  display: none;
  padding-inline-start: var(--space-s);
  margin-block: var(--space-3xs);
  max-height: 20rem;
  overflow-y: auto;
}

.workspace-tool-card[data-expanded] .workspace-tool-card__section {
  display: block;
}

.workspace-tool-card__section-label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-block-end: var(--space-3xs);
  opacity: 0.6;
}

/* Intermediate text between tool rounds */
.workspace-tool-card__intermediate {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  padding: var(--space-3xs) 0;
}

/* ===== Thinking blocks (collapsible in assistant bubble) ===== */
/* Same muted, borderless style as tool cards. */
.workspace-thinking {
  margin-block-end: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.workspace-thinking__header {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) 0;
  cursor: pointer;
  user-select: none;
}

.workspace-thinking__header:hover {
  color: var(--color-text);
}

.workspace-thinking__icon {
  flex-shrink: 0;
  width: 1em;
  height: 1em;
  transition: transform 0.15s ease;
}

.workspace-thinking[data-expanded] .workspace-thinking__icon {
  transform: rotate(180deg);
}

.workspace-thinking__body {
  display: none;
  padding-inline-start: var(--space-s);
  border-inline-start: 2px solid var(--color-border);
  margin-inline-start: 0.45em;
  margin-block: var(--space-3xs);
  max-height: 30rem;
  overflow-y: auto;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  white-space: pre-wrap;
  line-height: 1.5;
}

.workspace-thinking[data-expanded] .workspace-thinking__body {
  display: block;
}

/* ===== Cold-start warmup indicator ===== */
.workspace-warmup {
  max-width: 48rem;
  width: 100%;
  margin-inline: auto;
  padding: var(--space-xs) var(--space-m) 0;
  color: var(--color-warning);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  text-align: center;
}

.workspace-warmup[data-variant="error"] { color: var(--color-error); }

.workspace-warmup[hidden] {
  display: none;
}



/* ===== Chat compose (card) ===== */
.workspace-compose {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-2xs);
  margin-block: var(--space-s);
  margin-inline: auto;
  max-width: 48rem;
  width: 100%;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.workspace-compose:hover {
  border-color: var(--color-border-strong);
}

.workspace-compose:focus-within {
  border-color: var(--color-primary);
}

.workspace-compose__field {
  resize: none;
  min-height: 2.5rem;
  max-height: 12rem;
  padding: var(--space-xs);
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.workspace-compose__field:hover,
.workspace-compose__field:focus {
  scrollbar-color: var(--color-border) transparent;
}

.workspace-compose__field::-webkit-scrollbar { width: 4px; }
.workspace-compose__field::-webkit-scrollbar-track { background: transparent; }
.workspace-compose__field::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: var(--radius-full);
}
.workspace-compose__field:hover::-webkit-scrollbar-thumb,
.workspace-compose__field:focus::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
}

.workspace-compose__field:focus {
  outline: none;
}

.workspace-compose__field:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.workspace-compose__field::placeholder {
  color: var(--color-text-muted);
}

.workspace-compose__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2xs);
}

.workspace-compose__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

.workspace-compose__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.workspace-compose__btn:hover {
  color: var(--color-text);
  background-color: var(--color-bg-muted);
}

/* Attach dropdown anchor */
.workspace-compose__attach { position: relative; }

/* Upward popover for attach options */
.workspace-compose__popover {
  display: none;
  position: fixed;
  width: max-content;
  min-width: 9rem;
  max-height: min(20rem, 50vh);
  overflow-y: auto;
  background-color: var(--color-panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3xs) 0;
  z-index: 200;
}
.workspace-compose__popover[data-open] { display: block; }

.workspace-compose__popover-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: start;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}
.workspace-compose__model-note {
  display: block;
  width: 100%;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  opacity: 0.7;
}
.workspace-compose__popover-item:hover {
  background-color: var(--color-panel-active);
  color: var(--color-text);
}

/* Text-style button variant (for Skills) */
.workspace-compose__btn[data-variant="text"] {
  width: auto;
  border-radius: var(--radius-full);
  padding: var(--space-3xs) var(--space-xs);
  gap: var(--space-2xs);
  font-size: var(--text-sm);
}

/* Skills dropdown anchor */
.workspace-compose__skills { position: relative; }

.workspace-compose__skills .workspace-compose__popover {
  width: 18rem;
}

.workspace-compose__popover-empty {
  padding: var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
}

.workspace-compose__skill-emoji {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
}

.workspace-compose__skill-name {
  flex: 1;
  min-width: 0;
  color: var(--color-text);
}

.workspace-compose__skill-desc {
  width: 100%;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Model dropdown anchor */
.workspace-compose__model-dropdown { position: relative; }

/* Chevron inside model trigger */
.workspace-compose__model-dropdown svg:last-child {
  transition: transform 0.2s;
}
.workspace-compose__model-dropdown [aria-expanded="true"] svg:last-child {
  transform: rotate(180deg);
}

/* Model popover: right-aligned override */
/* Model popover: right-aligned via JS positionPopover (no CSS inset needed). */

.workspace-compose__no-models {
  padding: var(--space-2xs) var(--space-xs);
  color: var(--color-error-dark);
}

.workspace-compose__hint {
  text-align: end;
  color: var(--color-error-dark);
}

/* Selected item highlight */
.workspace-compose__popover-item[data-selected] {
  color: var(--color-text);
  font-weight: 600;
}

.workspace-compose__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  border: none;
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  cursor: pointer;
  transition: background-color 0.15s;
  flex-shrink: 0;
}

.workspace-compose__send:hover {
  background-color: var(--color-primary-dark);
}

.workspace-compose__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.workspace-compose__send[data-streaming] {
  background-color: var(--color-error);
}

.workspace-compose__send[data-streaming]:hover {
  background-color: var(--color-error-dark);
}


/* ===== Chat attachments ===== */
.workspace-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  padding-block-end: var(--space-2xs);
}

.workspace-attachments:empty {
  display: none;
}

.workspace-attachment {
  position: relative;
  width: 5rem;
  height: 5rem;
}

.workspace-attachment__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.workspace-attachment__text {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-muted);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  padding: var(--space-3xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-attachment__remove {
  position: absolute;
  inset-block-start: 2px;
  inset-inline-end: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.workspace-attachment:hover .workspace-attachment__remove {
  opacity: 1;
}

/* ===== Chat greeting (empty state) ===== */
.workspace-greeting {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--space-xl);
  text-align: center;
}

.workspace-greeting__content {
  max-width: 28rem;
}

.workspace-greeting__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.workspace-greeting__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-block-start: var(--space-2xs);
}

.workspace-greeting__error {
  padding: var(--space-m);
  color: var(--color-error);
  text-align: center;
}

.workspace-greeting__upgrade {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-m);
  text-align: center;
}

/* ===== Sidenav ===== */
.sidenav {
  display: flex;
  flex-direction: column;
  background-color: var(--color-panel);
  border-inline-end: 1px solid var(--color-panel-border);
  color: var(--color-text);
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
}

.sidenav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xs);
  margin: var(--space-3xs) 0;
  flex-shrink: 0;
}

.sidenav__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  text-decoration: none;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  transition: max-width 0.1s ease-in-out, opacity 0.08s ease-in-out;
}

.sidenav__logo:hover { text-decoration: none; }

.sidenav__collapse {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  padding: var(--space-xs);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.sidenav__collapse:hover {
  color: var(--color-text);
  background-color: var(--color-panel-hover);
}

.sidenav__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  padding: var(--space-2xs);
  flex-shrink: 0;
}

.sidenav__action {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-2xs) var(--space-s);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text);
  text-decoration: none;
  transition: background-color 0.1s;
}

.sidenav__action svg {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  max-width: none;
}

.sidenav__action span {
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  white-space: nowrap;
  margin-inline-start: 0;
  transition: max-width 0.2s ease, opacity 0.15s ease, margin-inline-start 0.2s ease;
}

.sidenav__action:hover {
  background-color: var(--color-panel-hover);
  text-decoration: none;
}

.sidenav__action[data-active] {
  background-color: var(--color-panel-active);
  font-weight: var(--font-medium);
}

.sidenav__action[data-variant="primary"] {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: var(--font-medium);
}

.sidenav__action[data-variant="primary"]:hover {
  background-color: var(--color-primary-dark);
}

.sidenav__section {
  display: none;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.sidenav__conversations {
  display: none;
  min-height: 0;
}

.sidenav__conv-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.sidenav__conv-row {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  transition: background-color 0.1s;
}

.sidenav__conv-row:hover {
  background-color: var(--color-panel-hover);
}

.sidenav__conv-row:has([data-active]) {
  background-color: var(--color-panel-active);
}

.sidenav__conv-item {
  flex: 1;
  min-width: 0;
  display: block;
  padding: var(--space-2xs) var(--space-xs);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  transition: color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidenav__conv-row:hover .sidenav__conv-item {
  color: var(--color-text);
}

.sidenav__conv-item:hover {
  text-decoration: none;
}

.sidenav__conv-item[data-active] {
  color: var(--color-text);
  font-weight: var(--font-medium);
}

.sidenav__conv-menu {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.1s, background-color 0.1s;
  margin-inline-end: var(--space-3xs);
}

.sidenav__conv-row:hover .sidenav__conv-menu,
.sidenav__conv-row:has(.sidenav__conv-popover[data-open]) .sidenav__conv-menu {
  display: inline-flex;
}

.sidenav__conv-menu:hover {
  color: var(--color-text);
  background-color: var(--color-panel-hover);
}

.sidenav__conv-popover {
  display: none;
  position: absolute;
  top: 100%;
  inset-inline-end: 0;
  min-width: 8rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3xs) 0;
  z-index: 200;
}

.sidenav__conv-popover[data-open] {
  display: block;
}

.sidenav__conv-popover-item {
  display: block;
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: start;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.1s, color 0.1s;
}

.sidenav__conv-popover-item:hover {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
}

.sidenav__conv-popover-item[data-variant="danger"] {
  color: var(--color-error);
}

.sidenav__conv-popover-item[data-variant="danger"]:hover {
  background-color: var(--color-error-light);
  color: var(--color-error);
}

.sidenav__bottom {
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--color-panel-border);
  padding: var(--space-2xs);
}

.sidenav__sandbox {
  display: flex;
  justify-content: center;
  padding: var(--space-3xs);
}

.sidenav__status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidenav__status-dot[data-status="running"] { background-color: var(--color-success); }
.sidenav__status-dot[data-status="starting"] { background-color: var(--color-warning); }
.sidenav__status-dot[data-status="provisioning"] { background-color: var(--color-warning); }
.sidenav__status-dot[data-status="stopped"] { background-color: var(--color-text-muted); }
.sidenav__status-dot[data-status="error"] { background-color: var(--color-error); }
.sidenav__status-dot[data-status="failed"] { background-color: var(--color-error); }
.sidenav__status-dot[data-status="unavailable"] { background-color: var(--color-error); }
.sidenav__status-dot[data-status="no_quota"] { background-color: var(--color-text-muted); }

.sidenav__action[data-disabled] { opacity: 0.4; pointer-events: none; }

.sidenav__gauges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-s);
  min-height: 3.25rem;
}

.sidenav__gauges[data-state] { gap: 0; }
.sidenav__gauges[data-state="loading"] .dot { color: var(--color-primary); }

.gauge-na {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  opacity: 0.4;
}

.gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3xs);
}

.gauge__ring {
  width: 2.25rem;
  height: 2.25rem;
  transform: rotate(-90deg);
}

.gauge__track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 3;
}

.gauge__arc {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.gauge__arc[data-level="ok"]   { stroke: var(--color-success); }
.gauge__arc[data-level="warn"] { stroke: var(--color-warning); }
.gauge__arc[data-level="crit"] { stroke: var(--color-error); }

.gauge__value {
  font-size: 0.5rem;
  font-weight: var(--font-medium);
  fill: var(--color-text-muted);
  text-anchor: middle;
  dominant-baseline: central;
  transform: rotate(90deg);
  transform-origin: 18px 18px;
}

.gauge__label {
  font-size: var(--text-2xs);
  color: var(--color-text-muted);
}

/* ===== Sidenav stats container (gauges + overlays) ===== */
.sidenav__stats {
  position: relative;
  min-height: 3.25rem;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.2s ease, opacity 0.15s ease;
}

/* Semi-transparent overlay (starting, failed) — sits on top of gauges */
.sidenav__stats-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: color-mix(in srgb, var(--color-surface) 70%, transparent);
  z-index: 1;
}

.sidenav__stats-overlay[data-state="failed"] {
  color: var(--color-error);
}

/* Full-cover update panel — replaces gauges entirely */
.sidenav__stats-update {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3xs);
  background-color: var(--color-surface);
  z-index: 2;
}

.sidenav__stats-update-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ===== Sidenav expanded state ===== */
.app-layout[data-expanded] .sidenav__logo { max-width: 12rem; opacity: 1; transition: max-width 0.2s ease-in-out 0.1s, opacity 0.15s ease-in-out 0.1s; }
.app-layout[data-expanded] .sidenav__action span { max-width: 12rem; opacity: 1; margin-inline-start: var(--space-2xs); }
.app-layout[data-expanded] .sidenav__section { display: block; padding: var(--space-xs) var(--space-s) var(--space-3xs); }
.app-layout[data-expanded] .sidenav__conversations { display: flex; flex-direction: column; flex: 1; padding: 0 var(--space-s) var(--space-s); overflow-y: auto; }
.app-layout[data-expanded] .sidenav__bottom { padding: var(--space-2xs) var(--space-s); }
.app-layout[data-expanded] .sidenav__sandbox { display: none; }
.app-layout[data-expanded] .sidenav__stats { max-height: 5rem; opacity: 1; }
.app-layout[data-expanded] .sidenav__gauges { max-height: 5rem; opacity: 1; }

/* ===== Topbar actions (locale + user) ===== */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
}

/* ===== Topbar locale switcher ===== */
.topbar__locale {
  position: relative;
}

.topbar__locale-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s;
}

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

/* ===== Topbar user avatar ===== */
.topbar__user {
  position: relative;
  padding: var(--space-3xs);
}

.topbar__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.topbar__avatar:hover {
  opacity: 0.85;
}

/* ===== Topbar popovers (shared by locale + user) ===== */
.topbar__popover,
.user-popover {
  display: none;
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + var(--space-2xs));
  min-width: 10rem;
  background-color: var(--color-bg-alt);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3xs) 0;
  z-index: 200;
}

.topbar__popover[data-open],
.user-popover[data-open] {
  display: block;
}

.user-popover {
  min-width: 12rem;
}

.topbar__popover-item {
  display: block;
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  text-align: start;
  transition: background-color 0.1s, color 0.1s;
}

.topbar__popover-item:hover,
.topbar__popover-item.active {
  background-color: var(--color-panel-active);
  color: var(--color-text);
  text-decoration: none;
}

.user-popover__header {
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.user-popover__divider {
  border-bottom: 1px solid var(--color-border);
  margin: var(--space-3xs) 0;
}

.user-popover__item {
  display: block;
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  text-align: start;
  transition: background-color 0.1s, color 0.1s;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.user-popover__item:hover {
  background-color: var(--color-panel-active);
  color: var(--color-text);
  text-decoration: none;
}

/* ===== App topbar ===== */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-s);
  flex-shrink: 0;
  gap: var(--space-s);
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-surface);
}

.topbar__title-group {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  margin-inline-end: auto;
}

.topbar__title {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

/* ===== Plan badge ===== */
.plan-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-3xs) var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background-color: var(--color-bg-muted);
  border-radius: var(--radius-full);
  line-height: 1;
}

.plan-badge a {
  color: var(--color-primary);
  text-decoration: none;
  margin-inline-start: var(--space-3xs);
}

.plan-badge a:hover {
  text-decoration: underline;
}

/* ===== Sidenav overlay (hidden on desktop, shown on mobile when open) ===== */
.sidenav-overlay {
  display: none;
}

/* ===== Sidenav mobile toggle ===== */
.sidenav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xs);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text);
}

/* ===== Update Banner ===== */
.update-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  padding: var(--space-s) var(--space-m);
  background-color: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.update-banner__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

/* ===== Settings Tabs ===== */

/* ===== Page progress bar (HTMX navigation) ===== */
.page-progress {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: var(--progress-height);
  z-index: 9999;
  background-color: var(--color-border);
  overflow: hidden;
  pointer-events: none;
}

.page-progress:not([data-active]) {
  visibility: hidden;
}

.page-progress__bar {
  height: 100%;
  width: 30%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: page-progress-slide 1.2s ease-in-out infinite;
}

@keyframes page-progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ===== Page loading overlay (initial page load) ===== */
.page-loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg);
}

.page-loading:not([data-active]) {
  display: none;
}

.page-loading__bar {
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: var(--progress-height);
  background-color: var(--color-border);
  overflow: hidden;
}

.page-loading__bar-fill {
  height: 100%;
  width: 30%;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: page-progress-slide 1.2s ease-in-out infinite;
}

.page-loading__spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-full);
  animation: page-loading-rotate 0.7s linear infinite;
}

@keyframes page-loading-rotate {
  to { transform: rotate(360deg); }
}

/* ===== Confirm dialog ===== */
.confirm-dialog {
  margin: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-lg);
  padding: var(--space-l);
  max-width: 24rem;
  width: calc(100% - var(--space-l));
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.confirm-dialog__message {
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: var(--space-m);
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
}

/* ===== Drawer ===== */
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 400;
  width: var(--drawer-width);
  min-width: var(--drawer-min-width);
  max-width: 100vw;
  background-color: var(--color-surface);
  border-inline-start: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[dir="rtl"] .drawer {
  /*rtl:ignore*/
  transform: translateX(-100%);
}

.drawer[data-open] {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 399;
  background: rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.drawer-overlay[data-open] {
  opacity: 1;
  pointer-events: auto;
}

.drawer__layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.drawer__nav {
  width: 12rem;
  flex-shrink: 0;
  background-color: var(--color-panel);
  border-inline-end: 1px solid var(--color-border);
  padding-block: var(--space-s);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drawer__nav-header {
  display: flex;
  align-items: center;
  padding-inline: var(--space-xs);
  padding-block-end: var(--space-s);
}

.drawer__nav-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  padding-inline: var(--space-3xs);
}

.drawer__nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: start;
  width: 100%;
  transition: color 0.15s, background-color 0.15s;
}

.drawer__nav-item:hover {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

.drawer__nav-item[data-active] {
  color: var(--color-text);
  background-color: var(--color-panel-active);
  font-weight: var(--font-medium);
}

.drawer__nav-item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.drawer__panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xs);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-text-muted);
}

.drawer__close:hover {
  color: var(--color-text);
  background-color: var(--color-bg-alt);
}

.drawer__panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-s);
}

.drawer__panel-body:has(.drawer__loading) {
  display: flex;
}

.drawer__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

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

.drawer__spinner {
  animation: drawer-spin 0.8s linear infinite;
}

.drawer__content-header {
  display: flex;
  align-items: center;
  height: var(--space-2xl);
  padding: var(--space-s);
  border-block-end: 1px solid var(--color-border);
}

.drawer__content-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

/* ===== Account info ===== */
.account-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.account-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
}

.account-field__label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.account-field__value {
  font-size: var(--text-base);
  color: var(--color-text);
}

/* ===== Provider Select ===== */
.provider-select {
  position: relative;
  width: 100%;
}

.provider-select__trigger {
  display: flex;
  align-items: center;
  width: 100%;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: inherit;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s;
}

.provider-select__trigger:hover {
  outline: 1px solid var(--color-border);
}

.provider-select__label {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-inline-end: auto;
}

.provider-select__trigger svg {
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--color-text-muted);
}

.provider-select__trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.provider-select__icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.provider-select__popover {
  display: none;
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + var(--space-2xs));
  max-height: 16rem;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  background-color: var(--color-panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-3xs) 0;
  z-index: 200;
}

/* Force scrollbar track visible on overlay-scrollbar systems (macOS). */
.provider-select__popover::-webkit-scrollbar {
  width: 6px;
}
.provider-select__popover::-webkit-scrollbar-track {
  background: transparent;
}
.provider-select__popover::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

.provider-select__popover[data-open] {
  display: block;
}

.provider-select__item {
  display: flex;
  align-items: center;
  gap: var(--space-2xs);
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: start;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  transition: background-color 0.1s, color 0.1s;
}

.provider-select__item img {
  flex-shrink: 0;
}

.provider-select__item:hover {
  background-color: var(--color-panel-active);
  color: var(--color-text);
  text-decoration: none;
}

.provider-select__item[data-active] {
  color: var(--color-primary);
  font-weight: var(--font-semibold);
}

/* ===== Toggle Switch ===== */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 2.5rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch__track {
  position: absolute;
  inset: 0;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  transition: background-color 0.2s;
  cursor: pointer;
}

.toggle-switch__track::after {
  content: "";
  position: absolute;
  top: 0.125rem;
  inset-inline-start: 0.125rem;
  width: 1rem;
  height: 1rem;
  background-color: var(--color-surface);
  border-radius: var(--radius-full);
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-switch__track {
  background-color: var(--color-success);
}

.toggle-switch input:checked + .toggle-switch__track::after {
  transform: translateX(1.25rem);
}

.toggle-switch input:focus-visible + .toggle-switch__track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== Key Drill (two-pane slide navigation) ===== */
.key-drill {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  overflow: hidden;
  height: 100%;
}

/* Persistent header — row 1, never slides */
.key-drill > .drawer__content-header {
  grid-row: 1;
}

.key-drill > .drawer__content-header > [data-show="detail"] {
  display: none;
}

.key-drill[data-drill="detail"] > .drawer__content-header > [data-show="list"] {
  display: none;
}

.key-drill[data-drill="detail"] > .drawer__content-header > [data-show="detail"] {
  display: inline-flex;
}

/* Panes — row 2, overlap and slide */
.key-drill__pane {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-m);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.key-drill__pane[data-pane="detail"] {
  transform: translateX(100%);
  visibility: hidden;
}

.key-drill[data-drill="detail"] .key-drill__pane[data-pane="list"] {
  transform: translateX(-100%);
}

.key-drill[data-drill="detail"] .key-drill__pane[data-pane="detail"] {
  transform: translateX(0);
}

/* Back button */
.key-drill__back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3xs);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  padding: var(--space-3xs) var(--space-2xs);
  transition: background-color 0.15s;
}

.key-drill__back:hover {
  background-color: var(--color-bg-alt);
}

/* ===== Key Row (list item) ===== */
/* ===== Key List ===== */

.key-row {
  display: grid;
  grid-template-columns: 20px 1fr 1fr 1fr auto;
  align-items: center;
  gap: var(--space-s);
  width: 100%;
  padding: var(--space-s);
  border: none;
  background: none;
  cursor: pointer;
  text-align: start;
  transition: background-color 0.15s;
}

.key-row__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.key-row__icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.provider-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-s);
  background-color: var(--color-bg-muted);
  font-size: 10px;
  font-weight: var(--font-bold);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.key-row:hover {
  background-color: var(--color-bg-muted);
}

.key-row__title {
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-row__preview {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.key-row__chevron {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

/* ===== Key Status (shared dot indicator) ===== */
.key-status {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  color: var(--color-text-muted);
}

.key-status[data-active] {
  color: var(--color-success);
}

/* ===== Key Detail (detail pane content) ===== */
.key-detail {
  display: none;
}

.key-detail[data-active] {
  display: block;
}

.key-detail__title {
  font-weight: var(--font-semibold);
  font-size: var(--text-base);
}

.key-detail__toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
}

/* ===== Models Section ===== */
.models-section__label {
  padding-block-end: var(--space-3xs);
}

/* ===== Model Checkbox ===== */
.model-check {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
  font-size: var(--text-sm);
  cursor: pointer;
}

.model-check input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ===== Add Key Reveal ===== */
.add-key-reveal {
  text-align: end;
  margin-block-start: var(--space-s);
}

.add-key-reveal summary {
  list-style: none;
}

.add-key-reveal summary::-webkit-details-marker {
  display: none;
}

.add-key-reveal[open] > summary {
  display: none;
}

.add-key-reveal__trigger {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--color-primary);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-2xs) var(--space-s);
  margin-block-start: var(--space-s);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.add-key-reveal__trigger:hover {
  color: var(--color-primary-dark);
  background-color: var(--color-bg-muted);
}

.add-key-reveal__body-wrap {
  overflow: hidden;
  max-height: 0;
  text-align: start;
  background: var(--color-bg-alt);
  padding: var(--space-s);
  border-radius: var(--radius-md);
  transition: max-height 0.3s ease;
}

/* ===== Confirm Dialog ===== */
dialog.confirm-dialog {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  background-color: var(--color-surface);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
  max-width: 22rem;
  width: 90vw;
}

dialog.confirm-dialog::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
}

.confirm-dialog__title {
  font-weight: var(--font-semibold);
  font-size: var(--text-base);
  margin-block-end: var(--space-2xs);
}

.confirm-dialog__message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-block-end: var(--space-m);
}

/* ===== Locale Select (dropdown) ===== */
.locale-select {
  position: relative;
  width: 100%;
}

.locale-select__trigger {
  display: flex;
  align-items: center;
  width: 100%;
  gap: var(--space-2xs);
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: inherit;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s;
}

.locale-select__trigger:hover {
  background-color: var(--color-bg-muted);
}

.locale-select__label {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-inline-end: auto;
}

.locale-select__trigger svg {
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--color-text-muted);
}

.locale-select__trigger[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.locale-select__popover {
  display: none;
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + var(--space-2xs));
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3xs) 0;
  z-index: 200;
}

.locale-select__popover[data-open] {
  display: block;
}

.locale-select__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background-color 0.1s, color 0.1s;
}

.locale-select__item:hover {
  background-color: var(--color-bg-muted);
  color: var(--color-text);
  text-decoration: none;
}

.locale-select__item[data-active] {
  color: var(--color-primary);
  font-weight: var(--font-semibold);
}

.locale-select__check {
  color: var(--color-primary);
}

/* ===== Toast Container ===== */
.toast-container {
  position: fixed;
  bottom: var(--space-m);
  inset-inline-end: var(--space-m);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: 500;
  pointer-events: none;
  max-width: 24rem;
  width: calc(100% - 2 * var(--space-m));
}

.toast-container .alert {
  pointer-events: auto;
  translate: 0 var(--space-m);
  opacity: 0;
  transition: translate 0.3s ease, opacity 0.3s ease;
}

.toast-container .alert[data-visible] {
  translate: 0;
  opacity: 1;
}

/* ===== Password Rules ===== */
.password-rules {
  list-style: none;
  padding-inline-start: 0;
  font-size: var(--text-sm);
}

.password-rules li {
  color: var(--color-error);
  padding-block: var(--space-3xs);
}

.password-rules li::before {
  content: "\2717 ";
}

.password-rules li[data-met] {
  color: var(--color-success);
}

.password-rules li[data-met]::before {
  content: "\2713 ";
}

/* ===== Password Strength ===== */
.password-strength {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.password-strength__bar {
  display: flex;
  gap: 4px;
  flex: 1;
}

.password-strength__segment {
  block-size: 4px;
  flex: 1;
  border-radius: var(--radius-sm);
  background-color: var(--color-border);
  transition: background-color 0.2s;
}

.password-strength__segment[data-active="weak"] {
  background-color: var(--color-error);
}

.password-strength__segment[data-active="fair"] {
  background-color: var(--color-warning);
}

.password-strength__segment[data-active="good"] {
  background-color: var(--color-info);
}

.password-strength__segment[data-active="strong"] {
  background-color: var(--color-success);
}

.password-strength__label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  min-inline-size: 3em;
}

/* ── Approval modal ─────────────────────────────────────────────────────── */

.approval-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.approval-modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-l);
  max-inline-size: 28rem;
  inline-size: 90vw;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.approval-modal__header {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  margin-block-end: var(--space-m);
}

.approval-modal__title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin: 0;
}

.approval-modal__badge {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  background: var(--color-warning-light);
  color: var(--color-warning);
  padding: var(--space-3xs) var(--space-xs);
  border-radius: var(--radius-sm);
}

.approval-modal__tool-name {
  font-size: var(--text-md);
  font-weight: var(--font-medium);
  font-family: var(--font-mono);
  margin-block-end: var(--space-s);
}

.approval-modal__preview {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-s);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-all;
  max-block-size: 8rem;
  overflow-y: auto;
  margin-block-end: var(--space-m);
}

.approval-modal__countdown {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  margin-block-end: var(--space-m);
}

.approval-modal__countdown-bar {
  flex: 1;
  block-size: 4px;
  background: var(--color-warning);
  border-radius: 2px;
  transition: width 1s linear;
}

.approval-modal__timer {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  min-inline-size: 2.5em;
  text-align: end;
}

.approval-modal__actions {
  display: flex;
  gap: var(--space-s);
  justify-content: flex-end;
}

/* --- Scheduled tasks --- */

.schedule-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-block-start: 10vh;
  padding-inline: var(--space-m);
}
.schedule-modal[hidden] { display: none; }
.schedule-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.schedule-modal__panel {
  position: relative;
  width: min(32rem, 100%);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  animation: schedule-modal-in 0.15s ease-out;
}
@keyframes schedule-modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.schedule-type-tabs {
  display: flex;
  gap: 2px;
  background: var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.schedule-type-tabs__btn {
  flex: 1;
  padding: var(--space-2xs) var(--space-s);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border: none;
  background: var(--color-surface);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.schedule-type-tabs__btn:hover { background: var(--color-bg-alt); }
.schedule-type-tabs__btn[data-active] {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.schedule-interval__number {
  width: 5rem !important;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
}
.schedule-interval__unit {
  width: auto !important;
  padding: var(--space-2xs) var(--space-xs);
  padding-inline-end: var(--space-xl);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  appearance: none;
  background-color: var(--color-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' fill='none' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-xs) center;
  background-size: 12px;
}

.schedule-job {
  padding: var(--space-s);
}
.schedule-job__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-s);
}
.schedule-job__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
}
.schedule-job__message {
  font-weight: var(--font-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.schedule-job__meta {
  margin-block-start: var(--space-xs);
  padding-block-start: var(--space-xs);
  border-block-start: 1px solid var(--color-border);
}
.schedule-job__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.schedule-job__result {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  padding-block: var(--space-xs);
  border-block-start: 1px solid var(--color-border);
}
.schedule-job__status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  margin-block-start: 5px;
}
.schedule-job__status-dot[data-status="ok"] { background: var(--color-success); }
.schedule-job__status-dot[data-status="error"] { background: var(--color-error); }
.schedule-job__status-dot[data-status="skipped"] { background: var(--color-warning); }
.schedule-job__result-text {
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.schedule-run {
  padding: var(--space-s);
}
.schedule-run__status {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px var(--space-2xs);
  border-radius: var(--radius-sm);
}
.schedule-run__status[data-status="ok"] {
  background: color-mix(in srgb, var(--color-success) 15%, transparent);
  color: var(--color-success);
}
.schedule-run__status[data-status="error"] {
  background: color-mix(in srgb, var(--color-error) 15%, transparent);
  color: var(--color-error);
}
.schedule-run__status[data-status="skipped"] {
  background: color-mix(in srgb, var(--color-warning) 15%, transparent);
  color: var(--color-warning);
}
.schedule-run__result {
  color: var(--color-text-muted);
  white-space: pre-wrap;
  max-height: 10rem;
  overflow-y: auto;
}
.schedule-run__error {
  color: var(--color-error);
  white-space: pre-wrap;
  max-height: 10rem;
  overflow-y: auto;
}

.schedule-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-2xl) 0;
}

/* ── Channels ──────────────────────────────────────────────────────── */

.channels-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-block-start: 10vh;
  padding-inline: var(--space-m);
}
.channels-modal[hidden] { display: none; }
.channels-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}
.channels-modal__panel {
  position: relative;
  width: min(32rem, 100%);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-m);
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  animation: channels-modal-in 0.15s ease-out;
}
@keyframes channels-modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.channel-card {
  padding: var(--space-s);
}
.channel-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-s);
}
.channel-card__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-3xs);
  min-width: 0;
}
.channel-card__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.channel-card__meta {
  margin-block-start: var(--space-xs);
  padding-block-start: var(--space-xs);
  border-block-start: 1px solid var(--color-border);
}
.channels-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-s);
  padding: var(--space-2xl) 0;
}
