:root {
  color-scheme: light;
  --bg: #f5f5f7; --surface: #fff; --field: #eaeaee; --ink: #1c1c1e;
  --muted: #66666f; --line: #e4e4e9; --blue: #006bd6; --blue-soft: #e8f1fc;
  --red: #c92c37; --green: #237e48; --overlay: rgb(0 0 0 / .3);
  --navigation: rgb(250 250 252 / .94); --hover: #f4f4f8;
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; color: var(--ink); background: var(--bg);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101012; --surface: #1c1c1f; --field: #28282d; --ink: #f5f5f7;
  --muted: #a5a5af; --line: #343438; --blue: #66adff; --blue-soft: #1a2a40;
  --red: #ff7c83; --green: #6ac28a; --overlay: rgb(0 0 0 / .6);
  --navigation: rgb(22 22 25 / .96); --hover: #27272b;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, select, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; border: 0; background: none; }
button:disabled { cursor: default; opacity: .5; }
button, input, select, a { touch-action: manipulation; }
button, a { text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 3px;
}
::selection { background: var(--blue-soft); color: var(--ink); }
input { caret-color: var(--blue); }
input::placeholder { color: var(--muted); opacity: 1; }
svg { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 20; padding: 12px; background: var(--surface); }
.skip-link:focus { top: 12px; }
.shell { min-height: 100dvh; padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px)); }
.sidebar { display: none; }
.content { width: min(100% - 40px, 760px); margin: auto; padding-top: max(28px, var(--tg-content-safe-area-inset-top, 0px)); }
.page-head { display: flex; align-items: center; justify-content: space-between; min-height: 46px; gap: 12px; margin-bottom: 6px; }
h1 { font-size: 34px; line-height: 1.16; letter-spacing: -.035em; font-weight: 720; }
.subtitle { color: var(--muted); font-size: 14px; min-height: 22px; }
.head-action { padding: 10px 0 10px 12px; color: var(--blue); min-height: 44px; font-weight: 550; white-space: nowrap; }
.head-action svg { width: 21px; vertical-align: middle; }
.search { display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--field); min-height: 44px; border-radius: 12px; margin: 20px 0 14px; }
.search > svg { width: 19px; height: 19px; color: var(--muted); }
.search input { width: 100%; min-width: 0; padding: 11px 0; color: var(--ink); background: none; border: 0; outline: none; font-size: 16px; }
.search:focus-within { box-shadow: 0 0 0 2px var(--blue); }
.search input:focus-visible { outline: none; }
.clear-search { padding: 8px; margin-right: -8px; color: var(--muted); min-height: 40px; }
.clear-search svg { width: 16px; height: 16px; }
.filters { display: flex; align-items: center; gap: 12px; margin: 14px 0 22px; }
.segments { display: flex; padding: 3px; gap: 3px; background: var(--field); border-radius: 10px; flex: 1; min-width: 0; }
.segments button { flex: 1; min-height: 34px; padding: 5px 8px; font-size: 13px; font-weight: 550; border-radius: 7px; white-space: nowrap; }
.segments button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.chat-select { max-width: 142px; min-width: 0; min-height: 40px; background: none; border: 0; color: var(--blue); font-size: 14px; padding: 7px 0 7px 3px; }
.section-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 26px 2px 9px; color: var(--muted); font-size: 12px; font-weight: 550; letter-spacing: .035em; text-transform: uppercase; }
.group { background: var(--surface); border-radius: 14px; overflow: hidden; }
.message-row { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 12px; width: 100%; text-align: left; padding: 16px; }
.message-row + .message-row::before { position: absolute; content: ""; left: 66px; right: 0; top: 0; height: 1px; background: var(--line); }
.message-row:hover, .user-row:hover { background: var(--hover); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--field); color: var(--muted); font-size: 13px; font-weight: 650; flex: 0 0 auto; }
.avatar.blue { background: var(--blue-soft); color: var(--blue); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.row-name { font-size: 15px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.excerpt { color: var(--ink); font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-meta { display: flex; gap: 7px; align-items: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.row-meta svg { width: 13px; height: 13px; }
.status-deleted { color: var(--red); }
.status-edited { color: var(--blue); }
.dot { width: 3px; height: 3px; background: currentColor; border-radius: 50%; }
.bottom-nav { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--navigation); backdrop-filter: blur(20px); }
.nav-item { display: flex; flex: 1; max-width: 130px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 49px; color: var(--muted); font-size: 10px; font-weight: 550; }
.nav-item svg { width: 23px; height: 23px; }
.nav-item[aria-current="page"] { color: var(--blue); }
.empty { padding: 62px 20px; text-align: center; color: var(--muted); }
.empty > svg { width: 36px; height: 36px; margin-bottom: 16px; opacity: .7; }
.empty h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; color: var(--ink); margin-bottom: 8px; }
.empty p { font-size: 14px; line-height: 1.6; max-width: 320px; margin: 0 auto; }
.empty .text-button { margin-top: 12px; }
.text-button { min-height: 44px; color: var(--blue); padding: 10px 14px; }
.load-more { display: block; width: 100%; margin: 14px 0; }
.skeleton { margin-top: 24px; }
.skeleton i { display: block; height: 16px; margin: 16px; border-radius: 5px; background: var(--field); }
.skeleton i:nth-child(2n) { width: 65%; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; border-radius: 12px; overflow: hidden; margin-top: 20px; }
.tile { aspect-ratio: 1; position: relative; overflow: hidden; background: var(--field); display: grid; place-items: center; padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile > svg { width: 28px; height: 28px; color: var(--muted); }
.tile .round-preview { width: 60%; aspect-ratio: 1; border-radius: 50%; background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.tile .tile-length { position: absolute; bottom: 8px; left: 8px; color: var(--ink); font-size: 11px; background: var(--surface); border-radius: 5px; padding: 2px 5px; }
.tile .selected-mark { position: absolute; right: 8px; bottom: 8px; width: 25px; height: 25px; display: grid; place-items: center; color: #fff; background: var(--blue); border: 2px solid var(--surface); border-radius: 50%; }
.tile .selected-mark svg { width: 14px; height: 14px; }
.tile[aria-pressed="true"]::after { content: ""; position: absolute; inset: 0; border: 3px solid var(--blue); pointer-events: none; }
.selection-bar { position: sticky; bottom: 85px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 16px 0 0; padding: 9px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; }
.danger { color: var(--red); }
.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 18px; background: var(--blue); color: #fff; border-radius: 12px; font-weight: 600; font-size: 15px; }
:root[data-theme="dark"] .primary { color: #101012; }
.primary.danger-button { background: var(--red); color: #fff; }
:root[data-theme="dark"] .primary.danger-button,
:root[data-theme="dark"] .tile .selected-mark { color: #101012; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 16px; min-height: 56px; font-size: 15px; }
.setting-row + .setting-row { border-top: 1px solid var(--line); }
.setting-copy { display: flex; flex-direction: column; gap: 3px; }
.setting-copy small { color: var(--muted); font-size: 12px; }
.setting-value { color: var(--muted); text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.switch { appearance: none; border: 0; margin: 0; width: 48px; height: 29px; flex: 0 0 auto; border-radius: 20px; background: var(--field); position: relative; cursor: pointer; transition: background .18s; }
.switch::before { content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .2); transition: transform .18s; }
.switch:checked { background: #29884f; }
.switch:checked::before { transform: translateX(19px); }
.switch:disabled { opacity: .45; cursor: default; }
.section-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 9px 16px 0; }
.button-row { width: 100%; text-align: left; padding: 15px 16px; min-height: 52px; font-size: 15px; }
.button-row:hover { background: var(--hover); }
.profile-row { display: flex; gap: 13px; align-items: center; padding: 20px 16px; }
.profile-row .avatar { width: 47px; height: 47px; font-size: 17px; }
.profile-name { font-size: 17px; font-weight: 650; margin-bottom: 3px; }
.profile-id { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin: 18px 0 24px; }
.status-light { background: var(--green); width: 6px; height: 6px; border-radius: 50%; }
.status-light.offline { background: var(--muted); }
.user-row { display: flex; width: 100%; align-items: center; text-align: left; gap: 12px; padding: 16px; }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-row .user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 15px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; }
.user-info small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.user-trailing { display: flex; align-items: center; gap: 8px; }
.user-trailing > svg { width: 15px; color: var(--muted); }
.user-storage { font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.user-storage small { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.admin-overview { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 18px 2px 0; gap: 12px; }
.entry-screen { min-height: 85dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 28px; }
.entry-screen h1 { font-size: 28px; margin: 20px 0 12px; }
.entry-screen p { max-width: 330px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.entry-screen > svg { width: 42px; height: 42px; color: var(--muted); }
.entry-mark { width: 32px; height: 32px; border: 2px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: loading .8s linear infinite; }
@keyframes loading { to { transform: rotate(360deg); } }
dialog { color: var(--ink); background: var(--bg); border: 0; padding: 0; }
dialog::backdrop { background: var(--overlay); }
.sheet { position: fixed; inset: auto 0 0; width: min(100%, 620px); max-width: 100%; max-height: 94dvh; margin: auto auto 0; border-radius: 22px 22px 0 0; }
.sheet[open] { animation: sheet-in .22s cubic-bezier(.16, 1, .3, 1); }
@keyframes sheet-in { from { transform: translateY(22px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
.sheet-top { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.sheet-top h2 { font-size: 17px; font-weight: 650; letter-spacing: -.02em; }
.close-button { display: grid; place-items: center; min-width: 40px; min-height: 40px; color: var(--muted); border-radius: 50%; }
.sheet-body { padding: 20px 20px calc(28px + env(safe-area-inset-bottom, 0px)); }
.sheet-heading { font-size: 24px; letter-spacing: -.025em; font-weight: 650; margin-bottom: 8px; }
.metadata { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; margin: 8px 0 24px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; font-size: 16px; }
.detail-media { display: block; margin: 20px auto; max-width: 100%; max-height: 55dvh; border-radius: 14px; }
video.detail-media { width: 100%; background: #101012; }
video.detail-media.round { width: 240px; height: 240px; border-radius: 50%; }
.media-loading { text-align: center; color: var(--muted); padding: 30px; }
.detail-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; font-size: 12px; color: var(--muted); }
.version { padding: 16px; }
.version + .version { border-top: 1px solid var(--line); }
.version time { display: block; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.version p { font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.confirmation { width: min(calc(100% - 48px), 340px); border-radius: 18px; background: var(--surface); padding: 24px; margin: auto; }
.confirmation h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 10px; }
.confirmation p { font-size: 14px; line-height: 1.6; color: var(--muted); }
.confirm-actions { display: flex; flex-direction: column; gap: 7px; margin-top: 22px; }
.confirm-actions button { width: 100%; }
.form-label { display: block; color: var(--muted); font-size: 13px; margin: 22px 1px 9px; }
.form-input { width: 100%; background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 13px 14px; min-height: 48px; }
.form-error { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 9px; }
.form-submit { width: 100%; margin-top: 22px; }
.inline-info { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.inline-info span:first-child { color: var(--muted); }
.footnote { text-align: center; color: var(--muted); font-size: 11px; padding: 32px 0 8px; }
.demo-note { color: var(--muted); font-size: 11px; padding: 6px 0; text-align: center; }
#toast { position: fixed; left: 50%; bottom: calc(95px + env(safe-area-inset-bottom, 0px)); z-index: 30; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 14px; box-shadow: 0 4px 20px rgb(0 0 0 / .12); opacity: 0; pointer-events: none; transition: opacity .18s; }
#toast.visible { opacity: 1; }
@media (min-width: 800px) {
  .shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); padding-bottom: 40px; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; padding: 36px 16px 24px; border-right: 1px solid var(--line); }
  .side-title { font-size: 17px; font-weight: 650; padding: 0 14px 32px; letter-spacing: -.02em; }
  .side-nav .nav-item { flex-direction: row; justify-content: flex-start; max-width: none; gap: 12px; font-size: 14px; min-height: 44px; padding: 10px 14px; border-radius: 10px; margin-bottom: 5px; width: 100%; }
  .side-nav .nav-item svg { width: 20px; height: 20px; }
  .side-nav .nav-item[aria-current="page"] { background: var(--blue-soft); }
  .side-profile { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; }
  .side-profile strong { display: block; font-size: 13px; font-weight: 600; }
  .side-profile small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
  .bottom-nav { display: none; }
  .content { width: min(100% - 80px, 760px); padding-top: 54px; }
  .search { margin-top: 28px; }
  .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .selection-bar { bottom: 24px; }
  .sheet { inset: 0 0 0 auto; margin: 0; width: min(520px, 70vw); max-height: 100dvh; border-radius: 0; }
  .sheet[open] { animation: none; }
  #toast { bottom: 30px; }
}
@media (max-width: 374px) {
  h1 { font-size: 30px; }
  .content { width: calc(100% - 28px); }
  .chat-select { max-width: 105px; font-size: 12px; }
  .segments button { padding-inline: 5px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
