/*
 * Tiny Chat dashboard and sign-in page.
 * Served as a file because the CSP is style-src 'self' (no inline styles).
 */

:root {
  color-scheme: light dark;

  --tc-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --tc-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --tc-bg: #f5f6f8;
  --tc-surface: #ffffff;
  --tc-surface-2: #f1f3f5;
  --tc-surface-3: #e6e9ed;
  --tc-border: #e4e7eb;
  --tc-border-strong: #d0d5db;
  --tc-text: #15181c;
  --tc-text-2: #464d56;
  --tc-muted: #6b727c;

  --tc-accent: #2563eb;
  --tc-accent-hover: #1d4ed8;
  --tc-accent-soft: #eaf0fe;
  --tc-accent-text: #1d4ed8;
  --tc-on-accent: #ffffff;
  --tc-focus-ring: rgba(37, 99, 235, 0.22);

  --tc-bubble-visitor: #ffffff;
  --tc-bubble-operator: #2563eb;

  --tc-success-soft: #e7f6ec;
  --tc-success-text: #17663a;
  --tc-danger-soft: #fdeceb;
  --tc-danger-border: #f6c9c4;
  --tc-danger-text: #b42318;
  --tc-warning-soft: #fff6e5;
  --tc-warning-border: #f5dfb0;
  --tc-warning-text: #8a5300;

  --tc-code-bg: #f3f4f6;
  --tc-code-text: #1f2937;
  --tc-toast-bg: #1f2329;
  --tc-toast-text: #ffffff;

  --tc-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --tc-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --tc-shadow-lg: 0 24px 60px rgba(16, 24, 40, 0.2), 0 2px 6px rgba(16, 24, 40, 0.08);

  --tc-header-height: 56px;
  --tc-pane-header-height: 60px;
  --tc-list-width: 320px;
  --tc-details-width: 300px;
  --tc-reading-width: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tc-bg: #0e1013;
    --tc-surface: #16191d;
    --tc-surface-2: #1e2227;
    --tc-surface-3: #2a2f36;
    --tc-border: #272c32;
    --tc-border-strong: #3a4048;
    --tc-text: #e8eaed;
    --tc-text-2: #c3c8ce;
    --tc-muted: #8c949e;

    --tc-accent: #3b82f6;
    --tc-accent-hover: #2563eb;
    --tc-accent-soft: rgba(59, 130, 246, 0.16);
    --tc-accent-text: #8db4fa;
    --tc-focus-ring: rgba(59, 130, 246, 0.32);

    --tc-bubble-visitor: #1e2227;
    --tc-bubble-operator: #2563eb;

    --tc-success-soft: rgba(34, 160, 90, 0.16);
    --tc-success-text: #6fd39b;
    --tc-danger-soft: rgba(240, 82, 72, 0.14);
    --tc-danger-border: rgba(240, 82, 72, 0.32);
    --tc-danger-text: #ff8a80;
    --tc-warning-soft: rgba(245, 166, 35, 0.12);
    --tc-warning-border: rgba(245, 166, 35, 0.3);
    --tc-warning-text: #f4c46b;

    --tc-code-bg: #0f1215;
    --tc-code-text: #d7dce2;
    --tc-toast-bg: #2b3038;

    --tc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --tc-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --tc-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

/* ------------------------------------------------------------------ */
/* Base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--tc-bg);
  color: var(--tc-text);
  font-family: var(--tc-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
p {
  margin: 0;
}

a {
  color: var(--tc-accent-text);
}

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

:focus-visible {
  outline: 2px solid var(--tc-accent);
  outline-offset: 2px;
}

.tc-visually-hidden,
.tc-offscreen {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.tc-skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--tc-surface);
  color: var(--tc-text);
  box-shadow: var(--tc-shadow-lg);
  text-decoration: none;
}

.tc-skip:focus {
  top: 8px;
}

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

.tc-mono {
  font-family: var(--tc-mono);
  font-size: 0.92em;
}

.tc-small {
  font-size: 12px;
}

.tc-break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tc-warning-text {
  color: var(--tc-warning-text);
}

/* ------------------------------------------------------------------ */
/* Controls */

.tc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--tc-border-strong);
  border-radius: 9px;
  background: var(--tc-surface);
  color: var(--tc-text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

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

.tc-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.tc-button:disabled:hover {
  background: var(--tc-surface);
}

.tc-button-primary {
  border-color: var(--tc-accent);
  background: var(--tc-accent);
  color: var(--tc-on-accent);
}

.tc-button-primary:hover,
.tc-button-primary:disabled:hover {
  border-color: var(--tc-accent-hover);
  background: var(--tc-accent-hover);
}

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

.tc-button-danger:hover {
  border-color: var(--tc-danger-border);
  background: var(--tc-danger-soft);
}

.tc-button-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--tc-text-2);
}

.tc-button-ghost:hover {
  background: var(--tc-surface-2);
  color: var(--tc-text);
}

.tc-button-small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.tc-button-block {
  width: 100%;
  height: 40px;
}

.tc-button.is-done {
  border-color: var(--tc-success-text);
  color: var(--tc-success-text);
}

.tc-icon-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -8px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--tc-text-2);
  cursor: pointer;
}

.tc-icon-button:hover {
  background: var(--tc-surface-2);
  color: var(--tc-text);
}

.tc-chevron-left {
  display: block;
  width: 10px;
  height: 10px;
  margin-left: 4px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
}

.tc-link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--tc-accent-text);
  font-weight: 600;
  cursor: pointer;
}

.tc-link-button:hover {
  text-decoration: underline;
}

.tc-link-button:disabled {
  color: var(--tc-muted);
  cursor: default;
  text-decoration: none;
}

.tc-input {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--tc-border-strong);
  border-radius: 9px;
  background: var(--tc-surface);
  color: var(--tc-text);
  font-size: 14px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.tc-input:focus {
  border-color: var(--tc-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--tc-focus-ring);
}

.tc-textarea {
  height: auto;
  min-height: 64px;
  padding: 8px 12px;
  line-height: 1.5;
  resize: vertical;
}

.tc-select {
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--tc-border-strong);
  border-radius: 9px;
  background-color: var(--tc-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%236b727c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  color: var(--tc-text);
  font-size: 13px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.tc-select:focus {
  border-color: var(--tc-accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--tc-focus-ring);
}

.tc-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tc-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.tc-label {
  color: var(--tc-text);
  font-size: 13px;
  font-weight: 600;
}

.tc-help {
  color: var(--tc-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.tc-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tc-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--tc-accent);
}

.tc-alert {
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 13.5px;
}

.tc-alert-error {
  border-color: var(--tc-danger-border);
  background: var(--tc-danger-soft);
  color: var(--tc-danger-text);
}

.tc-badge {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--tc-surface-2);
  color: var(--tc-text-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.tc-badge-success {
  background: var(--tc-success-soft);
  color: var(--tc-success-text);
}

.tc-badge-warning {
  background: var(--tc-warning-soft);
  color: var(--tc-warning-text);
}

.tc-badge-muted {
  background: var(--tc-surface-2);
  color: var(--tc-muted);
}

/* ------------------------------------------------------------------ */
/* Brand */

.tc-brand-mark {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--tc-accent);
}

.tc-brand-mark::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 6px;
  width: 14px;
  height: 10px;
  border-radius: 4px;
  background: #ffffff;
}

.tc-brand-mark::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 8px;
  border-top: 4px solid #ffffff;
  border-right: 4px solid transparent;
}

/* ------------------------------------------------------------------ */
/* App shell */

body.tc-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.tc-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 20px;
  height: var(--tc-header-height);
  padding: 0 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--tc-border);
  background: var(--tc-surface);
}

.tc-brand {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  color: var(--tc-text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.tc-nav {
  display: flex;
  gap: 4px;
  min-width: 0;
}

.tc-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--tc-text-2);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tc-nav-link:hover {
  background: var(--tc-surface-2);
  color: var(--tc-text);
}

.tc-nav-link[aria-current="page"] {
  background: var(--tc-accent-soft);
  color: var(--tc-accent-text);
}

.tc-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--tc-accent);
  color: var(--tc-on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.tc-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.tc-me {
  overflow: hidden;
  max-width: 200px;
  color: var(--tc-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-logout {
  margin: 0;
}

.tc-banner {
  flex-shrink: 0;
  padding: 8px 16px;
  border-bottom: 1px solid var(--tc-warning-border);
  background: var(--tc-warning-soft);
  color: var(--tc-warning-text);
  font-size: 13px;
  text-align: center;
}

.tc-main {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  outline: none;
}

/* ------------------------------------------------------------------ */
/* Inbox layout: one pane on phones, list + conversation on tablets,
   list + conversation + details at 1024px and wider. */

.tc-inbox {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
}

/* Panes and scrollers are containing blocks, so visually hidden labels
   (position: absolute) stay inside them instead of growing the page. */
.tc-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.tc-list-pane,
.tc-conversation-pane {
  grid-row: 1;
  grid-column: 1;
}

.tc-list-pane {
  display: flex;
  flex-direction: column;
  background: var(--tc-surface);
}

.tc-conversation-pane {
  position: relative;
  display: none;
  flex-direction: column;
  background: var(--tc-bg);
}

.tc-details-pane {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--tc-surface);
}

.tc-inbox[data-has-conversation="true"] .tc-list-pane {
  display: none;
}

.tc-inbox[data-has-conversation="true"] .tc-conversation-pane {
  display: flex;
}

.tc-inbox[data-has-conversation="true"][data-details-open="true"] .tc-details-pane {
  display: block;
}

@media (min-width: 768px) {
  .tc-inbox {
    grid-template-columns: var(--tc-list-width) minmax(0, 1fr);
  }

  .tc-list-pane,
  .tc-inbox[data-has-conversation="true"] .tc-list-pane {
    display: flex;
    grid-column: 1;
    border-right: 1px solid var(--tc-border);
  }

  .tc-conversation-pane,
  .tc-inbox[data-has-conversation="true"] .tc-conversation-pane {
    display: flex;
    grid-column: 2;
  }

  .tc-details-pane {
    left: auto;
    width: 340px;
    border-left: 1px solid var(--tc-border);
    box-shadow: var(--tc-shadow-lg);
  }

  .tc-back {
    display: none;
  }
}

@media (min-width: 1024px) {
  .tc-inbox[data-has-conversation="true"] {
    grid-template-columns: var(--tc-list-width) minmax(0, 1fr) var(--tc-details-width);
  }

  .tc-details-pane {
    position: static;
    grid-row: 1;
    grid-column: 3;
    width: auto;
    box-shadow: none;
  }

  .tc-inbox[data-has-conversation="true"] .tc-details-pane {
    display: block;
  }

  .tc-details-toggle,
  .tc-details-close {
    display: none;
  }
}

/* ------------------------------------------------------------------ */
/* Conversation list */

.tc-list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--tc-border);
}

.tc-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--tc-surface-2);
}

.tc-tab {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--tc-text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tc-tab:hover {
  color: var(--tc-text);
}

.tc-tab[aria-selected="true"] {
  background: var(--tc-surface);
  color: var(--tc-text);
  box-shadow: var(--tc-shadow);
}

.tc-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--tc-accent);
  color: var(--tc-on-accent);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.tc-callout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--tc-border);
  border-radius: 10px;
  background: var(--tc-accent-soft);
}

.tc-callout-text {
  color: var(--tc-text-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.tc-list-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tc-list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.tc-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}

.tc-row:hover {
  background: var(--tc-surface-2);
}

.tc-row[aria-current="true"] {
  background: var(--tc-accent-soft);
}

.tc-avatar {
  display: flex;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tc-surface-3);
  color: var(--tc-text-2);
  font-size: 14px;
  font-weight: 650;
}

.tc-row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.tc-row-top,
.tc-row-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tc-row-name,
.tc-row-site,
.tc-row-preview {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-row-name {
  flex: 1;
  font-weight: 600;
}

.tc-row-time {
  flex-shrink: 0;
  color: var(--tc-muted);
  font-size: 12px;
}

.tc-row-site {
  color: var(--tc-muted);
  font-size: 12px;
}

.tc-row-preview {
  flex: 1;
  color: var(--tc-text-2);
  font-size: 13px;
}

.tc-row-preview.is-system {
  color: var(--tc-muted);
  font-style: italic;
}

.tc-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tc-accent);
}

.tc-row.is-unread .tc-row-name {
  font-weight: 750;
}

.tc-row.is-unread .tc-row-preview {
  color: var(--tc-text);
  font-weight: 500;
}

.tc-row.is-unread .tc-row-time {
  color: var(--tc-accent-text);
  font-weight: 600;
}

.tc-list-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 16px;
  color: var(--tc-muted);
  font-size: 13px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Conversation */

.tc-placeholder {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px;
  color: var(--tc-muted);
  text-align: center;
}

.tc-placeholder-icon {
  position: relative;
  width: 56px;
  height: 56px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: var(--tc-surface-3);
}

.tc-placeholder-icon::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 14px;
  width: 28px;
  height: 19px;
  border-radius: 7px;
  background: var(--tc-surface);
}

.tc-placeholder-icon::after {
  content: "";
  position: absolute;
  top: 34px;
  left: 18px;
  border-top: 7px solid var(--tc-surface);
  border-right: 7px solid transparent;
}

.tc-placeholder-title {
  color: var(--tc-text);
  font-size: 15px;
  font-weight: 650;
}

.tc-conversation {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.tc-conversation-header,
.tc-details-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 12px;
  min-height: var(--tc-pane-header-height);
  padding: 10px 16px;
  border-bottom: 1px solid var(--tc-border);
  background: var(--tc-surface);
}

.tc-conversation-heading {
  flex: 1;
  min-width: 0;
}

.tc-conversation-title {
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-conversation-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-top: 3px;
  color: var(--tc-muted);
  font-size: 12.5px;
}

.tc-conversation-site {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-conversation-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.tc-status-pill {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--tc-surface-2);
  color: var(--tc-text-2);
  font-size: 11.5px;
  font-weight: 650;
}

.tc-status-pill.is-open {
  background: var(--tc-success-soft);
  color: var(--tc-success-text);
}

.tc-status-pill.is-blocked {
  background: var(--tc-danger-soft);
  color: var(--tc-danger-text);
}

.tc-thread {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 8px 20px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
}

.tc-thread-top {
  display: flex;
  justify-content: center;
  padding: 8px 0 0;
}

.tc-thread-top:empty,
.tc-thread-status:empty {
  display: none;
}

.tc-messages {
  display: flex;
  flex-direction: column;
  max-width: var(--tc-reading-width);
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.tc-thread-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 32px 16px;
  color: var(--tc-muted);
  font-size: 13px;
  text-align: center;
}

.tc-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 4px;
  color: var(--tc-muted);
  font-size: 12px;
  font-weight: 600;
}

.tc-day::before,
.tc-day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--tc-border);
}

.tc-system {
  display: flex;
  flex-wrap: wrap;
  align-self: center;
  justify-content: center;
  gap: 6px;
  max-width: 90%;
  margin: 12px 0 2px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--tc-surface-3);
  color: var(--tc-text-2);
  font-size: 12px;
  text-align: center;
}

.tc-system-time {
  color: var(--tc-muted);
}

.tc-message {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(80%, 560px);
  margin-top: 12px;
}

.tc-message.is-grouped {
  margin-top: 3px;
}

.tc-message.is-grouped .tc-message-meta {
  display: none;
}

.tc-message.is-operator {
  align-self: flex-end;
  align-items: flex-end;
}

.tc-message-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0 4px 3px;
  color: var(--tc-muted);
  font-size: 12px;
}

.tc-message-author {
  color: var(--tc-text-2);
  font-weight: 600;
}

.tc-bubble {
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--tc-border);
  border-radius: 16px;
  background: var(--tc-bubble-visitor);
  color: var(--tc-text);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tc-message.is-visitor .tc-bubble {
  border-top-left-radius: 6px;
}

.tc-message.is-operator .tc-bubble {
  border-color: transparent;
  border-top-right-radius: 6px;
  background: var(--tc-bubble-operator);
  color: #ffffff;
}

.tc-message.is-pending .tc-bubble {
  opacity: 0.72;
}

.tc-message.is-failed .tc-bubble {
  border-color: var(--tc-danger-border);
  background: var(--tc-danger-soft);
  color: var(--tc-danger-text);
  opacity: 1;
}

.tc-message-status {
  margin: 4px 4px 0;
  color: var(--tc-muted);
  font-size: 12px;
}

.tc-message.is-failed .tc-message-status {
  color: var(--tc-danger-text);
}

.tc-jump {
  position: relative;
  z-index: 2;
  align-self: center;
  height: 32px;
  margin: -44px 0 12px;
  padding: 0 14px;
  border: 1px solid var(--tc-border);
  border-radius: 999px;
  background: var(--tc-surface);
  color: var(--tc-accent-text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--tc-shadow-lg);
  cursor: pointer;
}

.tc-composer {
  flex-shrink: 0;
  padding: 10px 16px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--tc-border);
  background: var(--tc-surface);
}

.tc-composer-note {
  max-width: var(--tc-reading-width);
  margin: 0 auto 8px;
  padding: 8px 12px;
  border: 1px solid var(--tc-warning-border);
  border-radius: 9px;
  background: var(--tc-warning-soft);
  color: var(--tc-warning-text);
  font-size: 13px;
}

.tc-composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: var(--tc-reading-width);
  margin: 0 auto;
  padding: 5px 5px 5px 12px;
  border: 1px solid var(--tc-border-strong);
  border-radius: 12px;
  background: var(--tc-surface);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.tc-composer-box:focus-within {
  border-color: var(--tc-accent);
  box-shadow: 0 0 0 3px var(--tc-focus-ring);
}

.tc-reply {
  flex: 1;
  min-width: 0;
  height: 36px;
  min-height: 36px;
  max-height: 220px;
  padding: 7px 0;
  overflow-y: hidden;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--tc-text);
  line-height: 1.45;
  resize: none;
}

.tc-reply:disabled {
  cursor: not-allowed;
}

.tc-reply::placeholder {
  color: var(--tc-muted);
}

.tc-composer-hint {
  max-width: var(--tc-reading-width);
  margin: 6px auto 0;
  color: var(--tc-muted);
  font-size: 11.5px;
}

.tc-composer-hint.is-error {
  color: var(--tc-danger-text);
}

/* ------------------------------------------------------------------ */
/* Details */

.tc-details-title {
  font-size: 14px;
  font-weight: 700;
}

.tc-details {
  margin: 0;
  padding: 4px 16px 24px;
}

.tc-detail {
  padding: 10px 0;
  border-bottom: 1px solid var(--tc-border);
}

.tc-detail:last-child {
  border-bottom: 0;
}

.tc-detail dt {
  margin-bottom: 3px;
  color: var(--tc-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tc-detail dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0;
}

.tc-detail-value {
  min-width: 0;
}

.tc-detail dd.tc-small {
  color: var(--tc-text-2);
  line-height: 1.45;
}

/* ------------------------------------------------------------------ */
/* Websites */

.tc-websites {
  height: 100%;
  overflow-y: auto;
}

.tc-websites-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.tc-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.tc-page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.tc-page-subtitle {
  margin-top: 4px;
  color: var(--tc-muted);
}

.tc-websites-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 40px 16px;
  border: 1px dashed var(--tc-border-strong);
  border-radius: 14px;
  color: var(--tc-muted);
  text-align: center;
}

.tc-website-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tc-card {
  min-width: 0;
  border: 1px solid var(--tc-border);
  border-radius: 14px;
  background: var(--tc-surface);
  box-shadow: var(--tc-shadow-sm);
}

.tc-website {
  padding: 18px 20px 20px;
}

.tc-website-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tc-swatch {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 9px;
  background-color: var(--tc-accent);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.tc-website-titles {
  flex: 1;
  min-width: 0;
}

.tc-website-name,
.tc-website-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-website-name {
  font-size: 16px;
  font-weight: 700;
}

.tc-website-url {
  margin-top: 1px;
  color: var(--tc-muted);
  font-size: 13px;
}

.tc-website-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.tc-website-meta-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: baseline;
  gap: 12px;
}

.tc-website-meta dt {
  color: var(--tc-muted);
  font-size: 13px;
}

.tc-website-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.tc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tc-chip {
  max-width: 100%;
  padding: 2px 8px;
  border: 1px solid var(--tc-border);
  border-radius: 6px;
  background: var(--tc-surface-2);
  font-family: var(--tc-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tc-snippet {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--tc-border);
}

.tc-snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.tc-snippet-label {
  font-size: 13px;
  font-weight: 650;
}

.tc-code {
  margin: 0 0 8px;
  padding: 12px 14px;
  border: 1px solid var(--tc-border);
  border-radius: 10px;
  background: var(--tc-code-bg);
  color: var(--tc-code-text);
  font-family: var(--tc-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------------------------------------------------ */
/* Dialog */

.tc-dialog {
  width: min(560px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--tc-border);
  border-radius: 16px;
  background: var(--tc-surface);
  color: var(--tc-text);
  box-shadow: var(--tc-shadow-lg);
}

.tc-dialog::backdrop {
  background: rgba(12, 15, 20, 0.45);
}

.tc-website-form {
  gap: 0;
  max-height: calc(100vh - 34px);
  max-height: calc(100dvh - 34px);
}

.tc-dialog-header {
  padding: 18px 20px 4px;
}

.tc-dialog-title {
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 12px 20px 18px;
  overflow-y: auto;
}

.tc-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--tc-border);
}

.tc-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tc-color-swatch-input {
  flex-shrink: 0;
  width: 44px;
  height: 38px;
  padding: 3px;
  border: 1px solid var(--tc-border-strong);
  border-radius: 9px;
  background: var(--tc-surface);
  cursor: pointer;
}

.tc-color-text {
  width: 120px;
}

/* ------------------------------------------------------------------ */
/* Toasts */

.tc-toasts {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}

.tc-toast {
  padding: 10px 14px;
  border-left: 3px solid var(--tc-danger-text);
  border-radius: 10px;
  background: var(--tc-toast-bg);
  color: var(--tc-toast-text);
  font-size: 13.5px;
  box-shadow: var(--tc-shadow-lg);
  animation: tc-toast-in 0.18s ease-out;
}

.tc-toast-info {
  border-left-color: var(--tc-accent);
}

@keyframes tc-toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ------------------------------------------------------------------ */
/* Sign-in page */

body.tc-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
}

.tc-auth-main {
  width: 100%;
  max-width: 380px;
}

.tc-auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.tc-auth-brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tc-auth-card {
  padding: 28px 24px 24px;
  border: 1px solid var(--tc-border);
  border-radius: 16px;
  background: var(--tc-surface);
  box-shadow: var(--tc-shadow);
}

.tc-auth-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tc-auth-subtitle {
  margin: 4px 0 20px;
  color: var(--tc-muted);
}

.tc-auth-card .tc-alert {
  margin-bottom: 16px;
}

.tc-auth-card .tc-button-block {
  margin-top: 6px;
}

.tc-auth-footer {
  margin-top: 16px;
  color: var(--tc-muted);
  font-size: 12.5px;
  text-align: center;
}

/* ------------------------------------------------------------------ */
/* Small screens */

@media (max-width: 767px) {
  .tc-header {
    gap: 12px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .tc-brand-name,
  .tc-me {
    display: none;
  }

  .tc-nav-link {
    padding: 0 10px;
  }

  .tc-conversation-header {
    gap: 8px;
    padding: 8px 12px;
  }

  .tc-conversation-actions {
    gap: 4px;
  }

  .tc-conversation-actions .tc-button-small {
    padding: 0 10px;
  }

  .tc-thread {
    padding: 4px 12px 12px;
  }

  .tc-message {
    max-width: 88%;
  }

  .tc-composer {
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .tc-composer-hint:not(.is-error) {
    display: none;
  }

  .tc-websites-inner {
    padding: 20px 16px 40px;
  }

  .tc-website {
    padding: 16px;
  }

  .tc-website-meta-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .tc-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .tc-website-form {
    height: 100%;
    max-height: none;
  }

  .tc-dialog-body {
    flex: 1;
  }
}

@media (max-width: 420px) {
  .tc-conversation-subtitle .tc-conversation-site {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
