:root {
  --bg: #EBEEF1;
  --surface: #FFFFFF;
  --surface-2: #F4F6F9;
  --surface-3: #EDF1F5;
  --ink: #13171C;
  --ink-2: #545E6B;
  --ink-3: #8B95A1;
  --line: #E4E8ED;
  --line-2: #D3D9E0;
  --shadow: 0 1px 2px rgba(20,28,40,.05), 0 8px 24px rgba(20,28,40,.06);
  --shadow-sm: 0 1px 2px rgba(20,28,40,.06);
  --accent: #157A66;
  --on-accent: #FFFFFF;
  --font-head: "Playfair Display", Georgia, serif;
  --font-body: "Hanken Grotesk", system-ui, sans-serif;
  --row-py: 14px;
  --radius: 13px;
  --radius-lg: 18px;
}

[data-theme="dark"] {
  --bg: #0C0F13;
  --surface: #14191F;
  --surface-2: #1A2129;
  --surface-3: #202935;
  --ink: #E9EDF2;
  --ink-2: #A2ADBA;
  --ink-3: #6C7783;
  --line: #232C36;
  --line-2: #2E3845;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.45);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}

.staging-banner {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  display: grid;
  place-items: center;
  height: 26px;
  padding: 0 12px;
  background: #C62828;
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-align: center;
}

body:has(> .staging-banner) { padding-top: 26px; }
body:has(> .staging-banner) .topbar { top: 26px; }

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.auth-page {
  background: var(--surface-2);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -.01em;
  text-decoration: none;
}

.logo.lg {
  justify-content: center;
  font-size: 27px;
}

.mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex: none;
}

.logo.lg .mark {
  width: 34px;
  height: 34px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 90%, transparent);
  backdrop-filter: blur(8px);
}

.topbar .sp {
  flex: 1;
}

.topbar .before-search {
  flex: 0;
}

.search {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  max-width: 380px;
  height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  color: var(--ink-3);
}

.search.active {
  border-color: var(--line-2);
  color: var(--ink);
}

.search svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.search input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
}

.search input::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

.search .clear {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  cursor: pointer;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  text-decoration: none;
}

.avatar::-webkit-details-marker { display: none; }

.avatar-tray {
  position: relative;
  flex: none;
  margin-left: auto;
}

.avatar-tray-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  z-index: 50;
}

.avatar-tray-menu form { display: contents; }

.avatar-tray-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.avatar-tray-item:hover { background: var(--surface-2); }

.avatar-tray-item--danger { color: var(--danger, #C24A40); }

.screen-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 22px 40px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.composer.big {
  padding: 18px;
}

.composer .cin {
  flex: 1;
  min-height: 30px;
  max-height: 150px;
  padding: 3px 0;
  resize: none;
  overflow: hidden;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.composer.big .cin {
  min-height: 44px;
  font-size: 17px;
}

.composer .cin::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

.composer .send {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

.composer .send svg {
  width: 18px;
  height: 18px;
}

.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 4px 12px;
}

.list-head .lt {
  min-width: 0;
  font-family: var(--font-head);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -.01em;
}

.list-head .lm {
  flex: none;
  color: var(--ink-3);
  font-size: 13px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.conv-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: var(--row-py) 16px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.conv-row + .conv-row {
  border-top: 1px solid var(--line);
}

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

.ci {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 10px;
  background: color-mix(in oklab, var(--accent) 12%, var(--surface));
  color: var(--accent);
}

.ci svg {
  width: 18px;
  height: 18px;
}

.cbody {
  min-width: 0;
  flex: 1;
}

.ctitle,
.csnip {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctitle {
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 550;
}

.csnip {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: 14px;
}

.cmeta {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.ctime {
  color: var(--ink-3);
  font-size: 12.5px;
}

.chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 20px;
  font-weight: 600;
  letter-spacing: .02em;
}

.chip {
  padding: 2px 9px;
  font-size: 11.5px;
}

.status-pill {
  padding: 4px 13px;
  font-size: 12.5px;
}

.sd {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.chip.received,
.status-pill.received {
  background: var(--surface-3);
  color: var(--ink-2);
}

.chip.working,
.status-pill.working {
  background: color-mix(in oklab, #C77F2A 18%, var(--surface));
  color: #B5751F;
}

.chip.waiting,
.status-pill.waiting {
  background: color-mix(in oklab, #7A6CC7 16%, var(--surface));
  color: #6356B0;
}

.chip.done,
.status-pill.done {
  background: color-mix(in oklab, var(--accent) 16%, var(--surface));
  color: var(--accent);
}

.chip.failed,
.status-pill.failed {
  background: color-mix(in oklab, #C24A40 16%, var(--surface));
  color: #B23A30;
}

[data-theme="dark"] .chip.working,
[data-theme="dark"] .status-pill.working {
  color: #E2A24E;
}

[data-theme="dark"] .chip.waiting,
[data-theme="dark"] .status-pill.waiting {
  color: #A99BE6;
}

[data-theme="dark"] .chip.failed,
[data-theme="dark"] .status-pill.failed {
  color: #E8736A;
}

mark {
  padding: 0 1px;
  border-radius: 3px;
  background: color-mix(in oklab, var(--accent) 22%, var(--surface));
  color: var(--ink);
}

.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 22px;
  background: var(--surface-2);
}

.auth-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 34px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card .logo {
  justify-content: center;
}

.auth-h {
  margin: 6px 0 0;
  text-align: center;
  font-family: var(--font-head);
  font-size: 27px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -.01em;
}

.auth-sub {
  margin: 0 0 6px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14.5px;
}

.field-l {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
}

.input.is-invalid {
  border-color: #C24A40;
}

.input:focus {
  outline: 2px solid color-mix(in oklab, var(--accent) 24%, transparent);
  outline-offset: 1px;
}

.field-error {
  color: #C24A40;
  font-size: 12.5px;
  line-height: 1.35;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap .input {
  padding-right: 82px;
}

.eye {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* `.btn` sets an explicit `display`, which would otherwise win over the UA
   `[hidden] { display: none }` rule and leave "hidden" buttons visible. */
.btn[hidden] {
  display: none;
}

.btn.block {
  width: 100%;
}

/* Compact variant for inline row actions (e.g. channel connect/disconnect). */
.btn.sm {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: 14px;
}

.btn.primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn.danger {
  background: #C5392C;
  color: #fff;
}

.btn.ghost {
  border-color: var(--line-2);
  background: var(--surface);
  color: var(--ink);
}

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

.link.right {
  display: block;
  margin-top: -4px;
  text-align: right;
}

.auth-hint {
  margin: 6px 0 -4px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

.auth-foot {
  margin: 22px 0 0;
  color: var(--ink-3);
  font-family: var(--font-head);
  font-size: 13.5px;
  font-style: italic;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 14px 10px;
  text-align: center;
}

.empty .mark {
  width: 46px;
  height: 46px;
  opacity: .9;
}

.empty h2 {
  margin: 4px 0 0;
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.empty p {
  max-width: 42ch;
  margin: 0;
  color: var(--ink-2);
  font-size: 15px;
}

.starters {
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.starter {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 14px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  text-align: left;
  cursor: pointer;
}

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

.starter .d {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}

.thread-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.thread-top {
  gap: 12px;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}

.back svg {
  width: 16px;
  height: 16px;
}

.thread-title-wrap {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.thread-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
}

.thread {
  width: 100%;
  max-width: 680px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 auto;
  padding: 24px 22px;
}

.msg {
  max-width: 84%;
  display: flex;
  gap: 10px;
}

.msg.user {
  align-self: flex-end;
}

.msg.nestor .am {
  width: 28px;
  height: 28px;
  flex: none;
}

.bubble {
  padding: 12px 15px;
  border-radius: 15px;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.msg.user .bubble {
  border: 1px solid color-mix(in oklab, var(--accent) 24%, var(--line));
  border-bottom-right-radius: 5px;
  background: color-mix(in oklab, var(--accent) 13%, var(--surface));
}

.msg.nestor .bubble {
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  background: var(--surface-2);
}

.msg-time {
  display: block;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 11px;
  text-align: right;
}

.day-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.date-sep {
  position: sticky;
  top: 69px;
  z-index: 3;
  align-self: center;
  padding: 4px 13px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.quote {
  margin: 10px 0 4px;
  padding: 10px 13px;
  border-left: 3px solid var(--accent);
  border-radius: 0 9px 9px 0;
  background: var(--surface);
}

.quote .qs {
  margin-bottom: 3px;
  color: var(--ink-3);
  font-size: 12.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.quote .qsubj {
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 600;
}

.quote .qbody {
  color: var(--ink-2);
  font-size: 13.5px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.thread-foot {
  position: sticky;
  bottom: 0;
  padding: 14px 22px 22px;
  background: linear-gradient(to bottom, transparent, var(--surface) 26%);
}

.thread-status {
  width: 100%;
  max-width: 680px;
  display: flex;
  justify-content: center;
  margin: 0 auto 10px;
}

.thread-composer {
  max-width: 680px;
  margin: 0 auto;
}

/* ── Settings ────────────────────────────────────── */
.settings-body .back {
  margin-bottom: 18px;
}

.settings-form-body {
  padding: 20px 18px !important;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-form-body form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-form-row {
  display: flex;
  gap: 12px;
}

.settings-form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.settings-form-field--port {
  flex: 0 0 90px;
}

.settings-form-error {
  padding: 10px 13px;
  border-radius: 8px;
  background: color-mix(in oklab, #C24A40 10%, var(--surface));
  color: #C24A40;
  font-size: 13.5px;
}

.settings-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding-top: 4px;
}

.settings-form-actions form {
  margin: 0;
}

.settings-oauth-body {
  padding: 8px 18px 18px;
}

.settings-provider-body {
  padding: 0;
}

.settings-provider-body form {
  margin: 0;
}

.settings-provider-body a {
  text-decoration: none;
}

.provider-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background .15s ease;
}

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

.provider-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  background: var(--surface);
}

.provider-mark--proton {
  color: #6d4aff;
  font-weight: 800;
}

.provider-copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.provider-name {
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 650;
}

.provider-detail {
  color: var(--ink-3);
  font-size: 12.5px;
}

.provider-chevron {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--ink-3);
}

.settings-body {
  max-width: 560px;
}

.settings-page-title {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -.01em;
  margin-bottom: 22px;
}

.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 14px;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.settings-card-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.settings-card-body {
  padding: 4px 18px;
}

.settings-card-body--accounts {
  padding: 0 18px;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 0;
}

.settings-field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.settings-field-value {
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 15px;
  user-select: text;
}

.settings-add-btn {
  padding: 5px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease;
}

.settings-add-btn:hover {
  background: var(--surface-2);
}

.settings-empty {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 18px;
  color: var(--ink-3);
}

.settings-empty-icon {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--ink-3);
  opacity: .7;
}

.settings-empty-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}

.settings-empty-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-3);
}

.settings-form-hint {
  margin: 0;
  padding: 10px 13px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
}

.settings-form-section-title {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background .12s ease;
}

.account-row:hover .account-email {
  color: var(--accent);
}

.account-row:last-child {
  border-bottom: 0;
}

.account-initial {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 9px;
  background: color-mix(in oklab, var(--accent) 12%, var(--surface));
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}

.account-info {
  flex: 1;
  min-width: 0;
}

.account-email {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 1px;
}

.account-provider-icon {
  width: 12px;
  height: 12px;
  flex: none;
}

.account-row-chevron {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--ink-3);
  opacity: .5;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 5px;
  vertical-align: middle;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0C0F13;
    --surface: #14191F;
    --surface-2: #1A2129;
    --surface-3: #202935;
    --ink: #E9EDF2;
    --ink-2: #A2ADBA;
    --ink-3: #6C7783;
    --line: #232C36;
    --line-2: #2E3845;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.45);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  }
}

@media (max-width: 600px) {
  .topbar {
    gap: 10px;
    padding: 13px 15px;
  }

  .topbar .before-search {
    display: none;
  }

  .search {
    min-width: 0;
    width: auto;
    max-width: none;
    flex: 1;
    padding: 0 10px;
  }

  .search input {
    display: block;
  }

  .search .clear:not([hidden]) {
    display: block;
  }

  .screen-body {
    padding: 18px 15px 32px;
  }

  .list-head {
    margin-right: 0;
    margin-left: 0;
  }

  .starters {
    grid-template-columns: 1fr;
  }

  .thread {
    padding: 18px 15px;
  }

  .msg {
    max-width: 90%;
  }

  .back {
    max-width: 44px;
    overflow: hidden;
    white-space: nowrap;
  }
}

/* ── Home / landing ──────────────────────────────── */
.home-screen {
  background: var(--bg);
}

.home {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.home-glow {
  position: absolute;
  top: -20%;
  left: 50%;
  width: 680px;
  max-width: 120vw;
  aspect-ratio: 1;
  transform: translateX(-50%);
  background: radial-gradient(
    circle at center,
    color-mix(in oklab, var(--accent) 22%, transparent),
    transparent 62%
  );
  pointer-events: none;
}

.home-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  max-width: 460px;
}

.home-inner > * {
  opacity: 0;
  animation: home-rise .6s cubic-bezier(.2, .7, .3, 1) forwards;
}

.home-mark { animation-delay: .02s; }
.home-title { animation-delay: .1s; }
.home-sub { animation-delay: .18s; }
.home-cta { animation-delay: .28s; }

.home-mark {
  width: 60px;
  height: 60px;
  color: var(--accent);
}

.home-mark .mark { width: 100%; height: 100%; }

.home-title {
  margin: 4px 0 0;
  font-family: var(--font-head);
  font-size: 46px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -.02em;
}

.home-sub {
  margin: 0;
  max-width: 38ch;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.55;
}

.home-cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 14px 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 10px 28px -12px color-mix(in oklab, var(--accent) 80%, transparent);
  transition: transform .18s ease, box-shadow .18s ease;
}

.home-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px -12px color-mix(in oklab, var(--accent) 85%, transparent);
}

.home-cta svg {
  width: 19px;
  height: 19px;
  transition: transform .18s ease;
}

.home-cta:hover svg { transform: translateX(3px); }

@keyframes home-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .home-inner > * { opacity: 1; animation: none; }
}

/* ── Canaux / Telegram ─────────────────────────────────────────────── */
.channel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: var(--row-py) 0;
}

.channel-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 9px;
  color: #fff;
}

.channel-mark--telegram { background: #229ED9; }

.channel-info { flex: 1 1 auto; min-width: 0; }

.channel-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.channel-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 1px;
}

.status-dot--off { background: var(--ink-3); }

.channel-actions { flex: none; }

.telegram-link {
  display: flex;
  gap: 20px;
  align-items: stretch;
  padding: 16px 0;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

.telegram-link[hidden] { display: none; }

.telegram-qr {
  flex: none;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
}

/* qrcodejs injects both a <canvas> and an <img>; constrain both so the QR
   keeps its inner white margin instead of overflowing onto the border. */
.telegram-qr canvas,
.telegram-qr img {
  display: block;
  width: 100%;
  height: 100%;
}

.telegram-steps {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}

.telegram-steps ol {
  margin: 0 0 14px;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.telegram-open { min-height: 38px; }

.telegram-hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
}

@media (max-width: 540px) {
  .telegram-link { flex-direction: column; align-items: center; }
  .telegram-steps { width: 100%; }
}

/* ── Modal / confirmation overlay ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 22, .48);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: modal-in .16s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.modal-text {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

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

body.modal-open { overflow: hidden; }
