/* Colors come from Telegram's theme (set on <html> by telegram-web-app.js), so the panel looks
   native in light and dark mode. The fallbacks are for opening the page outside Telegram. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #efeff4);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --subtitle: var(--tg-theme-subtitle-text-color, var(--hint));
  --header: var(--tg-theme-section-header-text-color, var(--hint));
  --link: var(--tg-theme-link-color, #2481cc);
  --accent: var(--tg-theme-accent-text-color, var(--link));
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e53935);
  --separator: var(--tg-theme-section-separator-color, rgba(128, 128, 128, 0.25));
  --ok: #34c759;
  --warn: #ff9500;
  --radius: 12px;
  --tabbar: 0px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-telegram]) {
    --bg: #0f0f10;
    --section: #1c1c1e;
    --text: #ffffff;
    --hint: #8e8e93;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    15px/1.4 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

.screen {
  padding: 12px 16px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 4px 14px;
}

.center {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 24px;
}

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

.small {
  font-size: 13px;
}

/* Grouped list, the Telegram settings look */
.section {
  margin-bottom: 22px;
}

.section-header {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--header);
  margin: 0 12px 6px;
}

.section-footer {
  font-size: 13px;
  color: var(--hint);
  margin: 6px 12px 0;
}

.card {
  background: var(--section);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 0;
  width: 100%;
  background: none;
  text-align: left;
}

.row + .row {
  border-top: 0.5px solid var(--separator);
}

button.row {
  cursor: pointer;
}

button.row:active {
  background: var(--separator);
}

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

.row-title {
  overflow-wrap: anywhere;
}

.row-subtitle {
  font-size: 13px;
  color: var(--subtitle);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.row-value {
  color: var(--hint);
  white-space: nowrap;
}

.chevron::after {
  content: "›";
  color: var(--hint);
  font-size: 22px;
  line-height: 1;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  background: var(--hint);
}

.dot.up {
  background: var(--ok);
}

.dot.down {
  background: var(--danger);
}

.danger-text {
  color: var(--danger);
}

.warn-text {
  color: var(--warn);
}

/* Switch */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex: none;
  border-radius: 31px;
  border: 0;
  padding: 0;
  background: var(--separator);
  transition: background 0.2s;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.switch.on {
  background: var(--ok);
}

.switch.on.danger {
  background: var(--danger);
}

.switch.on::after {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.5;
}

/* Buttons and fields */
.button {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 600;
  cursor: pointer;
}

.button.secondary {
  background: var(--separator);
  color: var(--text);
}

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.button.link {
  background: none;
  color: var(--link);
  padding: 6px 0;
  font-weight: 500;
}

.button:disabled {
  opacity: 0.5;
}

.button.block {
  width: 100%;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 0 14px 12px;
}

.field {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg);
}

.field:focus {
  outline: 2px solid var(--button);
  outline-offset: -1px;
}

textarea.field.prose {
  font-family: inherit;
  font-size: 14px;
  min-height: 160px;
}

textarea.field {
  min-height: 120px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
}

.editor {
  padding: 4px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  border-radius: 16px;
  background: var(--bg);
  font-size: 13px;
  max-width: 100%;
}

.chip span {
  overflow-wrap: anywhere;
}

.chip button {
  border: 0;
  background: none;
  color: var(--hint);
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}

.setting-head {
  padding: 12px 14px 4px;
}

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

.setting-description {
  font-size: 13px;
  color: var(--subtitle);
  margin-top: 2px;
}

.setting-meta {
  font-size: 12px;
  color: var(--hint);
}

.code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 60vh;
  overflow: auto;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--section);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.bubble.them {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bubble.us {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: var(--button);
  color: var(--button-text);
}

.bubble.system {
  align-self: center;
  max-width: 95%;
  background: transparent;
  color: var(--hint);
  font-size: 12px;
  text-align: center;
}

.bubble-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
  text-align: right;
}

.bubble-link {
  color: inherit;
  text-decoration: underline;
}

.purchase {
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.15);
}

.draft {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-top: 0.5px solid var(--separator);
}

.draft-text {
  max-width: 100%;
  align-self: stretch;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  background: var(--bg);
}

/* One rounded bar: quick replies, the text (1 to 4 lines, then scrolls), send. */
.composer-bar {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border: 1px solid var(--separator);
  border-radius: 22px;
  padding: 4px;
  background: var(--section);
}

.composer-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  padding: 7px 4px;
  line-height: 22px;
  font-family: inherit;
  overflow-y: hidden;
}

.composer-icon,
.composer-send {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
}

.composer-icon {
  background: transparent;
  color: var(--hint);
}

.composer-icon.active {
  color: var(--accent);
}

.composer-send {
  background: var(--button);
  color: var(--button-text);
}

.composer-send:disabled {
  opacity: 0.4;
}

.composer-count {
  align-self: flex-end;
  font-size: 12px;
  opacity: 0.6;
  padding-right: 12px;
}

.quick-replies {
  max-height: 40vh;
  overflow-y: auto;
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--section);
}

.quick-reply {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--separator);
  background: transparent;
  padding: 10px 12px;
}

.quick-reply:last-child {
  border-bottom: 0;
}

.quick-reply-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.quick-reply-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  opacity: 0.7;
}

.load-more {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.form-error {
  margin: 0 12px 12px;
}

.banner {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--section);
  margin-bottom: 18px;
  border-left: 4px solid var(--warn);
}

.banner.danger {
  border-left-color: var(--danger);
}

/* Tab bar */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--section);
  border-top: 0.5px solid var(--separator);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}

.tab {
  flex: 1;
  height: var(--tabbar);
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--hint);
  font-size: 11px;
  cursor: pointer;
}

.tab.active {
  color: var(--button);
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #ffffff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* Bottom sheet (PIN) */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}

.sheet {
  width: 100%;
  max-width: 640px;
  background: var(--section);
  border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sheet h2 {
  margin: 0;
  font-size: 18px;
}

.pin-input {
  font-size: 24px;
  letter-spacing: 0.4em;
  text-align: center;
}

/* Toast */
/* At the top: at the bottom it would cover the message bar, or hide behind the keyboard. */
.toast {
  position: fixed;
  left: 50%;
  top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--section);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  z-index: 30;
}

.toast.error {
  background: var(--danger);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--separator);
  border-top-color: var(--button);
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
  .switch,
  .switch::after {
    transition: none;
  }
}

/* iOS zooms the page into a text field whose text is smaller than 16px. */
input,
textarea,
select,
.field,
textarea.field,
textarea.field.prose,
.composer-input {
  font-size: 16px;
}

/* A conversation: full screen, no tabs; the agent strip and the message bar stay at the bottom. */
.screen.chat-screen {
  padding-bottom: 0;
  min-height: var(--tg-viewport-stable-height, 100vh);
  display: flex;
  flex-direction: column;
}

.chat-screen .chat {
  flex: 1;
}

.chat-screen > .center {
  min-height: 0;
  flex: 1;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0 8px;
}

.chat-header-title {
  flex: 1;
  font-size: 20px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-dock {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0 calc(8px + env(safe-area-inset-bottom));
  background: var(--bg);
}

.chat-dock .composer {
  padding: 0;
}

.turn {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@keyframes tray-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

.slide-in {
  animation: slide-in 0.2s ease-out;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
}

.knowledge-intro {
  margin: 4px 0 12px;
  line-height: 1.45;
}

.knowledge-block {
  margin-bottom: 18px;
}

.knowledge-block .section {
  margin-bottom: 8px;
}

.fixed-text summary {
  cursor: pointer;
  font-weight: 600;
}

.fixed-text pre {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
  margin: 10px 0 0;
}

.quick-reply.static {
  cursor: default;
  border-bottom: 1px solid var(--separator);
  padding: 8px 0;
}

.quick-reply.static:last-child {
  border-bottom: 0;
}

.quick-reply-full {
  display: block;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--hint);
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--section);
  font-size: 20px;
  display: grid;
  place-items: center;
}

.filter-chips {
  display: flex;
  gap: 8px;
  margin: 4px 0 12px;
}

.filter-chip {
  border: 1px solid var(--separator);
  border-radius: 16px;
  padding: 6px 14px;
  background: var(--section);
  font-size: 14px;
}

.filter-chip.active {
  background: var(--button);
  border-color: var(--button);
  color: var(--button-text);
}

.waiting-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  flex: none;
}

.waiting-title {
  font-weight: 700;
}

.inline.wrap {
  flex-wrap: wrap;
}

/* Tones shared by dots and tags: ok, info, warn, danger, muted. */
.dot.ok {
  background: var(--ok);
}

.dot.info {
  background: var(--accent);
}

.dot.warn {
  background: var(--warn);
}

.dot.danger {
  background: var(--danger);
}

.tone-tag {
  --tone: var(--accent);
  display: inline-block;
  flex: none;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 15%, transparent);
  white-space: nowrap;
}

.tone-tag.warn {
  --tone: var(--warn);
}

.tone-tag.danger {
  --tone: var(--danger);
}

.tone-tag.ok {
  --tone: var(--ok);
}

.tone-tag.muted {
  --tone: var(--hint);
}

/* A small rounded button for one-tap actions in headers and strips. */
.pill {
  flex: none;
  border: 0;
  border-radius: 16px;
  padding: 7px 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.pill.primary {
  background: var(--button);
  color: var(--button-text);
}

/* Home list */
.filter-chips {
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}

.filter-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  min-height: 36px;
}

.chip-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--warn);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.filter-chip.active .chip-count {
  background: var(--button-text);
  color: var(--button);
}

.chat-row {
  min-height: 64px;
  padding: 9px 14px 9px 12px;
}

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

.chat-row-line + .chat-row-line {
  margin-top: 3px;
}

.chat-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.chat-row-time {
  flex: none;
  font-size: 13px;
  color: var(--hint);
}

.chat-row.waiting .chat-row-time {
  color: var(--warn);
  font-weight: 600;
}

.chat-row-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--subtitle);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.chat-row.waiting .chat-row-text {
  color: var(--text);
}

.draft-preview {
  margin-top: 4px;
}

.avatar {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: hsl(var(--hue) 55% 55%);
  color: #ffffff;
  font-size: 18px;
  font-weight: 600;
}

.empty {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-title {
  font-weight: 600;
}

.inline-error {
  color: var(--danger);
  margin: 0 12px 8px;
}

/* Conversation */
.day-separator {
  align-self: center;
  margin: 8px 0 2px;
  padding: 2px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--hint) 18%, transparent);
  color: var(--hint);
  font-size: 12px;
  font-weight: 600;
}

/* Drafts sit where the answer would go: right side, dashed, clearly not sent. */
.drafts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.draft-card {
  --tone: var(--accent);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--section);
  border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
}

.draft-card.warn {
  --tone: var(--warn);
}

.draft-card.danger {
  --tone: var(--danger);
}

.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.draft-reason {
  font-size: 14px;
}

.draft-card.danger .draft-reason {
  color: var(--danger);
}

.draft-bubble {
  align-self: flex-end;
  max-width: 92%;
  padding: 8px 12px;
  border-radius: 14px 14px 4px 14px;
  border: 1.5px dashed color-mix(in srgb, var(--button) 70%, transparent);
  background: color-mix(in srgb, var(--button) 10%, transparent);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.draft-bubble.sent {
  border-style: solid;
}

textarea.field.draft-editor {
  min-height: 90px;
  resize: none;
  line-height: 1.4;
}

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

.draft-actions .button:first-child {
  flex: 1;
}

.draft-actions .button.link {
  padding: 6px 4px;
}

.meaning {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg);
  font-size: 14px;
}

.meaning-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tag {
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--section);
  color: var(--text);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

.older-drafts summary {
  cursor: pointer;
  padding: 6px 4px;
  color: var(--link);
  font-size: 14px;
}

.older-drafts[open] {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* The agent strip above the message bar. */
.agent-bar {
  border: 1px solid var(--separator);
  border-radius: 14px;
  background: var(--section);
  overflow: hidden;
}

.agent-bar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 6px;
}

.agent-bar-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  padding: 10px 6px 10px 12px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.agent-bar-mode {
  font-weight: 600;
  white-space: nowrap;
}

.agent-bar-summary {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--hint);
}

.agent-bar-chevron {
  color: var(--hint);
}

/* AI'a kapalı: no model reads this chat; the strip says so in red. */
.agent-bar.closed {
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, var(--section));
}

.agent-bar.closed .agent-bar-mode {
  color: var(--danger);
}

.closed-note {
  font-size: 14px;
  line-height: 1.45;
}

.exclusion-toggle {
  align-self: flex-start;
}

.agent-bar .pill {
  padding: 6px 12px;
}

.agent-bar-body {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--separator);
  animation: tray-up 0.18s ease-out;
}

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

/* The conversation's note for the agent, pinned under the title like a pinned message. */
.chat-note {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 0;
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--section);
  text-align: left;
  box-shadow: 0 1px 0 var(--separator);
  cursor: pointer;
}

.chat-note.blank {
  border-left-color: var(--separator);
}

/* While editing it stays on top of the conversation, above the keyboard. */
.chat-note.editing {
  flex-direction: column;
  align-items: stretch;
  cursor: default;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.chat-note-icon {
  flex: none;
  font-size: 15px;
}

.chat-note-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.chat-note-text {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-note.blank .chat-note-text {
  color: var(--accent);
  font-weight: 600;
}

.chat-note-meta {
  font-size: 12px;
  color: var(--hint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea.field.note-editor {
  min-height: 80px;
  resize: none;
  line-height: 1.4;
}

.spacer {
  flex: 1;
}

textarea.field.growing {
  min-height: 96px;
  resize: none;
  line-height: 1.45;
  overflow-y: auto;
}

/* Agent rules: one row per kind of message, the choice on the right. */
.rule-row {
  cursor: pointer;
}

.rule-row .row-main {
  display: flex;
  flex-direction: column;
}

/* The agent strip, compact: one slim row, details only when opened, never while typing. */
.agent-bar-toggle {
  padding: 7px 4px 7px 12px;
  font-size: 14px;
  gap: 7px;
}

.agent-bar-summary {
  font-size: 13px;
}

.agent-bar .pill {
  padding: 5px 12px;
  font-size: 13px;
}

.agent-bar-body {
  max-height: 38vh;
  gap: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.agent-bar-body .draft-bubble {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 14px;
}

.agent-bar-body .meaning {
  font-size: 13px;
}

.chat-dock:has(.composer-input:focus) .agent-bar-body {
  display: none;
}

.agent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill.danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.pill:disabled {
  opacity: 0.6;
}

/* Customer pictures: the initial stays underneath; the photo fades in once loaded. */
.avatar {
  position: relative;
  overflow: hidden;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar img.loaded {
  opacity: 1;
}

.avatar.small {
  width: 34px;
  height: 34px;
  font-size: 15px;
}

.avatar-wrap {
  position: relative;
  flex: none;
}

/* A teammate as a small initial; on a list row it sits on the customer's picture. */
.teammate {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  flex: none;
}

.avatar-wrap .teammate {
  position: absolute;
  right: -3px;
  bottom: -3px;
  box-shadow: 0 0 0 2px var(--section);
}

.teammate.typing {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.18);
  }
}

.chat-header {
  gap: 10px;
}

.chat-header-main {
  flex: 1;
  min-width: 0;
}

.chat-header-main .chat-header-title {
  font-size: 18px;
}

/* Always one line tall, so a teammate coming and going does not move the conversation. */
.chat-header-sub {
  min-height: 18px;
  font-size: 12px;
  color: var(--hint);
}

.here-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.here-chip .teammate {
  width: 16px;
  height: 16px;
  font-size: 9px;
}

.here-chip .teammate + .teammate {
  margin-left: -8px;
  box-shadow: 0 0 0 1.5px var(--bg);
}

.chat-row .chat-row-text.live-text {
  color: var(--accent);
}

/* What happens now, at the end of the conversation; the space is always kept. */
.live {
  min-height: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 92%;
  padding: 5px 11px;
  border-radius: 14px 14px 4px 14px;
  background: var(--section);
  color: var(--hint);
  font-size: 13px;
  animation: live-in 0.25s ease-out;
}

.live-pill.agent {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--section));
}

.live-pill .teammate {
  width: 16px;
  height: 16px;
  font-size: 9px;
}

.live-icon {
  font-size: 14px;
}

.live-pill.reading .live-icon {
  animation: look 2.4s ease-in-out infinite;
}

.live-pill.waiting .live-icon {
  animation: turn 2s ease-in-out infinite;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: dot 1.2s infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dot {
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@keyframes look {
  50% {
    transform: translateX(2px);
  }
}

@keyframes turn {
  50% {
    transform: rotate(180deg);
  }
}

@keyframes live-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .teammate.typing,
  .live-pill,
  .live-icon,
  .typing-dots i,
  .avatar img {
    animation: none !important;
    transition: none;
  }
  .typing-dots i {
    opacity: 0.7;
  }
}

/* Who wrote our messages, small, next to the time. */
.bubble-time {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.bubble-author {
  font-weight: 600;
}

.rule-select {
  flex: none;
  max-width: 46%;
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

/* A question written in plain words (Gözetim → ajana sor). */
textarea.field.question {
  font-family: inherit;
  min-height: 84px;
}

/* Notification choices: a row whose controls sit under its text. */
.row.column {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.person-picker {
  margin: 0 0 12px;
}

.quiet-times .field {
  flex: 1;
  min-width: 0;
}

.topic-row.muted .row-title {
  color: var(--hint);
}

/* One choice out of a few, side by side. */
.segmented {
  display: flex;
  border: 1px solid var(--separator);
  border-radius: 10px;
  overflow: hidden;
}

.segmented button {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 7px 4px;
  background: var(--section);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--separator);
}

.segmented button.active {
  background: var(--button);
  color: var(--button-text);
}

.row.column .filter-chips {
  margin: 0;
  flex-wrap: wrap;
  overflow: visible;
}

/* System: the gateway's dashboard on a phone. */
.system-card {
  padding: 12px 16px;
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 10px;
}

.stat-value {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--hint);
  font-size: 12px;
}

.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 40px;
}

.spark span {
  flex: 1;
  min-width: 0;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  opacity: 0.75;
}

.account-row {
  gap: 6px;
  align-items: stretch;
}

.account-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.account-error {
  white-space: normal;
  overflow-wrap: anywhere;
}

.meter {
  height: 4px;
  border-radius: 2px;
  background: var(--separator);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--ok);
}

.meter.mid span {
  background: var(--warn);
}

.meter.low span {
  background: var(--danger);
}

.request-time {
  display: inline-block;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dot.muted {
  background: var(--hint);
  opacity: 0.6;
}

.chat-keys {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.chat-key {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-key-main {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.chat-keys .editor {
  display: grid;
  gap: 8px;
}

.chat-key-main {
  display: flex;
  flex-direction: column;
}

.key-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 14px;
}
