.button,
.icon-button,
.ghost-button,
.link-button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover {
  border-color: var(--line-strong);
  background: #faf7ef;
}

.button--primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.button--primary:hover {
  background: var(--primary-2);
}

.button--soft {
  background: var(--surface-2);
}

.button--danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.button--danger:hover,
.button--danger:focus-visible {
  border-color: #8f2e25;
  background: #8f2e25;
  color: white;
}

.button--danger:active {
  border-color: #76251f;
  background: #76251f;
  color: white;
}

.button.is-loading,
.icon-button.is-loading {
  pointer-events: none;
  position: relative;
}

.button.is-loading {
  opacity: 0.86;
}

.loading-mark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 22px;
}

.loading-mark i {
  width: 5px;
  height: 14px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.38;
  animation: loading-pulse 820ms ease-in-out infinite;
}

.loading-mark i:nth-child(2) {
  animation-delay: 120ms;
}

.loading-mark i:nth-child(3) {
  animation-delay: 240ms;
}

.icon-button.is-loading .icon {
  display: none;
}

.icon-button.is-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 760ms linear infinite;
}

@keyframes loading-pulse {
  0%,
  100% {
    transform: scaleY(0.62);
    opacity: 0.36;
  }

  50% {
    transform: scaleY(1);
    opacity: 0.95;
  }
}

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

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ghost-button {
  min-height: 28px;
  padding: 5px 8px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(231, 244, 234, 0.88);
  font-size: 12px;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 650;
}

.chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.chip--good,
.status-chip--ok {
  border-color: #bedbc5;
  background: var(--good-bg);
  color: var(--good);
}

.chip--warn,
.status-chip--warn {
  border-color: #ecd2a8;
  background: var(--warning-bg);
  color: var(--warning);
}

.chip--danger {
  border-color: #efc5bd;
  background: var(--danger-bg);
  color: var(--danger);
}

.chip--info,
.chip--work {
  border-color: #bdd2dc;
  background: var(--ai-bg);
  color: var(--ai);
}

.xai-inline {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.65);
  color: currentColor;
  padding: 0;
}

.xai-inline .icon {
  width: 14px;
  height: 14px;
}

.chip--muted,
.status-chip--muted {
  background: var(--surface-2);
  color: var(--muted);
}

.chip--recommendation {
  border-color: rgba(34, 139, 72, 0.28);
  background: var(--good-bg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.chip--memory {
  border-style: dashed;
  font-weight: 800;
}

.chip--stop {
  border-color: rgba(180, 67, 48, 0.32);
  background: var(--danger-bg);
}

.chip--relevance {
  border-color: rgba(181, 107, 20, 0.26);
  background: rgba(181, 107, 20, 0.08);
  color: #765115;
}

.chip--management {
  border-color: rgba(63, 112, 131, 0.24);
  background: rgba(63, 112, 131, 0.09);
  color: var(--ai);
}

.chip--worktype {
  border-color: rgba(80, 91, 75, 0.2);
  background: rgba(240, 238, 231, 0.64);
  color: #4c5948;
}

.session-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid rgba(181, 107, 20, 0.35);
  border-radius: 7px;
  background: rgba(181, 107, 20, 0.1);
  color: var(--warning);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-badge::before {
  content: "";
  width: 16px;
  height: 9px;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0 45%, currentColor 45% 55%, transparent 55%);
  opacity: 0.82;
}

.session-badge.is-on {
  border-color: rgba(14, 107, 87, 0.32);
  background: rgba(14, 107, 87, 0.1);
  color: var(--primary);
}

.session-badge.is-on::before {
  background: currentColor;
  box-shadow: inset -7px 0 0 var(--surface);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  padding: 7px 10px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-weight: 650;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.search-field,
.filters label,
.journal-filters label,
.modal-form label,
.mail-composer label {
  display: grid;
  gap: 5px;
}

.search-field {
  position: relative;
}

.search-field .icon,
.journal-filters label .icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input,
.journal-filters label input[type="search"] {
  padding-left: 36px;
}

.list-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.list-search-row .search-field {
  flex: 1 1 auto;
  min-width: 0;
}

.list-search-row input {
  width: 100%;
}

.list-search-row__count {
  flex: 0 0 auto;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.checkbox-field {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.checkbox-field input {
  width: auto;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  min-height: 24px;
  overflow: hidden;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--nav-2);
  color: white;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.source-badge {
  cursor: pointer;
  text-decoration: none;
}

a.source-badge:hover {
  filter: brightness(0.96);
}

a.source-badge:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.source-badge--light {
  background: var(--surface-2);
  color: var(--primary);
}

.source-badge--origin {
  background: #edf2f6;
  color: #4e6474;
  box-shadow: inset 0 0 0 1px rgba(78, 100, 116, 0.18);
}

.avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 750;
}

.avatar--small {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.assistant-avatar {
  width: 42px;
  height: 42px;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eef7f3;
  box-shadow: inset 0 0 0 1px rgba(6, 47, 40, 0.12), 0 5px 14px rgba(6, 47, 40, 0.12);
  overflow: hidden;
}

.assistant-avatar--small {
  width: 34px;
  height: 34px;
}

.assistant-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.assistant-avatar__plate {
  fill: var(--surface);
}

.assistant-avatar__ring {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4.6;
}

.assistant-avatar__body,
.assistant-avatar__eye {
  fill: var(--primary);
}

.assistant-avatar__face {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.assistant-avatar__face {
  stroke: var(--primary);
  stroke-width: 2.25;
}

.assistant-avatar__question {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.9;
}

.assistant-avatar__question-dot {
  fill: var(--primary);
}
