:root {
    color-scheme: light;
    --ink: #392d27;
    --muted: #796a62;
    --paper: #fffdf9;
    --cream: #fff8ed;
    --peach: #f3b993;
    --peach-dark: #985033;
    --rose: #ec938e;
    --sage: #92aa8a;
    --line: rgba(112, 79, 58, 0.14);
    --shadow: 0 18px 50px rgba(117, 77, 52, 0.11);
    font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    background: var(--cream);
    color: var(--ink);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 15% 8%, rgba(255, 208, 181, 0.38), transparent 27rem),
        radial-gradient(circle at 90% 24%, rgba(236, 185, 178, 0.3), transparent 24rem),
        var(--cream);
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.ambient {
    position: fixed;
    z-index: -1;
    width: 14rem;
    height: 14rem;
    border: 1px solid rgba(199, 117, 80, 0.12);
    border-radius: 45% 55% 52% 48%;
    pointer-events: none;
}

.ambient-one {
    top: 13rem;
    left: -8rem;
    transform: rotate(23deg);
}

.ambient-two {
    right: -9rem;
    bottom: 18rem;
    transform: rotate(-18deg);
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(100% - 2rem, 52rem);
    margin: 0 auto;
    padding: 1.1rem 0;
}

.brand {
    display: inline-flex;
    gap: 0.65rem;
    align-items: center;
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 2.25rem;
    height: 2.25rem;
    place-items: center;
    border: 1px solid rgba(199, 117, 80, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: var(--peach-dark);
    font-size: 0.66rem;
    box-shadow: 0 7px 18px rgba(117, 77, 52, 0.08);
}

.nfc-note {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.language-switch {
    position: relative;
    display: grid;
    width: 4.4rem;
    height: 2rem;
    flex: 0 0 auto;
    grid-template-columns: repeat(2, 1fr);
    align-items: center;
    padding: 0.18rem;
    border: 1px solid rgba(79, 155, 104, 0.34);
    border-radius: 999px;
    background: rgba(255, 253, 249, 0.86);
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 7px 18px rgba(69, 133, 88, 0.1);
}

.language-switch-thumb {
    position: absolute;
    top: 0.18rem;
    bottom: 0.18rem;
    left: 0.18rem;
    width: calc(50% - 0.18rem);
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 3px 8px rgba(47, 104, 66, 0.22);
    transition: transform 180ms ease;
}

.language-switch[data-active-locale="en"] .language-switch-thumb {
    transform: translateX(100%);
}

.language-switch-option {
    position: relative;
    z-index: 1;
    transition: color 180ms ease;
}

.language-switch[data-active-locale="zh"] .language-switch-option[data-locale="zh"],
.language-switch[data-active-locale="en"] .language-switch-option[data-locale="en"] {
    color: #fff;
}

.language-switch:focus-visible {
    outline: 3px solid rgba(79, 155, 104, 0.3);
    outline-offset: 3px;
}

.page-shell {
    width: min(100% - 2rem, 34rem);
    margin: 0 auto;
    padding: 2.75rem 0 4rem;
}

.hero {
    position: relative;
}

.hero::before {
    position: absolute;
    top: -2.5rem;
    right: 0;
    width: 4.5rem;
    height: 4.5rem;
    border: 1px solid rgba(236, 147, 142, 0.24);
    border-radius: 50%;
    content: "";
}

.kicker,
.section-index {
    margin: 0 0 0.8rem;
    color: var(--peach-dark);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 9em;
    margin-bottom: 1.25rem;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: clamp(2.55rem, 12vw, 4.7rem);
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.035em;
}

h1 span {
    position: relative;
    color: var(--peach-dark);
}

h1 span::after {
    position: absolute;
    right: -1.15rem;
    bottom: 0.22rem;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50% 50% 50% 0;
    background: var(--rose);
    content: "";
    opacity: 0.78;
    transform: rotate(-45deg);
}

.hero-copy {
    max-width: 31rem;
    margin-bottom: 1.4rem;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.85;
}

.status-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    background: rgba(255, 253, 249, 0.86);
    box-shadow: 0 12px 35px rgba(117, 77, 52, 0.07);
    backdrop-filter: blur(12px);
}

.status-icon {
    grid-row: 1 / span 2;
    width: 0.7rem;
    height: 0.7rem;
    border: 3px solid rgba(199, 117, 80, 0.18);
    border-top-color: var(--peach-dark);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.status-label {
    margin-bottom: 0.2rem;
    font-size: 0.86rem;
    font-weight: 800;
}

.status-message {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.current-persona {
    grid-column: 1 / -1;
    width: fit-content;
    margin-top: 0.55rem;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    background: #f8ecdf;
    color: #865c45;
    font-size: 0.7rem;
    font-weight: 700;
}

.tone-success .status-icon {
    border: 0;
    background: var(--sage);
    box-shadow: 0 0 0 5px rgba(146, 170, 138, 0.15);
    animation: none;
}

.tone-waiting .status-icon,
.tone-offline .status-icon,
.tone-error .status-icon {
    border: 0;
    animation: none;
}

.tone-waiting .status-icon {
    background: #e7a96f;
    box-shadow: 0 0 0 5px rgba(231, 169, 111, 0.16);
}

.tone-offline .status-icon {
    background: #aaa19a;
    box-shadow: 0 0 0 5px rgba(170, 161, 154, 0.15);
}

.tone-error .status-icon {
    background: var(--rose);
    box-shadow: 0 0 0 5px rgba(236, 147, 142, 0.16);
}

.persona-section {
    margin-top: 4.5rem;
}

.section-heading {
    display: flex;
    gap: 1rem;
    align-items: end;
    justify-content: space-between;
    margin-bottom: 1.3rem;
}

.section-heading h2 {
    margin-bottom: 0;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: 1.75rem;
}

.section-heading > p {
    max-width: 8.5rem;
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.72rem;
    line-height: 1.55;
    text-align: right;
}

.persona-list {
    display: grid;
    gap: 1.3rem;
}

.persona-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 1.5rem;
    background: var(--paper);
    box-shadow: var(--shadow);
    transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.persona-card[data-current="true"] {
    border-color: rgba(146, 170, 138, 0.7);
    box-shadow: 0 20px 55px rgba(110, 137, 100, 0.16);
}

.persona-card[data-desired="true"]:not([data-current="true"]) {
    border-color: rgba(231, 169, 111, 0.8);
}

.card-visual {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    background: #fbf1e5;
}

.card-visual img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-number,
.card-badge {
    position: absolute;
    z-index: 1;
    top: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.75);
    border-radius: 999px;
    background: rgba(255, 253, 249, 0.85);
    color: var(--ink);
    font-size: 0.67rem;
    font-weight: 800;
    backdrop-filter: blur(10px);
}

.card-number {
    left: 0.85rem;
    padding: 0.42rem 0.58rem;
}

.card-badge {
    right: 0.85rem;
    display: none;
    padding: 0.42rem 0.7rem;
}

.persona-card[data-current="true"] .card-badge {
    display: block;
    color: #587052;
}

.persona-card[data-desired="true"]:not([data-current="true"]) .card-badge {
    display: block;
    color: #a4643f;
}

.card-content {
    padding: 1.3rem 1.2rem 1.25rem;
}

.card-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.card-title-row h3 {
    margin-bottom: 0;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: 1.55rem;
}

.mbti {
    color: var(--peach-dark);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.persona-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0 0 0.9rem;
    padding: 0;
    list-style: none;
}

.persona-meta li {
    padding: 0.35rem 0.55rem;
    border-radius: 0.55rem;
    background: #faf1e8;
    color: #795b4b;
    font-size: 0.68rem;
}

.persona-description,
.persona-hobbies {
    color: var(--muted);
    font-size: 0.81rem;
    line-height: 1.75;
}

.persona-description {
    margin-bottom: 0.7rem;
}

.persona-hobbies {
    margin-bottom: 1.15rem;
    padding-top: 0.7rem;
    border-top: 1px dashed var(--line);
}

.persona-hobbies strong {
    color: var(--ink);
}

.persona-button {
    width: 100%;
    min-height: 3rem;
    border: 0;
    border-radius: 0.85rem;
    background: var(--ink);
    color: #fffaf3;
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    transition: background 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.persona-button:hover:not(:disabled) {
    background: var(--peach-dark);
    transform: translateY(-1px);
}

.persona-button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.persona-button:focus-visible,
.brand:focus-visible {
    outline: 3px solid rgba(199, 117, 80, 0.36);
    outline-offset: 3px;
}

.persona-card[data-current="true"] .persona-button {
    background: #dbe6d7;
    color: #587052;
}

.page-footnote {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin: 2rem 0 0;
    color: var(--muted);
    font-size: 0.72rem;
}

.page-footnote span {
    color: var(--peach-dark);
}

.noscript {
    margin: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    background: #fff;
    color: #9f423d;
    text-align: center;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (min-width: 44rem) {
    .site-header {
        padding-top: 1.5rem;
    }

    .page-shell {
        padding-top: 4.5rem;
    }

    .status-card {
        grid-template-columns: auto 1fr auto;
    }

    .current-persona {
        grid-column: auto;
        grid-row: 1 / span 2;
        margin-top: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Compact persona picker and detail dialog */
:root {
    --green: #4f9b68;
    --green-dark: #2f6842;
    --green-soft: #f1faf3;
    --green-line: rgba(79, 155, 104, 0.42);
}

body {
    background:
        radial-gradient(circle at 12% 18%, rgba(213, 237, 210, 0.6), transparent 25rem),
        radial-gradient(circle at 92% 78%, rgba(255, 219, 191, 0.42), transparent 26rem),
        #fbfaf5;
}

.ambient-left {
    top: 9rem;
    left: -8rem;
    border-color: rgba(79, 155, 104, 0.14);
    transform: rotate(23deg);
}

.ambient-right {
    right: -9rem;
    bottom: 9rem;
    border-color: rgba(199, 117, 80, 0.12);
    transform: rotate(-18deg);
}

.page-shell {
    width: min(100% - 1.5rem, 62rem);
    padding: clamp(2.5rem, 7vw, 5.5rem) 0 3rem;
}

.persona-picker {
    position: relative;
}

.picker-heading {
    margin-bottom: clamp(1.4rem, 4vw, 2.4rem);
    text-align: center;
}

.eyebrow {
    margin-bottom: 0.55rem;
    color: var(--green-dark);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.picker-heading h1 {
    max-width: none;
    margin-bottom: 0.55rem;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: clamp(1.75rem, 5vw, 2.65rem);
    line-height: 1.2;
    letter-spacing: 0;
}

.picker-heading > p:last-child {
    margin-bottom: 0;
    color: var(--muted);
    font-size: clamp(0.78rem, 2vw, 0.92rem);
    line-height: 1.7;
}

.persona-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.5rem, 2vw, 1.25rem);
}

.persona-tile {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: 2px solid rgba(112, 79, 58, 0.12);
    border-radius: clamp(0.85rem, 2.5vw, 1.35rem);
    background: rgba(255, 253, 249, 0.94);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    text-align: left;
    box-shadow: 0 14px 38px rgba(92, 69, 52, 0.09);
    transition:
        border-color 180ms ease,
        background 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.persona-tile:hover:not(:disabled) {
    border-color: rgba(79, 155, 104, 0.38);
    transform: translateY(-3px);
}

.persona-tile:focus-visible {
    outline: 3px solid rgba(79, 155, 104, 0.3);
    outline-offset: 3px;
}

.persona-tile:disabled {
    cursor: wait;
    opacity: 0.7;
}

.persona-tile[data-current="true"] {
    border-color: var(--green);
    background: var(--green-soft);
    box-shadow: 0 16px 38px rgba(69, 133, 88, 0.18);
}

.tile-check {
    position: absolute;
    z-index: 2;
    top: clamp(0.4rem, 1.5vw, 0.75rem);
    right: clamp(0.4rem, 1.5vw, 0.75rem);
    display: grid;
    width: clamp(1.2rem, 4vw, 1.75rem);
    height: clamp(1.2rem, 4vw, 1.75rem);
    place-items: center;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-size: clamp(0.65rem, 2vw, 0.85rem);
    font-weight: 900;
    opacity: 0;
    transform: scale(0.72);
    transition: opacity 160ms ease, transform 160ms ease;
}

.persona-tile[data-current="true"] .tile-check {
    opacity: 1;
    transform: scale(1);
}

.tile-portrait {
    display: block;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: #f4eee6;
}

.tile-portrait img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 260ms ease;
}

.persona-tile:hover:not(:disabled) .tile-portrait img {
    transform: scale(1.025);
}

.tile-copy {
    display: grid;
    gap: 0.28rem;
    padding: clamp(0.58rem, 2vw, 1rem);
}

.tile-copy strong {
    overflow: hidden;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: clamp(0.88rem, 2.5vw, 1.3rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-copy > span {
    overflow: hidden;
    color: var(--muted);
    font-size: clamp(0.55rem, 1.7vw, 0.7rem);
    text-overflow: ellipsis;
    white-space: nowrap;
}

#persona-dialog {
    width: min(56rem, calc(100% - 1.5rem));
    max-height: calc(100dvh - 1.5rem);
    margin: auto;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 1.65rem;
    background: transparent;
    color: var(--ink);
}

#persona-dialog::backdrop {
    background: rgba(42, 35, 30, 0.5);
    backdrop-filter: blur(5px);
    animation: backdrop-enter 180ms ease-out both;
}

.dialog-layout {
    position: relative;
    display: grid;
    grid-template-columns: minmax(16rem, 0.9fr) minmax(19rem, 1.1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 1.65rem;
    background: var(--paper);
    box-shadow: 0 30px 90px rgba(45, 35, 28, 0.28);
}

#persona-dialog[open] .dialog-layout {
    animation: dialog-enter 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.dialog-close {
    position: absolute;
    z-index: 3;
    top: 0.85rem;
    right: 0.85rem;
    display: grid;
    width: 2.2rem;
    height: 2.2rem;
    place-items: center;
    border: 1px solid rgba(112, 79, 58, 0.14);
    border-radius: 50%;
    background: rgba(255, 253, 249, 0.9);
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 1.25rem;
    line-height: 1;
    backdrop-filter: blur(8px);
}

.dialog-visual {
    min-height: 31rem;
    background: #f4eee6;
    perspective: 75rem;
}

.dialog-card {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    will-change: transform;
}

.dialog-card-face {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    object-fit: cover;
}

.dialog-card-back {
    transform: rotateY(180deg);
}

#persona-dialog[data-motion] .dialog-close,
#persona-dialog[data-motion] .persona-action {
    pointer-events: none;
}

.dialog-content {
    align-self: center;
    padding: clamp(1.6rem, 4vw, 3rem);
}

.dialog-mbti {
    margin-bottom: 0.5rem;
    color: var(--green-dark);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}

.dialog-content h2 {
    margin-bottom: 1rem;
    font-family: "STKaiti", "KaiTi", serif;
    font-size: clamp(2rem, 5vw, 3rem);
}

.dialog-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.15rem;
}

.dialog-meta span {
    padding: 0.42rem 0.65rem;
    border-radius: 999px;
    background: #edf7ef;
    color: #486b51;
    font-size: 0.72rem;
}

.dialog-description,
.dialog-hobbies {
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.8;
}

.dialog-description {
    margin-bottom: 1rem;
}

.dialog-hobbies {
    margin-bottom: 1.35rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--green-line);
}

.persona-action {
    width: 100%;
    min-height: 3.2rem;
    border: 0;
    border-radius: 0.9rem;
    background: var(--green-dark);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    transition: background 160ms ease, transform 160ms ease;
}

.persona-action:hover:not(:disabled) {
    background: #245334;
    transform: translateY(-1px);
}

.persona-action:disabled {
    background: #d9e9dc;
    color: #52725b;
    cursor: not-allowed;
}

.status-toast {
    position: fixed;
    z-index: 10;
    right: 50%;
    bottom: 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.7rem;
    align-items: center;
    width: min(calc(100% - 1.5rem), 23rem);
    padding: 0.8rem 1rem;
    border: 1px solid rgba(112, 79, 58, 0.12);
    border-radius: 1rem;
    background: rgba(255, 253, 249, 0.94);
    box-shadow: 0 16px 42px rgba(71, 52, 40, 0.15);
    transform: translateX(50%);
    backdrop-filter: blur(12px);
}

.status-toast > span:last-child {
    display: grid;
    gap: 0.12rem;
}

.status-toast strong {
    font-size: 0.77rem;
}

.status-toast #status-message {
    color: var(--muted);
    font-size: 0.68rem;
}

.toast-dot {
    width: 0.68rem;
    height: 0.68rem;
    border: 3px solid rgba(79, 155, 104, 0.18);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.status-toast.tone-success .toast-dot {
    border: 0;
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(79, 155, 104, 0.13);
    animation: none;
}

.status-toast.tone-waiting .toast-dot,
.status-toast.tone-offline .toast-dot,
.status-toast.tone-error .toast-dot {
    border: 0;
    animation: none;
}

.status-toast.tone-waiting .toast-dot {
    background: #d99a5d;
}

.status-toast.tone-offline .toast-dot {
    background: #99928c;
}

.status-toast.tone-error .toast-dot {
    background: var(--rose);
}

@keyframes backdrop-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialog-enter {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 42rem) {
    .page-shell {
        padding-top: 2.5rem;
    }

    .site-header {
        width: min(100% - 1.25rem, 62rem);
    }

    .persona-list {
        gap: 0.45rem;
    }

    .persona-tile {
        border-width: 1.5px;
        border-radius: 0.9rem;
    }

    .tile-copy {
        padding: 0.55rem 0.45rem 0.65rem;
    }

    #persona-dialog {
        max-height: calc(100dvh - 1rem);
    }

    .dialog-layout {
        display: block;
        max-height: calc(100dvh - 1rem);
        overflow-y: auto;
        border-radius: 1.35rem;
    }

    .dialog-visual {
        height: min(45dvh, 23rem);
        min-height: 0;
    }

    .dialog-content {
        padding: 1.4rem 1.15rem 1.2rem;
    }

    .dialog-content h2 {
        font-size: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    #persona-dialog::backdrop,
    #persona-dialog[open] .dialog-layout {
        animation: none;
    }

    .persona-tile,
    .tile-check,
    .tile-portrait img,
    .persona-action {
        transition: none;
    }
}
