@font-face {
    font-family: "Inter";
    src: url("/assets/fonts/InterVariable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root,
[data-theme="light"] {
    color-scheme: light;
    --bg: #F7F4EF;
    --bg-deep: #F0EBE2;
    --surface: #FCFAF6;
    --surface-soft: #EFEAE1;
    --ink: #1A1A1A;
    --ink-hover: #333333;
    --ink-soft: #3A3833;
    --muted: #8A857D;
    --line: #D9D4CB;
    --line-strong: #BEB6AA;
    --own-bubble: #1A1A1A;
    --own-ink: #F7F4EF;
    --other-bubble: #FCFAF6;
    --other-ink: #1A1A1A;
    --hover: rgba(26, 26, 26, 0.045);
    --active: rgba(26, 26, 26, 0.075);
    --overlay: rgba(26, 26, 26, 0.34);
    --shadow-color: rgba(0, 0, 0, 0.04);
    --shadow-strong: rgba(0, 0, 0, 0.08);
    --scroll: #D9D4CB;
    --selection: rgba(26, 26, 26, 0.14);
    --preview-light-bg: #F7F4EF;
    --preview-dark-bg: #171614;
    --preview-paper-bg: #F2EBDC;
    --pattern-rules: url("/assets/patterns/rules-light.svg");
    --pattern-grain: url("/assets/patterns/grain-light.svg");
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #151412;
    --bg-deep: #100F0E;
    --surface: #1E1C19;
    --surface-soft: #272420;
    --ink: #F2EEE7;
    --ink-hover: #D8D2C8;
    --ink-soft: #D8D2C8;
    --muted: #9D968B;
    --line: #3A3630;
    --line-strong: #555048;
    --own-bubble: #EDE8DF;
    --own-ink: #1A1A1A;
    --other-bubble: #211F1B;
    --other-ink: #F2EEE7;
    --hover: rgba(242, 238, 231, 0.05);
    --active: rgba(242, 238, 231, 0.09);
    --overlay: rgba(0, 0, 0, 0.62);
    --shadow-color: rgba(0, 0, 0, 0.26);
    --shadow-strong: rgba(0, 0, 0, 0.4);
    --scroll: #4A453E;
    --selection: rgba(242, 238, 231, 0.18);
    --preview-light-bg: #F7F4EF;
    --preview-dark-bg: #171614;
    --preview-paper-bg: #F2EBDC;
    --pattern-rules: url("/assets/patterns/rules-dark.svg");
    --pattern-grain: url("/assets/patterns/grain-dark.svg");
}

[data-theme="paper"] {
    color-scheme: light;
    --bg: #F2EBDC;
    --bg-deep: #E9E0CE;
    --surface: #FBF6EA;
    --surface-soft: #ECE2CF;
    --ink: #1A1A1A;
    --ink-hover: #333333;
    --ink-soft: #3A3833;
    --muted: #887F71;
    --line: #D7CBB6;
    --line-strong: #BFB29C;
    --own-bubble: #1A1A1A;
    --own-ink: #F7F1E4;
    --other-bubble: #FBF6EA;
    --other-ink: #1A1A1A;
    --hover: rgba(26, 26, 26, 0.045);
    --active: rgba(26, 26, 26, 0.075);
    --overlay: rgba(26, 26, 26, 0.34);
    --shadow-color: rgba(0, 0, 0, 0.04);
    --shadow-strong: rgba(0, 0, 0, 0.08);
    --scroll: #D7CBB6;
    --selection: rgba(26, 26, 26, 0.14);
    --preview-light-bg: #F7F4EF;
    --preview-dark-bg: #171614;
    --preview-paper-bg: #F2EBDC;
    --pattern-rules: url("/assets/patterns/rules-paper.svg");
    --pattern-grain: url("/assets/patterns/grain-paper.svg");
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Inter", "PingFang SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: var(--selection);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

button {
    border: 0;
    padding: 0;
    background: none;
    cursor: pointer;
}

button:disabled {
    cursor: default;
    opacity: 0.42;
}

input,
textarea {
    border-radius: 0;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.78;
}

:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scroll);
    border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--line-strong);
}

[hidden] {
    display: none !important;
}

.icon {
    width: 20px;
    height: 20px;
    display: block;
    flex: 0 0 auto;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.muted {
    color: var(--muted);
}

.signature {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font-size: 21px;
    font-weight: 600;
    letter-spacing: -0.045em;
    line-height: 1;
}

.wordmark-lg {
    font-size: 27px;
}

.wordmark-mark {
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--ink);
    display: inline-block;
}

.icon-button {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.icon-button:hover {
    background: var(--hover);
    color: var(--ink);
}

.icon-button .icon {
    width: 19px;
    height: 19px;
}

.text-button {
    color: var(--muted);
    font-size: 12.5px;
    padding: 4px 2px;
    border-bottom: 1px solid transparent;
    transition: color 160ms ease, border-color 160ms ease;
}

.text-button:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.primary-button,
.secondary-button,
.small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    white-space: nowrap;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.primary-button {
    min-height: 46px;
    padding: 0 22px;
    background: var(--ink);
    color: var(--bg);
    font-size: 14px;
    font-weight: 500;
}

.primary-button:hover {
    background: var(--ink-hover);
}

.secondary-button {
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    font-size: 13.5px;
}

.secondary-button:hover {
    border-color: var(--ink);
    background: var(--hover);
}

.small-button {
    min-height: 34px;
    padding: 0 14px;
    background: var(--ink);
    color: var(--bg);
    font-size: 12.5px;
}

.small-button:hover {
    background: var(--ink-hover);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    letter-spacing: -0.02em;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.avatar-xs {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    font-size: 11px;
}

.avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 12px;
}

.avatar-md {
    width: 40px;
    height: 40px;
}

.avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    font-size: 22px;
}

.avatar-xl {
    width: 88px;
    height: 88px;
    border-radius: 18px;
    font-size: 28px;
}

.app {
    display: grid;
    grid-template-columns: 68px 260px minmax(0, 1fr);
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: var(--bg);
}

.desktop-rail {
    width: 68px;
    height: 100dvh;
    border-right: 1px solid var(--line);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 0 16px;
    gap: 22px;
    z-index: 22;
}

.rail-avatar-button {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 0;
    background: transparent;
}

.rail-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 15px;
}

.rail-avatar:hover {
    border-color: var(--line-strong);
}

.rail-nav,
.rail-bottom {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.rail-bottom {
    margin-top: auto;
}

.rail-button {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background-color 160ms ease, color 160ms ease;
}

.rail-button:hover {
    background: var(--hover);
    color: var(--ink);
}

.rail-button.is-active {
    background: var(--active);
    color: var(--ink);
}

.rail-button .icon {
    width: 22px;
    height: 22px;
}

.rail-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 5px;
    border: 1px solid var(--bg);
    background: var(--ink);
    color: var(--bg);
    font-size: 9.5px;
    font-weight: 600;
    line-height: 15px;
    text-align: center;
}

.sidebar-tabs,
.sidebar-bottom {
    display: none !important;
}

.sidebar {
    width: 260px;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
    background: var(--bg);
    min-width: 0;
    z-index: 20;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 26px 16px 20px 24px;
    gap: 12px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1px;
}

.sidebar-search {
    margin: 0 20px 20px 24px;
    height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 160ms ease;
}

.sidebar-search:focus-within {
    border-color: var(--ink);
}

.sidebar-search .icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.sidebar-search input {
    width: 100%;
    border: 0;
    background: transparent;
    outline: 0;
    font-size: 13px;
}

.sidebar-search input::-webkit-search-cancel-button {
    display: none;
}

.sidebar-tabs {
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
}

.tab {
    position: relative;
    padding: 8px 0 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: color 160ms ease;
}

.tab:hover {
    color: var(--ink);
}

.tab.is-active {
    color: var(--ink);
}

.tab.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--ink);
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 18px;
    min-height: 0;
}

.list-empty {
    padding: 56px 18px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    line-height: 1.9;
}

.list-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 12px 8px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.list-section-label::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
    opacity: 0.65;
}

.quick-action {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    padding-top: 9px;
    padding-bottom: 9px;
}

.quick-action-icon {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: transparent;
}

.quick-action-icon .icon {
    width: 17px;
    height: 17px;
}

.quick-action .conversation-side {
    flex-direction: row;
    align-items: center;
    gap: 7px;
    align-self: center;
}

.quick-action .conversation-side > .icon {
    width: 16px;
    height: 16px;
}

.conversation-item,
.contact-item {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 11px;
    align-items: center;
    padding: 11px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 160ms ease;
    margin-bottom: 1px;
    width: 100%;
    text-align: left;
}

.conversation-item:hover,
.contact-item:hover {
    background: var(--hover);
}

.conversation-item.is-active,
.contact-item.is-active {
    background: var(--active);
}

.conversation-main,
.contact-main {
    min-width: 0;
}

.conversation-name,
.contact-name {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--ink);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-preview,
.contact-meta {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.conversation-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    align-self: stretch;
    justify-content: center;
}

.conversation-time {
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1;
    white-space: nowrap;
}

.conversation-flags {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 16px;
}

.conversation-flags .icon {
    width: 12px;
    height: 12px;
    color: var(--muted);
}

.unread-badge {
    min-width: 19px;
    height: 18px;
    padding: 0 5px;
    border-radius: 6px;
    background: var(--ink);
    color: var(--bg);
    font-size: 10px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink);
    margin-right: 3px;
}

.contact-item.is-blocked {
    opacity: 0.56;
}

.contact-action {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}

.contact-action:hover {
    background: var(--hover);
    color: var(--ink);
}

.contact-action .icon {
    width: 16px;
    height: 16px;
}

.sidebar-bottom {
    border-top: 1px solid var(--line);
    padding: 13px 14px;
}

.me-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px;
    border-radius: 10px;
    text-align: left;
    transition: background-color 160ms ease;
}

.me-card:hover {
    background: var(--hover);
}

.me-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.45;
}

.me-card-text strong {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.me-card-text span {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.connection-state {
    margin-left: auto;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.connection-state.is-online {
    color: var(--ink);
}

.main-panel {
    min-width: 0;
    display: flex;
    overflow: hidden;
    background: var(--bg);
}

.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    height: 100dvh;
}

.chat-header {
    height: 72px;
    flex: 0 0 72px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    z-index: 5;
}

.mobile-back {
    display: none;
}

.chat-identity {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    text-align: left;
    border-radius: 10px;
    padding: 4px 6px 4px 4px;
    margin-left: -4px;
    transition: background-color 160ms ease;
}

.chat-identity:hover {
    background: var(--hover);
}

.chat-identity-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.45;
}

.chat-identity-text strong {
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-identity-text span {
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 420px;
}

.chat-tools {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 2px;
}

.typing-indicator {
    color: var(--muted);
    font-size: 11px;
    margin-right: 8px;
    white-space: nowrap;
    animation: fade-in 160ms ease;
}

.messages-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-anchor: none;
    position: relative;
    padding: 26px 0 18px;
    background-color: var(--bg);
    background-repeat: repeat;
    background-size: 160px 160px;
}

body[data-chat-bg="grain"] .messages-wrap {
    background-image: var(--pattern-grain);
}

body[data-chat-bg="rules"] .messages-wrap {
    background-image: var(--pattern-rules);
}

.messages {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0 32px 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.empty-state {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    text-align: center;
    padding: 40px;
}

.empty-state p {
    margin: 0;
    font-size: 13px;
}

.empty-mark {
    color: var(--line-strong);
    font-size: 44px;
    font-weight: 600;
    letter-spacing: -0.06em;
    line-height: 1;
}

.empty-rule {
    width: 42px;
    height: 1px;
    background: var(--line);
    margin-top: 6px;
}

.date-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0 16px;
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: 0.04em;
}

.date-divider::before,
.date-divider::after {
    content: "";
    height: 1px;
    flex: 1;
    background: var(--line);
    opacity: 0.55;
}

.load-more {
    align-self: center;
    color: var(--muted);
    font-size: 12px;
    padding: 8px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: color 160ms ease, border-color 160ms ease;
}

.load-more:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.message-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 4px 0;
    max-width: 100%;
    animation: message-in 160ms ease both;
}

.message-row.own {
    justify-content: flex-end;
}

.message-row.own + .message-row.own,
.message-row:not(.own) + .message-row:not(.own) {
    margin-top: 1px;
}

.message-avatar {
    margin-top: 18px;
}

.message-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 70%;
    min-width: 0;
}

.message-row.own .message-stack {
    align-items: flex-end;
}

.message-sender {
    margin: 0 0 4px 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
}

.bubble {
    position: relative;
    padding: 9px 14px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: var(--other-bubble);
    color: var(--other-ink);
    font-size: var(--chat-font-size, 15px);
    line-height: 1.65;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    max-width: 100%;
}

.message-row:not(.own) .bubble {
    border-color: var(--line);
}

.message-row.own .bubble {
    background: var(--own-bubble);
    color: var(--own-ink);
    border-color: var(--own-bubble);
}

.bubble a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bubble .mention {
    font-weight: 600;
    border-bottom: 1px solid currentColor;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 4px;
    padding: 0 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
    opacity: 0.9;
}

.message-row.own .message-meta {
    justify-content: flex-end;
}

.message-meta .read-state {
    color: var(--ink);
    opacity: 0.66;
}

.message-row.is-highlighted .bubble {
    outline: 1px solid var(--ink);
    outline-offset: 2px;
}

.message-row.system {
    justify-content: center;
    margin: 14px 0;
}

.system-note {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.6;
    text-align: center;
    padding: 3px 12px;
    background: var(--bg);
    border-radius: 6px;
}

.bubble-image {
    padding: 0;
    overflow: hidden;
    cursor: zoom-in;
    background: var(--other-bubble);
    border: 1px solid var(--line);
}

.message-row.own .bubble-image {
    border-color: var(--own-bubble);
    background: var(--own-bubble);
}

.bubble-image img {
    display: block;
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: cover;
}

.bubble-file {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 210px;
    text-align: left;
}

.file-glyph {
    width: 36px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    flex: 0 0 auto;
}

.message-row.own .file-glyph {
    border-color: var(--own-ink);
    color: var(--own-ink);
    opacity: 0.72;
}

.file-glyph .icon {
    width: 17px;
    height: 17px;
}

.file-copy {
    min-width: 0;
    line-height: 1.5;
}

.file-name {
    font-size: 13px;
    white-space: normal;
    word-break: break-all;
}

.file-size {
    display: block;
    color: var(--muted);
    font-size: 10.5px;
    margin-top: 2px;
}

.message-row.own .file-size {
    color: var(--own-ink);
    opacity: 0.62;
}

.bubble-voice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 108px;
    cursor: pointer;
    user-select: none;
}

.bubble-voice .icon {
    width: 17px;
    height: 17px;
}

.voice-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 18px;
}

.voice-bars span {
    display: block;
    width: 2px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.68;
}

.voice-bars span:nth-child(1) { height: 7px; }
.voice-bars span:nth-child(2) { height: 12px; }
.voice-bars span:nth-child(3) { height: 16px; }
.voice-bars span:nth-child(4) { height: 9px; }
.voice-bars span:nth-child(5) { height: 14px; }
.voice-bars span:nth-child(6) { height: 6px; }
.voice-bars span:nth-child(7) { height: 11px; }

.voice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.voice-duration {
    font-size: 11px;
    opacity: 0.7;
    margin-left: auto;
    white-space: nowrap;
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    margin-left: 5px;
}

.typing-dots span {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
    animation: typing 1200ms ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 160ms; }
.typing-dots span:nth-child(3) { animation-delay: 320ms; }

.scroll-bottom {
    position: absolute;
    right: 26px;
    bottom: 22px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    box-shadow: 0 4px 24px var(--shadow-color);
    transition: color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.scroll-bottom:hover {
    color: var(--ink);
    border-color: var(--ink);
}

.scroll-bottom .icon {
    transform: rotate(180deg);
    width: 17px;
    height: 17px;
}

.composer {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 32px 20px;
    border-top: 1px solid var(--line);
    background: var(--bg);
}

.composer-tools {
    display: flex;
    align-items: center;
    gap: 1px;
    height: 44px;
}

.composer-tools .icon-button {
    width: 32px;
    height: 32px;
}

.composer-input {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    transition: border-color 160ms ease;
}

.composer-input:focus-within {
    border-color: var(--ink);
}

.composer-input textarea {
    display: block;
    width: 100%;
    min-height: 44px;
    max-height: 160px;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    padding: 11px 14px;
    font-size: 14px;
    line-height: 1.55;
}

.send-button {
    height: 44px;
    padding: 0 22px;
    border-radius: 10px;
    background: var(--ink);
    color: var(--bg);
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color 160ms ease, opacity 160ms ease;
}

.send-button:hover {
    background: var(--ink-hover);
}

.record-panel {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px 0 6px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    font-size: 12px;
}

.voice-hold {
    flex: 1;
    min-width: 0;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.voice-hold:hover {
    border-color: var(--line-strong);
}

.record-panel.is-holding .voice-hold,
.record-panel.is-recording .voice-hold {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}

.record-panel.is-cancel .voice-hold {
    border-style: dashed;
}

.record-panel.is-recording .record-label,
.record-panel.is-holding .record-label {
    color: currentColor;
}

.record-time {
    font-variant-numeric: tabular-nums;
    opacity: 0.78;
}

.record-panel .text-button {
    flex: 0 0 auto;
    margin-left: 0;
}

.composer.is-voice .send-button {
    visibility: hidden;
}

.composer.is-voice #record-voice {
    color: var(--ink);
    background: var(--hover);
}

.record-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink);
    animation: pulse 1300ms ease-in-out infinite;
}

.record-label {
    color: var(--muted);
}

.record-panel .text-button {
    margin-left: auto;
}

.mention-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    width: 260px;
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 4px 24px var(--shadow-color);
    z-index: 30;
}

.mention-option {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px;
    border-radius: 7px;
    text-align: left;
    font-size: 12.5px;
}

.mention-option:hover,
.mention-option.is-active {
    background: var(--hover);
}

.mention-option .avatar {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    font-size: 10px;
}

.mention-hint {
    padding: 10px;
    color: var(--muted);
    font-size: 12px;
}

.details-panel {
    display: none;
    width: 320px;
    height: 100dvh;
    overflow-y: auto;
    border-left: 1px solid var(--line);
    background: var(--bg);
    padding: 28px 24px 40px;
}

.app.has-details .details-panel {
    display: block;
}

.details-close {
    position: absolute;
    top: 0;
    right: 0;
}

.details-head {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 9px;
    padding: 8px 0 26px;
    border-bottom: 1px solid var(--line);
}

.details-name {
    margin: 4px 0 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.details-username {
    color: var(--muted);
    font-size: 12px;
}

.details-signature {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
    max-width: 240px;
}

.details-section {
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
}

.details-section:last-child {
    border-bottom: 0;
}

.details-section-title {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.details-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    font-size: 13px;
}

.details-row .muted {
    font-size: 11.5px;
}

.details-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.details-input {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    padding: 7px 10px;
    font-size: 13px;
    outline: 0;
}

.details-input:focus {
    border-color: var(--ink);
}

.details-textarea {
    min-height: 90px;
    resize: vertical;
    line-height: 1.6;
}

.details-inline-form {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.details-inline-form .details-input {
    flex: 1;
}

.member-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.member-row {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 4px;
    border-radius: 8px;
}

.member-row:hover {
    background: var(--hover);
}

.member-row .avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 11px;
}

.member-name {
    min-width: 0;
    flex: 1;
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-name small {
    display: block;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 400;
}

.role-badge {
    color: var(--muted);
    font-size: 9.5px;
    letter-spacing: 0.06em;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 1px 5px;
    white-space: nowrap;
}

.announcement-box {
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--ink-soft);
    background: var(--surface-soft);
    border-radius: 8px;
    padding: 12px 14px;
    white-space: pre-wrap;
}

.danger-action {
    color: var(--ink);
    font-size: 12.5px;
    border-bottom: 1px solid var(--line);
    padding: 5px 0;
    transition: border-color 160ms ease;
}

.danger-action:hover {
    border-color: var(--ink);
}

.overlay-root:empty {
    display: none;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--overlay);
    animation: fade-in 160ms ease;
}

.modal {
    width: min(560px, 100%);
    max-height: min(86dvh, 860px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 4px 24px var(--shadow-strong);
    overflow: hidden;
    animation: modal-in 180ms ease;
}

.modal-wide {
    width: min(700px, 100%);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 15px 22px;
    border-top: 1px solid var(--line);
}

.modal-subtitle {
    margin: -8px 0 0;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.field label {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.05em;
}

.label-note {
    color: var(--muted);
    opacity: 0.66;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
    padding: 0 13px;
    font-size: 13.5px;
    outline: 0;
    transition: border-color 160ms ease;
}

.field textarea {
    padding: 10px 13px;
    min-height: 96px;
    resize: vertical;
    line-height: 1.65;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--ink);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.code-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.code-row input {
    flex: 1;
    min-width: 0;
}

.code-row .secondary-button {
    min-height: 44px;
    white-space: nowrap;
}

.field-hint {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.6;
    min-height: 18px;
}

.field-hint.is-error {
    color: var(--ink);
}

.field-hint.is-success {
    color: var(--muted);
}

.verify-phone-value {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    font-size: 15px;
    letter-spacing: 0.04em;
    background: var(--surface-soft);
}

.verify-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 22px;
    font-size: 12px;
}

.phone-input-group {
    display: flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
    transition: border-color 160ms ease;
}

.phone-input-group:focus-within {
    border-color: var(--ink);
}

.phone-prefix,
.verify-phone-prefix {
    color: var(--muted);
    font-size: 13.5px;
    letter-spacing: 0.03em;
}

.phone-prefix {
    padding: 0 10px 0 13px;
    border-right: 1px solid var(--line);
    margin-right: 2px;
    line-height: 22px;
}

.phone-input-group input {
    flex: 1;
    min-width: 0;
    min-height: 42px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0 13px 0 10px;
    outline: 0;
}

.phone-input-group input:focus {
    border: 0;
}

.verify-phone-prefix {
    margin-right: 7px;
}

.field-error {
    color: var(--ink);
    font-size: 11.5px;
    border-left: 2px solid var(--ink);
    padding-left: 7px;
    line-height: 1.5;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}

.check-row input {
    accent-color: var(--ink);
}

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 13px;
}

.switch {
    position: relative;
    width: 38px;
    height: 22px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: transparent;
    transition: background-color 160ms ease, border-color 160ms ease;
}

.switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 160ms ease, background-color 160ms ease;
}

.switch.is-on {
    border-color: var(--ink);
    background: var(--ink);
}

.switch.is-on::after {
    transform: translateX(16px);
    background: var(--bg);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.theme-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px;
    text-align: left;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.theme-card:hover {
    border-color: var(--line-strong);
}

.theme-card.is-active {
    border-color: var(--ink);
}

.theme-preview {
    height: 58px;
    border-radius: 6px;
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 5px;
    justify-content: center;
    padding: 9px;
}

.theme-preview-light {
    background: var(--preview-light-bg);
}

.theme-preview-dark {
    background: var(--preview-dark-bg);
}

.theme-preview-paper {
    background: var(--preview-paper-bg);
}

.theme-preview span {
    display: block;
    height: 3px;
    border-radius: 2px;
}

.theme-preview-light span,
.theme-preview-paper span {
    background: var(--ink);
}

.theme-preview-dark span {
    background: var(--preview-light-bg);
}

.theme-preview span:first-child {
    width: 62%;
}

.theme-preview span:last-child {
    width: 38%;
    opacity: 0.4;
}

.theme-label {
    display: block;
    text-align: center;
    color: var(--muted);
    font-size: 10.5px;
    padding: 6px 0 1px;
}

.theme-card.is-active .theme-label {
    color: var(--ink);
}

.choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.choice-chip {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    transition: border-color 160ms ease, color 160ms ease, background-color 160ms ease;
}

.choice-chip:hover {
    border-color: var(--line-strong);
    color: var(--ink);
}

.choice-chip.is-active {
    border-color: var(--ink);
    color: var(--ink);
    background: var(--hover);
}

.range-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.range-row input[type="range"] {
    flex: 1;
    accent-color: var(--ink);
}

.range-value {
    width: 34px;
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.settings-name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.settings-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-label {
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.profile-edit-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-edit-copy {
    flex: 1;
    min-width: 0;
}

.qr-frame {
    width: 220px;
    max-width: 100%;
    aspect-ratio: 1;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-frame img,
.qr-frame svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.qr-block p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.search-result {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 2px;
    border-bottom: 1px solid var(--line);
}

.search-result:last-child {
    border-bottom: 0;
}

.search-result-main {
    flex: 1;
    min-width: 0;
}

.search-result-main strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-main span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-highlight {
    border-bottom: 1px solid currentColor;
}

.people-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.people-row:last-child {
    border-bottom: 0;
}

.people-main {
    flex: 1;
    min-width: 0;
}

.people-main strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
}

.people-main span {
    display: block;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.6;
}

.people-main .relationship {
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: 0.03em;
}

.empty-note {
    padding: 22px 4px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.8;
    text-align: center;
}

.invite-list {
    max-height: 260px;
    overflow-y: auto;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.invite-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    font-size: 13px;
}

.invite-row:last-child {
    border-bottom: 0;
}

.invite-row .avatar {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    font-size: 11px;
}

.field .invite-row {
    color: var(--ink);
    font-size: 13px;
    letter-spacing: 0;
}

.invite-row span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.invite-row input[type="checkbox"] {
    appearance: none;
    position: relative;
    flex: none;
    width: 18px;
    height: 18px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
    background: transparent;
    accent-color: var(--ink);
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease;
}

.invite-row input[type="checkbox"]:checked {
    border-color: var(--ink);
    background: var(--ink);
}

.invite-row input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid var(--bg);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
}

.invite-row input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.tabs-inline {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--line);
}

.tabs-inline button {
    position: relative;
    color: var(--muted);
    font-size: 12.5px;
    padding: 6px 0 10px;
}

.tabs-inline button.is-active {
    color: var(--ink);
}

.tabs-inline button.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: var(--ink);
}

.file-drop {
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

.context-menu {
    position: fixed;
    z-index: 80;
    min-width: 168px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 4px 24px var(--shadow-strong);
    animation: fade-in 120ms ease;
}

.context-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 7px;
    color: var(--ink);
    font-size: 12.5px;
    text-align: left;
}

.context-menu button:hover {
    background: var(--hover);
}

.context-menu .icon {
    width: 15px;
    height: 15px;
    color: var(--muted);
}

.toast-root {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.toast {
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 15px;
    border-radius: 9px;
    background: var(--ink);
    color: var(--bg);
    font-size: 12.5px;
    line-height: 1.6;
    box-shadow: 0 4px 24px var(--shadow-strong);
    animation: toast-in 180ms ease;
    pointer-events: auto;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    animation: fade-in 160ms ease;
}

.lightbox img {
    max-width: min(1100px, 92vw);
    max-height: 88dvh;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.lightbox-close {
    position: absolute;
    top: 22px;
    right: 24px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-body {
    min-height: 100dvh;
    background: var(--bg);
    overflow-y: auto;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
    min-height: 100dvh;
}

.auth-aside {
    border-right: 1px solid var(--line);
    padding: 48px 4.5vw 40px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg);
    background-image: var(--pattern-rules);
    background-size: 160px 160px;
    overflow: hidden;
}

.auth-statement {
    margin: auto 0;
    padding: 40px 0;
    max-width: 620px;
}

.auth-statement h1 {
    margin: 16px 0 20px;
    font-size: clamp(42px, 5.6vw, 76px);
    font-weight: 600;
    letter-spacing: -0.065em;
    line-height: 1.02;
}

.auth-lede {
    margin: 0;
    max-width: 460px;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.9;
}

.auth-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.auth-rule {
    height: 1px;
    flex: 1;
    background: var(--line);
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 42px;
    background: var(--bg);
}

.auth-form-wrap {
    width: min(390px, 100%);
}

.auth-title {
    margin: 12px 0 4px;
    font-size: 29px;
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1.2;
}

.auth-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.auth-form-wrap .form {
    margin-top: 30px;
}

.auth-form-wrap .primary-button {
    width: 100%;
    margin-top: 4px;
}

.auth-switch {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.auth-tabs {
    display: flex;
    gap: 24px;
    margin: 0 0 20px;
    border-bottom: 1px solid var(--line);
}

.auth-tab {
    position: relative;
    padding: 0 0 10px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: color 160ms ease;
}

.auth-tab::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 1px;
    background: transparent;
}

.auth-tab:hover,
.auth-tab.is-active {
    color: var(--ink);
}

.auth-tab.is-active::after {
    background: var(--ink);
}

.auth-switch a {
    color: var(--ink);
    border-bottom: 1px solid var(--line-strong);
    padding-bottom: 1px;
    transition: border-color 160ms ease;
}

.auth-switch a:hover {
    border-color: var(--ink);
}

.scan-body {
    min-height: 100dvh;
    background: var(--bg);
}

.scan-top {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 0 4vw;
    border-bottom: 1px solid var(--line);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    transition: color 160ms ease;
}

.back-link:hover {
    color: var(--ink);
}

.back-link .icon {
    width: 16px;
    height: 16px;
}

.scan-status {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.03em;
    min-width: 110px;
    text-align: right;
}

.scan-shell {
    max-width: 1240px;
    margin: 0 auto;
    padding: 44px 4vw 60px;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 44px;
    align-items: start;
}

.scan-stage {
    min-width: 0;
}

.scan-viewport {
    position: relative;
    width: 100%;
    max-width: 620px;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg-deep);
    overflow: hidden;
}

.scan-viewport video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.scan-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px;
    background-color: var(--bg-deep);
    background-image: var(--pattern-rules);
    background-size: 160px 160px;
}

.scan-placeholder h1 {
    margin: 12px 0 8px;
    font-size: clamp(26px, 3vw, 38px);
    font-weight: 600;
    letter-spacing: -0.05em;
    line-height: 1.25;
}

.scan-placeholder p:last-child {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.scan-frame {
    position: absolute;
    inset: 11%;
    pointer-events: none;
}

.scan-viewport-modal {
    max-width: 520px;
    margin: 0 auto;
}

.scan-frame span {
    position: absolute;
    width: 34px;
    height: 34px;
    border-color: var(--ink);
    border-style: solid;
    opacity: 0.8;
}

.scan-frame span:nth-child(1) {
    top: 0;
    left: 0;
    border-width: 1px 0 0 1px;
}

.scan-frame span:nth-child(2) {
    top: 0;
    right: 0;
    border-width: 1px 1px 0 0;
}

.scan-frame span:nth-child(3) {
    bottom: 0;
    left: 0;
    border-width: 0 0 1px 1px;
}

.scan-frame span:nth-child(4) {
    bottom: 0;
    right: 0;
    border-width: 0 1px 1px 0;
}

.scan-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
}

.scan-note {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.7;
}

.scan-result {
    border-left: 1px solid var(--line);
    padding-left: 44px;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.scan-result h2 {
    margin: 4px 0 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.04em;
    line-height: 1.25;
}

.scan-result p {
    margin: 0;
}

.scan-person {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 0 8px;
}

.scan-person h2 {
    margin: 0;
    font-size: 22px;
}

.scan-person .muted {
    font-size: 12px;
}

.scan-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    font-size: 12.5px;
    word-break: break-all;
    line-height: 1.7;
    color: var(--muted);
}

.scan-result .primary-button,
.scan-result .secondary-button {
    width: 100%;
}

.error-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 32px;
    text-align: center;
    background-color: var(--bg);
    background-image: var(--pattern-rules);
    background-size: 160px 160px;
}

.error-code {
    margin: 0;
    color: var(--line-strong);
    font-size: clamp(72px, 12vw, 140px);
    font-weight: 600;
    letter-spacing: -0.08em;
    line-height: 1;
}

.error-page h1 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.error-page p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
    0%, 100% { opacity: 0.22; transform: translateY(0); }
    50% { opacity: 0.72; transform: translateY(-2px); }
}

@keyframes pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}




.mobile-tabbar {
    display: none;
}

.mobile-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 52px;
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: 0.02em;
    transition: color 160ms ease;
}

.mobile-tab .icon {
    width: 21px;
    height: 21px;
}

.mobile-tab.is-active {
    color: var(--ink);
}

.mobile-tab.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 18px;
    height: 1px;
    background: var(--ink);
}

.mobile-me-page {
    padding: 18px 8px 34px;
}

.mobile-me-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 26px;
    border-bottom: 1px solid var(--line);
    text-align: center;
}

.mobile-me-name {
    margin: 6px 0 0;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.mobile-me-username {
    color: var(--muted);
    font-size: 12px;
}

.mobile-me-signature {
    margin: 2px 0 0;
    max-width: 260px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.mobile-me-list {
    margin-top: 10px;
}

.mobile-me-row {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    padding: 15px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    font-size: 13px;
    text-align: left;
    transition: background-color 160ms ease;
}

.mobile-me-row:hover {
    background: var(--hover);
}

.mobile-me-row .icon {
    width: 18px;
    height: 18px;
    color: var(--muted);
}

.mobile-me-row .mobile-me-meta {
    margin-left: auto;
    color: var(--muted);
    font-size: 11.5px;
    white-space: nowrap;
}

.mobile-me-row .mobile-me-chevron {
    margin-left: auto;
    width: 16px;
    height: 16px;
}

.mobile-me-row.is-danger {
    color: var(--ink);
}



.app.rail-page {
    grid-template-columns: 68px minmax(0, 1fr);
}

.app.rail-page .sidebar {
    display: none;
}

.app.rail-page .chat-panel,
.app.rail-page .details-panel {
    display: none !important;
}

.desktop-page {
    display: none;
    flex: 1;
    min-width: 0;
    height: 100dvh;
    overflow-y: auto;
    background: var(--bg);
}

.app.rail-page .desktop-page {
    display: block;
}

.desktop-page-inner {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 48px 56px 64px;
}

.desktop-page-head {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 30px;
}

.desktop-page-head h1 {
    margin: 0;
    font-size: 40px;
    font-weight: 600;
    letter-spacing: -0.055em;
    line-height: 1.08;
}

.desktop-page-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
    max-width: 520px;
}

.desktop-page-search {
    margin-top: 14px;
    width: min(360px, 100%);
    height: 40px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    transition: border-color 160ms ease;
}

.desktop-page-search:focus-within {
    border-color: var(--ink);
}

.desktop-page-search .icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.desktop-page-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 13px;
}

.desktop-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 34px;
}

.desktop-quick-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-align: left;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.desktop-quick-card:hover {
    border-color: var(--line-strong);
    background: var(--hover);
}

.desktop-quick-icon {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    flex: 0 0 auto;
}

.desktop-quick-icon .icon {
    width: 18px;
    height: 18px;
}

.desktop-quick-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.desktop-quick-copy strong {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.desktop-quick-copy span {
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-quick-card > .icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex: 0 0 auto;
}

.desktop-contact-group {
    margin-top: 26px;
}

.desktop-group-letter {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.desktop-group-letter::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--line);
}

.desktop-friend-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 28px;
}

.desktop-friend-card {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    padding: 10px 6px;
    border-bottom: 1px solid var(--line);
    border-radius: 8px;
    text-align: left;
    transition: background-color 160ms ease;
}

.desktop-friend-card:hover {
    background: var(--hover);
}

.desktop-friend-card .avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 12px;
}

.desktop-friend-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.desktop-friend-main strong {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-friend-main span {
    color: var(--muted);
    font-size: 11.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.desktop-friend-card > .icon {
    width: 15px;
    height: 15px;
    color: var(--muted);
    flex: 0 0 auto;
}

.desktop-page-empty {
    padding: 54px 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
    text-align: center;
    border-top: 1px solid var(--line);
}

.desktop-settings-grid {
    column-count: 2;
    column-gap: 48px;
}

.desktop-settings-grid .settings-block {
    break-inside: avoid;
    padding: 22px 0;
    border-bottom: 1px solid var(--line);
}

.desktop-settings-grid .settings-block:last-child {
    border-bottom: 0;
}

.desktop-settings-page .qr-frame {
    width: 190px;
}

@media (max-width: 1120px) {
    .desktop-page-inner {
        padding: 36px 32px 48px;
    }

    .desktop-friend-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .desktop-settings-grid {
        column-count: 1;
    }

    .desktop-quick-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 1120px) {
    .details-panel {
        width: 300px;
        padding-left: 20px;
        padding-right: 20px;
    }

    .auth-shell {
        grid-template-columns: minmax(0, 1fr) minmax(390px, 0.85fr);
    }
}

@media (max-width: 900px) {
    .app,
    .app.has-details,
    .sidebar {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        height: 100dvh;
    }

    .desktop-rail {
        display: none;
    }

    .app.rail-page {
        grid-template-columns: minmax(0, 1fr);
    }

    .app.rail-page .sidebar {
        display: flex;
    }

    .desktop-page {
        display: none !important;
    }

    .top-actions {
        display: none;
    }

    .mobile-tabbar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 45;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        padding-bottom: env(safe-area-inset-bottom);
        border-top: 1px solid var(--line);
        background: var(--bg);
    }

    .app.chat-open + .mobile-tabbar {
        display: none;
    }

    .sidebar-tabs,
    .sidebar-bottom {
        display: none;
    }

    .sidebar-list {
        padding-bottom: 82px;
    }

    .sidebar.is-me .sidebar-search {
        display: none;
    }

    .main-panel {
        width: 100%;
        min-width: 0;
    }

    .app:not(.chat-open) .main-panel {
        display: none;
    }

    .app.chat-open .main-panel {
        display: flex;
    }

    .app.chat-open .sidebar {
        display: none;
    }

    .chat-panel {
        display: none;
        width: 100%;
    }

    .app.chat-open .chat-panel {
        display: flex;
    }

    .mobile-back {
        display: inline-flex;
    }

    .chat-header {
        padding: 0 12px;
        gap: 6px;
    }

    .chat-identity-text span {
        max-width: 180px;
    }

    .messages {
        padding: 0 16px;
    }

    .messages-wrap {
        padding-top: 18px;
    }

    .message-stack {
        max-width: 83%;
    }

    .message-avatar {
        display: none;
    }

    .message-row:not(.own) .message-stack {
        margin-left: 4px;
    }

    .composer {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
        gap: 6px;
    }

    .composer-tools .icon-button {
        width: 28px;
        height: 28px;
    }

    .composer-tools .icon {
        width: 17px;
        height: 17px;
    }

    .send-button {
        padding: 0 16px;
    }

    .details-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        width: min(340px, 88vw);
        box-shadow: 0 4px 24px var(--shadow-strong);
        display: none;
    }

    .app.has-details .details-panel {
        display: block;
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-aside {
        border-right: 0;
        border-bottom: 1px solid var(--line);
        min-height: 300px;
        padding: 32px 28px;
    }

    .auth-statement {
        padding: 32px 0 20px;
    }

    .auth-statement h1 {
        font-size: 44px;
    }

    .auth-panel {
        padding: 36px 28px 56px;
    }

    .scan-shell {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .scan-result {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding: 28px 0 0;
        min-height: 0;
    }
}

@media (max-width: 560px) {
    .field-row {
        grid-template-columns: 1fr;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal {
        max-height: 92dvh;
    }

    .theme-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .auth-aside {
        min-height: 240px;
    }

    .auth-statement h1 {
        font-size: 38px;
    }

    .auth-statement {
        padding-bottom: 6px;
    }

    .scan-top {
        padding: 0 18px;
    }

    .scan-status {
        display: none;
    }

    .scan-shell {
        padding: 26px 18px 44px;
    }

    .scan-actions .primary-button,
    .scan-actions .secondary-button {
        flex: 1;
    }
}

.captcha-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay);
    animation: fade-in 160ms ease;
}

.captcha-dialog {
    width: min(340px, 100%);
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 4px 24px var(--shadow-strong);
}

.captcha-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.captcha-head .eyebrow {
    margin: 0 0 5px;
}

.captcha-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.captcha-close {
    width: 28px;
    height: 28px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}

.captcha-close:hover {
    color: var(--ink);
    border-color: var(--line-strong);
}

.captcha-sub {
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.captcha-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 280 / 150;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    user-select: none;
}

.captcha-bg {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

.captcha-piece {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 1;
    pointer-events: none;
    transition: transform 90ms ease-out;
}

.captcha-track {
    position: relative;
    height: 42px;
    margin-top: 14px;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.captcha-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 21px;
    background: var(--line);
}

.captcha-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 32px;
    color: var(--muted);
    font-size: 12px;
    pointer-events: none;
}

.captcha-handle {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -1px 0 0 -1px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    background: var(--ink);
    color: var(--bg);
    cursor: grab;
    touch-action: none;
    transition: transform 90ms ease-out, background 160ms ease;
}

.captcha-dialog.is-dragging .captcha-handle,
.captcha-dialog.is-dragging .captcha-piece {
    transition: none;
}

.captcha-handle.is-dragging {
    cursor: grabbing;
}

.captcha-handle:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.captcha-handle svg {
    width: 18px;
    height: 18px;
}

.captcha-status {
    margin: 10px 0 0;
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.captcha-status.is-error {
    color: var(--ink);
}

.captcha-status.is-success {
    color: var(--ink);
    font-weight: 600;
}

.captcha-retry {
    margin: 2px 0 0;
    padding: 0 0 1px;
    border: 0;
    border-bottom: 1px solid var(--ink);
    background: none;
    color: var(--ink);
    font-size: 12px;
    cursor: pointer;
}

.captcha-dialog.is-passed .captcha-track {
    border-color: var(--ink);
}

.captcha-dialog.is-passed .captcha-hint {
    color: var(--ink);
}

.captcha-dialog.is-shaking {
    animation: captcha-shake 380ms ease;
}

body.captcha-open {
    overflow: hidden;
}

@keyframes captcha-shake {
    0%,
    100% {
        transform: translateX(0);
    }
    20% {
        transform: translateX(-6px);
    }
    40% {
        transform: translateX(5px);
    }
    60% {
        transform: translateX(-3px);
    }
    80% {
        transform: translateX(2px);
    }
}

@media (max-width: 380px) {
    .captcha-dialog {
        padding: 16px;
    }

    .captcha-sub {
        margin-bottom: 12px;
    }
}
