:root {
  --bg: #eef1ee;
  --panel: #f7f8f6;
  --ink: #1a1f1c;
  --muted: #66706b;
  --line: #d7ddd8;
  --accent: #1a6b4a;
  --accent-2: #14553b;
  --danger: #9b2f22;
  --ok: #1a6b4a;
  --chip: #e6ebe7;
  --warn: #8a5a12;
  --selected: #e7f4ec;
  --locked: #f3f1ee;
  --shadow: 0 1px 0 rgba(26, 31, 28, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html.in-telegram, html.in-telegram body {
  height: var(--tg-viewport-stable-height, 100dvh);
}
body {
  font: 13.5px/1.45 "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.nav-toggle {
  display: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 650;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
  background: rgba(26, 31, 28, 0.35);
}

.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}
aside, main { min-height: 0; }
aside {
  padding: 12px 10px 10px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
main {
  padding: 12px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  background: var(--bg);
}
.workspace-bar {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}
.workspace-tab {
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 650;
}
.workspace-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 12px;
  overflow: hidden;
}
.workspace[hidden] { display: none !important; }
#ws-manage {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}
.col-chats, .col-editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.col-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px 0;
}

.brand { margin: 0; flex: 0 0 auto; }
h1 { font-size: 18px; font-weight: 700; margin: 0 0 2px; letter-spacing: -0.02em; }
.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.brand-icon { width: 28px; height: 28px; flex: 0 0 auto; display: block; }
.lead, .hint, .muted { color: var(--muted); }
.lead { margin: 0; font-size: 12px; }
#app-version {
  display: inline-block;
  margin-left: 4px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
h2 {
  font-size: 12px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.04em;
  color: var(--ink);
}

label.field { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 6px;
}
.field-head .field { margin: 0; }
.len.warn { color: var(--danger); }
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}
input:disabled, textarea:disabled, select:disabled {
  background: #eef1ee;
  color: var(--muted);
  cursor: not-allowed;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(26, 107, 74, 0.22);
  border-color: var(--accent);
}
textarea {
  min-height: 88px;
  height: 128px;
  max-height: none;
  resize: vertical;
  overflow: auto;
  flex: 1 1 auto;
}
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

button, .btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}
button:hover:not(:disabled) { background: #f3f6f4; }
button:disabled { opacity: 0.45; cursor: not-allowed; color: #8a938e; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 650;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-primary:disabled {
  background: #c5cdc8;
  border-color: #c5cdc8;
  color: #f7f8f6;
  opacity: 1;
}
.btn-danger { color: var(--danger); border-color: #e2c8c3; }
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 6px 4px;
}
.btn-ghost:hover:not(:disabled) { background: var(--chip); color: var(--ink); }
.btn-wide { width: 100%; margin-top: 8px; }

#code-box {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--accent);
  background: #fff;
  border-radius: 10px;
}
#code-box .hint { margin: 8px 0 0; }

.banner {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--chip);
  font-size: 12px;
  margin: 0;
  flex: 0 0 auto;
}
.banner.err { background: #f6e4df; color: var(--danger); }
.banner.ok { background: #e4eee8; color: var(--ok); }
#update-banner { margin: 0; }

.aside-block {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.aside-block-label {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.aside-block-tg {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.account-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.account-list[hidden] { display: none !important; }
.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.account-chip.active {
  border-color: var(--accent);
  background: var(--selected);
}
.account-chip.locked {
  background: #f3f1ee;
  color: var(--muted);
}
.account-chip .slot-num {
  flex: 0 0 1.5em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.account-chip.active .slot-num { color: var(--accent); }
.account-chip .meta {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
}
.account-chip .title {
  font-weight: 650;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip .sub {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-chip .slot-tag {
  flex: 0 0 auto;
  font-size: 10px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
}
.account-chip .slot-tag.free {
  background: var(--selected);
  color: var(--accent);
}
.account-chip .slot-logout {
  flex: 0 0 auto;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 999px;
}
.account-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.account-card .me-name { font-weight: 650; }
.account-card .me-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.account-card .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 99px;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: 1px;
}
.chip {
  display: inline-block;
  background: var(--chip);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  margin-right: 6px;
}
.chip.ok { background: var(--selected); color: var(--accent); }

.login-card { width: min(420px, 100%); }
#login-modal { z-index: 45; }
#login-fields { margin-bottom: 4px; }

.tools-setup {
  flex: 0 0 auto;
  max-height: 46vh;
  overflow: auto;
}
.tools-setup[hidden] {
  display: none !important;
}
.tools-setup-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tools-setup-card h2 {
  font-size: 14px;
  letter-spacing: 0;
  color: var(--ink);
}
.tools-setup .steps {
  margin: 0;
  padding: 10px 10px 10px 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}
.tools-setup .steps li { margin: 0 0 6px; }
.tools-setup .steps li:last-child { margin-bottom: 0; }
.tools-setup .steps code {
  font-family: Consolas, "SF Mono", monospace;
  background: var(--chip);
  padding: 0 4px;
  border-radius: 4px;
}

.settings {
  border-top: 1px solid var(--line);
  margin-top: auto;
  padding-top: 8px;
}
.settings summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
}
.settings .stack { display: flex; flex-direction: column; gap: 10px; }
.settings .steps {
  margin: 0;
  padding: 10px 10px 10px 26px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
}
.settings .steps li { margin: 0 0 6px; }
.settings .steps li:last-child { margin-bottom: 0; }
.settings .steps code {
  font-family: Consolas, "SF Mono", monospace;
  background: var(--chip);
  padding: 0 4px;
  border-radius: 4px;
}

.targets {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 10px 8px;
  min-width: 0;
  overflow: hidden;
}
.targets-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.stat {
  margin: 0;
  font-size: 12px;
  color: var(--accent);
  background: var(--selected);
  border-radius: 999px;
  padding: 3px 10px;
  font-weight: 650;
  white-space: nowrap;
}
.folder-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 28px;
  margin: 0 0 2px;
  padding-bottom: 10px;
  scrollbar-width: thin;
}
.folder-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  height: 28px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  line-height: 1;
}
.folder-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.folder-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--locked);
}
.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 4px 0 6px;
  flex: 0 0 auto;
  min-height: 34px;
}
.toolbar .search {
  flex: 1 1 auto;
  min-width: 120px;
  margin: 0;
}
.check-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}
.scheme-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0 0 8px;
  flex: 0 0 auto;
  min-height: 34px;
}
.scheme-bar select, .scheme-bar input { width: auto; min-width: 0; flex: 1; }
.chats {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}
.chat {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}
.chat:hover { background: #f6faf7; }
.chat:has(input:checked) { background: var(--selected); }
.chat.picked { background: var(--selected); }
.chat.locked { opacity: 0.58; background: var(--locked); cursor: default; }
.chat.role-creator {
  border-left: 3px solid #c9a227;
  background: #fbf6e8;
}
.chat.role-admin {
  border-left: 3px solid #1a6b4a;
  background: #eef6f1;
}
.chat.role-member { border-left: 3px solid #c5cdc8; }
.chat.role-left, .chat.role-banned, .chat.role-kicked {
  border-left: 3px solid #c48a82;
  background: #f7eeec;
}
.chat.role-creator:hover, .chat.role-creator.picked { background: #f6edd2; }
.chat.role-admin:hover, .chat.role-admin.picked { background: #e3f0e8; }
.chat.role-member:hover, .chat.role-member.picked { background: #f3f6f4; }
.chat > input { margin-top: 10px; flex: 0 0 auto; }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.avatar::before { content: attr(data-letter); }
.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--chip);
}
.chat .meta { min-width: 0; flex: 1; }
.chat .title {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 6px;
  font-weight: 650;
  min-width: 0;
}
.title-marks {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}
.chat .title-text {
  min-width: 0;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  word-break: break-word;
}
.badge {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 650;
  color: var(--muted);
  background: var(--chip);
  border-radius: 4px;
  padding: 1px 5px;
}
.role-tag.role-creator { background: #f3e3b0; color: #7a5a00; }
.role-tag.role-admin { background: #cfe8d8; color: #14553b; }
.role-tag.role-member { background: #e7ebe8; color: #5c6661; }
.role-tag.role-left, .role-tag.role-banned, .role-tag.role-kicked { background: #f0d4cf; color: #9b2f22; }
.chip.role-creator { background: #f3e3b0; color: #7a5a00; }
.chip.role-admin { background: #cfe8d8; color: #14553b; }
.chip.role-member { background: #e7ebe8; color: #5c6661; }
.role-legend {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
  flex: 0 0 auto;
}
.role-dot::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  margin-right: 4px;
  vertical-align: 0;
}
.role-dot.creator::before { background: #c9a227; }
.role-dot.admin::before { background: #1a6b4a; }
.role-dot.member::before { background: #9aa39e; }
.chat .sub { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .sub.warn { color: var(--warn); }
.chat-empty { padding: 18px 12px; color: var(--muted); grid-column: 1 / -1; }

.stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.stage > section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.stage > .copy { flex: 1 1 auto; }
.section-head, .caption-head, .log-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.drop {
  min-height: 148px;
  max-height: 220px;
  flex: 0 0 auto;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.drop.has-image { border-style: solid; padding: 0; }
.drop img { max-width: 100%; max-height: 210px; display: block; margin: 0 auto; border-radius: 10px; object-fit: contain; }
.drop input[type="file"] { display: none; }

.publish-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px 0 12px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  background: var(--panel);
}
.interval {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.interval input {
  width: 78px;
  padding: 6px 8px;
}
.publish-count {
  font-size: 12px;
  color: var(--muted);
  margin-right: auto;
}
.btn-publish { padding: 10px 16px; font-size: 14px; }

.log {
  margin-top: 10px;
  flex: 0 1 120px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px 10px;
}
.history {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 8px;
  min-height: 0;
  flex: 0 0 auto;
}
.history:empty { display: none; }
.history-item {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.history-item.active { outline: 2px solid var(--accent); }
.history-item img { width: 72px; height: 54px; object-fit: cover; display: block; }
.history-item .cap {
  display: block;
  font-size: 11px;
  color: var(--muted);
  padding: 3px 5px 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 72px;
}
.history-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  line-height: 16px;
  font-size: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
}
#log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
}
.log-item { font-size: 12px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.log-item.ok { color: var(--ok); }
.log-item.fail { color: var(--danger); }

.chats-single { grid-template-columns: 1fr; }
.chat.picked { background: var(--selected); }
.manage-desk {
  overflow: auto;
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.manage-empty {
  color: var(--muted);
  padding: 48px 16px;
  text-align: center;
}
.manage-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.manage-avatar-lg, .manage-photo-preview {
  width: 56px;
  height: 56px;
  font-size: 20px;
  margin-top: 0;
}
.manage-photo-preview { width: 48px; height: 48px; font-size: 18px; }
.manage-head-text { min-width: 0; flex: 1; }
.manage-head-text h2 { font-size: 16px; letter-spacing: 0; }
.manage-tab {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1 1 auto;
}
.rights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.rights-grid label {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
}
.member-list {
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  min-height: 180px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.member-row .meta { flex: 1; min-width: 0; }
.member-row .title { font-weight: 650; }
.member-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.member-actions button { padding: 4px 8px; font-size: 12px; }
.manage-photo-row { margin-top: 4px; align-items: center; }
#manage-about { min-height: 88px; height: 120px; }
.create-bar, .publish-extra, .rules-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.create-bar { padding: 0 0 8px; }
.create-bar input { flex: 1 1 140px; min-width: 0; }
.create-bar .len { flex: 0 0 auto; }
.preview-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
}
.preview-row img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.publish-extra { margin-top: 6px; color: var(--muted); }
.publish-extra .row { margin-top: 6px; }
.rules-grid label { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.subhead { margin: 10px 0 4px; font-size: 13px; }
.stats-box { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}
.stat-card b { display: block; font-size: 16px; }
.invite-link { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }

.trial-badge {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--accent);
  font-weight: 650;
}
.broadcast-hint { margin: 0 0 8px; }
.inbox-desk { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); }
.inbox-list .chat { cursor: pointer; }
.inbox-list .chat.active {
  outline: 1px solid var(--accent);
  background: var(--selected);
}
.inbox-unread {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.inbox-thread { padding: 0; }
.inbox-thread .manage-head { padding: 10px 12px; margin: 0; border-bottom: 1px solid var(--line); }
.inbox-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}
.bubble {
  max-width: min(78%, 560px);
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  align-self: flex-start;
}
.bubble.out {
  align-self: flex-end;
  background: var(--selected);
  border-color: #cfe6d8;
}
.bubble .who { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.bubble .when { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble img { max-width: 220px; border-radius: 8px; display: block; margin: 4px 0; }
.inbox-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.inbox-compose textarea { min-height: 44px; height: 44px; resize: none; }
.inbox-compose .btn-primary { flex: 0 0 auto; }
.paywall {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(21, 32, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.paywall[hidden] { display: none !important; }
#authwall { z-index: 50; }
.site-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  font-size: 12px;
}
.site-user-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-settings {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  gap: 8px;
}
.me-settings[hidden] { display: none !important; }
.me-settings-body { display: flex; flex-direction: column; gap: 18px; }
.me-settings h3 { margin: 0 0 8px; font-size: 14px; }
.me-photo-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.me-privacy, .me-devices { display: flex; flex-direction: column; gap: 8px; }
.me-privacy label, .me-device {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.me-device {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  flex-direction: column;
  align-items: flex-start;
}
.me-device b { font-size: 13px; }
.me-device span { color: var(--muted); font-size: 12px; }
.paywall-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button.plan {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.plan:hover, .plan.active { border-color: var(--accent); }
.plan .price { font-size: 20px; font-weight: 800; }
.pay-amount { font-size: 22px; font-weight: 800; margin: 0; word-break: break-all; }
.pay-qr { margin: 4px auto 0; }
.pay-qr img {
  display: block;
  width: min(220px, 100%);
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
}
.pay-address { font-size: 13px; margin: 0; word-break: break-all; text-align: center; }
.paywall-card .btn-wide { text-align: center; text-decoration: none; }

@media (max-width: 1100px) {
  .workspace, #ws-manage { grid-template-columns: 1fr; }
  .col-editor { padding: 12px; }
  .chats { grid-template-columns: 1fr; }
  .publish-bar { flex-wrap: wrap; }
  .btn-publish { width: 100%; }
}

@media (max-width: 900px) {
  html, body, .app {
    height: var(--tg-viewport-stable-height, 100dvh);
  }
  .app { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; align-items: center; }
  aside {
    position: fixed;
    z-index: 20;
    inset: 0 auto 0 0;
    width: min(280px, 88vw);
    max-height: none;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    overflow: hidden;
  }
  body.nav-open aside { transform: none; box-shadow: 8px 0 24px rgba(26, 31, 28, 0.18); }
  body.nav-open .nav-backdrop { display: block; }
  main {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .workspace, #ws-manage, .inbox-desk { grid-template-columns: 1fr; }
}
