:root {
    --bg: #f7f7f8;
    --page: #ffffff;
    --panel: #ffffff;
    --panel-2: #f3f4f6;
    --panel-3: #ececf1;
    --text: #202123;
    --text-2: #4b5563;
    --muted: #8e8ea0;
    --line: rgba(0, 0, 0, .1);
    --line-2: rgba(0, 0, 0, .16);
    --accent: #10a37f;
    --accent-2: #0f8f70;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 18px 44px rgba(0, 0, 0, .08);
    --soft-shadow: 0 8px 24px rgba(0, 0, 0, .06);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 12px 30px rgba(0, 0, 0, .06);
    --radius: 16px;
    --radius-sm: 12px;
    --sans: Inter, "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    --bg: #212121;
    --page: #212121;
    --panel: #2f2f2f;
    --panel-2: #303030;
    --panel-3: #3a3a3a;
    --text: #ececec;
    --text-2: #c5c5d2;
    --muted: #9b9b9b;
    --line: rgba(255, 255, 255, .12);
    --line-2: rgba(255, 255, 255, .2);
    --accent: #10a37f;
    --accent-2: #19c37d;
    --danger: #f87171;
    --warning: #fbbf24;
    --shadow: 0 18px 44px rgba(0, 0, 0, .22);
    --soft-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    --card-shadow: 0 1px 2px rgba(0, 0, 0, .18), 0 14px 34px rgba(0, 0, 0, .18);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    letter-spacing: 0;
}

body,
input,
textarea,
select,
button {
    font-family: inherit;
}

body {
    user-select: text;
    -webkit-user-select: text;
    font-size: 15px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

button {
    border: 0;
}

.app-shell {
    min-height: 100vh;
    background: var(--bg);
}

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .82), rgba(246, 247, 249, .96)),
        linear-gradient(135deg, #ffe7df 0%, #f7f7f8 46%, #dff5ee 100%);
    color: #111827;
    overflow: hidden;
}

.auth-top {
    height: calc(54px + env(safe-area-inset-top));
    display: flex;
    align-items: end;
    justify-content: center;
    padding: 0 16px 14px;
    background: rgba(255, 255, 255, .72);
    border-bottom: 1px solid rgba(17, 24, 39, .08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.auth-top h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 850;
}

.auth-card {
    width: min(100%, 430px);
    margin: 0 auto;
    padding: 46px 18px 24px;
}

.auth-logo {
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    margin: 0 auto 28px;
    border-radius: 24px;
    color: #fff;
    background: linear-gradient(135deg, #f15b4a 0%, #ce3a55 52%, #1f9f87 100%);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .34), 0 18px 34px rgba(206, 58, 85, .24);
    font-size: 52px;
    line-height: 1;
    font-weight: 900;
}

.auth-card h2 {
    margin: 0;
    color: #111827;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 900;
}

.auth-card > p {
    margin: 6px 0 30px;
    color: #6b7280;
    font-size: 14px;
}

.auth-field {
    display: grid;
    gap: 8px;
    margin-bottom: 15px;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
}

.auth-field .input {
    min-height: 50px;
    border: 1px solid rgba(17, 24, 39, .08) !important;
    border-radius: 14px !important;
    background: rgba(255, 255, 255, .9) !important;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .06);
    font-size: 16px;
}

.auth-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 4px 0 16px;
    color: #374151;
    font-size: 13px;
}

.auth-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.auth-options a {
    color: #006dff;
    text-decoration: none;
}

.auth-submit {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    color: #fff;
    background: #202123;
    box-shadow: 0 14px 26px rgba(17, 24, 39, .16);
    font-size: 16px;
    font-weight: 850;
}

.auth-switch {
    width: 100%;
    min-height: 44px;
    margin-top: 12px;
    color: #0f8f70;
    background: transparent;
    font-size: 15px;
    font-weight: 750;
}

:root[data-theme="dark"] .auth-page {
    background:
        linear-gradient(180deg, rgba(33, 33, 33, .88), rgba(18, 18, 18, .98)),
        linear-gradient(135deg, #4a201c 0%, #212121 48%, #10382f 100%);
    color: #ececec;
}

:root[data-theme="dark"] .auth-top {
    background: rgba(33, 33, 33, .72);
    border-bottom-color: rgba(255, 255, 255, .1);
}

:root[data-theme="dark"] .auth-card h2,
:root[data-theme="dark"] .auth-field {
    color: #f7f7f8;
}

:root[data-theme="dark"] .auth-card > p,
:root[data-theme="dark"] .auth-options {
    color: #c5c5d2;
}

:root[data-theme="dark"] .auth-field .input {
    border-color: rgba(255, 255, 255, .1) !important;
    background: rgba(47, 47, 47, .9) !important;
}

:root[data-theme="dark"] .auth-submit {
    background: #10a37f;
    box-shadow: 0 14px 26px rgba(16, 163, 127, .18);
}

.admin-page .panel h2 {
    margin: 0;
    font-size: 17px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-stats div,
.admin-row,
.admin-log,
.admin-quality {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--card-shadow);
}

.admin-stats div {
    display: grid;
    gap: 4px;
    padding: 14px;
}

.admin-stats b {
    font-size: 28px;
    line-height: 1;
}

.admin-stats span,
.admin-row span,
.admin-row small,
.admin-log span {
    color: var(--muted);
    font-size: 12px;
}

.admin-row,
.admin-log,
.admin-quality {
    display: grid;
    gap: 5px;
    padding: 12px;
}

.admin-row b,
.admin-log b {
    font-size: 15px;
}

.admin-log div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.admin-log p {
    margin: 0;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.55;
}

.admin-quality {
    gap: 9px;
}

.admin-quality p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.view {
    min-height: 100vh;
    padding: calc(12px + env(safe-area-inset-top)) 14px calc(18px + env(safe-area-inset-bottom));
}

.app-mobile {
    width: min(100%, 720px);
    margin: 0 auto;
}

.mobile-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -12px -12px 16px;
    padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
    background: rgba(247, 247, 248, .9);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.mobile-title {
    min-width: 0;
}

:root[data-theme="dark"] .mobile-header {
    background: rgba(33, 33, 33, .9);
}

.mobile-title h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.12;
    font-weight: 750;
}

.mobile-title p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn,
.primary-btn,
.ghost-btn,
.danger-btn,
.send-btn,
.mini-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    transition: background .16s ease, color .16s ease, transform .12s ease, border-color .16s ease;
}

.icon-btn {
    width: 40px;
    color: var(--text);
    background: transparent;
    border: 1px solid transparent;
}

.icon-btn:hover,
.ghost-btn:hover,
.mini-btn:hover {
    background: var(--panel-2);
}

.primary-btn,
.ghost-btn,
.danger-btn {
    gap: 7px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
}

.primary-btn {
    color: #fff;
    background: var(--text);
}

:root[data-theme="dark"] .primary-btn {
    color: #111;
    background: #ececec;
}

.ghost-btn {
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
}

.danger-btn {
    color: var(--danger);
    background: rgba(220, 38, 38, .1);
    border: 1px solid rgba(220, 38, 38, .24);
}

:root[data-theme="dark"] .danger-btn {
    background: rgba(248, 113, 113, .12);
    border-color: rgba(248, 113, 113, .28);
}

.send-btn {
    width: 44px;
    height: 44px;
    color: #fff;
    background: var(--text);
}

:root[data-theme="dark"] .send-btn {
    color: #111;
    background: #ececec;
}

.icon-btn:active,
.primary-btn:active,
.ghost-btn:active,
.danger-btn:active,
.send-btn:active,
.mini-btn:active {
    transform: scale(.97);
}

button[disabled] {
    opacity: .48;
    pointer-events: none;
}

.mui-icon {
    font-size: 21px;
}

.search-box {
    position: relative;
    margin-bottom: 14px;
}

.search-box .mui-icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 18px;
}

.search-input,
.input,
.textarea,
.select {
    width: 100%;
    margin: 0;
    border: 1px solid transparent !important;
    border-radius: var(--radius) !important;
    outline: none;
    background: var(--panel-2) !important;
    color: var(--text) !important;
    user-select: text;
    -webkit-user-select: text;
    appearance: none;
    -webkit-appearance: none;
}

.search-input:focus,
.input:focus,
.textarea:focus,
.select:focus {
    background: var(--panel) !important;
    border-color: var(--line-2) !important;
    box-shadow: 0 0 0 3px rgba(16, 163, 127, .14);
}

.search-input {
    height: 50px;
    padding: 0 16px 0 44px !important;
}

.input,
.select {
    min-height: 46px;
    padding: 0 14px !important;
}

.select {
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) !important;
    background-position:
        calc(100% - 18px) 20px,
        calc(100% - 12px) 20px !important;
    background-size: 6px 6px, 6px 6px !important;
    background-repeat: no-repeat !important;
    padding-right: 34px !important;
}

.theme-select {
    max-width: 180px;
    background-color: var(--panel) !important;
    border-color: var(--line) !important;
    box-shadow: var(--soft-shadow);
}

.textarea {
    min-height: 104px;
    padding: 12px 14px !important;
    line-height: 1.6;
    resize: vertical;
}

.character-list {
    display: grid;
    gap: 12px;
}

.city-hero {
    min-height: 132px;
    display: flex;
    align-items: flex-end;
    margin-bottom: 12px;
    padding: 18px;
    overflow: hidden;
    border-radius: var(--radius);
    color: #fff;
    background:
        linear-gradient(135deg, rgba(0, 0, 0, .2), rgba(0, 0, 0, .62)),
        linear-gradient(135deg, #1f2937, #0f766e 48%, #7c2d12);
}

.city-hero span {
    display: inline-flex;
    margin-bottom: 7px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
}

.city-hero h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.18;
}

.city-hero p {
    max-width: 420px;
    margin: 7px 0 0;
    color: rgba(255, 255, 255, .82);
    font-size: 13px;
    line-height: 1.55;
}

.home-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 16px;
    padding: 4px;
    border-radius: 999px;
    background: var(--panel-2);
}

.tab-btn {
    min-height: 36px;
    border-radius: 999px;
    color: var(--text-2);
    background: transparent;
    font-size: 13px;
    font-weight: 650;
}

.tab-btn.active {
    color: var(--text);
    background: var(--panel);
    box-shadow: var(--soft-shadow);
}

.city-section {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.section-head h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.25;
    font-weight: 750;
}

.section-head span {
    color: var(--muted);
    font-size: 12px;
}

.text-link {
    min-height: 28px;
    padding: 0;
    color: var(--text-2);
    background: transparent;
    font-size: 12px;
}

.map-type-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.map-type-switch button {
    min-height: 38px;
    border-radius: 999px;
    color: var(--text-2);
    background: var(--panel-2);
    font-size: 13px;
    font-weight: 650;
}

.map-type-switch button.active {
    color: #fff;
    background: var(--text);
}

.rank-list,
.moment-list {
    display: grid;
    gap: 8px;
}

.rank-row,
.district-card,
.moment-card {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--soft-shadow);
}

.rank-row {
    display: grid;
    grid-template-columns: 28px 42px minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    padding: 10px;
    color: var(--text);
    text-align: left;
}

.rank-row > b {
    color: var(--muted);
    text-align: center;
}

.rank-row .avatar {
    width: 42px;
    height: 42px;
}

.rank-row span,
.moment-card div {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.rank-row strong,
.moment-card b {
    font-size: 14px;
}

.rank-row small,
.moment-card small,
.district-card small {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.city-map-scroll {
    width: 100%;
    height: min(62vh, 540px);
    overflow: auto;
    border: 1px solid rgba(148, 163, 184, .22);
    border-radius: 22px;
    background: #eef6f7;
    box-shadow: var(--card-shadow);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    scrollbar-width: none;
}

.city-map-scroll.full {
    height: calc(100vh - 74px - env(safe-area-inset-top));
    border-radius: 0;
    border: 0;
    box-shadow: none;
}

.map-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: var(--page);
}

.map-full-head {
    height: calc(58px + env(safe-area-inset-top));
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    border-bottom: 1px solid var(--line);
    background: var(--page);
}

.map-full-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.map-full-head span {
    color: var(--muted);
    font-size: 12px;
}

.city-map-scroll::-webkit-scrollbar {
    display: none;
}

.city-map-stage {
    position: relative;
    width: 980px;
    height: 560px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, .58) 1px, transparent 1px),
        linear-gradient(180deg, rgba(255, 255, 255, .58) 1px, transparent 1px),
        radial-gradient(circle at 18% 18%, rgba(255, 255, 255, .9) 0 105px, transparent 106px),
        radial-gradient(circle at 64% 22%, rgba(255, 255, 255, .68) 0 140px, transparent 142px),
        linear-gradient(135deg, #f5fbfb, #e9f4f0 42%, #f7eef5);
    background-size:
        64px 64px,
        64px 64px,
        auto,
        auto,
        auto;
}

.map-river {
    position: absolute;
    left: -40px;
    top: 275px;
    width: 1080px;
    height: 86px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(82, 190, 216, .68), rgba(65, 170, 205, .86));
    transform: rotate(-10deg);
    box-shadow: 0 16px 34px rgba(40, 120, 150, .16);
}

.map-road {
    position: absolute;
    border-radius: 999px;
    background: rgba(255, 255, 255, .78);
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, .22), 0 6px 18px rgba(148, 163, 184, .12);
}

.map-road.r1 {
    left: 60px;
    top: 70px;
    width: 820px;
    height: 34px;
    transform: rotate(7deg);
}

.map-road.r2 {
    left: 100px;
    top: 450px;
    width: 760px;
    height: 34px;
    transform: rotate(-6deg);
}

.map-road.r3 {
    left: 435px;
    top: 20px;
    width: 36px;
    height: 520px;
    transform: rotate(7deg);
}

.map-road.r4 {
    left: 720px;
    top: 40px;
    width: 34px;
    height: 470px;
    transform: rotate(-12deg);
}

.map-district,
.map-marker {
    position: absolute;
    border: 0;
}

.map-district {
    display: grid;
    align-content: start;
    gap: 5px;
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 24px;
    color: #283044;
    text-align: left;
    background: rgba(255, 255, 255, .68);
    box-shadow: 0 16px 36px rgba(68, 84, 110, .12);
    backdrop-filter: blur(8px);
}

.map-district b {
    font-size: 17px;
    line-height: 1.15;
    font-weight: 800;
}

.map-district small {
    display: -webkit-box;
    overflow: hidden;
    color: rgba(40, 48, 68, .68);
    font-size: 12px;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.map-district.pink {
    background: linear-gradient(135deg, rgba(255, 238, 247, .88), rgba(255, 255, 255, .58));
}

.map-district.gold {
    background: linear-gradient(135deg, rgba(255, 244, 204, .9), rgba(255, 255, 255, .58));
}

.map-district.green {
    background: linear-gradient(135deg, rgba(224, 246, 220, .9), rgba(255, 255, 255, .58));
}

.map-district.blue {
    background: linear-gradient(135deg, rgba(218, 242, 255, .9), rgba(255, 255, 255, .58));
}

.map-district.violet {
    background: linear-gradient(135deg, rgba(236, 226, 255, .9), rgba(255, 255, 255, .58));
}

.map-marker {
    z-index: 5;
    display: inline-grid;
    grid-template-columns: 34px minmax(0, auto);
    align-items: center;
    gap: 7px;
    width: auto;
    max-width: 142px;
    padding: 0;
    background: transparent;
    transform: translate(-50%, -50%);
}

.map-marker i {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, .88);
    border-radius: 50%;
    color: #fff;
    font-style: normal;
    font-size: 15px;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(40, 48, 68, .22);
}

.map-marker.male i {
    background: linear-gradient(135deg, #1f2937, #0f766e);
}

.map-marker.female i {
    background: linear-gradient(135deg, #be185d, #f59eae);
}

.map-marker span {
    display: grid;
    max-width: 98px;
    padding: 6px 9px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 13px;
    color: #263141;
    background: rgba(255, 255, 255, .86);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.15;
    box-shadow: 0 8px 18px rgba(40, 48, 68, .14);
    backdrop-filter: blur(8px);
}

.map-marker span small {
    overflow: hidden;
    color: rgba(38, 49, 65, .62);
    font-size: 10px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.moment-card {
    display: grid;
    gap: 8px;
    padding: 12px;
}

.moment-card p {
    margin: 0;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.55;
}

.district-roles {
    margin-top: 12px;
}

.character-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.character-card {
    padding: 15px;
    transition: background .16s ease, transform .16s ease, box-shadow .16s ease;
    box-shadow: var(--card-shadow);
}

.character-card:active {
    transform: scale(.995);
}

.character-main {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr);
    gap: 13px;
}

.avatar {
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #10a37f, #4f46e5);
    font-size: 17px;
    font-weight: 700;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-copy {
    min-width: 0;
}

.character-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.character-card h2 {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
    line-height: 1.25;
    font-weight: 750;
}

.character-card p {
    margin: 7px 0 11px;
    color: var(--text-2);
    font-size: 13.5px;
    line-height: 1.62;
}

.badge,
.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    white-space: nowrap;
}

.badge {
    height: 23px;
    padding: 0 8px;
    color: var(--muted);
    background: var(--panel-2);
    font-size: 12px;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    padding: 4px 8px;
    color: var(--text-2);
    background: var(--panel-2);
    font-size: 12px;
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-left: 58px;
}

.panel {
    padding: 14px;
    box-shadow: var(--soft-shadow);
}

.settings-list {
    display: grid;
    gap: 10px;
}

.settings-row {
    width: 100%;
    min-height: 64px;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 24px;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    text-align: left;
    box-shadow: var(--soft-shadow);
}

.settings-row-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--panel-2);
    color: var(--text);
}

.settings-row-copy {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.settings-row-copy b {
    overflow: hidden;
    font-size: 15px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-row-copy small {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-row > .mui-icon {
    color: var(--muted);
    font-size: 18px;
}

.settings-logout-btn {
    width: 100%;
    min-height: 50px;
    margin-top: 18px;
    border-radius: var(--radius);
    color: var(--danger);
    background: rgba(220, 38, 38, .1);
    border: 1px solid rgba(220, 38, 38, .22);
    box-shadow: var(--soft-shadow);
    font-size: 15px;
    font-weight: 750;
}

:root[data-theme="dark"] .settings-logout-btn {
    background: rgba(248, 113, 113, .12);
    border-color: rgba(248, 113, 113, .28);
}

.settings-logout-btn:active {
    transform: scale(.98);
}

.stack {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.secret-row {
    position: relative;
    width: 100%;
}

.secret-row .input {
    padding-right: 52px !important;
}

.secret-row .icon-btn {
    position: absolute;
    top: 0;
    right: 10px;
    bottom: 12px;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: auto 0;
    transform: none;
    color: var(--text);
    background: transparent;
    line-height: 1;
}

.secret-row .icon-btn .mui-icon {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    margin: 0;
    line-height: 1;
    font-size: 20px;
}

.secret-row .icon-btn .mui-icon-eye::before {
    width: 20px;
    height: 20px;
    display: block;
    content: "";
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 5C6.5 5 2.4 9.1 1 12c1.4 2.9 5.5 7 11 7s9.6-4.1 11-7c-1.4-2.9-5.5-7-11-7Zm0 11.2A4.2 4.2 0 1 1 12 7.8a4.2 4.2 0 0 1 0 8.4Zm0-1.8A2.4 2.4 0 1 0 12 9.6a2.4 2.4 0 0 0 0 4.8Z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
    mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 5C6.5 5 2.4 9.1 1 12c1.4 2.9 5.5 7 11 7s9.6-4.1 11-7c-1.4-2.9-5.5-7-11-7Zm0 11.2A4.2 4.2 0 1 1 12 7.8a4.2 4.2 0 0 1 0 8.4Zm0-1.8A2.4 2.4 0 1 0 12 9.6a2.4 2.4 0 0 0 0 4.8Z'/%3E%3C/svg%3E") center / 20px 20px no-repeat;
}

.secret-row .icon-btn:active {
    transform: scale(.97);
}

.status-box,
.info-list {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.7;
    white-space: pre-wrap;
}

.model-tools,
.model-list {
    display: grid;
    gap: 8px;
}

.model-tool-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.model-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--panel-2);
}

.model-row.active {
    box-shadow: inset 0 0 0 1px rgba(16, 163, 127, .42);
}

.model-row span {
    overflow: hidden;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-row span em {
    display: inline-flex;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    color: #fff;
    background: var(--accent);
    font-size: 11px;
    font-style: normal;
    vertical-align: middle;
}

.model-actions {
    display: flex;
    gap: 6px;
}

.mini-btn {
    min-width: 34px;
    height: 32px;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--line);
    font-size: 12px;
}

.danger-mini {
    color: var(--danger);
}

.steps {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.step-dot {
    height: 5px;
    border-radius: 999px;
    background: var(--panel-3);
}

.step-dot.active {
    background: var(--text);
}

.form-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.empty {
    padding: 28px 16px;
    border-radius: 10px;
    color: var(--muted);
    text-align: center;
    background: var(--panel-2);
}

.chat-view {
    height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: var(--page);
}

.chat-header {
    z-index: 20;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    align-items: center;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .chat-header {
    background: rgba(33, 33, 33, .9);
}

.chat-identity {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
}

.chat-identity .avatar {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

.chat-identity h1 {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 650;
}

.chat-identity p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.messages {
    overflow-y: auto;
    padding: 14px 12px 96px;
}

.chat-directory .search-box {
    margin-bottom: 0;
}

.message {
    display: flex;
    margin-bottom: 14px;
}

.message.user {
    justify-content: flex-end;
}

.bubble {
    max-width: 88%;
    padding: 11px 14px;
    border-radius: 10px;
    color: var(--text);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
}

.message.user .bubble {
    background: var(--panel-3);
    border-top-right-radius: 4px;
}

.message.assistant .bubble {
    max-width: 94%;
    padding-left: 0;
    padding-right: 0;
    background: transparent;
}

.mode-switch {
    display: none !important;
}

.message.side {
    align-items: flex-start;
    gap: 10px;
}

.side-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    font-size: 13px;
}

.side-bubble {
    min-width: 0;
    max-width: calc(100% - 44px);
    padding: 0;
}

.speaker-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.speaker-line b {
    font-weight: 700;
}

.speaker-line span {
    color: var(--muted);
}

.rp-memory {
    color: var(--muted);
    font-size: 11.5px;
}

.rp-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 9px 0;
}

.rp-meta span {
    padding: 5px 9px;
    border-radius: 7px;
    color: var(--text-2);
    background: var(--panel-2);
    font-size: 11.5px;
}

.rp-dialog {
    color: var(--text);
    font-size: 16px;
    line-height: 1.78;
    font-weight: 520;
}

.composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 22;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 8px;
    width: min(100%, 720px);
    margin: 0 auto;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .92);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

.composer-tools {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.composer-tools button {
    min-height: 32px;
    flex: 0 0 auto;
    padding: 0 10px;
    border-radius: 8px;
    color: var(--text-2);
    background: var(--panel-2);
    font-size: 12.5px;
}

:root[data-theme="dark"] .composer {
    background: rgba(33, 33, 33, .92);
}

.composer .textarea {
    min-height: 44px;
    max-height: 120px;
    resize: none;
    border-radius: 12px !important;
    background: var(--panel) !important;
    border-color: var(--line) !important;
    box-shadow: var(--soft-shadow);
}

.drawer-mask {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: none;
    background: rgba(0, 0, 0, .28);
}

:root[data-theme="dark"] .drawer-mask {
    background: rgba(0, 0, 0, .55);
}

.drawer-mask.open {
    display: block;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 31;
    width: min(92vw, 390px);
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
    overflow-y: auto;
    background: var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow);
    transform: translateX(100%);
    transition: transform .2s ease;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.drawer h2 {
    margin: 18px 0 10px;
    font-size: 16px;
    font-weight: 750;
}

.drawer-actions {
    align-items: center;
    margin-top: 22px;
    padding-top: 14px;
    gap: 18px;
}

.drawer-actions .danger-btn,
.drawer-actions .ghost-btn {
    min-width: 64px;
    min-height: 40px;
    padding: 0 18px;
}

.memory-item,
.relation-card,
.quality-card {
    border-radius: var(--radius);
    background: var(--panel-2);
}

.memory-item {
    margin-bottom: 8px;
    padding: 10px;
    color: var(--text-2);
    font-size: 13px;
    line-height: 1.55;
}

.relation-card {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px;
    box-shadow: inset 0 0 0 1px rgba(142, 142, 160, .1);
}

.relation-stage {
    display: grid;
    gap: 4px;
}

.relation-stage span {
    font-size: 18px;
    font-weight: 800;
}

.relation-stage small {
    color: var(--muted);
    line-height: 1.45;
}

.relation-line {
    display: flex;
    justify-content: space-between;
    color: var(--text-2);
    font-size: 12.5px;
}

.relation-line b {
    color: var(--text);
    font-weight: 650;
}

.meter-track {
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(142, 142, 160, .2);
}

.meter-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.meter-track i.warn {
    background: linear-gradient(90deg, #fbbf24, var(--warning));
}

.quality-card {
    display: grid;
    gap: 11px;
    margin-bottom: 14px;
    padding: 14px;
    box-shadow: inset 0 0 0 1px rgba(142, 142, 160, .1);
}

.empty-quality {
    color: var(--muted);
    font-size: 13px;
}

.quality-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding-bottom: 3px;
}

.quality-head span {
    color: var(--text-2);
    font-size: 12px;
}

.quality-head b {
    font-size: 26px;
    line-height: 1;
}

.quality-row {
    display: grid;
    gap: 5px;
}

.quality-line {
    display: flex;
    justify-content: space-between;
    color: var(--text-2);
    font-size: 12px;
}

.quality-line b {
    color: var(--text);
}

.quality-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(142, 142, 160, .18);
}

.quality-track i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ec4899, #8b5cf6 52%, #10a37f);
}

.typing {
    display: inline-flex;
    gap: 5px;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: blink 1s infinite ease-in-out;
}

.typing span:nth-child(2) {
    animation-delay: .15s;
}

.typing span:nth-child(3) {
    animation-delay: .3s;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    z-index: 100;
    max-width: min(90vw, 420px);
    padding: 10px 14px;
    border-radius: 999px;
    color: var(--page);
    background: var(--text);
    opacity: 0;
    transform: translate(-50%, 10px);
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (min-width: 760px) {
    .view {
        padding-left: 18px;
        padding-right: 18px;
    }

    .app-mobile {
        padding-top: 10px;
    }

    .character-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--soft-shadow);
    }
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: .35;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-3px);
    }
}
