:root {
  --forest: #172f2d;
  --accent: #2c7569;
  --accent-hover: #205d53;
  --mint: #edf5f1;
  --ink: #202c2b;
  --muted: #667772;
  --line: #e7ebea;
  --canvas: #f5f7f6;
  --paper: #fff;
  --danger: #b74d50;
  --radius: 12px;

  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}
* {
  box-sizing: border-box;
}
body,
html {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button,
a,
input,
select {
  outline-offset: 3px;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #98c5bc;
}
button,
.button {
  border: 1px solid #e3e8e6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 13px;

  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  transition:
    background 0.15s,
    border-color 0.15s;
}
button:hover,
.button:hover {
  background: #f3f6f4;
  border-color: #d4dfd9;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.primary,
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover,
.button.primary:hover {
  background: var(--accent-hover);
}
button.text {
  border: 0;
  padding: 0;
  background: none;
  color: #667e77;
}
button.text:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}
button.danger,
.error {
  color: var(--danger);
}
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  vertical-align: middle;
}
.icon-button {
  width: 34px;
  height: 34px;
  padding: 7px;
  flex-shrink: 0;
}
.icon-button .icon {
  width: 17px;
  height: 17px;
}
input,
select {
  border: 1px solid #dfe6e2;
  border-radius: 8px;
  background: #fcfdfc;
  color: var(--ink);
  padding: 10px 12px;
  min-width: 0;
  width: 100%;
}
input:focus,
select:focus {
  outline: none;
  border-color: var(--muted);
  box-shadow: 0 0 0 3px #3c927812;
}
input::placeholder {
  color: var(--muted);
}
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  box-shadow: none;
}
label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
h1,
h2,
p {
  margin: 0;
}
.muted {
  color: var(--muted);
}
.eyebrow {
  color: var(--muted);
}
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  background: #9ba8a1;
  border-radius: 50%;
}
.dot.green {
  background: #45ac79;
}
.dot.amber {
  background: #d4a24a;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 5px);
  gap: 2px;
  transform: rotate(45deg);
}
.brand-mark i {
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: #63ab97;
}
.brand-mark i:nth-child(2) {
  opacity: 0.55;
}
.brand-mark i:nth-child(3) {
  opacity: 0.7;
}
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.sidebar {
  width: 195px;
  flex-shrink: 0;
  background: var(--forest);
  color: #f5f9f7;
  padding: 25px 16px 17px;
  display: flex;
  flex-direction: column;
}
.sidebar > .brand {
  margin: 0 12px 36px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.sidebar nav button {
  justify-content: flex-start;
  gap: 12px;
  padding: 12px;
  border: 0;
  background: none;
  color: #c1d1cc;

  border-radius: 8px;
}
.sidebar nav button.active {
  background: #2c514b;
  color: #fff;
}
.sidebar nav button:hover {
  background: #24453f;
}
.sidebar-connection {
  display: flex;
  gap: 9px;
  justify-content: flex-start;
  align-items: center;
  padding: 16px 0 0;
  margin-top: auto;
  background: transparent !important;
  border: 0;
  border-top: 1px solid #ffffff15;
  border-radius: 0;
  color: #d1e0db;

  text-align: left;
}
.sidebar-connection span small {
  display: block;

  color: var(--muted);
  max-width: 115px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.telegram-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: #294a44;
  border-radius: 7px;
  flex-shrink: 0;
}
.sidebar-connection > .dot {
  margin-left: auto;
}
.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  max-width: 1700px;
  margin: 0 auto;
  padding: 30px;
  display: flex;
  flex-direction: column;
  overflow: auto;
  width: 100%;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.page-heading p {
  color: var(--muted);
  margin-top: 6px;
}
.page-heading .back {
  margin-bottom: 9px;
}
.back .icon {
  width: 13px;
  height: 13px;
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
}
.section-title h2 .icon {
  margin-right: 5px;
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.status.on {
  color: #39866c;
}
.status.paused {
  color: var(--muted);
}
.search-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-controls button {
  padding: 6px 10px;
  min-height: 30px;
}
.search-controls .selected {
  background: white;
  border-color: #dde5e0;
  color: var(--ink);
}
.search-table {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.table-head,
.search-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 72px 54px 126px 388px;
  gap: 14px;
  align-items: center;
}
.table-head {
  padding: 14px 20px;

  color: var(--muted);
  background: #fcfdfc;
  border-bottom: 1px solid var(--line);
}
.search-row {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.search-row:last-child {
  border: 0;
}
.search-title {
  display: flex;
  justify-content: flex-start;
  padding: 0;
  background: transparent !important;
  border: 0;
  gap: 13px;
  text-align: left;
  min-width: 0;
}
.search-symbol {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 35px;
  height: 35px;
  background: #f2f5f3;
  border-radius: 8px;
  color: #647d72;
}
.search-title > span:last-child {
  min-width: 0;
}
.search-title strong {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.search-title small {
  display: block;

  color: var(--muted);
  margin-top: 5px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 600px;
}
.search-source-count small {
  display: block;

  color: var(--muted);
  margin-top: 3px;
}
.new-count {
  color: #318266;
}
.new-count small {
  display: none;
}
.search-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.search-actions button {
  min-height: 36px;
  padding: 7px 9px;
  gap: 5px;
  white-space: nowrap;
}
.search-actions .icon {
  width: 15px;
  height: 15px;
}
.quiet-note {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);

  padding: 17px 4px;
}
.quiet-note .icon {
  width: 15px;
  height: 15px;
}
.setup-notice {
  padding: 18px 20px;
  border: 1px solid #e0e9e3;
  border-radius: 10px;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  background: #eff5f1;
  margin-top: 10px;
}
.setup-notice p {
  color: var(--muted);
  margin-top: 4px;
}
.empty {
  min-height: 230px;
  padding: 35px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  color: var(--muted);
  gap: 13px;
}
.empty > .icon {
  width: 30px;
  height: 30px;
  color: var(--muted);
}
.empty h2 {
  color: #6f8177;
}
.empty p {
  max-width: 290px;
}
/* Editor */
#search-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(220px, 0.85fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.editor-grid > .panel {
  overflow: auto;
  min-width: 0;
}
.editor-grid label {
  margin-bottom: 22px;
}
.tag-field {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid #dfe6e2;
  border-radius: 8px;
  padding: 7px;
  align-items: center;
  max-height: 155px;
  overflow: auto;
  background: #fcfdfc;
}
.tag-field:focus-within {
  border-color: var(--muted);
}
.tag {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #eef3ef;
  border-radius: 5px;
  padding: 5px 8px;

  max-width: 100%;
  overflow-wrap: anywhere;
}
.tag button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);

  width: 16px;
  height: 20px;
}
.tag-field input {
  border: 0;
  background: transparent;
  flex: 1;
  width: 130px;
  min-width: 110px;

  padding: 5px;
  box-shadow: none;
}
.field-hint {
  color: var(--muted);
  display: block;
}
.editor-conditions > .field-hint {
  margin: -12px 0 24px;
}
.chosen-sources {
  max-height: 180px;
  overflow: auto;
  margin-bottom: 20px;
}
.chosen-source {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #edf1ee;
  padding: 10px 0;
}
.chosen-source > span {
  flex: 1;
}
.chosen-source > span small {
  display: block;

  color: var(--muted);
  margin-top: 3px;
}
.chosen-source > .icon {
  width: 15px;
  height: 15px;
  color: #648d79;
}
.chosen-source .icon-button {
  width: 27px;
  height: 27px;
  border: 0;
  color: var(--muted);
}
.source-empty {
  color: var(--muted);

  margin-bottom: 24px;
}
.editor-sources .section-title button {
  padding: 6px 9px;
}
.toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;

  cursor: pointer;
}
.toggle input {
  appearance: none;
  width: 33px;
  height: 19px;
  border-radius: 20px;
  background: #d4dbd5;
  border: 0;
  padding: 2px;
  position: relative;
  transition: background 0.2s;
  margin: 0;
}
.toggle input:before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px #0002;
  transition: transform 0.2s;
}
.toggle input:checked {
  background: var(--accent);
}
.toggle input:checked:before {
  transform: translateX(14px);
}
.editor-summary h2 {
  margin-bottom: 20px;
}
.editor-summary dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 10px;
  margin: 0 0 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.editor-summary dt {
  color: var(--muted);
}
.editor-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
}
.editor-summary .toggle {
  margin-bottom: 18px;
}
.mobile-save {
  display: none;
}
/* Three panes */
.page-inbox {
  overflow: hidden;
  padding: 24px;
}
.inbox-heading {
  margin-bottom: 18px;
}
.run-tools {
  display: flex;
  align-items: center;
  gap: 14px;
}
.run-tools > button {
  padding: 9px 11px;
}
.run-tools .icon {
  width: 15px;
  height: 15px;
}
.run-status {
  border: 0;
  background: none;
  padding: 0;

  color: var(--muted);
}
.phone-copy {
  display: none;
}
.inbox-grid {
  display: grid;
  grid-template-columns: 185px minmax(270px, 0.95fr) minmax(310px, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}
.source-panel {
  padding: 14px 9px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.source-panel .section-title {
  padding: 0 5px;
  margin-bottom: 12px;
}
.source-panel .icon-button {
  width: 25px;
  height: 25px;
  border: 0;
}
.source-panel input {
  padding: 8px;
  margin-bottom: 10px;
}
#source-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
#source-list > button {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 7px;
  padding: 9px 7px;
  background: transparent;
  border: 0;
  justify-content: flex-start;

  text-align: left;
  margin-bottom: 3px;
}
#source-list > button.active {
  background: #edf4f0;
  color: #276f5d;
}
#source-list > button > .icon {
  width: 13px;
  height: 13px;
}
#source-list > button > span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#source-list > button > small {
  border-radius: 4px;
  background: #e9efeb;
  padding: 2px 5px;
  color: var(--muted);
}
.message-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.status-tabs {
  display: flex;
  gap: 1px;
  padding: 5px 7px 0;
  border-bottom: 1px solid var(--line);
  overflow: auto;
  flex-shrink: 0;
}
.status-tabs > button {
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  padding: 10px 7px;
  gap: 5px;
  border-radius: 0;

  color: var(--muted);
  white-space: nowrap;
}
.status-tabs > button.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}
.status-tabs span {
  background: #f0f4f0;
  padding: 1px 4px;
  border-radius: 10px;
}
.inbox-tools {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid #f0f3f0;
  flex-shrink: 0;
}
.inbox-tools input {
  padding: 8px;
  min-width: 0;
}
.inbox-tools .icon-button {
  background: #f6f8f6;
  border: 0;
}
.message-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.message-row {
  border-bottom: 1px solid #edf1ed;
}
.message-summary {
  border: 0;
  background: none;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
  text-align: left;
  width: 100%;
  padding: 15px 12px;
  border-radius: 0;
}
.message-summary:hover {
  background: #f9fbf9;
}
.message-row.active > .message-summary {
  background: #edf5ef;
}
.message-symbol {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: #f1f5f0;
  border-radius: 6px;
  flex-shrink: 0;
  color: var(--muted);
}
.message-symbol .icon {
  width: 16px;
  height: 16px;
}
.message-summary > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}
.message-summary strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.message-summary small {
  display: block;
  color: var(--muted);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 5px;
}
.message-summary > .dot {
  margin-top: 5px;
  width: 5px;
  height: 5px;
}
.excerpt {
  display: block;

  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.load-more {
  width: 100%;
  border: 0;
  padding: 13px;

  border-radius: 0;
}
.reader {
  padding: 22px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.reader-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
  flex-shrink: 0;
}
.reader-title .icon {
  width: 12px;
  height: 12px;
}
.reader h2 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex-shrink: 0;
}
.reader-meta {
  color: var(--muted);

  margin-bottom: 20px;
  flex-shrink: 0;
}
.fact-line {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 15px;
  flex-shrink: 0;
}
.fact-line small {
  color: var(--muted);
  margin-left: 7px;
}
.message-preview {
  white-space: pre-wrap;
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 9;
  -webkit-box-orient: vertical;
  flex: 0 1 auto;
  min-height: 45px;
  margin-bottom: 18px;
}
.contact-line {
  display: flex;
  align-items: baseline;
  gap: 12px;

  margin: 0 0 15px;
  flex-shrink: 0;
}
.contact-line > span {
  color: var(--muted);
}
.contact-line > div {
  min-width: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.contact-line a {
  padding: 5px 8px;
  border-radius: 5px;
  background: #f0f4ef;
  text-decoration: none;
  color: #447559;
  overflow-wrap: anywhere;
}
.contact-line small {
  color: var(--muted);
}
.keyword-line {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 15px;
  flex-shrink: 0;
  max-height: 60px;
  overflow: auto;
}
.keyword-line span {
  color: #6d8a72;
  background: #f3f7f1;
  padding: 4px 7px;
  border-radius: 5px;
}
#mobile-source-label {
  display: none;
}
/* Account and authentication */
.account-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  max-width: 1080px;
}
.account-grid .panel {
  padding: 26px;
}
.account-grid h2 {
  margin-bottom: 18px;
}
.account-grid h2 .icon {
  margin-right: 5px;
  color: #608b6b;
}
.account-grid .muted {
  margin-bottom: 22px;
}
.connected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 17px;
  background: #f0f6ef;
  border-radius: 9px;
  margin-bottom: 20px;
}
.connected > .icon {
  color: #3b9862;
  flex-shrink: 0;
}
.connected p {
  color: var(--muted);
  margin-top: 3px;
}
.qr-setup {
  display: flex;
  align-items: center;
  gap: 20px;
}
.qr-box {
  width: 165px;
  height: 165px;
  border: 1px solid #e3ebe0;
  background: white;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.qr-box img {
  width: 155px;
  height: 155px;
}
.qr-box > .icon {
  width: 45px;
  height: 45px;
  color: var(--muted);
}
.qr-setup ol {
  padding-left: 18px;

  color: var(--muted);
}
.qr-setup ol li {
  margin-bottom: 7px;
}
.qr-setup small {
  color: var(--muted);
}
.notice {
  padding: 15px;
  border: 1px solid #dfe8d9;
  background: #f6f8f2;
  border-radius: 8px;

  color: var(--muted);
}
.account-grid .field-hint {
  margin-top: 15px;
}
.account-grid .error {
  margin-top: 15px;
}
.account-grid form label {
  margin-bottom: 20px;
}
.auth-page {
  width: 100%;
  height: 100dvh;
  padding: 34px;
  display: flex;
  align-items: center;
  flex-direction: column;
  overflow: auto;
  background: radial-gradient(ellipse at top, #e9f1eb, #f6f8f6 60%);
}
.auth-page > .brand {
  margin-bottom: 55px;
  color: var(--forest);
}
.auth-card {
  width: 100%;
  max-width: 390px;
  background: white;
  border: 1px solid #e3e9e0;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 10px 50px #1b3e2505;
}
.auth-card h1 {
  margin: 14px 0 9px;
}
.auth-card > .muted {
  margin-bottom: 25px;
}
.auth-card label {
  margin-bottom: 20px;
}
.auth-card > .primary {
  width: 100%;
  margin: 5px 0;
}
.auth-error,
.auth-card .error {
  margin: 10px 0;
}
.auth-switch {
  color: var(--muted);
  text-align: center;
  margin-top: 18px;
}
.auth-switch button {
  margin-left: 3px;
}
.auth-note {
  color: var(--muted);
  margin: 25px auto;
  text-align: center;
}
/* Dialogs and feedback */
dialog {
  width: 460px;
  max-width: calc(100vw - 28px);
  max-height: 85dvh;
  overflow: auto;
  border: 1px solid #e3e8df;
  border-radius: 16px;
  background: white;
  color: var(--ink);
  padding: 25px;
  box-shadow: 0 20px 80px #142d201f;
}
dialog::backdrop {
  background: #132e2436;
  backdrop-filter: blur(4px);
}
.modal-heading {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: center;
  margin-bottom: 24px;
}
.modal-heading h2 {
  overflow-wrap: anywhere;
}
.modal-heading button {
  background: #f5f7f2;
  border: 0;
  border-radius: 50%;
}
dialog > p {
  margin-bottom: 20px;
}
dialog label {
  margin-bottom: 18px;
}
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions > span {
  margin-right: auto;
  color: var(--muted);
}
.chat-list {
  max-height: 45dvh;
  overflow: auto;
  margin: 15px 0;
}
.chat-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
  cursor: pointer;
}
.chat-option small {
  display: block;

  color: var(--muted);
  margin-top: 4px;
}
.chat-option span {
  overflow-wrap: anywhere;
}
.full-message {
  white-space: pre-wrap;
  overflow-wrap: anywhere;

  max-height: 65dvh;
  overflow: auto;
}
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 15px);
  background: #23392e;
  color: #fff;
  padding: 12px 18px;
  max-width: 90vw;
  border-radius: 10px;

  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  z-index: 100;
  box-shadow: 0 8px 30px #122b221a;
}
#toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}
.boot {
  height: 100dvh;
  width: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.mobile-top,
.bottom-nav {
  display: none;
}
* {
  scrollbar-width: thin;
  scrollbar-color: #d5ded2 transparent;
}
@media (min-width: 721px) and (max-width: 1200px) {
  .sidebar {
    width: 160px;
    padding: 25px 11px 15px;
  }
  .sidebar > .brand {
    margin-left: 10px;
  }
  .sidebar nav button {
    gap: 9px;
  }
  .main {
    padding: 22px;
  }
  .table-head,
  .search-row {
    grid-template-columns: minmax(180px, 1fr) 75px 60px 126px;
    gap: 10px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .table-head > :last-child {
    display: none;
  }
  .search-actions {
    grid-column: 1 / -1;
    padding-left: 48px;
  }
  .editor-grid {
    grid-template-columns: 1fr 1fr;
  }
  .editor-summary {
    grid-column: 1/-1;
    display: flex;
    align-items: center;
    gap: 20px;
    max-height: 160px;
  }
  .editor-summary h2 {
    display: none;
  }
  .editor-summary dl {
    min-width: 200px;
    margin: 0;
    padding: 0;
    border: 0;
    gap: 8px;
  }
  .editor-summary .field-hint {
    display: none;
  }
  .editor-summary .toggle {
    margin: 0;
    max-width: 180px;
  }
  .editor-grid > .panel {
    padding: 18px;
  }
  .page-inbox {
    padding: 18px;
  }
  .inbox-grid {
    grid-template-columns: 180px minmax(245px, 1fr) minmax(275px, 1.1fr);
    gap: 8px;
  }
  .source-panel {
    padding: 12px 7px;
  }
  .reader {
    padding: 17px;
  }
  .run-tools {
    align-items: flex-end;
    flex-direction: column;
    gap: 5px;
  }
  .status-tabs > button {
    padding: 10px 5px;
  }
  .message-summary {
    padding: 13px 10px;
  }
  .message-symbol {
    display: none;
  }
  .account-grid {
    grid-template-columns: 1fr;
  }
  .account-grid .panel {
    padding: 22px;
  }
  .qr-setup {
    max-width: 530px;
  }
}

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

@media (min-width: 721px) and (max-width: 980px) {
  .sidebar {
    width: 140px;
  }
  .inbox-grid {
    grid-template-columns: minmax(230px, 1fr) minmax(270px, 1.1fr);
  }
  .source-panel {
    display: none;
  }
  #mobile-source-label {
    display: block;
    padding: 0 12px 10px;
  }
  .source-chip {
    max-width: 100%;
  }
  .table-head,
  .search-row {
    grid-template-columns: minmax(140px, 1fr) 64px 42px 116px;
    gap: 8px;
  }
  .editor-grid {
    display: flex;
    flex-direction: column;
    overflow: auto;
  }
  .editor-grid > .panel {
    flex-shrink: 0;
  }
  .editor-summary {
    max-height: none;
    flex-wrap: wrap;
  }
  .run-tools > button {
    padding: 8px;
  }
  .inbox-heading {
    gap: 10px;
  }
}
@media (min-width: 721px) {
  .reader {
    overflow: hidden;
  }
  .reader h2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .reader-meta {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-shrink: 0;
  }
  .contact-line {
    max-height: 85px;
    overflow: auto;
  }
  .reader .message-preview {
    min-height: 0;
  }
}

/* Shared page template: title/subtitle and actions align the same way in every view. */
.page-heading-copy {
  min-width: 0;
  flex: 1;
}
.page-heading-copy h1 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.page-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.source-panel .section-title {
  gap: 4px;
}

/* Search selection stays above sources; the same control is used on mobile. */
.mobile-search-switcher {
  display: none;
}
.search-switcher {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  padding: 10px;
  background: #f2f7f5;
  border-color: #dce8e3;
}
.source-panel > .search-switcher {
  flex-shrink: 0;
  margin-bottom: 18px;
}
.search-switcher-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 3px;
}
.search-switcher small {
  color: var(--muted);
}
.search-switcher strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.search-switcher > .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.search-picker-modal {
  width: 480px;
}
.search-picker-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 45dvh;
  overflow: auto;
  margin-top: 14px;
}
.search-picker-list > button {
  width: 100%;
  min-height: 68px;
  border: 1px solid transparent;
  background: transparent;
  padding: 12px;
  gap: 10px;
  justify-content: flex-start;
  text-align: left;
  flex-shrink: 0;
}
.search-picker-list > button:hover {
  background: #f5f8f6;
}
.search-picker-list > button.active {
  background: #edf5f1;
  border-color: #d7e9df;
  color: var(--accent);
}
.search-picker-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.search-picker-copy strong {
  overflow-wrap: anywhere;
}
.search-picker-copy small,
.search-picker-count small {
  color: var(--muted);
}
.search-picker-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.search-picker-check {
  width: 18px;
  flex-shrink: 0;
  display: flex;
}
.search-picker-check .icon {
  width: 18px;
  height: 18px;
}
.search-picker-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Explicit lead states replace the overflow menu on every device. */
.message-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.message-action-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 20px;
}
.message-action-heading > small {
  color: var(--muted);
}
.message-telegram {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: none;
}
.message-telegram:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.message-telegram .icon {
  width: 13px;
  height: 13px;
}
.lead-status-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.lead-status-options button {
  min-width: 0;
  padding: 8px 5px;
  min-height: 36px;
  white-space: nowrap;
}
.lead-status-options button.active {
  opacity: 1;
  background: var(--mint);
  border-color: #99c4b8;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px #99c4b8;
}
@media (min-width: 1201px) {
  .reader .lead-status-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 721px) and (max-width: 980px) {
  .mobile-search-switcher {
    display: block;
    grid-column: 1/-1;
  }
  .inbox-grid {
    grid-template-rows: auto minmax(0, 1fr);
  }
  .mobile-search-switcher .search-switcher {
    min-height: 56px;
  }
}

/* Compact desktop reference, with room for readable source names. */
@media (min-width: 981px) {
  .main {
    padding: 22px 24px;
  }
  .page-heading {
    margin-bottom: 18px;
  }
  .inbox-grid {
    grid-template-columns: 245px minmax(260px, 1.05fr) minmax(300px, 0.95fr);
  }
  .reader {
    padding: 18px;
    container-type: inline-size;
  }
  .reader-title {
    margin-bottom: 12px;
  }
  .reader-meta {
    margin-bottom: 14px;
  }
  .fact-line {
    padding: 10px 0;
    margin-bottom: 12px;
  }
  .contact-line,
  .keyword-line,
  .message-preview {
    margin-bottom: 12px;
  }
  .reader .lead-status-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 981px) and (max-width: 1400px) {
  .sidebar {
    width: 160px;
    padding: 22px 12px 14px;
  }
  .sidebar > .brand {
    margin-left: 8px;
  }
  .main {
    padding: 18px;
  }
  .inbox-grid {
    grid-template-columns: 220px minmax(240px, 1fr) minmax(280px, 0.95fr);
  }
}
@container (min-width: 355px) {
  .reader .lead-status-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
#source-list > button > span {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
#run-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.health-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
}
.health-button:hover {
  background: none;
  color: var(--accent);
}
.health-button .dot {
  margin-right: 1px;
}
.health-summary p {
  margin: 12px 0;
  color: var(--muted);
}
.health-summary dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 16px 0;
}
.health-summary dt {
  color: var(--muted);
}
.health-summary dd {
  margin: 0;
  text-align: right;
}
.health-sources,
.origin-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.health-sources article,
.origin-list > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.health-sources small,
.origin-list small {
  color: var(--muted);
}
.origin-list a {
  align-self: flex-start;
  margin-top: 5px;
}
.duplicate-link {
  flex-shrink: 0;
  align-self: flex-start;
  margin-bottom: 10px;
}
.initial-history {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-bottom: 20px;
}
.onboarding-next {
  margin-top: 22px;
}
#toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
#toast button {
  background: transparent;
  color: white;
  border-color: #ffffff55;
  padding: 7px 10px;
}
.bot-auth {
  max-width: 420px;
}
.auth-avatar {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  margin-bottom: 22px;
  object-fit: cover;
}
.bot-auth h1 {
  margin-top: 10px;
}
#bot-entry .button {
  width: 100%;
  min-height: 46px;
}
#bot-entry .field-hint {
  margin-top: 10px;
}
.auth-steps {
  margin: 24px 0 0;
  padding: 20px 0 0 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.auth-steps li {
  padding-left: 4px;
  margin-bottom: 7px;
}

/* The login layout responds to both available width and viewport height. */
.auth-page {
  padding: clamp(12px, 3dvh, 28px) max(16px, env(safe-area-inset-right))
    clamp(12px, 3dvh, 28px) max(16px, env(safe-area-inset-left));
  justify-content: safe center;
  gap: clamp(12px, 2.8dvh, 24px);
}
.auth-page > .brand {
  margin: 0;
  flex-shrink: 0;
}
.auth-card.bot-auth {
  padding: clamp(20px, 3.4dvh, 28px);
  max-width: 420px;
  flex-shrink: 0;
}
.auth-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(16px, 3dvh, 24px);
}
.auth-identity .auth-avatar {
  width: clamp(40px, 8dvh, 56px);
  height: clamp(40px, 8dvh, 56px);
  border-radius: 14px;
  margin: 0;
}
.auth-identity strong,
.auth-identity small {
  display: block;
}
.auth-identity small {
  margin-top: 3px;
  color: var(--muted);
}
.bot-auth h1 {
  margin: 0 0 10px;
}
.bot-auth > .muted {
  margin-bottom: clamp(16px, 3dvh, 24px);
}
.auth-page > .auth-note {
  margin: 0;
  max-width: 380px;
  flex-shrink: 0;
}
.auth-help {
  margin-top: clamp(16px, 3dvh, 24px);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.auth-help summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 36px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
}
.auth-help summary::-webkit-details-marker {
  display: none;
}
.auth-help[open] summary .icon {
  transform: rotate(180deg);
}
.auth-help .auth-steps {
  margin-top: 4px;
  padding-top: 0;
  border: 0;
}

@media (max-height: 540px) {
  .auth-page {
    gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .auth-page > .brand,
  .auth-page > .auth-note {
    display: none;
  }
  .auth-card.bot-auth {
    padding: 20px;
  }
  .auth-identity {
    margin-bottom: 14px;
  }
  .bot-auth > .muted {
    margin-bottom: 16px;
  }
  .auth-help {
    margin-top: 12px;
  }
}
@media (min-width: 981px) and (max-height: 680px) {
  .main {
    padding-top: 14px;
    padding-bottom: 14px;
  }
  .page-heading {
    margin-bottom: 12px;
  }
  .page-heading .back {
    margin-bottom: 4px;
  }
  .reader {
    padding: 14px;
  }
  .reader-title {
    margin-bottom: 8px;
  }
  .reader-meta,
  .contact-line,
  .keyword-line {
    margin-bottom: 10px;
  }
  .fact-line {
    margin-bottom: 10px;
    padding: 8px 0;
  }
  .sidebar > .brand {
    margin-bottom: 24px;
  }
}
.auth-page {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.auth-card.bot-auth {
  margin: 0;
}

/* Telegram provides the visible height and safe insets for its embedded window. */
.radar-miniapp #app {
  height: var(--radar-viewport, 100dvh);
  padding-top: var(--radar-inset-top, 0px);
  padding-left: var(--radar-inset-left, 0px);
  padding-right: var(--radar-inset-right, 0px);
}
.radar-miniapp .auth-page,
.radar-miniapp .boot {
  height: 100%;
}

