:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  --color-text: #101828;
  --color-text-muted: #475467;
  --color-text-subtle: #6b7280;
  --color-text-strong: #1f2937;
  --color-text-inverse: #ffffff;
  --color-bg: #f5f7fb;
  --color-bg-gradient-top: #f5f7fb;
  --color-bg-gradient-bottom: #e3e9f8;
  --color-surface: #ffffff;
  --color-surface-muted: #f3f4ff;
  --color-surface-soft: #f8fafc;
  --color-surface-elevated: #f9fafb;
  --color-primary: #1d4ed8;
  --color-primary-strong: #1e3a8a;
  --color-primary-soft: #e0e7ff;
  --color-primary-surface: #eef2ff;
  --color-success: #15803d;
  --color-success-soft: #ecfdf3;
  --color-success-surface: #dcfce7;
  --color-warning: #b45309;
  --color-warning-soft: #fffbeb;
  --color-warning-surface: #fef3c7;
  --color-danger: #b91c1c;
  --color-danger-surface: #fee2e2;
  --color-danger-soft: #fef2f2;
  --color-info: #0369a1;
  --color-info-surface: #e0f2fe;
  --color-accent-purple: #5b21b6;
  --color-code-bg: #0f172a;
  --color-code-text: #e2e8f0;
  --color-border-soft: #cbd5f5;
  background-color: var(--color-bg);
  color: var(--color-text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --color-text: #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-text-subtle: #72829c;
  --color-text-strong: #f8fafc;
  --color-text-inverse: #0b1120;
  --color-bg: #0b1120;
  --color-bg-gradient-top: #0b1120;
  --color-bg-gradient-bottom: #132238;
  --color-surface: #15263d;
  --color-surface-muted: #132238;
  --color-surface-soft: #182b45;
  --color-surface-elevated: #1b2f4d;
  --color-primary: #60a5fa;
  --color-primary-strong: #93c5fd;
  --color-primary-soft: rgba(96, 165, 250, 0.16);
  --color-primary-surface: rgba(37, 99, 235, 0.18);
  --color-success: #4ade80;
  --color-success-soft: rgba(74, 222, 128, 0.12);
  --color-success-surface: rgba(22, 163, 74, 0.2);
  --color-warning: #facc15;
  --color-warning-soft: rgba(250, 204, 21, 0.12);
  --color-warning-surface: rgba(202, 138, 4, 0.2);
  --color-danger: #f87171;
  --color-danger-surface: rgba(248, 113, 113, 0.22);
  --color-danger-soft: rgba(248, 113, 113, 0.12);
  --color-info: #38bdf8;
  --color-info-surface: rgba(14, 165, 233, 0.25);
  --color-accent-purple: #c4b5fd;
  --color-code-bg: #0b1222;
  --color-code-text: #f8fafc;
  --color-border-soft: rgba(148, 163, 184, 0.32);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(
    180deg,
    var(--color-bg-gradient-top) 0%,
    var(--color-bg-gradient-bottom) 100%
  );
  color: var(--color-text);
  color-scheme: inherit;
}

button,
input,
select,
textarea {
  color: var(--color-text);
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
  outline: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-subtle);
  opacity: 1;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
  color: var(--color-text-subtle);
}

a {
  color: var(--color-primary);
  text-decoration-color: rgba(29, 78, 216, 0.4);
}

a:hover {
  color: var(--color-primary-strong);
  text-decoration-color: rgba(30, 58, 138, 0.6);
}

button:focus-visible,
.btn:focus-visible,
.chat-list__item:focus-visible,
.chat-list__menu-trigger:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.chat-page .app-container {
  height: 100vh;
  overflow: hidden;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: clamp(0.55rem, 1.4vw, 0.85rem) clamp(0.75rem, 2vw, 1.25rem);
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

:root[data-theme="dark"] .top-bar {
  box-shadow: 0 1px 6px rgba(2, 6, 23, 0.55);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.top-bar--cloud-warning {
  background: var(--color-danger-surface);
  border-bottom: 2px solid var(--color-danger);
}

.top-bar--cloud-warning .top-bar__title {
  color: var(--color-danger);
  font-weight: 700;
}

:root[data-theme="dark"] .top-bar--cloud-warning {
  background: rgba(248, 113, 113, 0.15);
  border-bottom: 2px solid var(--color-danger);
}

:root[data-theme="dark"] .top-bar--cloud-warning .top-bar__title {
  color: var(--color-danger);
}

:root[data-theme="dark"] .top-bar__cloud-warning {
  background: rgba(248, 113, 113, 0.2);
  color: var(--color-danger);
}

.top-bar__section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1 1 auto;
}

.top-bar__logo {
  width: clamp(28px, 2.8vw, 38px);
  height: auto;
  display: inline-block;
  border-radius: 8px;
}

.top-bar__title {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-bar__cloud-warning {
  font-size: 0.75em;
  font-weight: 500;
  color: var(--color-danger);
  background: var(--color-danger-soft);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  white-space: nowrap;
  opacity: 0.9;
  flex-shrink: 0;
}

.top-bar__cloud-warning--hidden {
  display: none;
}

@media (max-width: 480px) {
  .top-bar__cloud-warning {
    display: none;
  }
}

.top-bar__mobile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-soft);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.top-bar__mobile-toggle:hover,
.top-bar__mobile-toggle:focus-visible {
  transform: translateY(-1px);
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.35);
  outline: none;
}

.top-bar__mobile-toggle-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.top-bar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.top-bar__menu {
  display: none;
  position: relative;
  flex: 0 0 auto;
  align-items: center;
}

.top-bar__menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.7rem;
  background: var(--color-surface-soft);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.top-bar__menu-trigger:hover,
.top-bar__menu-trigger:focus-visible {
  transform: translateY(-1px);
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.35);
  outline: none;
}

.top-bar__menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 160px;
  padding: 0.3rem 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: 0.65rem;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
  z-index: 12;
}

:root[data-theme="dark"] .top-bar__menu-dropdown {
  box-shadow: 0 24px 40px rgba(2, 6, 23, 0.55);
}

.top-bar__menu-item {
  display: block;
  width: 100%;
  padding: 0.55rem 0.95rem;
  background: transparent;
  color: var(--color-text);
  text-decoration: none;
  text-align: left;
  font: inherit;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.top-bar__menu-item:hover,
.top-bar__menu-item:focus-visible {
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
  outline: none;
}

.top-bar__menu-form {
  margin: 0;
}

.top-bar__menu[data-open="true"] .top-bar__menu-dropdown {
  display: block;
}

@media (max-width: 959px) {
  .top-bar {
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
  }

  .top-bar__section {
    gap: 0.45rem;
  }

  .top-bar__title {
    font-size: 1.05rem;
  }

  .top-bar__logo {
    width: 30px;
  }

  .top-bar__actions {
    display: none;
  }

  .top-bar__menu {
    display: inline-flex;
  }
}

@media (min-width: 960px) {
  .top-bar__mobile-toggle {
    display: none;
  }

  .top-bar__logo {
    width: 34px;
  }

  .top-bar__menu {
    display: none;
  }
}

.user-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
  font-weight: 500;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(0.9rem, 2vw, 1.4rem);
  padding: clamp(0.75rem, 2.5vw, 1.75rem);
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
}

aside,
main {
  background: var(--color-surface);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  padding: clamp(1rem, 2.5vw, 1.25rem);
}

.chat-layout > aside,
.chat-layout > main {
  flex: 1 1 auto;
  min-height: 0;
  box-sizing: border-box;
  padding: clamp(1rem, 2.5vw, 1.25rem);
}

.chat-layout > aside {
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.chat-layout[data-mobile-view="list"] > aside {
  display: flex;
}

.chat-layout > main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

:root[data-theme="dark"] .chat-layout > aside,
:root[data-theme="dark"] .chat-layout > main {
  box-shadow: 0 20px 38px rgba(2, 6, 23, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.chat-layout[data-mobile-view="list"] > main {
  display: none;
}

@media (min-width: 960px) {
  .chat-layout {
    display: grid;
    grid-template-columns: clamp(240px, 28vw, 320px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 1.2rem;
    padding: 1.25rem 1.75rem 1.5rem;
  }

  .chat-layout > aside,
  .chat-layout[data-mobile-view="list"] > aside {
    display: flex;
  }

  .chat-layout > main,
  .chat-layout[data-mobile-view="list"] > main {
    display: flex;
  }

}

.chat-detail {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.chat-list__header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.chat-list__header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.chat-list__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  border: 1px solid var(--color-border-soft);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.chat-list__close:hover,
.chat-list__close:focus-visible {
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.35);
  outline: none;
}

@media (max-width: 959px) {
  .chat-list__header {
    grid-template-columns: auto 1fr auto;
  }

  .chat-list__close {
    display: inline-flex;
  }

  .chat-list__stats {
    grid-template-columns: 1fr;
  }

  .message-list {
    padding-right: 0;
  }
}

@media (min-width: 960px) {
  .chat-list__header {
    grid-template-columns: 1fr auto;
  }
}

.chat-list__search {
  margin-bottom: 0.75rem;
}

.chat-list__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-soft);
}

.chat-list__stats-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.chat-list__stats-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
}

.chat-list__stats-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.chat-list__search-form {
  display: flex;
  width: 100%;
}

.chat-list__search-field {
  position: relative;
  flex: 1;
}

.chat-list__search-field input[type="search"] {
  width: 100%;
  padding: 0.55rem 2.1rem 0.55rem 0.75rem;
  border-radius: 0.6rem;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-soft);
  color: inherit;
  font-size: 0.94rem;
  box-sizing: border-box;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.chat-list__search-field input[type="search"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.chat-list__search-clear {
  position: absolute;
  top: 50%;
  right: 0.6rem;
  transform: translateY(-50%);
  width: 1.4rem;
  height: 1.4rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.2s ease, background 0.2s ease;
}

.chat-list__search-clear:hover {
  color: var(--color-primary);
  background: rgba(29, 78, 216, 0.08);
}

.chat-list__search-clear:focus-visible {
  outline-offset: 4px;
}

.chat-list__search-field input[type="search"]:focus + .chat-list__search-clear,
.chat-list__search-field input[type="search"]:not(:placeholder-shown) + .chat-list__search-clear {
  opacity: 1;
  pointer-events: auto;
}

.chat-list {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-list__body {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.9rem;
  box-sizing: border-box;
  scrollbar-gutter: stable both-edges;
}

.chat-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chat-list__group {
  margin-top: 0.75rem;
}

.chat-list__group:first-of-type {
  margin-top: 0.45rem;
}

.chat-list__group-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-subtle);
  margin-bottom: 0.3rem;
}

.chat-list__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 0.45rem;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease, color 0.2s ease;
  background: var(--color-surface-soft);
  color: var(--color-text);
  width: 100%;
}

.chat-list__row:nth-child(even):not(.chat-list__row--active) {
  background: var(--color-surface-muted);
}

.chat-list__row:hover:not(.chat-list__row--active) {
  background: var(--color-primary-surface);
}

.chat-list__row--active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: inset 0 0 0 1px var(--color-primary-strong);
}

.chat-list__row--active .chat-list__menu-trigger {
  color: var(--color-text-inverse);
}

.chat-list__item {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
}

.chat-list__item:hover {
  color: inherit;
}

.chat-list__item--active {
  font-weight: 600;
}

.chat-list__row--active .chat-list__item {
  color: inherit;
}

.chat-list__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  line-height: 1.2;
}

.chat-list__empty {
  margin: 1.5rem 0;
  color: var(--color-primary);
  text-align: center;
}

.chat-list__menu-container {
  position: relative;
  display: flex;
  align-items: center;
}


.chat-list__menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chat-list__menu-trigger:hover,
.chat-list__menu-container[data-open="true"] .chat-list__menu-trigger {
  background: rgba(255, 255, 255, 0.25);
  color: var(--color-primary);
}

.chat-list__row--active .chat-list__menu-container[data-open="true"] .chat-list__menu-trigger,
.chat-list__row--active .chat-list__menu-trigger:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--color-text-inverse);
}

.chat-list__menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  min-width: 140px;
  padding: 0.4rem 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: 0.5rem;
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.16);
  z-index: 5;
}

:root[data-theme="dark"] .chat-list__menu {
  box-shadow: 0 20px 34px rgba(2, 6, 23, 0.5);
}

.chat-list__menu-container[data-open="true"] .chat-list__menu {
  display: block;
}

.chat-list__menu-item {
  display: block;
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  color: var(--color-danger);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.chat-list__menu-item:hover {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.chat-detail__header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: clamp(0.9rem, 2vw, 1.2rem);
}

.chat-detail__title {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  min-width: 0;
}

.chat-detail__title-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--color-primary);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
}

.chat-detail__title-status[hidden] {
  display: none !important;
}

.chat-detail__title-status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
}

.chat-detail__title-status--active {
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.22);
  animation: indicatorPulse 1.4s ease-in-out infinite;
}

.chat-detail__title-status--active::before {
  animation: indicatorPulse 1.4s ease-in-out infinite;
}

.chat-detail__sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-text-subtle);
  font-size: 0.88rem;
}

.chat-detail__meta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.chat-detail__meta-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chat-detail__meta-divider {
  color: currentColor;
}

.chat-detail__header-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.3rem;
}

.chat-detail__goal-run-toggle {
  position: relative;
  padding-inline: 0.9rem;
  font-size: 0.82rem;
}

.chat-detail__goal-run-toggle[data-goal-run-open="true"] {
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.12);
}

.chat-detail__goal-run-toggle[data-goal-run-has-updates="true"]::after {
  content: "";
  position: absolute;
  top: 0.4rem;
  right: 0.55rem;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-surface);
}

@media (max-width: 720px) {
  .chat-detail__sub {
    font-size: 0.8rem;
    gap: 0.3rem;
  }

  .chat-detail__meta-group--created {
    display: none;
  }

  .chat-detail__header-actions {
    justify-content: flex-start;
  }

  .chat-detail__goal-run-toggle {
    width: 100%;
    justify-content: center;
  }
}

.chat-detail__empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  text-align: center;
  color: var(--color-text-subtle);
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.85rem;
  background: var(--color-surface-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
  position: relative;
}

.message--user {
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.25);
}

.message--assistant {
  background: var(--color-success-soft);
  border-color: rgba(21, 128, 61, 0.25);
}

.message--tool-error {
  background: var(--color-danger-soft);
  border-color: rgba(185, 28, 28, 0.35);
}

.message--tool-error .message__meta-label {
  color: var(--color-danger);
}

.message__meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding-right: 0;
}

.message__thinking-anchor {
  display: none;
}

.message__content p {
  margin: 0 0 0.75rem;
}

.message__content {
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-word;
  padding-right: 2.5rem;
}

.message__content > :first-child {
  margin-top: 0;
}

.message__content > :last-child {
  margin-bottom: 0;
}

.message__content pre {
  margin: 0.6rem 0;
  padding: 0.7rem;
  border-radius: 0.75rem;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.5;
  border: 1px solid rgba(148, 163, 184, 0.35);
  position: relative;
  padding-right: 2.75rem;
}

.message__tool-error {
  margin: 0.6rem 0;
  padding: 0.6rem 0.85rem;
  border-radius: 0.75rem;
  background: rgba(185, 28, 28, 0.1);
  color: var(--color-text-strong);
  white-space: pre-wrap;
}

.message__content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.message__content pre > code.code-highlight {
  display: block;
  white-space: pre;
}

.message__content .code-highlight {
  color: var(--color-code-text);
}

.message__content .code-highlight .c,
.message__content .code-highlight .cm,
.message__content .code-highlight .c1,
.message__content .code-highlight .cs {
  color: #94a3b8;
  font-style: italic;
}

.message__content .code-highlight .k,
.message__content .code-highlight .kc,
.message__content .code-highlight .kd,
.message__content .code-highlight .kn,
.message__content .code-highlight .kr,
.message__content .code-highlight .kt {
  color: #38bdf8;
  font-weight: 600;
}

.message__content .code-highlight .o,
.message__content .code-highlight .ow {
  color: #f472b6;
  font-weight: 600;
}

.message__content .code-highlight .s,
.message__content .code-highlight .sa,
.message__content .code-highlight .sb,
.message__content .code-highlight .sc,
.message__content .code-highlight .sd,
.message__content .code-highlight .s1,
.message__content .code-highlight .s2,
.message__content .code-highlight .sh,
.message__content .code-highlight .si,
.message__content .code-highlight .sr,
.message__content .code-highlight .ss,
.message__content .code-highlight .sx {
  color: #facc15;
}

.message__content .code-highlight .m,
.message__content .code-highlight .mb,
.message__content .code-highlight .mf,
.message__content .code-highlight .mh,
.message__content .code-highlight .mi,
.message__content .code-highlight .mo,
.message__content .code-highlight .il {
  color: #f97316;
}

.message__content .code-highlight .nf,
.message__content .code-highlight .na,
.message__content .code-highlight .nc,
.message__content .code-highlight .nn {
  color: #c084fc;
}

.message__content .code-highlight .nt {
  color: #38bdf8;
}

.message__content .code-highlight .p,
.message__content .code-highlight .w {
  color: var(--color-code-text);
}

.message__content .code-highlight .bp,
.message__content .code-highlight .nb,
.message__content .code-highlight .ni,
.message__content .code-highlight .nl,
.message__content .code-highlight .nv,
.message__content .code-highlight .py {
  color: var(--color-code-text);
}

.message__content .code-highlight .err {
  color: #ef4444;
  background: rgba(248, 113, 113, 0.2);
  border-radius: 0.25rem;
  padding: 0 0.1rem;
}

.message__content .code-highlight .gd {
  background: rgba(248, 113, 113, 0.14);
}

.message__content .code-highlight .gi {
  background: rgba(16, 185, 129, 0.14);
}

.message__content code {
  background: rgba(15, 23, 42, 0.08);
  color: var(--color-text-strong);
  padding: 0.08rem 0.3rem;
  border-radius: 0.35rem;
  font-size: 0.88em;
}

.message__content code.copyable-path {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  vertical-align: baseline;
  line-height: 1.2;
  background: rgba(29, 78, 216, 0.12);
  color: var(--color-primary-strong);
  border: 1px solid rgba(29, 78, 216, 0.25);
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.12);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  padding: 0.1rem 0.4rem;
}

.message__content code.copyable-path:hover,
.message__content code.copyable-path:focus-visible {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(29, 78, 216, 0.45);
  color: var(--color-primary-strong);
  box-shadow: 0 10px 18px rgba(29, 78, 216, 0.18);
  outline: none;
}

.message__content code.copyable-path::after {
  content: attr(data-copy-tooltip);
  position: absolute;
  left: 50%;
  transform: translate(-50%, calc(-100% - 0.35rem));
  background: var(--color-surface);
  color: var(--color-text-strong);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 0.45rem;
  padding: 0.2rem 0.45rem;
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5;
}

.message__content code.copyable-path:hover::after,
.message__content code.copyable-path:focus-visible::after,
.message__content code.copyable-path[data-copy-state="copied"]::after,
.message__content code.copyable-path[data-copy-state="error"]::after {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 0.55rem));
}

.message__content code.copyable-path[data-copy-state="copied"]::after {
  background: var(--color-success);
  color: var(--color-text-inverse);
  border-color: transparent;
}

.message__content code.copyable-path[data-copy-state="error"]::after {
  background: var(--color-danger);
  color: var(--color-text-inverse);
  border-color: transparent;
}

.message__content ul,
.message__content ol {
  margin: 0.5rem 0 0.85rem 1.25rem;
  padding-left: 1.25rem;
}

.message__content li {
  margin: 0.25rem 0;
}

.message__content blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 0.85rem;
  border-left: 3px solid rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.04);
  border-radius: 0.5rem;
  color: var(--color-text-muted);
}

.message__content hr {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.4);
  margin: 1.5rem 0;
}

.message__content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.85rem 0;
  font-size: 0.95rem;
}

.message__content th,
.message__content td {
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 0.45rem 0.75rem;
  text-align: left;
}

.message__content thead {
  background: rgba(148, 163, 184, 0.2);
}

.message__content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.75rem 0;
  border-radius: 0.75rem;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.15);
}

.message__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding-right: 2.5rem;
}

.message__stat {
  display: inline-flex;
  align-items: center;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  border: 1px solid rgba(148, 163, 184, 0.35);
  line-height: 1.2;
}

.message__stat:hover {
  background: rgba(148, 163, 184, 0.32);
}

.message__stat--ctx {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.message__stat--ctx-warning {
  background: var(--color-warning-soft);
  border-color: rgba(180, 83, 9, 0.55);
  color: var(--color-warning);
}

.message__stat--ctx-critical {
  background: var(--color-danger-soft);
  border-color: rgba(185, 28, 28, 0.6);
  color: var(--color-danger);
}

.message__stat--ctx-critical-animated {
  animation: messageCtxPulse 1.25s ease-in-out infinite;
}

@keyframes messageCtxPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(185, 28, 28, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(185, 28, 28, 0);
  }
}

.copy-button {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.18);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  padding: 0;
}

.copy-button:hover,
.copy-button:focus-visible {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.copy-button[data-state="copied"] {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-text-inverse);
}

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

.copy-button__icon {
  font-size: 0.85rem;
  line-height: 1;
}

/* Tool pills for inline tool call display */
.message__tool-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--color-surface-soft);
  border-radius: 0.5rem;
  border: 1px solid var(--color-border-soft);
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.tool-pill:hover,
.tool-pill:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
  background: var(--color-surface-soft);
  color: var(--color-text);
  outline: none;
}

.tool-pill__icon {
  font-size: 0.8rem;
  opacity: 0.8;
}

.tool-pill__name {
  font-weight: 600;
  text-transform: capitalize;
}

.tool-pill__status {
  font-size: 0.65rem;
  opacity: 0.8;
  font-style: italic;
  color: var(--color-text-muted);
}

/* Expandable tool pills */
.tool-pill--expandable {
  border: 1px solid var(--color-border-soft);
  border-radius: 0.85rem;
  margin: 0.25rem 0;
  background: var(--color-surface-soft);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s ease;
}

.tool-pill--expandable:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tool-pill__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem;
  cursor: pointer;
  user-select: none;
  border-radius: 0.85rem 0.85rem 0 0;
  transition: background-color 0.2s ease;
}

.tool-pill__header:hover {
  background: var(--color-surface);
}

.tool-pill__toggle {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 0.7rem;
  opacity: 0.6;
}

.tool-pill--expanded .tool-pill__toggle {
  transform: rotate(180deg);
}

.tool-pill__content {
  display: none;
  padding: 0 0.75rem 0.75rem;
  background: var(--color-surface-soft);
  border-radius: 0 0 0.85rem 0.85rem;
}

.tool-pill--expanded .tool-pill__content {
  display: block;
}

.tool-pill__details {
  margin: 0.5rem 0;
}

.tool-pill__details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.35rem;
  padding: 0.5rem 0;
}

.tool-pill__details pre {
  margin: 0;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface-elevated);
  color: var(--color-text);
  white-space: pre-wrap;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.4;
  border: 1px solid var(--color-border-soft);
}

.tool-pill__error {
  margin: 0.5rem 0;
  color: var(--color-danger);
  font-weight: 600;
  padding: 0.75rem;
  background: var(--color-danger-surface);
  border-radius: 0.75rem;
  border: 1px solid var(--color-danger);
}

.tool-pill__duration {
  font-size: 0.65rem;
  opacity: 0.8;
  font-style: italic;
  color: var(--color-text-muted);
}



.copy-button[data-state="copied"] .copy-button__icon::before {
  content: "✓";
  font-weight: 600;
}

.copy-button[data-state="error"] .copy-button__icon::before {
  content: "!";
  font-weight: 600;
}

.copy-button[data-state]:not([data-state="copied"]):not([data-state="error"]) .copy-button__icon::before,
.copy-button:not([data-state]) .copy-button__icon::before {
  content: "⧉";
}

.message__copy-button {
  position: absolute;
}

.code-block__copy-button {
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  color: var(--color-code-text);
}

.message__content pre .code-block__copy-button:hover,
.message__content pre .code-block__copy-button:focus-visible {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.55);
  color: var(--color-code-bg);
}

.message-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  flex: 1 1 auto;
  min-width: 0;
}

.message-form select,
.message-form textarea,
input[type="email"],
input[type="password"] {
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: var(--color-surface);
}

.message-form textarea {
  resize: vertical;
  min-height: clamp(80px, 20vh, 140px);
}

.chat-detail__composer {
  position: relative;
  margin-top: clamp(0.9rem, 2.2vw, 1.25rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-auto-rows: auto;
  row-gap: clamp(0.75rem, 2vw, 1rem);
  column-gap: clamp(0.75rem, 2vw, 1rem);
  align-items: end;
}

.message-form {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: clamp(0.6rem, 1.8vw, 0.9rem);
}

.composer-controls {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 0.75rem);
  flex-wrap: wrap;
  width: 100%;
}

.composer-controls__spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.composer-controls__attachments {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  position: relative;
}

.composer-controls__send {
  flex: 0 0 auto;
}

.document-drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.model-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.65rem;
  background: var(--color-surface);
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  max-width: 100%;
  cursor: pointer;
}

.model-selector:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.model-selector__text {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.model-selector__current {
  font-weight: 600;
  color: var(--color-text-strong);
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-selector select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  background: transparent;
}

.document-drawer__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-strong);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.document-drawer__toggle:hover,
.document-drawer__toggle:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.document-drawer__icon {
  font-size: 1rem;
}

.document-drawer__label {
  font-size: 0.85rem;
}

.document-drawer__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 0.35rem;
}

.document-drawer__panel {
  position: absolute;
  bottom: calc(100% + 0.6rem);
  right: 0;
  width: min(260px, 80vw);
  max-height: 480px;
  border-radius: 1rem;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.document-drawer[data-open="true"] .document-drawer__panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

.document-drawer__header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.document-drawer__header p {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.document-drawer__close {
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.document-drawer__upload {
  position: relative;
}

.document-drawer__file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.document-drawer__upload-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 0.75rem;
  border: 1px dashed var(--color-primary);
  background: var(--color-primary-surface);
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.document-drawer__upload-label:hover,
.document-drawer__upload-label:focus-visible {
  background: var(--color-primary-soft);
  transform: translateY(-1px);
}

.document-drawer__upload-icon {
  font-size: 1rem;
}

.document-drawer__status .alert {
  margin: 0;
}

.document-drawer__progress {
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.document-progress {
  border: 1px solid var(--color-border-soft);
  border-radius: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--color-surface-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.document-progress__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.document-progress__primary {
  flex: 1;
  font-weight: 600;
  color: var(--color-text-strong);
}

.document-progress__secondary {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.document-progress__bar {
  position: relative;
  width: 100%;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--color-primary-surface);
  overflow: hidden;
}

.document-progress__bar-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--color-primary);
  transition: width 0.2s ease-out;
}

.document-progress[data-state="error"] {
  border-color: var(--color-danger);
}

.document-progress[data-state="error"] .document-progress__primary {
  color: var(--color-danger);
}

.document-drawer__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.document-drawer__item {
  border: 1px solid var(--color-border-soft);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--color-surface-soft);
}

.document-drawer__item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.document-drawer__item-title {
  flex: 1;
  font-weight: 600;
  color: var(--color-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-drawer__item-size {
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.document-drawer__item-actions {
  display: flex;
  justify-content: flex-end;
}

.document-drawer__delete {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.document-drawer__delete:hover,
.document-drawer__delete:focus-visible {
  text-decoration: underline;
}

.document-drawer__empty {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

@media (max-width: 900px) {
  .document-drawer {
    position: static;
    align-items: center;
    gap: 0.5rem;
  }

  .document-drawer__panel {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0 auto;
    width: min(480px, 100%);
    max-height: 75vh;
    border-radius: 1.2rem 1.2rem 0 0;
    transform: translateY(10px);
    z-index: 1400;
  }

  .chat-detail__composer {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 0.75rem;
  }

  .composer-controls {
    gap: 0.6rem;
  }
}

@media (max-width: 720px) {
  .chat-detail__composer {
    row-gap: 0.65rem;
  }

  .message-form {
    gap: 0.55rem;
  }

  .message-form__field {
    gap: 0.25rem;
  }

  .message-form textarea {
    min-height: clamp(70px, 24vh, 110px);
  }

  .composer-controls {
    gap: 0.45rem;
  }

  .model-selector {
    padding: 0.25rem 0.45rem;
    border-radius: 0.55rem;
    gap: 0.35rem;
  }

  .model-selector__text {
    display: none;
  }

  .model-selector__current {
    max-width: 10ch;
  }

  .document-drawer__toggle {
    padding: 0.32rem 0.5rem;
    font-size: 0.76rem;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.12);
  }

  .document-drawer__label {
    display: none;
  }

  .document-drawer__count {
    min-width: 1.35rem;
    height: 1.35rem;
    font-size: 0.7rem;
  }

  .message-form__label-text {
    display: none;
  }
}

body.context-overlay-open,
body.thinking-overlay-open {
  overflow: hidden;
}

.context-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.context-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.context-overlay__dialog {
  position: relative;
  width: min(900px, 90vw);
  max-height: 90vh;
  border-radius: 1.25rem;
  background: var(--color-surface);
  box-shadow: 0 40px 120px rgba(15, 23, 42, 0.45);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
  box-sizing: border-box;
}

.context-overlay__dialog:focus {
  outline: none;
}

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

.context-overlay__header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.context-overlay__header p {
  margin: 0.35rem 0 0;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}

.context-overlay__close {
  border: none;
  background: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-text-muted);
}

.context-overlay__body {
  overflow-y: auto;
  padding-right: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.thinking-overlay__dialog {
  width: min(1040px, 94vw);
  max-height: 92vh;
}

.thinking-overlay__header {
  align-items: center;
}

.thinking-overlay__heading {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.thinking-overlay__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.thinking-overlay__subtitle {
  margin: 0;
  color: var(--color-text-subtle);
  font-size: 0.9rem;
}

.thinking-overlay__meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.thinking-overlay__status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}

.thinking-overlay__status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.85;
  animation: thinkingDotPulse 1.2s ease-in-out infinite;
}

.thinking-overlay__status[data-state="idle"] {
  color: var(--color-text-muted);
}

.thinking-overlay__status[data-state="idle"]::before {
  opacity: 0.35;
  animation: none;
}

.thinking-overlay__body {
  padding-right: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.thinking-overlay__content {
  margin: 0;
  padding: 1.1rem 1.25rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--color-surface-muted), var(--color-surface));
  color: var(--color-text);
  border: 1px solid var(--color-border-soft);
  border-left: 4px solid var(--color-primary);
  box-shadow: 0 16px 28px rgba(15, 23, 42, 0.1);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: var(
    --font-family-mono,
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    "Courier New",
    monospace
  );
}

.thinking-overlay__content:focus {
  outline: none;
}

.thinking-overlay__content::-webkit-scrollbar {
  width: 0.5rem;
}

.thinking-overlay__content::-webkit-scrollbar-thumb {
  background: rgba(79, 70, 229, 0.35);
  border-radius: 999px;
}

.thinking-overlay__content::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 720px) {
  .thinking-overlay__content {
    max-height: 55vh;
    font-size: 0.88rem;
  }
}

.context-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.context-section h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.context-section__block {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-soft);
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.4;
}

.context-section--empty {
  padding: 1.25rem;
  border-radius: 0.85rem;
  background: var(--color-surface-soft);
  border: 1px dashed var(--color-border-soft);
  text-align: center;
  color: var(--color-text-subtle);
}

.context-document-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.context-document__title {
  font-weight: 600;
  color: var(--color-text-strong);
}

.context-document__summary {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.context-tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.context-tool {
  padding: 1rem;
  border-radius: 0.85rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-soft);
}

.context-tool__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.context-tool__error {
  margin: 0 0 0.75rem;
  color: var(--color-danger);
  font-weight: 600;
}

.context-tool__details {
  margin: 0.5rem 0;
}

.context-tool__details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.context-tool__details pre {
  margin: 0;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface-elevated);
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.context-document__summary--empty {
  color: var(--color-text-subtle);
  font-style: italic;
}



.context-chunk-group {
  border: 1px solid var(--color-border-soft);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  background: var(--color-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.context-chunk-group__header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.context-chunk-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.context-chunk {
  border: 1px solid var(--color-border-soft);
  border-radius: 0.85rem;
  background: var(--color-surface);
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.context-chunk__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.context-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-soft);
}

.context-chip--score {
  background: var(--color-primary-surface);
  color: var(--color-primary);
  border-color: rgba(29, 78, 216, 0.25);
}

.context-chip--score-high {
  background: var(--color-success-surface);
  color: var(--color-success);
  border-color: rgba(21, 128, 61, 0.3);
}

.context-chip--score-medium {
  background: var(--color-warning-surface);
  color: var(--color-warning);
  border-color: rgba(180, 83, 9, 0.3);
}

.context-chip--score-low {
  background: var(--color-danger-surface);
  color: var(--color-danger);
  border-color: rgba(185, 28, 28, 0.3);
}

.context-chip--muted {
  color: var(--color-text-subtle);
}

.context-chunk__summary {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.context-chunk__excerpt {
  margin: 0;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border-soft);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}

.message__meta-label {
  font-weight: 600;
}

.message__context-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  background: var(--color-primary-surface);
  color: var(--color-primary);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.message__tools-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: none;
  border-radius: 999px;
  background: var(--color-surface-soft);
  color: var(--color-text-strong);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.message__context-button:hover,
.message__context-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.2);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  outline: none;
}

.message__tools-button:hover,
.message__tools-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.2);
  background: var(--color-surface-elevated);
  color: var(--color-text-strong);
  outline: none;
}

@media (max-width: 640px) {
  .context-overlay__dialog {
    width: min(96vw, 640px);
    max-height: 88vh;
    padding: 1.25rem;
  }

  .context-chip {
    font-size: 0.7rem;
  }
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
  line-height: 1;
}

.btn--compact {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn.primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-strong));
  color: var(--color-text-inverse);
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.28);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 22px rgba(29, 78, 216, 0.32);
}

.btn.secondary {
  background: var(--color-primary-soft);
  color: var(--color-primary-strong);
  border-color: rgba(29, 78, 216, 0.35);
}

.btn.secondary:hover {
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.45);
}

.btn.tertiary {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid rgba(29, 78, 216, 0.3);
}

.btn.tertiary:hover {
  background: rgba(29, 78, 216, 0.08);
}

.btn.is-success {
  background: var(--color-success-soft);
  color: var(--color-success);
  border-color: rgba(21, 128, 61, 0.35);
}

.btn.is-success:hover {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.btn.is-error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: rgba(185, 28, 28, 0.35);
}

.btn.is-error:hover {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.top-bar__actions .btn {
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
}

.settings-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 2rem;
  padding: 1.5rem 2rem 2rem;
}

@media (max-width: 960px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    margin-bottom: 1rem;
  }
}

@media (max-width: 900px) {
  .tool-server-grid,
  .tool-definition-grid {
    grid-template-columns: 1fr;
  }
}

.settings-sidebar {
  background: var(--color-surface);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  padding: 1.5rem;
  height: fit-content;
}

.settings-nav {
  display: block;
}

.settings-nav__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-nav__entry {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem;
  border-radius: 0.9rem;
  background: var(--color-surface-soft);
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.settings-nav__entry:hover {
  border-color: rgba(29, 78, 216, 0.35);
  background: var(--color-primary-surface);
}

.settings-nav__entry.is-active {
  border-color: var(--color-primary);
  background: var(--color-primary-surface);
  box-shadow: 0 10px 25px rgba(29, 78, 216, 0.15);
}

.settings-nav__entry.is-dragging {
  opacity: 0.6;
}

.settings-nav__entry.is-drop-target {
  border-color: var(--color-primary);
}

.settings-nav__handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
  font-size: 1rem;
  color: var(--color-text-muted);
  cursor: grab;
}

.settings-nav[data-reordering="true"] .settings-nav__handle {
  cursor: grabbing;
}

.settings-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  text-decoration: none;
  color: inherit;
}

.settings-nav__label {
  font-weight: 600;
  color: var(--color-text-strong);
}

.settings-nav__description {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.tool-server-grid,
.tool-definition-grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 1.5rem;
}

.tool-server-card,
.tool-definition-card {
  background: var(--color-surface-soft);
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.tool-server-list,
.tool-definition-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tool-server-entry,
.tool-definition-entry {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  background: var(--color-surface-soft);
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.05);
}

.tool-server-entry__header,
.tool-definition-entry__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tool-assignment {
  border: 1px dashed rgba(15, 23, 42, 0.12);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.tool-assignment h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.tool-assignment .checkbox-field {
  margin-bottom: 0.35rem;
}

.settings-main {
  background: var(--color-surface);
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

:root[data-theme="dark"] .settings-main {
  box-shadow: 0 22px 46px rgba(2, 6, 23, 0.55);
}

.settings-module {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 1rem;
  padding: 1.5rem;
  background: var(--color-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

:root[data-theme="dark"] .settings-module {
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 20px 36px rgba(2, 6, 23, 0.45);
}

.theme-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.theme-preview__swatch {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 110px;
  padding: 1rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.theme-preview__swatch span {
  font-weight: 600;
  font-size: 0.95rem;
}

.theme-preview__swatch--light {
  background: linear-gradient(150deg, #f5f7fb 0%, #e3e9f8 100%);
  color: #1f2937;
}

.theme-preview__swatch--dark {
  background: linear-gradient(150deg, #0b1120 0%, #1c2f4a 100%);
  color: #f8fafc;
}

.theme-preview__swatch:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.12);
}

.theme-preview__swatch.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.32), 0 18px 32px rgba(29, 78, 216, 0.25);
  transform: translateY(-3px);
}

:root[data-theme="dark"] .theme-preview__swatch:hover {
  box-shadow: 0 18px 34px rgba(2, 6, 23, 0.55);
}

:root[data-theme="dark"] .theme-preview__swatch.is-active {
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.45), 0 24px 38px rgba(8, 47, 73, 0.45);
}

.settings-module h2 {
  margin: 0;
  font-size: 1.1rem;
}

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

.settings-module__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.settings-module__header p {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.form-grid label.full-width {
  grid-column: 1 / -1;
}

.settings-code-block {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

:root[data-theme="dark"] .settings-code-block {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.22);
}

.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.settings-field__value {
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  background: var(--color-surface);
  border: 1px dashed rgba(99, 102, 241, 0.35);
  color: var(--color-text-muted);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--color-text-strong);
}

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

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
  color: var(--color-text-strong);
}

.form-grid .field-hint {
  font-weight: 400;
  color: var(--color-text-subtle);
  font-size: 0.82rem;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: var(--color-surface);
}

.form-grid textarea {
  resize: vertical;
  min-height: 120px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.settings-module--danger {
  border-color: rgba(239, 68, 68, 0.35);
  background: var(--color-danger-soft);
}

.settings-module--wide {
  padding: 1.75rem;
  gap: 1.75rem;
}

.infra-module {
  gap: 1.75rem;
}

.infra-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.infra-tab {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.infra-tab.is-active {
  border-color: rgba(29, 78, 216, 0.45);
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.18);
}

.infra-tab__label {
  pointer-events: none;
}

.infra-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.1);
  color: var(--color-primary-strong);
  font-size: 0.8rem;
  font-weight: 600;
}

.infra-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.infra-search {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-surface-soft);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  padding: 0.55rem 0.75rem;
}

.infra-search input {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--color-text);
}

.infra-search input:focus-visible {
  outline: none;
}

.infra-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.infra-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(29, 78, 216, 0.25);
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.infra-filter-chip.is-active {
  background: rgba(21, 128, 61, 0.12);
  border-color: rgba(21, 128, 61, 0.35);
  color: var(--color-success);
}

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

.infra-filter-reset {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.infra-panels {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.infra-panel[hidden] {
  display: none;
}

.infra-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .infra-layout {
    grid-template-columns: 1fr;
  }
}

.infra-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--color-surface);
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  max-height: 520px;
  overflow-y: auto;
}

.infra-summary__heading {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
  font-weight: 700;
  padding-top: 0.25rem;
}

.infra-summary__heading--divider {
  padding-top: 1rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.infra-empty {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
  text-align: center;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  background: var(--color-surface-soft);
}

.infra-placeholder {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.infra-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: var(--color-surface);
  color: var(--color-text-strong);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.infra-card--add {
  border-style: dashed;
  background: rgba(59, 130, 246, 0.08);
  color: var(--color-primary-strong);
}

.infra-card .badge {
  font-size: 0.75rem;
}

.infra-card__title {
  font-size: 0.95rem;
}

.infra-card__meta {
  font-size: 0.82rem;
  color: var(--color-text-subtle);
}

.infra-card__status {
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

.infra-card__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(148, 163, 184, 0.18);
  color: var(--color-text-subtle);
}

.infra-card__tag--server {
  background: rgba(3, 105, 161, 0.15);
  color: var(--color-info);
}

.infra-card__tag--tool {
  background: rgba(29, 78, 216, 0.15);
  color: var(--color-primary-strong);
}

.infra-card.is-active {
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 12px 24px rgba(29, 78, 216, 0.18);
  background: var(--color-primary-surface);
}

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

.infra-details {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--color-surface);
  border-radius: 1rem;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.1);
  padding: 1.25rem;
  max-height: 540px;
  overflow-y: auto;
}

.infra-detail {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.infra-detail.is-active {
  display: flex;
}

.infra-detail[hidden] {
  display: none !important;
}

.infra-detail .form-grid {
  margin-top: 0.5rem;
}

.infra-detail .form-actions {
  justify-content: flex-start;
}

.infra-detail .inline-form {
  margin-top: 0.75rem;
}

.infra-detail .inline-form button {
  padding: 0.45rem 0.85rem;
}

.infra-detail .badge {
  font-size: 0.75rem;
}

.btn.danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: rgba(185, 28, 28, 0.35);
}

.btn.danger:hover {
  background: var(--color-danger-surface);
}

.log-monitor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.log-monitor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.log-monitor__search {
  flex: 1;
  min-width: 220px;
}

.log-monitor__search input[type="search"] {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: var(--color-surface);
}

.log-monitor__search input[type="search"]::placeholder {
  color: var(--color-text-subtle);
}

.log-monitor__body {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  background: var(--color-surface);
  padding: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, SFMono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.log-monitor__list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
}

.log-monitor__entry {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  padding-bottom: 0.6rem;
}

.log-monitor__entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.log-monitor__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--color-text-subtle);
}

.log-monitor__time {
  font-variant-numeric: tabular-nums;
  color: var(--color-text-strong);
}

.log-monitor__level {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  font-weight: 600;
  border-radius: 0.4rem;
  padding: 0.1rem 0.4rem;
}

.log-monitor__level--debug {
  background: rgba(15, 118, 110, 0.16);
  color: #0f766e;
}

.log-monitor__level--info {
  background: var(--color-info-surface);
  color: var(--color-info);
}

.log-monitor__level--warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.log-monitor__level--error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.log-monitor__level--critical {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

.log-monitor__logger {
  font-weight: 500;
  color: var(--color-text-muted);
}

.log-monitor__location {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.log-monitor__message {
  margin-top: 0.2rem;
  font-size: 0.9rem;
  color: var(--color-text-strong);
  white-space: pre-wrap;
  word-break: break-word;
}

.log-monitor__details {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.log-monitor__extra,
.log-monitor__exception,
.log-monitor__stack {
  margin: 0;
  padding: 0.5rem;
  border-radius: 0.6rem;
  background: var(--color-surface-soft);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-monitor__exception {
  border-left: 3px solid var(--color-danger);
}

.log-monitor__stack {
  border-left: 3px solid var(--color-warning);
}

.log-monitor__empty {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-subtle);
}

.log-monitor__status {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.log-monitor__status::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.log-monitor__status[data-state="live"] {
  color: var(--color-success);
}

.log-monitor__status[data-state="reconnecting"] {
  color: var(--color-warning);
}

.log-monitor__status[data-state="error"] {
  color: var(--color-danger);
}

@media (min-width: 1024px) {
  .log-monitor__layout {
    flex-direction: row;
    align-items: stretch;
  }

  .log-monitor {
    flex: 3;
  }

  .log-chat {
    flex: 2;
  }
}

.user-management {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 960px) {
  .user-management {
    grid-template-columns: 320px 1fr;
  }
}

.user-create-card {
  border: 1px dashed rgba(148, 163, 184, 0.5);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--color-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-create-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.user-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.user-card__header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.user-card__header p {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.badge {
  align-self: flex-start;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--color-info-surface);
  color: var(--color-info);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge--admin {
  background: var(--color-primary-surface);
  color: var(--color-accent-purple);
}

.badge--cloud {
  background: #dbeafe;
  color: #1e40af;
}

.badge--local {
  background: #dcfce7;
  color: #15803d;
}

.badge--ollama {
  background: #fef3c7;
  color: #b45309;
}

.endpoint-badges {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--color-text-strong);
  min-width: 160px;
}

.inline-form input,
.inline-form select {
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: var(--color-surface);
}

.inline-form .btn {
  height: fit-content;
  padding: 0.5rem 0.9rem;
}

.inline-form .btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.empty-state {
  margin: 1rem 0 0;
  color: var(--color-text-subtle);
  font-style: italic;
}

.llm-backend-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 1100px) {
  .llm-backend-grid {
    grid-template-columns: 320px 1fr;
  }
}

.llm-backend-card {
  border: 1px dashed rgba(148, 163, 184, 0.5);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--color-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.llm-backend-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.llm-endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.llm-endpoint-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.llm-endpoint-card__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.llm-endpoint-card__header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.llm-endpoint-card__header p {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
}

.llm-endpoint-meta {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.llm-endpoint-meta dt {
  font-weight: 600;
  color: var(--color-text-strong);
}

.llm-endpoint-meta dd {
  margin: 0;
  color: var(--color-text-muted);
}

.llm-endpoint-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.llm-endpoint-actions .btn {
  padding: 0.45rem 0.9rem;
}

.badge--active {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.badge--inactive {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.badge--info {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.small-print {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.custom-model-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 1100px) {
  .custom-model-grid {
    grid-template-columns: 320px 1fr;
  }
}

.custom-model-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 1rem;
  padding: 1.25rem;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.custom-model-grid > .custom-model-card:first-child {
  border-style: dashed;
  background: var(--color-surface-soft);
}

.custom-model-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.custom-model-card__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.custom-model-card__header p {
  margin: 0.25rem 0 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.custom-model-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.custom-model-meta {
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.custom-model-meta dt {
  font-weight: 600;
  color: var(--color-text-strong);
}

.custom-model-meta dd {
  margin: 0;
  color: var(--color-text-muted);
}

.custom-model-params {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.custom-model-thinking {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.custom-model-thinking label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.custom-model-tools {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.custom-model-tools__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.custom-model-tools__header h4 {
  margin: 0;
  font-size: 1rem;
}

.custom-model-tools__table-wrapper {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  overflow: hidden;
  overflow-x: auto;
}

.custom-model-tools__table {
  width: 100%;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.custom-model-tools__table thead {
  background: var(--color-surface-soft);
}

.custom-model-tools__head {
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-subtle);
}

.custom-model-tools__head--check {
  width: 3rem;
  text-align: center;
}

.custom-model-tools__cell {
  padding: 0.65rem 0.85rem;
  vertical-align: top;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.custom-model-tools__cell--check {
  text-align: center;
  width: 3rem;
}

.custom-model-tools__cell--name {
  font-weight: 600;
  color: var(--color-text-strong);
}

.custom-model-tools__cell--name label {
  cursor: pointer;
}

.custom-model-tools__cell--description {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.custom-model-tools__table tbody tr:first-child .custom-model-tools__cell {
  border-top: none;
}

.custom-model-tools__row:nth-child(even) {
  background: var(--color-surface-soft);
}

.custom-model-tools__row.is-disabled {
  opacity: 0.75;
}

.custom-model-tools__row.is-disabled .custom-model-tools__cell--name {
  color: var(--color-text-muted);
}

.custom-model-tools__row.is-disabled label {
  color: inherit;
}

.custom-model-tools__status {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.custom-model-tools__status.is-active {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.custom-model-tools__status.is-disabled {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.field-hint {
  color: var(--color-text-subtle);
  font-size: 0.75rem;
  line-height: 1.3;
  display: block;
}

.custom-model-flags {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.custom-model-list .inline-form {
  margin-top: 0.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.alert-info {
  background: var(--color-info-surface);
  color: var(--color-info);
}

.chat-detail__status-log {
  margin: 0 0 1rem;
}

.chat-detail__status-log:empty {
  display: none;
  margin: 0;
}

/* Remove margin when no alerts are present */
.chat-detail__status-log:not(:has(.alert)) {
  margin: 0;
  display: none;
}

.planner-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0 0 1.25rem;
}

.planner-card {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.9rem;
  background: var(--color-surface);
  padding: 0.85rem 1rem;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.08);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

:root[data-theme="dark"] .planner-card {
  border-color: rgba(148, 163, 184, 0.24);
  background: var(--color-surface-elevated);
  box-shadow: 0 8px 18px rgba(3, 7, 18, 0.5);
}

.planner-card--running {
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 10px 20px rgba(29, 78, 216, 0.18);
}

.planner-card--completed {
  border-color: rgba(21, 128, 61, 0.45);
}

.planner-card--failed {
  border-color: rgba(185, 28, 28, 0.45);
}

.planner-card--aborted {
  border-color: rgba(180, 83, 9, 0.45);
}

.planner-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.planner-card__title {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--color-text-strong);
  overflow-wrap: anywhere;
}

.planner-card__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--color-primary-surface);
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.planner-card__status--pending {
  background: var(--color-info-surface);
  color: var(--color-info);
}

.planner-card__status--running {
  background: var(--color-primary-surface);
  color: var(--color-primary-strong);
}

.planner-card__status--completed {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.planner-card__status--failed {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.planner-card__status--aborted {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.planner-card__prompt {
  margin: 0 0 0.5rem;
  color: var(--color-text-subtle);
  font-size: 0.86rem;
  line-height: 1.45;
}

.planner-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--color-text-subtle);
  font-size: 0.78rem;
  margin-bottom: 0.6rem;
}

.planner-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.planner-step {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.8rem;
  padding: 0.65rem 0.85rem;
  background: var(--color-surface-soft);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.planner-step--running {
  border-color: rgba(29, 78, 216, 0.4);
  background: rgba(29, 78, 216, 0.08);
}

.planner-step--retrying {
  border-color: rgba(180, 83, 9, 0.45);
  background: rgba(250, 204, 21, 0.12);
}

.planner-step--succeeded {
  border-color: rgba(21, 128, 61, 0.4);
  background: var(--color-success-surface);
}

.planner-step--failed {
  border-color: rgba(185, 28, 28, 0.45);
  background: var(--color-danger-soft);
}

.planner-step--skipped {
  border-color: rgba(148, 163, 184, 0.3);
  background: rgba(148, 163, 184, 0.15);
}

.planner-step__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.planner-step__title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--color-text-strong);
  overflow-wrap: anywhere;
}

.planner-step__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.24);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.planner-step__status--pending {
  background: rgba(148, 163, 184, 0.24);
  color: var(--color-text-subtle);
}

.planner-step__status--running {
  background: var(--color-primary-surface);
  color: var(--color-primary);
}

.planner-step__status--retrying {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.planner-step__status--succeeded {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.planner-step__status--failed {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.planner-step__status--skipped {
  background: rgba(148, 163, 184, 0.28);
  color: var(--color-text-muted);
}

.planner-step__meta {
  font-size: 0.78rem;
  color: var(--color-text-subtle);
  margin-bottom: 0.25rem;
}

.planner-step__summary {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.45;
  white-space: pre-wrap;
}

:root[data-theme="dark"] .planner-step__summary {
  color: var(--color-text-muted);
}

.planner-step__summary-text {
  margin-bottom: 0.4rem;
}

.planner-step__detail {
  margin: 0;
  border-radius: 0.6rem;
  padding: 0.6rem;
  background: var(--color-surface-elevated);
  color: var(--color-text);
  font-family: ui-monospace, SFMono-Regular, SFMono, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

:root[data-theme="dark"] .planner-step__detail {
  background: rgba(30, 41, 59, 0.45);
  color: var(--color-text-muted);
}

:root[data-theme="dark"] .planner-step {
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.65);
}

:root[data-theme="dark"] .planner-step--running {
  background: rgba(59, 130, 246, 0.16);
}

:root[data-theme="dark"] .planner-step--retrying {
  background: rgba(250, 204, 21, 0.16);
}

:root[data-theme="dark"] .planner-step--succeeded {
  background: rgba(34, 197, 94, 0.18);
}

:root[data-theme="dark"] .planner-step--failed {
  background: rgba(248, 113, 113, 0.18);
}

:root[data-theme="dark"] .planner-step--skipped {
  background: rgba(148, 163, 184, 0.32);
}

/* Goal run panel */

.goal-run-panel {
  position: fixed;
  right: clamp(1rem, 4vw, 2rem);
  bottom: clamp(1rem, 5vw, 2.25rem);
  width: min(50vw, calc(100vw - 2.5rem));
  max-width: min(960px, calc(100vw - 2.5rem));
  max-height: min(75vh, 640px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 1rem;
  background: var(--color-surface);
  box-shadow: 0 20px 34px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 1300;
}

:root[data-theme="dark"] .goal-run-panel {
  border-color: rgba(148, 163, 184, 0.24);
  background: var(--color-surface-elevated);
  box-shadow: 0 26px 46px rgba(3, 7, 18, 0.52);
}

.goal-run-panel[hidden] {
  display: none;
}

.goal-run-panel[data-goal-run-open="true"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

@media (max-width: 720px) {
  .goal-run-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-height: min(80vh, 70rem);
  }
}

.goal-run-panel[data-goal-run-loading="true"] {
  opacity: 0.72;
  pointer-events: none;
}

.goal-run-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  gap: 1rem;
}

:root[data-theme="dark"] .goal-run-panel__header {
  border-color: rgba(71, 85, 105, 0.4);
}

.goal-run-panel__title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.goal-run-panel__title h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-strong);
}

.goal-run-panel__subtitle {
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

.goal-run-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.goal-run-panel__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.goal-run-panel__actions .btn.tertiary {
  padding-inline: 0.65rem;
}

.goal-run-panel__actions .goal-run-panel__close {
  color: var(--color-text-subtle);
}

.goal-run-panel__actions .goal-run-panel__close:hover,
.goal-run-panel__actions .goal-run-panel__close:focus-visible {
  color: var(--color-text);
}

.goal-run-panel__error {
  margin: 0 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.65rem;
  font-size: 0.86rem;
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.12);
}

.goal-run-panel__empty {
  padding: 0.6rem 1rem 0.8rem;
  font-size: 0.86rem;
  color: var(--color-text-subtle);
}

.goal-run-panel__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem 1rem 1rem;
  overflow-y: auto;
}

.goal-run-panel__runs {
  max-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
}

.goal-run-list__item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.75rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.1);
  color: var(--color-text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.goal-run-list__item:hover,
.goal-run-list__item:focus-visible {
  border-color: rgba(79, 70, 229, 0.35);
  background: rgba(79, 70, 229, 0.08);
  transform: translateY(-1px);
}

.goal-run-list__item.is-active {
  border-color: rgba(79, 70, 229, 0.5);
  background: rgba(79, 70, 229, 0.12);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.15);
}

:root[data-theme="dark"] .goal-run-list__item {
  background: rgba(30, 41, 59, 0.6);
  border-color: rgba(71, 85, 105, 0.35);
  color: var(--color-text);
}

.goal-run-list__title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-strong);
}

.goal-run-list__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(79, 70, 229, 0.12);
  color: rgba(79, 70, 229, 1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.goal-run-status-badge--pending,
.goal-run-list__status.goal-run-status-badge--pending {
  background: var(--color-info-surface);
  color: var(--color-info);
}

.goal-run-status-badge--running,
.goal-run-list__status.goal-run-status-badge--running {
  background: var(--color-primary-surface);
  color: var(--color-primary);
}

.goal-run-status-badge--completed,
.goal-run-list__status.goal-run-status-badge--completed {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.goal-run-status-badge--aborted,
.goal-run-list__status.goal-run-status-badge--aborted {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.goal-run-status-badge--default,
.goal-run-list__status.goal-run-status-badge--default {
  background: rgba(148, 163, 184, 0.24);
  color: var(--color-text-muted);
}

.goal-run-list__meta {
  font-size: 0.75rem;
  color: var(--color-text-subtle);
}

.goal-run-list__active-goal {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.goal-run-panel__detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
  overflow-y: auto;
}

.goal-run-detail__status {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.goal-run-status__header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.goal-run-status__objective {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-strong);
}

.goal-run-status__meta {
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

.goal-run-status__info {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.6rem;
  font-size: 0.8rem;
  color: var(--color-text);
}

.goal-run-status__info dt {
  font-weight: 600;
  color: var(--color-text-subtle);
}

.goal-run-status__info dd {
  margin: 0;
  color: var(--color-text);
  word-break: break-word;
}

.goal-run-status__abort {
  align-self: flex-start;
}

.goal-run-metrics__list {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(148, 163, 184, 0.12);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--color-text);
}

.goal-run-metrics__item--guardrail {
  font-weight: 600;
  color: var(--color-warning);
}

.goal-run-detail__recap {
  padding: 0.75rem 0.85rem;
  border-left: 4px solid var(--color-warning);
  background: rgba(251, 191, 36, 0.12);
  color: var(--color-text);
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  border-radius: 0.5rem;
}

.goal-run-detail__goals,
.goal-run-detail__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.goal-run-empty {
  font-size: 0.82rem;
  color: var(--color-text-subtle);
}

.goal-run-goals__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.goal-run-goal {
  border-left: 3px solid rgba(148, 163, 184, 0.6);
  padding-left: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.goal-run-goals__list--nested {
  margin-top: 0.5rem;
  margin-left: 0.4rem;
  border-left: 1px dashed rgba(148, 163, 184, 0.4);
  padding-left: 0.8rem;
}

.goal-run-goal__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.goal-run-goal__title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-strong);
}

.goal-run-goal__status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: rgba(148, 163, 184, 0.2);
}

.goal-run-goal__status--pending {
  background: var(--color-info-surface);
  color: var(--color-info);
  border-color: rgba(59, 130, 246, 0.35);
}

.goal-run-goal__status--in-progress {
  background: var(--color-primary-surface);
  color: var(--color-primary);
  border-color: rgba(79, 70, 229, 0.55);
}

.goal-run-goal__status--completed {
  background: var(--color-success-surface);
  color: var(--color-success);
  border-color: rgba(22, 163, 74, 0.45);
}

.goal-run-goal__status--blocked {
  background: var(--color-warning-surface);
  color: var(--color-warning);
  border-color: rgba(180, 83, 9, 0.5);
}

.goal-run-goal__status--aborted {
  background: rgba(248, 113, 113, 0.18);
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.45);
}

.goal-run-goal__description,
.goal-run-goal__observation {
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text);
  line-height: 1.4;
}

.goal-run-actions__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.goal-run-action {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 0.85rem;
  background: rgba(15, 23, 42, 0.02);
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

:root[data-theme="dark"] .goal-run-action {
  border-color: rgba(71, 85, 105, 0.4);
  background: rgba(30, 41, 59, 0.55);
}

.goal-run-action__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.goal-run-action__decision {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(148, 163, 184, 0.28);
  color: var(--color-text-muted);
}

.goal-run-action__decision--continue {
  background: var(--color-info-surface);
  color: var(--color-info);
}

.goal-run-action__decision--goal-achieved {
  background: var(--color-success-surface);
  color: var(--color-success);
}

.goal-run-action__decision--goal-blocked,
.goal-run-action__decision--replan {
  background: var(--color-warning-surface);
  color: var(--color-warning);
}

.goal-run-action__decision--abort-run {
  background: var(--color-danger-surface);
  color: var(--color-danger);
}

.goal-run-action__decision-button {
  border: none;
  cursor: pointer;
  font: inherit;
  line-height: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.goal-run-action__decision-button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.goal-run-action__decision-button[aria-expanded="true"] {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.28);
}

.goal-run-action__goal {
  font-size: 0.78rem;
  color: var(--color-text-subtle);
}

.goal-run-action__timestamp {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.goal-run-action__body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-text);
  line-height: 1.4;
}

.goal-run-action__debug {
  margin-top: 0.6rem;
  padding: 0.85rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.02);
  border: 1px solid rgba(148, 163, 184, 0.26);
  font-size: 0.78rem;
  color: var(--color-text);
}

:root[data-theme="dark"] .goal-run-action__debug {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.3);
}

.goal-run-action__debug-title {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.45rem;
  color: var(--color-text-muted);
}

.goal-run-action__debug-pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.goal-run-action__line {
  word-break: break-word;
}

@media (max-width: 959px) {
  .goal-run-panel__body {
    flex-direction: column;
  }

  .goal-run-panel__runs {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 0.25rem;
  }

  .goal-run-list__item {
    min-width: 220px;
  }
}

@keyframes indicatorPulse {
  0% {
    transform: scale(0.96);
    opacity: 0.65;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.96);
    opacity: 0.65;
  }
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  background: var(--color-primary-surface);
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(29, 78, 216, 0.18);
}

.status-indicator__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
}

.status-indicator--active {
  animation: indicatorPulse 1.4s ease-in-out infinite;
}

.status-indicator--active .status-indicator__dot {
  animation: indicatorPulse 1.4s ease-in-out infinite;
}

@keyframes thinkingPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(67, 56, 202, 0.0);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.18);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(67, 56, 202, 0.0);
  }
}

@keyframes thinkingDotPulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.85);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

.thinking-indicator-wrapper {
  display: inline-flex;
  align-items: center;
}

.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  background: var(--color-primary-surface);
  color: var(--color-primary);
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  align-self: flex-start;
}

.thinking-indicator:hover,
.thinking-indicator:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(29, 78, 216, 0.2);
  background: var(--color-primary-soft);
  outline: none;
}

.thinking-indicator__dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
  display: inline-block;
}

.thinking-indicator__chevron {
  font-size: 0.7rem;
  line-height: 1;
  transition: transform 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.thinking-indicator--active {
  animation: thinkingPulse 1.6s ease-in-out infinite;
}

.thinking-indicator--active .thinking-indicator__dot {
  animation: thinkingDotPulse 1.2s ease-in-out infinite;
}

.thinking-indicator--open {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: 0 10px 24px rgba(29, 78, 216, 0.28);
}

.thinking-indicator--open .thinking-indicator__chevron {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .status-indicator--active,
  .status-indicator--active .status-indicator__dot,
  .chat-detail__title-status--active,
  .chat-detail__title-status::before,
  .thinking-indicator--active,
  .thinking-indicator--active .thinking-indicator__dot,
  .thinking-indicator__chevron {
    animation: none;
    transition: none;
  }

  .thinking-overlay__status::before {
    animation: none;
  }
}

.auth-card {
  margin: clamp(1.5rem, 8vh, 4rem) auto;
  max-width: 360px;
  width: 100%;
  padding: clamp(1.5rem, 5vw, 2.4rem);
  background: var(--color-surface);
  border-radius: 1.25rem;
  box-shadow: 0 25px 45px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: center;
}

:root[data-theme="dark"] .auth-card {
  box-shadow: 0 34px 60px rgba(2, 6, 23, 0.6);
}

.auth-card__logo {
  width: clamp(72px, 22vw, 96px);
  height: auto;
  margin: 0 auto 0.5rem;
  border-radius: 18px;
}

.auth-card h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  text-align: left;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.auth-form input {
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.6rem 0.75rem;
  font: inherit;
}

.message--empty {
  text-align: center;
  color: var(--color-text-subtle);
}

@media (max-width: 480px) {
  .auth-card {
    max-width: min(100%, 320px);
    padding: clamp(1.25rem, 6vw, 1.75rem);
    border-radius: 1rem;
    box-shadow: 0 18px 32px rgba(15, 23, 42, 0.14);
  }

  .auth-card__logo {
    width: clamp(64px, 28vw, 80px);
    border-radius: 15px;
  }

  .auth-form {
    gap: 0.75rem;
  }

  .auth-form label {
    font-size: 0.9rem;
  }
}
.log-monitor__layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.log-chat {
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 0.75rem;
  background: var(--color-surface);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 420px;
}

.log-chat__header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: baseline;
  justify-content: space-between;
}

.log-chat__model {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.log-chat__model--missing {
  color: var(--color-warning);
}

.log-chat__history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
}

.log-chat__message {
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.22);
  background: var(--color-surface-soft);
  color: var(--color-text-strong);
  align-self: flex-start;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-chat__message--user {
  align-self: flex-end;
  background: var(--color-primary-soft);
  color: var(--color-primary-contrast);
}

.log-chat__message--assistant {
  background: rgba(14, 165, 233, 0.12);
  color: var(--color-text-strong);
}

.log-chat__message--error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  box-shadow: inset 0 0 0 1px rgba(185, 28, 28, 0.28);
}

.log-chat__message small {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
  color: inherit;
  opacity: 0.8;
}

.log-chat__message p {
  margin: 0;
}

.log-chat__status {
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.log-chat__status[data-state="pending"] {
  color: var(--color-warning);
}

.log-chat__status[data-state="success"] {
  color: var(--color-success);
}

.log-chat__status[data-state="error"] {
  color: var(--color-danger);
}

.log-chat__composer {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.log-chat__composer textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border-soft);
  padding: 0.75rem;
  font: inherit;
  background: var(--color-surface-soft);
  color: var(--color-text-strong);
}

.log-chat__composer textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.log-chat__actions {
  display: flex;
  justify-content: flex-end;
}

.log-chat__actions .btn {
  min-width: 104px;
}

.log-chat[data-loading="true"] {
  opacity: 0.7;
  pointer-events: none;
}

/* Image Grid and Preview Styles */
.document-drawer__section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.document-drawer__section-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-strong);
}

.document-drawer__image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.document-drawer__image-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.75rem;
  background: var(--color-surface-soft);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.document-drawer__image-item:hover {
  background: var(--color-surface);
  border-color: rgba(29, 78, 216, 0.25);
}

.document-drawer__image-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.document-drawer__image-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.5rem;
  transition: transform 0.2s ease;
}

.document-drawer__image-item:hover .document-drawer__image-thumbnail {
  transform: scale(1.05);
}

.document-drawer__image-placeholder {
  font-size: 2rem;
  opacity: 0.5;
  color: var(--color-text-muted);
}

.document-drawer__image-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.document-drawer__image-filename {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-drawer__image-details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--color-text-subtle);
}

.document-drawer__image-size,
.document-drawer__image-dimensions {
  white-space: nowrap;
}

.document-drawer__image-reference {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.document-drawer__image-reference code {
  flex: 1;
  font-size: 0.7rem;
  background: rgba(15, 23, 42, 0.08);
  padding: 0.2rem 0.3rem;
  border-radius: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-drawer__copy-btn {
  background: none;
  border: none;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 0.3rem;
  transition: background 0.2s ease;
  color: var(--color-text-muted);
}

.document-drawer__copy-btn:hover {
  background: rgba(29, 78, 216, 0.1);
  color: var(--color-primary);
}

/* Responsive adjustments for image grid */
@media (max-width: 900px) {
  .document-drawer__image-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }
}

@media (max-width: 720px) {
  .document-drawer__image-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.4rem;
  }
  
  .document-drawer__image-item {
    padding: 0.4rem;
  }
  
  .document-drawer__image-filename {
    font-size: 0.75rem;
  }
  
  .document-drawer__image-details {
    font-size: 0.65rem;
  }
}

/* Image Upload Result Styles */
.upload-status {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.upload-status--success {
  background: var(--color-success-surface);
  color: var(--color-success);
  border: 1px solid rgba(21, 128, 61, 0.25);
}

.upload-status--error {
  background: var(--color-danger-surface);
  color: var(--color-danger);
  border: 1px solid rgba(185, 28, 28, 0.25);
}

.image-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.image-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.75rem;
  background: var(--color-surface-soft);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.image-item:hover {
  background: var(--color-surface);
  border-color: rgba(29, 78, 216, 0.25);
}

.image-item__preview {
  width: 60px;
  height: 60px;
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.image-item__thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0.5rem;
}

.image-item__placeholder {
  font-size: 1.5rem;
  opacity: 0.5;
  color: var(--color-text-muted);
}

.image-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  flex: 1;
}

.image-item__filename {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-item__details {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.image-item__size,
.image-item__dimensions {
  white-space: nowrap;
}

.image-item__reference {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.2rem;
}

.image-item__reference code {
  flex: 1;
  font-size: 0.8rem;
  background: rgba(15, 23, 42, 0.08);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-item__actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.btn--compact {
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn--compact:hover {
  background: var(--color-primary-surface);
  border-color: rgba(29, 78, 216, 0.35);
  color: var(--color-primary);
}

.btn--danger {
  background: var(--color-danger-surface);
  border-color: rgba(185, 28, 28, 0.25);
  color: var(--color-danger);
}

.btn--danger:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-text-inverse);
}

.btn.success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: var(--color-text-inverse);
}

.btn.error {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-text-inverse);
}

.loading-indicator.error {
  color: var(--color-danger);
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: 0.75rem;
  border-radius: 0.5rem;
  text-align: center;
}

/* Virtual scrolling styles */
.virtual-scroll-container {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-background);
}

.virtual-scroll-spacer {
  width: 1px;
  float: left;
}

.virtual-scroll-content {
  position: relative;
}

/* Performance optimizations for large lists */
.model-item {
  will-change: transform;
  contain: layout style paint;
}

/* Reduce repaints during scrolling */
.virtual-scroll-container {
  scroll-behavior: smooth;
}

/* Show model count for virtual scrolling */
.virtual-model-count {
  padding: 0.5rem 1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* Responsive adjustments for upload results */
@media (max-width: 720px) {
  .image-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0.6rem;
  }
  
  .image-item__preview {
    width: 50px;
    height: 50px;
    align-self: center;
  }
  
  .image-item__actions {
    justify-content: flex-end;
  }
}

/* Model Management Styles */
.model-management-section {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border-soft);
  padding-top: 1rem;
}

.model-management-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.model-management-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.model-management-header h4 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.model-selector {
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 0.5rem;
}

.model-selector-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.search-input-wrapper {
  min-width: 200px;
  max-width: 400px;
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
}

.model-search-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.375rem 0 0 0.375rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.875rem;
  border-right: none;
}

.search-clear-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border-soft);
  border-left: none;
  border-radius: 0 0.375rem 0.375rem 0;
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.search-clear-btn:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

/* Loading states */
.search-loading {
  animation: pulse 1.5s ease-in-out infinite;
  font-weight: 500;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.model-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.1);
}

.model-bulk-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0; /* Prevent buttons from shrinking */
  align-items: center;
}

.model-bulk-actions .btn {
  flex-shrink: 0;
  white-space: nowrap; /* Prevent button text from wrapping */
}

.model-list {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--color-border-soft);
  border-radius: 0.375rem;
  background: var(--color-surface-soft);
}

.model-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border-soft);
  transition: background-color 0.15s ease;
}

.model-item:last-child {
  border-bottom: none;
}

.model-item:hover {
  background: var(--color-surface-elevated);
}

.model-item.hidden {
  display: none;
}

.model-item input[type="checkbox"] {
  margin-right: 0.75rem;
  flex-shrink: 0;
}

.model-item label {
  flex: 1;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  word-break: break-word;
}

.model-item .model-size {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-left: 0.5rem;
}

.loading-indicator {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.model-selection-summary {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.btn.small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 0.375rem;
}

/* Responsive adjustments for model selector */
@media (max-width: 900px) {
  .search-input-wrapper {
    max-width: 300px;
  }
  
  .model-bulk-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 720px) {
  .model-selector-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .search-input-wrapper {
    min-width: auto;
    max-width: none;
    margin-bottom: 0.5rem;
  }
  
  .model-search-input {
    min-width: auto;
  }
  
  .model-bulk-actions {
    justify-content: center;
  }
}
  
  .search-input-wrapper {
    min-width: auto;
    max-width: none;
    margin-bottom: 0.5rem;
  }
  
  .model-search-input {
    min-width: auto;
  }
  
  .model-bulk-actions {
    justify-content: center;
  }
}
