/* V1 parity — gui/theme.py TextNow light + purple accent */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f5f5f5;
  --card: #ffffff;
  --border: #e8e8e8;
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --nav-sel: #ede9fe;
  --nav-sel-text: #5b21b6;
  --text: #1a1a1a;
  --muted: #6b7280;
  --row-alt: #fafafa;
  --green: #059669;
  --red: #dc2626;
  --btn-secondary: #e5e7eb;
  --btn-secondary-text: #374151;
  --bubble-out: #8149f8;
  --bubble-in: #f1f1f1;
  --bubble-in-text: #2b2e38;
  --inbox-row-sel: #f0f0f0;
  --sidebar-w: 184px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

a {
  color: inherit;
}

/* ── App shell: sidebar + content ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  overflow-y: auto;
  /* Hide scrollbar but keep sidebar scroll when viewport is short. */
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.sidebar-brand {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

a.nav-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  line-height: 36px;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  transition: background 0.12s;
}

a.nav-item:hover {
  background: #ebebeb;
}

a.nav-item[aria-current="page"] {
  background: var(--nav-sel);
  color: var(--nav-sel-text);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 8px 4px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--panel);
}

.content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: auto;
  background: var(--bg);
  /* Hide scrollbar but keep layout stable (language switch won't jump). */
  scrollbar-width: none;
  scrollbar-gutter: stable both-edges;
}

.content.page-pad {
  padding: 16px 20px;
}

/* ── Page chrome ── */
.page-intro {
  margin: 0 0 20px;
}

.page-intro-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text);
  line-height: 1.45;
}

.page-intro-rule {
  width: 20%;
  min-width: 96px;
  max-width: 280px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
}

.page-hint {
  color: var(--muted);
  font-size: 11px;
  margin: 0 0 12px;
  line-height: 1.4;
}

.page h1,
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
}

.meta {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 12px;
}

.meta.ok {
  color: var(--green);
}

.error {
  color: var(--red);
  font-size: 12px;
}

/* ── Cards & toolbar ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

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

/* Send page: keep action buttons on one line when possible. */
.card.send-task-card .toolbar {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  align-items: center;
}
.card.send-task-card .toolbar.send-task-toolbar {
  margin-bottom: 0;
}
.send-task-workers {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text);
  margin-right: 4px;
  margin-bottom: 0;
}
.send-task-workers span {
  white-space: nowrap;
  color: var(--muted);
  flex-shrink: 0;
}
.send-task-workers-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.send-task-workers-auto {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.send-task-card .send-task-workers input {
  display: inline-block;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  padding: 4px 6px;
  margin: 0;
}
.card.send-task-card .toolbar::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.toolbar-accounts {
  flex-direction: row;
  gap: 6px;
  /* Force toolbar rows stay on a single line when possible. */
  flex-wrap: nowrap;
}

.toolbar-accounts .toolbar-row {
  flex-wrap: nowrap;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.btn {
  font-family: inherit;
  font-size: 12px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
}

button.btn-primary,
.toolbar button:last-of-type {
  background: var(--accent);
  color: #fff;
}

button.btn-primary:hover,
.toolbar button:last-of-type:hover {
  background: var(--accent-hover);
}

button.btn-secondary,
.toolbar button:first-of-type {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
}

button.btn-secondary:hover {
  background: #d1d5db;
}

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

/* ── Overview stats ── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 4px;
}

.overview-grid-8 {
  margin-bottom: 12px;
}

.attention-card {
  margin-top: 8px;
}

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

.attention-head h2 {
  margin: 0;
  font-size: 15px;
}

.badge {
  background: var(--nav-sel);
  color: var(--nav-sel-text);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}

.attention-table {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.attention-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.attention-row.head {
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
}

.proxy-editor,
.field-textarea,
.logs-view {
  width: 100%;
  box-sizing: border-box;
  font-family: Consolas, "Segoe UI", monospace;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--row-alt);
  resize: none;
}

.field-textarea-sm {
  height: 100px;
  min-height: 100px;
  max-height: 100px;
}

.field-textarea-md {
  height: 120px;
  min-height: 120px;
  max-height: 120px;
}

.field-textarea-lg {
  height: 180px;
  min-height: 180px;
  max-height: 180px;
}

.proxy-editor {
  height: 280px;
  min-height: 280px;
  max-height: 280px;
}

.account-row-inner .account-cell-text {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

.account-row-inner.is-dragging,
.account-row-inner.is-dragging .account-cell-text {
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

.proxy-row {
  display: grid;
  grid-template-columns: 32px 72px 1fr 110px 72px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.proxy-row.table-header {
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
}

.proxy-row.table-header input[type="checkbox"] {
  margin: 0;
}

.proxy-scheme-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}

.proxy-ip-cell {
  font-family: Consolas, "Segoe UI", monospace;
  font-size: 12px;
  color: var(--muted);
}

.proxy-ip-cell.has-ip {
  color: var(--text);
}

.proxy-ip-cell.is-probing {
  font-style: italic;
}

.proxy-line-mono {
  font-family: Consolas, "Segoe UI", monospace;
  font-size: 12px;
  word-break: break-all;
}

.field-input {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}

.email-row {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 0.7fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.email-row.table-header {
  font-weight: 600;
  color: var(--muted);
  background: var(--panel);
}

.email-status-pending { color: var(--muted); }
.email-status-used { color: #b8860b; }
.email-status-verified { color: #2e7d32; }

.email-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.email-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.email-import-modal textarea.email-import-editor {
  width: 100%;
  height: 220px;
  min-height: 220px;
  max-height: 220px;
  resize: none;
  margin-top: 8px;
  box-sizing: border-box;
}

.email-import-format {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.email-export-filename {
  width: 100%;
  margin: 6px 0 12px;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.logs-view {
  min-height: 420px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  white-space: pre-wrap;
  margin-top: 8px;
  scrollbar-width: none;
}

.inline-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.inline-label select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px;
}

.quota-row {
  display: grid;
  grid-template-columns: 24px repeat(4, 1fr);
  gap: 8px;
  align-items: center;
  justify-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}

.quota-row > span {
  width: 100%;
  text-align: center;
}

.quota-row > span.user_key {
  justify-self: center;
}

.quota-row.head,
.table-header.quota-row {
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  cursor: default;
}

.quota-row.selected {
  background: var(--nav-sel);
}

.quota-limit-edit {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.quota-limit-edit input {
  width: 88px;
}

.quota-body {
  max-height: calc(100vh - 340px);
  overflow: auto;
  scrollbar-width: none;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat-value.ok {
  color: var(--green);
}

.stat-value.bad {
  color: var(--red);
}

/* ── Data table (accounts / threads) ── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--card);
}

.table-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  height: 32px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.viewport.accounts-viewport {
  min-height: 0;
}

.accounts-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.accounts-page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.accounts-page-size input {
  width: 56px;
}

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

.accounts-page-indicator {
  font-size: 12px;
  color: var(--muted);
  min-width: 72px;
  text-align: center;
}

.viewport {
  height: calc(100vh - 220px);
  min-height: 400px;
  overflow-y: scroll;
  background: var(--card);
  scrollbar-width: none;
  scrollbar-gutter: stable both-edges;
}

.content::-webkit-scrollbar,
.viewport::-webkit-scrollbar,
.chat-log::-webkit-scrollbar,
.logs-view::-webkit-scrollbar,
.quota-body::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.page-inbox .viewport {
  height: calc(100vh - 88px);
  min-height: 300px;
  border: none;
  border-radius: 0;
}

.spacer {
  position: relative;
  width: 100%;
}

.account-row,
.thread-row {
  position: absolute;
  left: 0;
  right: 0;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.account-row {
  height: 40px;
}

.thread-row {
  height: 56px;
  overflow: hidden;
}

.account-row:nth-child(even),
.thread-row:nth-child(even) {
  background: var(--row-alt);
}

.account-row-inner {
  display: grid;
  grid-template-columns: 28px minmax(200px, 3fr) 96px 72px 76px minmax(100px, 1.5fr);
  gap: 8px;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}

.table-header.account-row-inner {
  height: 32px;
}

.col-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.col-sort:hover {
  color: var(--text);
}

.col-sort-active {
  color: var(--text);
}

.sort-mark {
  margin-left: 3px;
  font-size: 10px;
  letter-spacing: -1px;
  color: var(--muted);
}

.col-sort-active .sort-mark {
  color: var(--accent);
}

.account-row:hover,
.thread-row:hover {
  background: var(--inbox-row-sel);
}

.user_key,
.account {
  color: var(--accent);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.email,
.contact {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone,
.preview,
.slot {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-reply-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: #6b7280;
  background: #ececf1;
  vertical-align: middle;
}

.status {
  font-size: 11px;
}

.status-ok {
  color: var(--green);
}

.status-bad {
  color: var(--red);
}

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

.unread {
  text-align: right;
  color: var(--accent);
  font-weight: 700;
}

.thread-link {
  display: block;
  color: inherit;
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.thread-row-inner {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 24px 20px;
  gap: 8px;
  align-items: center;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 6px 12px;
  font-size: 12px;
  box-sizing: border-box;
  overflow: hidden;
}

.js-contact-avatar {
  flex: none;
  line-height: 0;
}

.tn-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tn-avatar__ico-contact {
  display: block;
  width: 14px;
  height: 14px;
  color: #ffffff;
  opacity: 0.92;
  flex-shrink: 0;
}

.thread-main {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.thread-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.thread-row-inner .preview,
.thread-row-inner .account {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 14px;
  max-height: 14px;
}

.thread-row-inner .account {
  font-size: 11px;
  color: var(--muted);
}

.thread-time {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  flex-shrink: 0;
}

.thread-row-active {
  background: var(--nav-sel);
}

.thread-row-active .contact,
.thread-row-active .account {
  color: var(--nav-sel-text);
}

.thread-row-inner .contact {
  font-weight: 600;
}

.thread-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  height: 24px;
  width: 24px;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.icon-pin {
  width: 20px;
  height: 20px;
  display: block;
  color: #9ca3af;
  transform: rotate(180deg);
  flex-shrink: 0;
}

.icon-pin-active {
  color: #7c3aed;
  transform: none;
}

.thread-pin:hover .icon-pin:not(.icon-pin-active) {
  color: #7c3aed;
}

.thread-row-active .thread-pin:hover .icon-pin:not(.icon-pin-active) {
  color: #5b21b6;
}

.thread-row-active .icon-pin:not(.icon-pin-active) {
  color: rgba(91, 33, 182, 0.45);
}

.thread-row-active .icon-pin-active {
  color: #5b21b6;
}

.thread-row-active .preview,
.thread-row-active .thread-time {
  color: var(--nav-sel-text);
  opacity: 0.85;
}

/* ── Inbox split (TN web messaging) ── */
.page-inbox {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.inbox-split {
  display: flex;
  height: calc(100vh - 0px);
  min-height: 600px;
}

.inbox-list-pane {
  width: 280px;
  min-width: 250px;
  max-width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--row-alt);
  display: flex;
  flex-direction: column;
}

.inbox-list-head {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.inbox-list-head .page-intro {
  margin-bottom: 10px;
}

.inbox-list-head .page-intro-title {
  font-size: 13px;
}

.inbox-list-head .page-intro-rule {
  min-width: 48px;
}

.inbox-list-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.inbox-chat-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.inbox-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px;
}

.inbox-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Chat ── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 0;
}

.chat-page .chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-page .chat-header h1 {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  scrollbar-width: none;
}

.bubble {
  display: block;
  width: fit-content;
  max-width: 72%;
  margin-bottom: 10px;
  padding: 5px 12px;
  border-radius: 15px;
  font-size: 14px;
  line-height: 1.35;
}

.bubble.in {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  margin-right: auto;
}

.bubble.out {
  background: var(--bubble-out);
  color: #ffffff;
  margin-left: auto;
}

.bubble-body,
.bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-meta {
  font-size: 10px;
  opacity: 0.75;
  margin-top: 4px;
}

.chat-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 4px;
}

.chat-compose {
  display: none;
}

.chat-footer {
  flex-shrink: 0;
  border-top: 1px solid #e8e8e8;
  background: #ffffff;
}

.chat-progress-wrap {
  padding: 8px 16px 0;
}

.chat-progress-bar {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.14);
  overflow: hidden;
}

.chat-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8b5cf6 0%, #7c3aed 100%);
  transition: width 180ms ease;
}

.chat-footer-status {
  padding: 6px 16px 0;
  font-size: 11px;
  color: var(--muted);
}

.chat-error-toast {
  position: fixed;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%) translateY(12px);
  z-index: 12000;
  max-width: min(520px, 92vw);
  padding: 12px 18px;
  border-radius: 10px;
  background: rgba(127, 29, 29, 0.96);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  opacity: 0;
  animation: chat-error-toast-in 0.28s ease forwards;
  pointer-events: none;
  word-break: break-word;
}

.chat-error-toast-out {
  animation: chat-error-toast-out 0.38s ease forwards;
}

@keyframes chat-error-toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes chat-error-toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
}

.chat-input-error,
.chat-footer .grow-wrap.chat-input-error textarea {
  color: #b91c1c !important;
  border-color: #fca5a5 !important;
  background: #fef2f2 !important;
}

.chat-footer .input form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 14px;
  margin: 0;
}

.chat-footer .grow-wrap {
  flex: 1;
  min-width: 0;
  order: 0;
  display: grid;
}

.chat-footer .emoji-btn,
.chat-footer .gallery-btn,
.chat-footer #send_button {
  order: 1;
  flex: none;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.chat-emoji-panel {
  display: grid;
  grid-template-columns: repeat(4, 36px);
  gap: 4px;
  padding: 8px 16px 0;
  justify-content: start;
}

.chat-emoji-item {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-emoji-item:hover {
  background: rgba(0, 0, 0, 0.06);
}

.chat-footer .icon-mask {
  width: 24px;
  height: 24px;
}

.tn-hidden {
  display: none !important;
}

.grow-wrap::after {
  content: attr(data-replicated-value) " ";
  white-space: pre-wrap;
  visibility: hidden;
  grid-area: 1 / 1 / 2 / 2;
  font-size: 15px;
  line-height: 24px;
  padding: 0;
  min-height: 24px;
  max-height: 120px;
  overflow: hidden;
}

#grow-wrap > textarea,
.grow-wrap > textarea,
#grow-wrap > #text-input,
.grow-wrap > #text-input {
  grid-area: 1 / 1 / 2 / 2;
  width: 100%;
  min-height: 24px;
  max-height: 120px;
  resize: none;
  overflow-y: auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #2b2e38;
  padding: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 24px;
  outline: none;
  box-shadow: none;
}

.grow-wrap > textarea::placeholder,
#grow-wrap > #text-input::placeholder {
  color: #9ca3af;
}

.grow-wrap > textarea:focus,
#grow-wrap > #text-input:focus {
  outline: none;
}

.icon-chat {
  width: 22px;
  height: 22px;
  display: block;
  flex-shrink: 0;
}

.icon-emoji,
.icon-gallery {
  color: #111827;
}

.icon-send {
  color: #8149f8;
}

.icon-mask {
  display: block;
  width: 22px;
  height: 22px;
  background: #111827;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.icon-mask-emoji {
  mask-image: url(/assets/icons/emoji.svg);
  -webkit-mask-image: url(/assets/icons/emoji.svg);
}

.icon-mask-gallery {
  mask-image: url(/assets/icons/gallery.svg);
  -webkit-mask-image: url(/assets/icons/gallery.svg);
}

.icon-mask-send {
  width: 22px;
  height: 22px;
  background: #8149f8;
  mask-image: url(/assets/icons/send.svg);
  -webkit-mask-image: url(/assets/icons/send.svg);
}

.icon-mask-pin {
  width: 20px;
  height: 20px;
  background: #9ca3af;
  mask-image: url(/assets/icons/Unpin.svg);
  -webkit-mask-image: url(/assets/icons/Unpin.svg);
  transform: rotate(180deg);
}

.icon-mask-pin-active {
  background: #7c3aed;
  transform: none;
}

.chat-footer .emoji-btn:hover .icon-emoji,
.chat-footer .gallery-btn:hover .icon-gallery {
  color: #8149f8;
}

.chat-footer #send_button:hover .icon-send {
  color: #6d3dd8;
}

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

.chat-compose textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  background: var(--bg);
  border: 1px solid #dadada;
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
}

.chat-compose-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.chat-compose button {
  background: var(--accent);
  color: #fff;
  height: 40px;
  padding: 0 18px;
}

/* ── Send form ── */
.send-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}

.send-form input,
.send-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
}

.send-form textarea {
  min-height: 100px;
}

/* Send page controls (send.rs currently doesn't wrap in .send-form). */
.send-settings-card input,
.send-task-card input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
}

.send-settings-card textarea,
.send-task-card textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  box-sizing: border-box;
}

.send-task-card textarea {
  min-height: 80px;
}

/* ── License gate ── */
.license-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.license-gate {
  width: 440px;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 28px 32px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.license-gate h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

.license-gate label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 16px;
}

.license-gate input {
  width: 100%;
  margin-top: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.license-gate button {
  margin-top: 16px;
  background: var(--accent);
  color: #fff;
  width: 100%;
  height: 36px;
}

/* ── Lang switch ── */
.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-switch button {
  flex: 1;
  height: 28px;
  padding: 0;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  line-height: 28px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-switch button.active {
  color: var(--nav-sel-text);
  border-color: var(--accent);
  background: var(--nav-sel);
  font-weight: 600;
}

.sidebar-queue {
  margin-bottom: 6px;
}

.sidebar-queue-label {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-queue-bar {
  height: 6px;
  background: var(--panel);
  border-radius: 3px;
  overflow: hidden;
}

.sidebar-queue-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.sidebar-queue-idle .sidebar-queue-label {
  margin-bottom: 0;
}

.health-schedule-card h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.health-schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.health-schedule-label {
  color: var(--muted);
  font-size: 13px;
  min-width: 6em;
}

.health-schedule-time {
  width: 8.5rem;
}

.sidebar-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* footer 内容不应被裁剪：sticky 负责保持可见 */

.license-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.send-settings-grid,
.send-task-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.send-settings-card,
.send-task-card {
  margin-bottom: 16px;
}

.send-schedule-time {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.send-schedule-time select {
  min-width: 64px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: Consolas, "Segoe UI", monospace;
}

.send-schedule-colon {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
}

.send-schedule-preview {
  font-weight: 600;
  margin-left: 4px;
}

.send-schedule-tz {
  margin-top: 0;
  font-weight: 600;
}

.queue-status {
  margin: 0 0 12px;
  font-weight: 600;
}
  width: 100%;
  margin-top: 6px;
}

.recent-table {
  font-size: 12px;
}

.recent-row {
  display: grid;
  grid-template-columns: 140px 1fr 60px 2fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.recent-row.head {
  font-weight: 600;
  color: var(--muted);
}

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

.btn-sm {
  height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.chat-compose-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.image-path-input {
  flex: 1;
  min-width: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  width: 480px;
  max-width: calc(100vw - 32px);
}

.modal-card.modal-wide {
  width: 640px;
}

.modal-card textarea {
  width: 100%;
  margin-top: 8px;
  resize: none;
  box-sizing: border-box;
}

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

.login-dialog .login-cred-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.login-dialog .login-cred-row label {
  font-size: 12px;
  color: var(--muted);
}

.login-dialog .login-cred-row input {
  width: 100%;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.login-dialog-progress {
  margin-top: 4px;
}

.login-dialog-status {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.login-dialog-status-ok {
  color: var(--accent);
}

.login-dialog-status-err {
  color: #c44;
}

.context-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 199;
  background: transparent;
}

.context-menu {
  position: fixed;
  z-index: 200;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  height: auto;
}

.context-menu button:hover {
  background: var(--nav-sel);
}

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

.bubble-img {
  max-width: 280px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
}

/* ── Startup splash ── */
.startup-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #0f172a 0%, #312e81 45%, #6d28d9 100%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.startup-overlay-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.startup-card {
  position: relative;
  width: min(440px, 92vw);
  padding: 34px 38px 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.startup-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 60%
  );
  transform: translateX(-120%);
  animation: startup-scan 2.8s ease-in-out infinite;
}

@keyframes startup-scan {
  0% {
    transform: translateX(-120%);
  }
  55%,
  100% {
    transform: translateX(120%);
  }
}

.startup-progress-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  margin-bottom: 18px;
  overflow: hidden;
}

.startup-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7c3aed, #22d3ee, #34d399);
  transition: width 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.55);
}

.boot-progress-pulse {
  width: 18%;
  animation: boot-progress-pulse 1.4s ease-in-out infinite;
}

@keyframes boot-progress-pulse {
  0%,
  100% {
    width: 12%;
    opacity: 0.65;
  }
  50% {
    width: 28%;
    opacity: 1;
  }
}

.boot-splash-static {
  transition: opacity 0.28s ease;
}

.startup-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #f8fafc;
  text-align: center;
}

.startup-sub {
  margin-top: 6px;
  margin-bottom: 22px;
  text-align: center;
  color: rgba(226, 232, 240, 0.72);
  font-size: 12px;
}

.startup-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.startup-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.35);
  color: rgba(226, 232, 240, 0.55);
  transition: background 0.28s ease, color 0.28s ease, transform 0.28s ease, box-shadow 0.28s ease;
}

.startup-step-lead {
  flex-shrink: 0;
  width: 1.1em;
  text-align: center;
  font-size: 12px;
  opacity: 0.85;
}

.startup-step-active {
  color: #f8fafc;
  background: rgba(124, 58, 237, 0.28);
  transform: translateX(3px);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.35), 0 8px 20px rgba(91, 33, 182, 0.22);
  animation: startup-step-glow 1.6s ease-in-out infinite;
}

@keyframes startup-step-glow {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.28), 0 6px 16px rgba(91, 33, 182, 0.16);
  }
  50% {
    box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.5), 0 10px 24px rgba(91, 33, 182, 0.28);
  }
}

.startup-step-ready {
  color: #bbf7d0;
  background: rgba(16, 185, 129, 0.14);
  transform: translateX(0);
  animation: startup-step-pop 0.38s ease-out;
}

@keyframes startup-step-pop {
  0% {
    transform: scale(0.98);
  }
  60% {
    transform: scale(1.01);
  }
  100% {
    transform: scale(1);
  }
}

.startup-step-ready .startup-step-lead {
  color: #34d399;
}

.startup-step-name {
  flex: 1;
  font-weight: 600;
}

.startup-step-status {
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 11px;
  min-width: 6.5em;
  text-align: right;
  letter-spacing: 0.02em;
}

.startup-done {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #fde68a;
  letter-spacing: 0.12em;
  animation: startup-pulse 1.2s ease-in-out infinite;
}

.startup-license-form {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.startup-license-hint {
  margin: 0 0 10px;
  font-size: 12px;
  color: rgba(226, 232, 240, 0.78);
  text-align: center;
}

.startup-license-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.startup-license-row input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.45);
  color: #f8fafc;
  font-family: inherit;
  font-size: 13px;
}

.startup-license-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: #fca5a5;
  text-align: center;
}

@keyframes startup-pulse {
  0%,
  100% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
}
