@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=Source+Serif+4:wght@400;600&display=swap");

:root {
  --bg-top: #fbf8f3;
  --bg: #f3f0ea;
  --bg-accent: #efe6d9;
  --panel: #ffffff;
  --ink: #201f1a;
  --muted: #5a564d;
  --accent: #c66a2b;
  --accent-dark: #8e4a1d;
  --danger: #9f2f2f;
  --border: #d7d0c4;
  --shadow: rgba(30, 30, 30, 0.08);
  --header-bg: rgba(255, 255, 255, 0.9);
  --surface-soft: #f8f4ee;
  --success-bg: #ebf7eb;
  --success-border: #b9dbb9;
  --success-ink: #215f2e;
  --warn-bg: #fff1e6;
  --warn-border: #e1b99d;
  --warn-ink: #7a3b18;
}

body[data-theme="hell"] {
  color-scheme: light;
}

body[data-theme="dunkel"] {
  color-scheme: dark;
  --bg: #1f1f22;
  --bg-top: #2a2930;
  --bg-accent: #17171a;
  --panel: #2a2a2f;
  --ink: #f4f3ef;
  --muted: #b9b5ac;
  --accent: #d47d3f;
  --accent-dark: #f0a169;
  --danger: #ff8f8f;
  --border: #3d3b42;
  --shadow: rgba(0, 0, 0, 0.35);
  --header-bg: rgba(32, 32, 36, 0.92);
  --surface-soft: #333138;
  --success-bg: #203827;
  --success-border: #305f3c;
  --success-ink: #b9efc7;
  --warn-bg: #3b2b21;
  --warn-border: #6a4731;
  --warn-ink: #f0cfb4;
}

@media (prefers-color-scheme: dark) {
  body[data-theme="system"] {
    color-scheme: dark;
    --bg: #1f1f22;
    --bg-top: #2a2930;
    --bg-accent: #17171a;
    --panel: #2a2a2f;
    --ink: #f4f3ef;
    --muted: #b9b5ac;
    --accent: #d47d3f;
    --accent-dark: #f0a169;
    --danger: #ff8f8f;
    --border: #3d3b42;
    --shadow: rgba(0, 0, 0, 0.35);
    --header-bg: rgba(32, 32, 36, 0.92);
    --surface-soft: #333138;
    --success-bg: #203827;
    --success-border: #305f3c;
    --success-ink: #b9efc7;
    --warn-bg: #3b2b21;
    --warn-border: #6a4731;
    --warn-ink: #f0cfb4;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg-top) 0%, var(--bg) 55%, var(--bg-accent) 100%);
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.sidebar {
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  height: 100vh;
  width: 240px;
  flex: 0 0 auto;
  overflow: visible;
  transition: width 320ms ease, border-color 320ms ease, background-color 320ms ease;
}

.sidebar-arrow-toggle {
  position: absolute;
  top: 14px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  z-index: 12;
}

.sidebar-arrow-icon {
  line-height: 1;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 20px;
  height: 100%;
  min-height: 0;
  padding: 24px 16px;
  opacity: 1;
  visibility: visible;
  transition: opacity 400ms ease;
}

.main-content {
  padding: 0 0 28px 10px;
}

.main-pane {
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

body.is-sidebar-collapsed .sidebar {
  width: 42px;
}

body.is-sidebar-collapsed .sidebar-nav {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-nav {
    transition: none;
  }
}

.brand a {
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 22px;
  text-decoration: none;
  color: var(--ink);
}

.nav a {
  text-decoration: none;
  color: var(--accent-dark);
  font-weight: 600;
}

.nav {
  display: grid;
  gap: 12px;
  align-items: flex-start;
}

.header-links {
  width: 100%;
}

.sidebar-agent-list,
.sidebar-tool-list,
.sidebar-admin-list {
  width: 100%;
  display: grid;
  gap: 4px;
}

.sidebar-admin-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.sidebar-admin-summary::-webkit-details-marker {
  display: none;
}

.sidebar-admin-summary::after {
  content: "▾";
  float: right;
  transition: transform 160ms ease;
}

.sidebar-admin-list:not([open]) .sidebar-admin-summary::after {
  transform: rotate(-90deg);
}

.sidebar-admin-items {
  display: grid;
  gap: 4px;
}

.button.sidebar-agent-button,
.button.sidebar-tool-button,
.button.sidebar-admin-button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: var(--accent-dark);
  border: none;
  border-radius: 8px;
  padding: 0px 10px;
  line-height: 1.2;
  transition: color 160ms ease, transform 160ms ease;
}

.button.sidebar-agent-button:hover,
.button.sidebar-tool-button:hover,
.button.sidebar-admin-button:hover {
  background: transparent;
  color: var(--accent);
  transform: translateX(2px);
}

.button.sidebar-agent-button.is-active {
  background: transparent;
}

.nav-user {
  font-size: 13px;
  color: var(--muted);
}

.sidebar-history {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-history-header .small {
  margin: 0;
}

.sidebar-history-header-actions {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sidebar-history-list {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

.sidebar-history-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
  transition: box-shadow 140ms ease;
}

.sidebar-history-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 28px;
}

.sidebar-history-link.is-favorite {
  text-shadow: 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent);
}

.sidebar-history-item.is-favorite .sidebar-history-link {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.sidebar-history-menu-toggle {
  opacity: 0;
  pointer-events: none;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 24px;
  height: 24px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 140ms ease, color 140ms ease;
}

.sidebar-history-item:hover .sidebar-history-menu-toggle,
.sidebar-history-item:focus-within .sidebar-history-menu-toggle {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-history-menu-toggle:hover {
  color: var(--accent);
}

body.is-history-favorites-only .sidebar-history-item:not(.is-favorite) {
  display: none;
}

.sidebar-history-toggle {
  opacity: 0;
  pointer-events: none;
}

.sidebar-history-header:hover .sidebar-history-toggle,
.sidebar-history-header:focus-within .sidebar-history-toggle {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-history-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 2px);
  min-width: 120px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 20px var(--shadow);
  display: none;
  z-index: 30;
  padding: 4px;
  height: auto;
  max-height: none;
  overflow: visible;
}

.sidebar-history-menu.is-floating {
  position: fixed;
  right: auto;
  bottom: auto;
}

.sidebar-history-menu.is-above {
  top: auto;
  bottom: calc(100% + 2px);
}

.sidebar-history-menu.is-floating.is-above {
  bottom: auto;
}

.sidebar-history-header-menu {
  top: calc(100% + 4px);
}

.sidebar-history-menu.is-open {
  display: grid;
}

.sidebar-history-menu-item {
  border: none;
  background: transparent;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 32px;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.sidebar-history-menu-item:hover {
  background: var(--surface-soft);
}

.sidebar-history-menu-item.danger {
  color: var(--danger);
}

.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sidebar-footer .nav-user-link {
  display: inline-flex;
  width: 100%;
}

.nav-form {
  margin: 0;
}

.nav-form .button {
  padding: 8px 12px;
}

.page-header {
  margin: 36px 0 20px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 32px;
}

.muted {
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 16px 36px var(--shadow);
  margin-bottom: 24px;
}

.auth-panel {
  max-width: 520px;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table.compact th,
.table.compact td {
  font-size: 12px;
  padding: 10px 6px;
}

.table-scroll {
  overflow-x: auto;
}

.table-panel h2 {
  margin: 0 0 6px;
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 22px;
}

.table-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.table th,
.table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.button:hover {
  background: var(--accent-dark);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button.ghost {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.button.ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input,
textarea,
select {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
}

textarea {
  font-family: "Source Serif 4", "Times New Roman", serif;
}

.template-editor {
  position: relative;
  min-height: 180px;
}

.template-highlight,
.template-editor textarea {
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  white-space: pre-wrap;
  word-wrap: break-word;
  padding: 12px;
  border-radius: 12px;
  box-sizing: border-box;
  tab-size: 2;
}

.template-highlight {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink);
  min-height: 180px;
  overflow: auto;
  pointer-events: none;
}

.template-editor textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  -webkit-text-fill-color: transparent;
}

.template-var {
  color: #2f7f3b;
  font-weight: 600;
}

.template-var.missing {
  color: var(--danger);
}

.form-actions,
.inline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.alert {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-ink);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.alert.small {
  margin: 8px 0 0;
  padding: 8px 12px;
  font-size: 12px;
}

.empty-state {
  text-align: center;
  padding: 40px 0;
}

.mono {
  font-family: "SFMono-Regular", "Consolas", "Liberation Mono", monospace;
  font-size: 13px;
}

.small {
  font-size: 12px;
}

.variables-editor {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface-soft);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #2c2b28;
  color: #f7f4ee;
  font-size: 13px;
}

.chip-label {
  line-height: 1;
}

.chip-close {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #f7f4ee;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
}

.chip-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.chip-controls input {
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
}

.meta-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.meta-label {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  gap: 20px;
}

.code-block {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  white-space: pre-wrap;
}

.settings-shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.settings-menu {
  padding: 14px;
  display: grid;
  gap: 8px;
  align-content: start;
  margin-bottom: 0;
  position: sticky;
  top: 96px;
}

.settings-menu-footer-link {
  margin-top: 14px;
  display: block;
}

.settings-menu-footer-link:hover {
  background: var(--surface-soft);
}

.settings-link {
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}

.settings-link:hover {
  border-color: var(--border);
  background: var(--surface-soft);
}

.settings-link.active {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent-dark);
}

.settings-content h2 {
  margin: 0 0 8px;
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 26px;
}

.settings-content {
  margin-bottom: 0;
}

.settings-content h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.settings-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-ink);
}

.danger-zone {
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding-top: 18px;
}

.nav-user-link {
  text-decoration: none;
}

.nav-user-link:hover {
  text-decoration: underline;
}

.settings-modal-wrap {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 60px 20px;
}

.settings-modal-wrap[hidden] {
  display: none;
}

.settings-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(19, 18, 22, 0.46);
}

.settings-modal {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  margin-bottom: 0;
}

.settings-modal-wide {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.settings-modal .settings-shell {
  margin-bottom: 0;
}

.settings-modal .settings-menu {
  position: static;
  top: auto;
}

.settings-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-modal-head h1 {
  margin: 0;
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 30px;
}

.settings-modal-close {
  text-decoration: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  font-weight: 600;
}

.settings-modal-close:hover {
  color: var(--ink);
}

.history-modal-wrap {
  z-index: 60;
}

.history-modal {
  width: min(460px, 100%);
}

.history-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.history-modal-head h2 {
  margin: 0;
  font-family: "Source Serif 4", "Times New Roman", serif;
  font-size: 26px;
}

.history-modal-input-wrap {
  margin-top: 10px;
}

.history-modal-input-wrap[hidden] {
  display: none;
}

.history-modal-actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}


.wc-app {
  width: min(980px, 100%);
  min-height: calc(100dvh - 24px);
  margin: 16px auto 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wc-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  background: var(--ink);
  color: var(--panel);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.3;
  box-shadow: 0 12px 24px var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.wc-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.wc-toast.is-error {
  background: var(--danger);
  color: #fff;
}

.wc-new-chat {
  background: transparent;
  border: none;
  color: transparent;
  padding: 4px 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wc-new-chat-icon {
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
}

.wc-new-chat::after {
  content: attr(data-label);
  display: inline-block;
  color: var(--ink);
  overflow: hidden;
  white-space: nowrap;
  width: 0ch;
  transition: width 0.85s ease;
}

.wc-new-chat:hover::after {
  width: 8ch;
}

.wc-chat-panel {
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  border-radius: 20px;
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 20px 40px var(--shadow);
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  height: 100dvh;
  min-height: 100dvh;
  max-height: 100dvh;
  position: relative;
}

.wc-chat-panel.wc-center-composer .wc-composer {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100% - 36px));
  margin: 0;
}

.wc-chat-header {
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.wc-chat-header.wc-hidden {
  display: none;
}

.wc-chat-agent-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--accent);
  flex: 1;
}

.wc-chat-header .wc-new-chat {
  position: static;
  margin: 0;
  flex-shrink: 0;
}

.wc-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 74dvh;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 55%, transparent) color-mix(in srgb, var(--surface-soft) 80%, transparent);
}

.wc-messages::-webkit-scrollbar {
  width: 8px;
}

.wc-messages::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--surface-soft) 80%, transparent);
  border-radius: 999px;
}

.wc-messages::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 999px;
}

.wc-messages::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 75%, transparent);
}

.wc-messages {
  scrollbar-gutter: stable;
}

.wc-message {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.45;
  max-width: 80%;
  word-wrap: break-word;
  border: 1px solid var(--border);
}

.wc-fade-in {
  animation: wc-fade-in 0.35s ease-out;
}

.wc-message.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border-top-right-radius: 3px;
}

.wc-message.assistant {
  align-self: flex-start;
  background: color-mix(in srgb, var(--surface-soft) 40%, var(--panel));
  border-top-left-radius: 3px;
  position: relative;
  margin-bottom: 30px;
}

.wc-message-content {
  margin: 0;
}

.wc-message-actions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding-top: 6px;
  opacity: 0;
  pointer-events: auto;
  transition: opacity 140ms ease;
}

.wc-message.assistant:hover .wc-message-actions,
.wc-message.assistant:focus-within .wc-message-actions,
.wc-message-actions:hover,
.wc-message-actions:focus-within {
  opacity: 1;
}

.wc-message-actions .button.small {
  padding: 4px 8px;
  border-radius: 8px;
  background: transparent;
  color: var(--accent-dark);
  border: none;
}

.wc-message-actions .button.small:hover {
  background: transparent;
  color: var(--accent);
}

.wc-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.wc-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.3;
  animation: wc-typing-bounce 1.2s infinite ease-in-out;
}

.wc-typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.wc-typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes wc-typing-bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-4px);
    opacity: 0.9;
  }
}

@keyframes wc-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wc-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  margin-top: auto;
}

.wc-composer.wc-awaiting-first-delta {
  animation: wc-border-glow 1.4s infinite;
  border-radius: 16px;
  padding: 4px;
}

@keyframes wc-border-glow {
  0% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent),
      0 0 12px color-mix(in srgb, var(--accent) 30%, transparent);
  }
  50% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent),
      0 0 18px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  100% {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 20%, transparent),
      0 0 12px color-mix(in srgb, var(--accent) 30%, transparent);
  }
}

.wc-composer-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.wc-example-bubbles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.wc-example-bubbles.wc-hidden {
  display: none;
}

.wc-example-bubble {
  background: color-mix(in srgb, var(--panel) 90%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  transition: transform 0.2s ease, border-color 0.2s ease, opacity 0.3s ease;
}

.wc-example-bubble.wc-is-revealing,
.wc-example-bubble.wc-is-visible {
  opacity: 1;
  transform: translateY(0);
}

.wc-example-bubble:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 70%, var(--border));
}

.wc-input {
  flex: 1;
  background: color-mix(in srgb, var(--panel) 90%, var(--surface-soft));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 14px;
  color: var(--ink);
  padding: 12px 14px;
  resize: none;
  overflow: hidden;
  min-height: 54px;
  max-height: 160px;
  font-size: 15px;
}

.wc-input:focus {
  outline: none;
  border-color: var(--accent);
}

.wc-send {
  background: transparent;
  border: none;
  color: transparent;
  padding: 12px 18px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.wc-send-icon {
  color: var(--ink);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
}

.wc-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.wc-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.wc-error {
  color: var(--danger);
  font-size: 14px;
  min-height: 18px;
  margin: 0;
}

.wc-is-streaming .wc-message-content::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 14px;
  margin-left: 3px;
  vertical-align: text-bottom;
  background: var(--accent-dark);
  animation: chat-cursor 0.8s steps(1, end) infinite;
}

@keyframes chat-cursor {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}


@media (max-width: 720px) {
  .actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(240px, 86vw);
    height: 100dvh;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-105%);
    transition: transform 500ms ease;
    box-shadow: 0 20px 34px var(--shadow);
    overflow: hidden;
    z-index: 35;
  }

  .sidebar-arrow-toggle {
    top: 12px;
    right: 10px;
  }

  .sidebar-nav {
    flex-direction: column;
    gap: 20px;
    align-items: flex-start;
    padding: 24px 16px;
    height: 100%;
    overflow: auto;
  }

  .mobile-sidebar-toggle {
    display: inline-flex;
    position: fixed;
    left: 12px;
    top: 12px;
    z-index: 34;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--accent-dark);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    font-family: inherit;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    border: none;
    background: rgba(17, 16, 20, 0.44);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 30;
  }

  body.is-sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.is-sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.is-sidebar-open {
    overflow: hidden;
  }

  body.is-sidebar-collapsed .sidebar-nav {
    opacity: 1;
    pointer-events: auto;
  }

  .main-pane {
    padding-top: 56px;
  }

  .chip-controls {
    grid-template-columns: 1fr;
  }

  .settings-shell {
    grid-template-columns: 1fr;
  }

  .settings-menu {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .settings-modal-wrap {
    align-items: end;
    padding: 10px;
  }

  .settings-modal-wide {
    max-height: calc(100vh - 16px);
  }

  .wc-message {
    max-width: 100%;
  }

  .wc-composer-row {
    flex-wrap: wrap;
  }

  .wc-send {
    width: 100%;
    justify-content: center;
  }
}

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

  .panel {
    padding: 18px;
  }
}

/* File Upload Styles */
.wc-file-button {
  border: none;
  background: var(--surface-soft);
  color: var(--ink);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.wc-file-button:hover {
  background: var(--bg-accent);
}

.wc-file-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wc-file-icon {
  font-size: 24px;
  line-height: 1;
  font-weight: 400;
}

.wc-file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 8px;
}

.wc-file-preview.wc-hidden {
  display: none;
}

.wc-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.wc-file-name {
  color: var(--ink);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-file-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.wc-file-remove:hover {
  color: var(--danger);
}

.wc-composer.wc-drag-over {
  background: var(--surface-soft);
  border-color: var(--accent);
}

.wc-composer.wc-drag-over .wc-composer-row {
  pointer-events: none;
}

/* Agent Selector Styles */
.wc-agent-selector {
  position: relative;
  margin-bottom: 12px;
  width: 100%;
}

.wc-agent-selector.wc-hidden {
  display: none;
}

.wc-agent-selector-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border: none;
  border-radius: 8px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 12px;
}

.wc-agent-selector-button:hover {
  background: var(--surface-soft);
}

.wc-agent-name {
  flex: 1;
  text-align: left;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wc-dropdown-arrow {
  font-size: 10px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.wc-agent-selector-button:hover .wc-dropdown-arrow {
  color: var(--accent);
}

.wc-agent-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
}

.wc-agent-dropdown.wc-hidden {
  display: none;
}

.wc-agent-list {
  padding: 4px;
}

.wc-agent-item {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
  display: block;
}

.wc-agent-item:hover {
  background: var(--surface-soft);
}

.wc-agent-item.wc-agent-selected {
  background: var(--bg-accent);
  color: var(--accent);
  font-weight: 500;
}

.wc-agent-item.wc-agent-empty {
  color: var(--muted);
  cursor: default;
  font-style: italic;
}

.wc-agent-item.wc-agent-empty:hover {
  background: transparent;
}
