:root {
  color-scheme: light dark;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  --bg: var(--tg-theme-bg-color, light-dark(#f4f5fa, #13151e));
  --surface: var(--tg-theme-secondary-bg-color, light-dark(#fff, #1d202c));
  --ink: var(--tg-theme-text-color, light-dark(#202239, #f2f1fb));
  --muted: var(--tg-theme-hint-color, light-dark(#586176, #abadbf));
  --line: color-mix(in srgb, var(--ink) 13%, transparent);
  --accent: #5b49cc;
  --focus: light-dark(#5b49cc, #aa9cff);
  --tint: color-mix(in srgb, var(--focus) 12%, var(--surface));
  --danger: light-dark(#9b2849, #ffa6be);
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
main {
  width: min(100%, 840px);
  margin-inline: auto;
  padding: max(22px, env(safe-area-inset-top)) clamp(14px, 5vw, 32px) max(30px, env(safe-area-inset-bottom));
}
header { margin-bottom: 17px; }
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: .84rem; font-weight: 760; letter-spacing: .02em;
}
.mark, .avatar { display: grid; place-items: center; flex: none; }
.mark { width: 27px; height: 27px; border-radius: 8px; background: linear-gradient(145deg, #8374f2, #5241bf); }
.mark::before, .mark::after { content: ""; grid-area: 1 / 1; }
.mark::before { width: 14px; height: 16px; background: #fff; clip-path: polygon(50% 0, 94% 18%, 88% 64%, 72% 83%, 50% 100%, 28% 83%, 12% 64%, 6% 18%); }
.mark::after { width: 7px; height: 4px; border-left: 2px solid #5b46cf; border-bottom: 2px solid #5b46cf; transform: translateY(-1px) rotate(-45deg); }
h1 {
  margin: 15px 0 0; font-size: clamp(1.65rem, 6vw, 2.45rem); letter-spacing: -.045em;
  line-height: 1.12; overflow-wrap: anywhere;
}
p, blockquote { margin: 0; line-height: 1.5; color: var(--muted); }
.panel, details {
  padding: clamp(14px, 4vw, 22px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; min-width: 0;
}
#group-list { padding: 9px; }
#group-list > p, #group-list > a { margin: 8px; }
ul { list-style: none; margin: 0; padding: 0; }
.group + .group { border-top: 1px solid var(--line); }
.group button {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: 12px; text-align: left; background: transparent; color: var(--ink); padding: 8px; margin: 0;
}
.group button:hover { background: var(--tint); }
.group button::after { content: '›'; color: var(--muted); font-size: 1.6rem; padding-inline: 4px; }
.avatar {
  position: relative; width: 46px; height: 46px; border-radius: 13px;
  background: var(--tint); color: var(--focus); overflow: hidden;
}
.avatar::before, .avatar::after { content: ""; position: absolute; background: currentColor; }
.avatar::before { width: 7px; height: 7px; border-radius: 50%; top: 12px; left: 14px; box-shadow: 11px 2px 0 -1px currentColor; }
.avatar::after { width: 14px; height: 8px; border-radius: 8px 8px 3px 3px; top: 22px; left: 10px; box-shadow: 12px 1px 0 -1px currentColor; }
.avatar.has-photo::before, .avatar.has-photo::after { display: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.group strong { display: block; overflow-wrap: anywhere; }
.group small { display: block; color: var(--muted); margin-top: 4px; font-weight: 480; }
details { margin-top: 13px; padding-block: 0; }
summary {
  display: flex; align-items: center; min-height: 50px; gap: 10px; cursor: pointer;
  font-weight: 680; list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: ""; width: 7px; height: 7px; margin-left: auto; margin-right: 3px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
}
details[open] summary::after { transform: rotate(225deg); }
details ol { margin: 0 0 16px; padding-left: 23px; color: var(--muted); line-height: 1.5; }
details li + li { margin-top: 7px; }
.help-icon {
  display: grid; place-items: center; width: 23px; height: 23px; flex: none;
  border-radius: 50%; background: var(--tint); color: var(--focus); font-size: .8rem; font-weight: 750;
}
button, a#open {
  min-height: 40px; border: 1px solid transparent; border-radius: 10px; padding: 8px 13px;
  font: inherit; font-weight: 670; background: var(--accent); color: white;
  cursor: pointer; text-decoration: none; margin-top: 12px;
}
a#open { display: inline-flex; align-items: center; }
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
button:disabled { opacity: .62; cursor: wait; }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover { background: var(--tint); }
.danger { color: var(--danger); }
.back { margin-top: 12px; min-height: 36px; font-size: .86rem; }
.back + h1 { margin-top: 11px; }
.segments {
  display: grid; gap: 4px; padding: 4px; border: 1px solid var(--line);
  border-radius: 13px; background: var(--surface);
}
.primary-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sub-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.settings-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segments button {
  margin: 0; min-width: 0; padding: 6px 2px; min-height: 41px; font-size: clamp(.72rem, 3vw, .9rem);
  border-radius: 9px; color: var(--muted); background: transparent; line-height: 1.18;
  white-space: normal; overflow-wrap: anywhere;
}
.segments button:hover { background: var(--tint); }
.segments button[aria-pressed="true"] { background: var(--tint); color: var(--focus); }
#content { margin-top: 14px; }
#content:empty { margin: 0; }
#content > .panel + .panel, .editor-layout > .panel + .panel { margin-top: 12px; }
#manage-status {
  margin-top: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; font-size: .88rem;
}
#manage-status[data-tone="success"] { color: light-dark(#236746, #91dbb3); }
#manage-status[data-tone="error"] { color: var(--danger); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
.panel h3 { margin: 0 0 12px; font-size: 1.03rem; line-height: 1.3; }
.field { display: grid; gap: 7px; margin-top: 11px; font-size: .88rem; font-weight: 620; }
.panel input:not([type="checkbox"]), .panel select, .panel textarea {
  width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; font-size: 1rem; font-weight: 450;
  color: inherit; background: color-mix(in srgb, var(--bg) 70%, var(--surface));
}
.panel textarea { resize: vertical; min-height: 132px; line-height: 1.5; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.line { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; }
.line > div:first-child, .line > strong { min-width: 0; overflow-wrap: anywhere; }
.line + .line { border-top: 1px solid var(--line); }
.line:last-child { padding-bottom: 0; }
.line button { margin: 0; flex: none; min-height: 37px; padding: 6px 9px; font-size: .82rem; }
.row-actions, .actions { display: flex; gap: 7px; flex-wrap: wrap; }
.row-actions { justify-content: flex-end; }
.line p, .message { white-space: pre-wrap; overflow-wrap: anywhere; }
.line p { font-size: .87rem; }
.message { margin-top: 7px; }
.evidence { background: var(--tint); border-left: 2px solid var(--focus); border-radius: 0 9px 9px 0; padding: 10px 12px; color: var(--ink); }
@media (min-width: 660px) {
  .editor-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .editor-layout > .panel + .panel { margin-top: 0; }
}
@media (max-width: 410px) {
  .primary-nav, .settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 350px) {
  .line { align-items: flex-start; }
  .row-actions { display: grid; }
}

