:root {
    --paper: #F4F1E9;
    --paper-deep: #EAE5D8;
    --paper-light: #FBFAF6;
    --ink: #23241F;
    --ink-soft: #62615A;
    --ink-faint: #79746A;
    --line: #D8D2C3;
    --line-soft: #E6E0D2;
    --forest: #24473D;
    --forest-deep: #1A352D;
    --forest-soft: #35604F;
    --wheat: #C9A227;
    --wheat-soft: #E3CB86;
    --bubble-ai: #FFFFFF;
    --danger: #A6473C;
    --radius: 16px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(35, 36, 31, .04);
    --shadow: 0 1px 2px rgba(35, 36, 31, .04), 0 12px 32px rgba(35, 36, 31, .06);
    --shadow-lg: 0 2px 4px rgba(35, 36, 31, .04), 0 24px 60px rgba(35, 36, 31, .1);
    --focus-ring: 0 0 0 3px rgba(53, 96, 79, .16);
    --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
    --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background:
        radial-gradient(900px 520px at 78% -12%, #FCFAF4 0%, transparent 62%),
        radial-gradient(720px 460px at -10% 110%, #EFEADF 0%, transparent 58%),
        var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

:focus-visible {
    outline: 2px solid var(--forest-soft);
    outline-offset: 2px;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- shell ---------- */

.shell {
    display: grid;
    grid-template-columns: clamp(320px, 30vw, 380px) minmax(0, 1fr);
    height: 100dvh;
    max-width: 1200px;
    margin: 0 auto;
    padding: 22px;
    gap: 18px;
}

/* ---------- persona sidebar ---------- */

.persona {
    display: flex;
    flex-direction: column;
    padding: 30px 26px 24px;
    background:
        radial-gradient(120% 68% at 0% 0%, rgba(78, 122, 103, .5) 0%, transparent 58%),
        linear-gradient(168deg, #2A5045 0%, var(--forest) 48%, var(--forest-deep) 100%);
    color: #F3F1E8;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    overflow: clip;
    box-shadow: 0 18px 42px rgba(26, 53, 45, .16);
}

.persona::before {
    content: "";
    position: absolute;
    inset: auto auto -110px -90px;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 162, 39, .16) 0%, transparent 68%);
    pointer-events: none;
}

.persona::after {
    content: "";
    position: absolute;
    inset: auto -60px -80px auto;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px solid rgba(244, 241, 233, .09);
    box-shadow: 0 0 0 26px rgba(244, 241, 233, .03);
    pointer-events: none;
}

.seal {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #DDBA4C 0%, var(--wheat) 58%, #B78F1C 100%);
    color: var(--forest-deep);
    font-family: var(--serif);
    font-size: 32px;
    line-height: 1;
    border-radius: 16px;
    border: 1px solid rgba(26, 53, 45, .22);
    box-shadow:
        inset 0 0 0 4px rgba(255, 252, 240, .18),
        0 10px 24px rgba(0, 0, 0, .22);
}

.persona-id { margin-top: 20px; }

.persona-name {
    margin: 0;
    font-family: var(--serif);
    font-size: 32px;
    font-weight: 600;
    letter-spacing: .08em;
}

.persona-tagline {
    margin: 5px 0 0;
    font-size: 13px;
    color: rgba(243, 241, 232, .66);
    letter-spacing: .05em;
}

.online {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    font-size: 12px;
    letter-spacing: .06em;
    color: rgba(243, 241, 232, .72);
}

.online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8FBF9F;
    animation: pulse 2.6s ease-in-out infinite;
}

.state {
    margin-top: 26px;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: rgba(12, 32, 26, .16);
    border: 1px solid rgba(243, 241, 232, .13);
    border-radius: 16px;
}

.state-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.state-label {
    font-size: 12px;
    letter-spacing: .12em;
    color: rgba(243, 241, 232, .6);
}

.mood {
    font-family: var(--serif);
    font-size: 15px;
    padding: 2px 12px;
    border-radius: 999px;
    background: rgba(243, 241, 232, .1);
    color: #F3F1E8;
    transition: background .25s ease, color .25s ease;
}

.mood[data-mood="happy"]    { background: rgba(201, 162, 39, .24); color: #F0D07A; }
.mood[data-mood="excited"]  { background: rgba(224, 138, 89, .22); color: #F2B78E; }
.mood[data-mood="shy"]      { background: rgba(214, 143, 160, .22); color: #F0B6C4; }
.mood[data-mood="sad"]      { background: rgba(130, 152, 178, .22); color: #B9CADD; }
.mood[data-mood="tired"]    { background: rgba(160, 160, 150, .2);  color: #CFCFC4; }
.mood[data-mood="angry"]    { background: rgba(178, 91, 79, .24);   color: #EFA79C; }

.meter-head {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: rgba(243, 241, 232, .66);
    margin-bottom: 8px;
}

.meter-head span:last-child {
    font-variant-numeric: tabular-nums;
    color: rgba(243, 241, 232, .9);
}

.meter-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(243, 241, 232, .13);
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--wheat-soft);
    box-shadow: 0 0 10px rgba(227, 203, 134, .35);
    transition: width .6s cubic-bezier(.22, 1, .36, 1);
}

.meter-fill.wheat { background: #9DBBA8; box-shadow: none; }

.memory-note {
    margin: 0;
    font-size: 12px;
    line-height: 1.65;
    color: rgba(243, 241, 232, .62);
}

/* ---------- 3D cat ---------- */

.cat-stage {
    position: relative;
    flex: 1 1 280px;
    min-height: 280px;
    max-height: 460px;
    height: auto;
    margin-top: 18px;
    border-radius: 18px;
    background:
        radial-gradient(82% 72% at 50% 80%, rgba(244, 241, 233, .13), transparent 70%),
        radial-gradient(58% 48% at 50% 18%, rgba(201, 162, 39, .08), transparent 70%);
    cursor: pointer;
    overflow: hidden;
    transition: background .3s ease;
    -webkit-tap-highlight-color: transparent;
}

.cat-stage:hover {
    background:
        radial-gradient(82% 72% at 50% 80%, rgba(244, 241, 233, .19), transparent 70%),
        radial-gradient(58% 48% at 50% 18%, rgba(201, 162, 39, .12), transparent 70%);
}

.cat-stage canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity .4s ease;
}

.cat-stage.is-ready canvas {
    opacity: 1;
}

.cat-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: .9;
    pointer-events: none;
    transition: opacity .3s ease;
}

.cat-fallback svg {
    width: 180px;
    height: 180px;
    max-width: 72%;
    max-height: 78%;
    display: block;
}

.cat-stage.is-ready .cat-fallback {
    opacity: 0;
}

.cat-caption {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 8px;
    padding: 3px 8px;
    border-radius: 8px;
    background: linear-gradient(90deg, transparent 0%, rgba(10, 28, 22, .55) 16%, rgba(10, 28, 22, .55) 84%, transparent 100%);
    color: rgba(243, 241, 232, .84);
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}

.cat-caption.is-visible {
    opacity: 1;
    transform: none;
}

.cat-stage:focus-visible {
    outline: 2px solid rgba(227, 203, 134, .6);
    outline-offset: 2px;
}

.persona-foot {
    margin-top: auto;
    padding-top: 22px;
}

.foot-actions {
    display: grid;
    gap: 8px;
}

.mem-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mem-btn.has-pending::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--wheat);
    box-shadow: 0 0 0 3px rgba(201, 162, 39, .18);
}

.mem-count {
    min-width: 19px;
    height: 19px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(242, 239, 230, .16);
    color: #F2EFE6;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.ghost-btn {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(243, 241, 232, .2);
    border-radius: 11px;
    background: rgba(243, 241, 232, .04);
    color: rgba(243, 241, 232, .9);
    font-family: inherit;
    font-size: 13px;
    letter-spacing: .04em;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mem-btn {
    background: rgba(243, 241, 232, .12);
    border-color: rgba(243, 241, 232, .26);
    font-weight: 600;
}

.ghost-btn:hover {
    background: rgba(243, 241, 232, .16);
    border-color: rgba(243, 241, 232, .42);
    color: #FFFDF6;
}

.ghost-btn:disabled { opacity: .45; cursor: not-allowed; }

.tech {
    margin: 14px 0 0;
    font-size: 11px;
    letter-spacing: .16em;
    text-align: center;
    color: rgba(243, 241, 232, .45);
}

.tech a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---------- chat panel ---------- */

.chat {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, #FDFCF9 0%, #FAF8F2 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .72);
}

.chat-id {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-avatar {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--forest);
    color: #F3F1E8;
    font-family: var(--serif);
    font-size: 19px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}

.chat-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 18px;
    letter-spacing: .04em;
}

.chat-sub {
    margin: 3px 0 0;
    font-size: 12px;
    color: var(--ink-soft);
}

.mood-chip {
    flex: none;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    background: #FFFFFF;
    transition: color .25s ease, border-color .25s ease, background .25s ease;
}

.mood-chip[data-mood="happy"],
.mood-chip[data-mood="excited"] { color: #8A6A12; border-color: var(--wheat-soft); }
.mood-chip[data-mood="shy"]     { color: #A05C70; border-color: #E7C3CC; }
.mood-chip[data-mood="sad"]     { color: #5A7189; border-color: #C3D0DC; }
.mood-chip[data-mood="angry"]   { color: var(--danger); border-color: #DCB4AE; }

.notice {
    margin: 16px 28px 0;
    padding: 10px 14px;
    font-size: 12.5px;
    line-height: 1.7;
    color: #7A5A16;
    background: #FBF3DC;
    border: 1px solid #EADCB2;
    border-radius: 10px;
}

.notice code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(122, 90, 22, .08);
}

/* ---------- messages ---------- */

.messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 26px 14px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: #DAD4C5; border-radius: 999px; }
.messages::-webkit-scrollbar-thumb:hover { background: #C9C2B0; }

.empty {
    margin: auto;
    padding: 20px 8px 36px;
    max-width: 440px;
    text-align: center;
}

.empty-seal {
    width: 78px;
    height: 78px;
    margin: 0 auto 22px;
    display: grid;
    place-items: center;
    font-family: var(--serif);
    font-size: 40px;
    line-height: 1;
    color: var(--forest);
    background: radial-gradient(circle at 32% 22%, #FFFFFF 0%, #F7F4EC 70%);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow:
        inset 0 0 0 4px rgba(201, 162, 39, .12),
        0 12px 28px rgba(35, 36, 31, .07);
}

.empty-quote {
    margin: 0;
    font-family: var(--serif);
    font-size: 24px;
    letter-spacing: .05em;
}

.empty-hint {
    margin: 10px 0 24px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.suggests {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    max-width: 380px;
    margin: 0 auto;
}

.suggest {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 13px;
    color: var(--forest);
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 11px;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.suggest:hover {
    background: #FFFFFF;
    border-color: var(--forest-soft);
    box-shadow: 0 4px 12px rgba(35, 36, 31, .06);
    transform: translateY(-1px);
}

.suggest:active { transform: translateY(0); }

.msg {
    display: flex;
    gap: 11px;
    max-width: 78%;
    animation: rise .28s cubic-bezier(.22, 1, .36, 1) both;
}

.msg.ai { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
    flex: none;
    width: 32px;
    height: 32px;
    margin-top: 2px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-family: var(--serif);
    font-size: 16px;
    background: var(--forest);
    color: #F3F1E8;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
}

.bubble-wrap { min-width: 0; }

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg.ai .bubble {
    background: var(--bubble-ai);
    border: 1px solid var(--line);
    border-top-left-radius: 5px;
    box-shadow: var(--shadow-sm);
}

.msg.user .bubble {
    background: linear-gradient(165deg, #2B5348 0%, #24473D 100%);
    color: #F6F3EB;
    border: 1px solid rgba(26, 53, 45, .55);
    border-top-right-radius: 5px;
    box-shadow: 0 6px 16px rgba(36, 71, 61, .16);
}

.msg.system {
    align-self: center;
    max-width: 100%;
}

.bubble.has-image { padding: 6px; }

.bubble-img {
    display: block;
    width: auto;
    height: auto;
    max-width: 240px;
    max-height: 320px;
    border-radius: 12px;
}

.bubble.has-image .bubble-text {
    display: block;
    padding: 6px 9px 4px;
}

.msg.system .bubble {
    font-size: 12.5px;
    color: var(--danger);
    background: #FBF0EE;
    border: 1px solid #EBCFC9;
    border-radius: 10px;
    padding: 8px 12px;
}

.meta {
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--ink-faint);
    display: flex;
    gap: 8px;
    align-items: center;
}

.msg.user .meta { justify-content: flex-end; }

.action-tag {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--paper-deep);
    color: #6E6859;
}

/* typing indicator */

.typing {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
}

.typing i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #8C8779;
    animation: blink 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }

/* ---------- composer ---------- */

.attach-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 28px 0;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.attach-preview[hidden] { display: none; }

.attach-preview img {
    flex: none;
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 9px;
    background: var(--paper-deep);
}

.attach-preview-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: var(--ink-soft);
}

.attach-remove {
    flex: none;
    padding: 4px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--danger);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.attach-remove:hover { background: #FBF0EE; }

.composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 8px 26px 0;
    padding: 10px 10px 10px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(35, 36, 31, .03), 0 6px 20px rgba(35, 36, 31, .05);
    transition: border-color .2s ease, box-shadow .2s ease;
}

.attach {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--ink-faint);
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.attach:hover:not(:disabled) { background: var(--paper-deep); color: var(--forest); }
.attach:disabled { opacity: .38; cursor: not-allowed; }

.composer:focus-within {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring), 0 8px 24px rgba(35, 36, 31, .07);
}

#input {
    flex: 1;
    min-width: 0;
    height: 38px;
    min-height: 38px;
    max-height: 132px;
    padding: 6px 0;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.7;
}

#input::placeholder { color: var(--ink-faint); }

.send {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: var(--forest);
    color: #F5F2EA;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(36, 71, 61, .18);
    transition: background .2s ease, transform .15s ease, opacity .2s ease, box-shadow .2s ease;
}

.send:hover:not(:disabled) {
    background: var(--forest-soft);
    box-shadow: 0 6px 16px rgba(36, 71, 61, .22);
}

.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }

.hint {
    margin: 9px 0 15px;
    text-align: center;
    font-size: 11.5px;
    letter-spacing: .03em;
    color: var(--ink-faint);
}

@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(143, 191, 159, .16); }
    50%      { box-shadow: 0 0 0 5px rgba(143, 191, 159, .05); }
}

/* ---------- memory hint ---------- */

.msg.system.memory-hint {
    align-self: center;
    max-width: 100%;
    display: block;
}

.memory-hint .bubble {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 7px 14px;
    font-size: 12.5px;
    color: #4C6455;
    background: #F2F6F0;
    border: 1px solid #D9E4D8;
    border-radius: 999px;
}

.hint-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--forest);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.hint-link:hover { color: var(--forest-deep); }

/* ---------- memory drawer ---------- */

body.drawer-open { overflow: hidden; }

.drawer-mask {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(28, 30, 26, .32);
    backdrop-filter: blur(2px);
    animation: mask-in .22s ease both;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 41;
    height: 100dvh;
    width: min(404px, 94vw);
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-left: 1px solid var(--line);
    box-shadow: -24px 0 64px rgba(35, 36, 31, .16);
    animation: drawer-in .28s cubic-bezier(.22, 1, .36, 1) both;
}

.drawer[hidden],
.drawer-mask[hidden] { display: none; }

.drawer-head {
    flex: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 24px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--paper-light);
}

.drawer-head h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: .04em;
}

.drawer-head p {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.drawer-close {
    flex: none;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--ink-soft);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.drawer-close:hover {
    background: #fff;
    border-color: var(--forest-soft);
    color: var(--forest);
}

.drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 24px 26px;
}

.drawer-body::-webkit-scrollbar { width: 7px; }
.drawer-body::-webkit-scrollbar-thumb { background: #DAD4C5; border-radius: 999px; }

.drawer-foot {
    flex: none;
    padding: 14px 24px 20px;
    border-top: 1px solid var(--line);
    background: var(--paper-light);
}

.danger-btn {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #E3BFB8;
    border-radius: 10px;
    background: transparent;
    color: var(--danger);
    font-family: inherit;
    font-size: 13px;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.danger-btn:hover { background: #FBF0EE; border-color: #D8A79E; }
.danger-btn:disabled { opacity: .5; cursor: not-allowed; }

.drawer-note {
    margin: 10px 0 0;
    font-size: 11.5px;
    line-height: 1.7;
    color: var(--ink-soft);
}

/* ---------- drawer tabs / transcript ---------- */

.drawer-tabs {
    flex: none;
    display: flex;
    gap: 4px;
    padding: 0 24px 12px;
    background: var(--paper-light);
    border-bottom: 1px solid var(--line-soft);
}

.drawer-tab {
    padding: 6px 13px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 12.5px;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.drawer-tab:hover { background: var(--paper-deep); color: var(--ink); }
.drawer-tab.is-active { background: var(--paper-deep); color: var(--ink); font-weight: 600; }

.export-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper-light);
    color: var(--forest);
    font: inherit;
    font-size: 13px;
    letter-spacing: .03em;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease;
}

.export-btn:hover { background: var(--paper-deep); border-color: var(--line); }
.export-btn:disabled { opacity: .5; cursor: not-allowed; }

.transcript-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding: 2px 0 8px;
    background: var(--paper-light);
}

.transcript-search {
    flex: 1;
    min-width: 0;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}

.transcript-search:focus {
    outline: none;
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.transcript-count {
    align-self: center;
    font-size: 11px;
    color: var(--ink-faint);
    white-space: nowrap;
}

.transcript-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transcript-item {
    padding: 11px 12px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: #fff;
}

.transcript-item[data-role="user"] { background: var(--paper-light); }

.transcript-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px;
    font-size: 11px;
    color: var(--ink-faint);
}

.transcript-role { font-weight: 600; color: var(--forest); }
.transcript-item[data-role="user"] .transcript-role { color: var(--ink-soft); }
.transcript-time { font-variant-numeric: tabular-nums; white-space: nowrap; }

.transcript-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--ink);
}

.transcript-action {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--paper-deep);
    color: var(--ink-faint);
    font-size: 11px;
}

.transcript-img {
    display: block;
    max-width: 180px;
    max-height: 220px;
    margin-top: 6px;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
}

.transcript-more {
    align-self: center;
    margin: 2px 0 6px;
    padding: 6px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink-soft);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.transcript-more:hover { background: var(--paper-deep); }
.transcript-more:disabled { opacity: .5; cursor: not-allowed; }

.transcript-empty {
    padding: 34px 12px;
    text-align: center;
    color: var(--ink-faint);
    font-size: 13px;
    line-height: 1.7;
}

.record-link { white-space: nowrap; }

@media (max-width: 480px) {
    .record-link span { display: none; }
}

.drawer-loading {
    margin: 0;
    padding: 28px 0;
    text-align: center;
    font-size: 13px;
    color: var(--ink-soft);
}

.drawer-alert {
    margin: 0 0 12px;
    padding: 8px 12px;
    font-size: 12.5px;
    line-height: 1.65;
    color: #7A5A16;
    background: #FBF3DC;
    border: 1px solid #EADCB2;
    border-radius: 10px;
}

.mem-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 8px;
    font-size: 12px;
    letter-spacing: .12em;
    color: var(--ink-soft);
}

.mem-section-title:first-child { margin-top: 2px; }

.mem-section-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--paper-deep);
    color: #7C7663;
    font-size: 11px;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.mem-card {
    padding: 12px 14px;
    margin-bottom: 9px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.mem-card.pending {
    background: #FFFCF2;
    border-color: #EADCB2;
}

.mem-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
}

.mem-type {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--paper-deep);
    color: #7C7663;
    font-size: 11px;
    letter-spacing: .06em;
}

.mem-card.pending .mem-type {
    background: #F6E9C4;
    color: #8A6A12;
}

.mem-content {
    margin: 0;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.mem-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.mem-act {
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.mem-act:hover:not(:disabled) {
    background: #fff;
    border-color: var(--forest-soft);
    color: var(--forest);
}

.mem-act.primary {
    background: var(--forest);
    border-color: var(--forest);
    color: #F5F2EA;
}

.mem-act.primary:hover:not(:disabled) {
    background: var(--forest-soft);
    border-color: var(--forest-soft);
    color: #F5F2EA;
}

.mem-act.danger { color: var(--danger); border-color: #E3BFB8; }
.mem-act.danger:hover:not(:disabled) { background: #FBF0EE; border-color: #D8A79E; color: var(--danger); }
.mem-act:disabled { opacity: .5; cursor: not-allowed; }

.mem-edit {
    width: 100%;
    min-height: 74px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.mem-edit:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.mem-empty {
    padding: 18px 4px 6px;
}

.mem-empty p {
    margin: 0;
    font-size: 13.5px;
    color: var(--ink-soft);
}

.mem-empty .mem-empty-sub {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.7;
    color: #9A9484;
}

.mem-summary {
    margin: 0;
    padding: 11px 13px;
    font-size: 12.5px;
    line-height: 1.8;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, .62);
    border: 1px dashed var(--line);
    border-radius: 12px;
}

@keyframes drawer-in {
    from { opacity: 0; transform: translateX(28px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes mask-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}


/* ---------- responsive ---------- */

@media (max-height: 800px) and (min-width: 861px) {
    .persona { padding: 20px 20px 16px; }
    .seal { width: 50px; height: 50px; font-size: 26px; }
    .persona-id { margin-top: 12px; }
    .persona-name { font-size: 26px; }
    .state { margin-top: 18px; padding-top: 14px; gap: 12px; }
    .persona-foot { padding-top: 14px; }
    .cat-stage { min-height: 210px; margin-top: 10px; }
    .cat-fallback svg { width: 150px; height: 150px; }
    .tech { display: none; }
}

@media (max-width: 860px) {
    .cat-stage { display: none; }
    .shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
        padding: 0;
        gap: 0;
        height: 100dvh;
    }

    .persona {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        border-radius: 0;
    }

    .seal {
        width: 42px;
        height: 42px;
        font-size: 22px;
        border-radius: 11px;
    }

    .persona-id { margin-top: 0; flex: 1; min-width: 0; }
    .persona-name { font-size: 19px; white-space: nowrap; }
    .persona-tagline { display: none; }
    .online { display: none; }

    .state {
        margin-top: 0;
        padding: 0;
        border: 0;
        background: transparent;
        flex-direction: row;
        align-items: center;
        gap: 12px;
    }

    .state-row { gap: 6px; }
    .state-label, .meter, .memory-note { display: none; }

    .persona-foot { margin-top: 0; padding-top: 0; }
    .foot-actions { display: flex; gap: 6px; }
    .ghost-btn { width: auto; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
    .mem-btn { justify-content: center; gap: 5px; }
    .mem-count { height: 17px; min-width: 17px; padding: 0 4px; font-size: 10px; }
    .mem-btn.has-pending::after { display: none; }
    .tech { display: none; }

    .chat {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        box-shadow: none;
    }

    .chat-head { padding: 13px 18px; }
    .chat-avatar { display: none; }
    .chat-title { font-size: 16px; }
    .messages { padding: 20px 16px 8px; }
    .empty { padding: 12px 4px 28px; }
    .empty-seal { width: 66px; height: 66px; font-size: 34px; margin-bottom: 18px; }
    .empty-quote { font-size: 21px; }
    .suggests { max-width: 100%; }
    .suggest { padding: 9px 10px; font-size: 12.5px; }
    .notice { margin: 12px 16px 0; }
    .composer { margin: 8px 16px 0; }
    .attach-preview { margin: 8px 16px 0; }
    .bubble-img { max-width: 200px; max-height: 260px; }
    .msg { max-width: 88%; }

    .drawer {
        top: auto;
        bottom: 0;
        width: 100%;
        height: 88dvh;
        border-left: 0;
        border-top: 1px solid var(--line);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -18px 48px rgba(35, 36, 31, .16);
        animation: sheet-in .28s cubic-bezier(.22, 1, .36, 1) both;
    }

    .drawer-head { padding: 18px 18px 14px; }
    .drawer-body { padding: 16px 18px 22px; }
    .drawer-foot { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); }

    @keyframes sheet-in {
        from { opacity: 0; transform: translateY(24px); }
        to   { opacity: 1; transform: translateY(0); }
    }
}

/* ---------- account / auth ---------- */

.head-side {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: none;
}

.account {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.account-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
    font-weight: 600;
}

.account-form {
    display: inline;
    margin: 0;
}

.account-link {
    appearance: none;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--forest-soft);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

.account-link:hover {
    color: var(--forest-deep);
    border-bottom-color: currentColor;
}

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    height: auto;
    padding: 24px 0;
}

.auth-page {
    width: 100%;
    padding: 32px 20px;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 440px);
    gap: 28px;
    align-items: stretch;
    justify-content: center;
    max-width: 820px;
    margin: 0 auto;
}

.auth-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 36px;
    padding: 38px 34px 34px;
    color: #F3F1E8;
    background:
        radial-gradient(120% 62% at 100% 0%, rgba(201, 162, 39, .15) 0%, transparent 55%),
        linear-gradient(165deg, #2A5045 0%, var(--forest) 48%, var(--forest-deep) 100%);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 60px rgba(26, 53, 45, .18);
    overflow: hidden;
}

.auth-aside::before,
.auth-aside::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(244, 241, 233, .1);
    pointer-events: none;
}

.auth-aside::before { width: 340px; height: 340px; right: -160px; bottom: -140px; }
.auth-aside::after { width: 220px; height: 220px; right: -100px; bottom: -80px; }

.auth-aside-top {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
}

.auth-aside .seal {
    flex: none;
    width: 52px;
    height: 52px;
    font-size: 26px;
    border-radius: 14px;
}

.auth-aside-name {
    margin: 0;
    font-family: var(--serif);
    font-size: 21px;
    letter-spacing: .1em;
}

.auth-aside-kicker {
    margin: 3px 0 0;
    font-size: 12px;
    letter-spacing: .06em;
    color: rgba(243, 241, 232, .64);
}

.auth-aside-main { position: relative; }

.auth-aside-quote {
    margin: 0;
    font-family: var(--serif);
    font-size: 25px;
    line-height: 1.55;
    letter-spacing: .04em;
}

.auth-aside-copy {
    margin: 14px 0 0;
    font-size: 12.5px;
    line-height: 1.8;
    color: rgba(243, 241, 232, .68);
}

.auth-features {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 12.5px;
    color: rgba(243, 241, 232, .78);
}

.auth-features li {
    display: flex;
    align-items: center;
    gap: 9px;
}

.auth-features li::before {
    content: "";
    flex: none;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--wheat-soft);
}

.auth-card {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 36px 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.auth-brand {
    display: none;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-seal {
    width: 52px;
    height: 52px;
    font-size: 26px;
    border-radius: 14px;
    flex: none;
}

.auth-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: .06em;
}

.auth-sub {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.auth-head { margin-bottom: 18px; }

.auth-heading {
    margin: 0;
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: .05em;
}

.auth-heading-sub {
    margin: 5px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.auth-lead {
    margin: 0 0 10px;
    font-family: var(--serif);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: .04em;
    color: var(--ink);
}

.auth-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 20px;
    padding: 4px;
    background: var(--paper-deep);
    border-radius: 12px;
}

.auth-tab {
    flex: 1;
    padding: 9px 10px;
    text-align: center;
    font-size: 13px;
    color: var(--ink-soft);
    text-decoration: none;
    border-radius: 9px;
    transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}

.auth-tab:hover { color: var(--ink); }

.auth-tab.is-active {
    background: #FFFFFF;
    color: var(--forest);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(35, 36, 31, .08);
}

.auth-alert {
    margin: 0 0 16px;
    padding: 10px 13px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.55;
    background: #F7E7E4;
    color: var(--danger);
    border: 1px solid #E7C7C1;
}

.auth-form {
    margin: 0;
}

.auth-note + .auth-form {
    margin-top: 18px;
}

.auth-form .field {
    margin-bottom: 16px;
}

.auth-form label {
    display: block;
    margin-bottom: 7px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.auth-form input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font: inherit;
    color: var(--ink);
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 11px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.auth-form input::placeholder { color: var(--ink-faint); }

.auth-form input:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.auth-submit {
    width: 100%;
    height: 47px;
    margin-top: 6px;
    padding: 0 16px;
    font: inherit;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: .02em;
    color: #F4F1E9;
    background: var(--forest);
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(36, 71, 61, .16);
    transition: background .2s ease, box-shadow .2s ease, transform .15s ease;
}

.auth-submit:hover {
    background: var(--forest-soft);
    box-shadow: 0 8px 20px rgba(36, 71, 61, .2);
}

.auth-submit:active { transform: translateY(1px); }

.auth-note {
    margin: 16px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.auth-code {
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--paper-deep);
    border-radius: 5px;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 22px;
    font-size: 12.5px;
}

.auth-back::after {
    content: "→";
    transition: transform .2s ease;
}

.auth-back:hover::after { transform: translateX(3px); }

/* ---------- admin ---------- */

.admin-page {
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 24px 72px;
}

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.admin-seal {
    flex: none;
    width: 48px;
    height: 48px;
    font-size: 24px;
    border-radius: 13px;
    box-shadow:
        inset 0 0 0 3px rgba(255, 252, 240, .18),
        0 6px 16px rgba(0, 0, 0, .16);
}

.admin-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
    letter-spacing: .05em;
}

.admin-sub {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.admin-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: none;
}

.admin-flash {
    margin: 0 0 18px;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 11px;
    background: #F7E7E4;
    color: var(--danger);
    border: 1px solid #E7C7C1;
}

.admin-flash.ok {
    background: #E8F0EA;
    color: var(--forest);
    border-color: #C9D9CD;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.stat {
    padding: 18px 20px;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-family: var(--serif);
    font-size: 28px;
    line-height: 1.2;
    letter-spacing: .02em;
    color: var(--forest);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    margin-top: 4px;
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--ink-soft);
}

.admin-card {
    margin-bottom: 22px;
    padding: 22px 24px;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.admin-card h2 {
    margin: 0 0 16px;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .06em;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 11px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--line-soft);
}

.admin-table th {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .08em;
    color: var(--ink-faint);
    border-bottom-color: var(--line);
}

.admin-table tbody tr {
    transition: background .18s ease;
}

.admin-table tbody tr:hover {
    background: rgba(234, 229, 216, .45);
}

.admin-table tr:last-child td {
    border-bottom: 0;
}

.admin-table .empty-row {
    padding: 24px;
    text-align: center;
    color: var(--ink-soft);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.badge.active::before,
.badge.disabled::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge.active {
    color: var(--forest);
    background: #E8F0EA;
    border-color: #C9D9CD;
}

.badge.disabled {
    color: var(--danger);
    background: #F7E7E4;
    border-color: #E7C7C1;
}

.badge.admin {
    color: #8A6A12;
    background: #FBF3DA;
    border-color: var(--wheat-soft);
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-inline-form {
    display: inline;
    margin: 0;
}

.mini-btn {
    appearance: none;
    display: inline-block;
    padding: 5px 11px;
    font: inherit;
    font-size: 12px;
    color: var(--ink);
    text-decoration: none;
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
    transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.mini-btn:hover {
    color: var(--forest);
    border-color: var(--forest-soft);
    background: #FBFAF6;
}

.mini-btn.danger {
    color: var(--danger);
    border-color: #E7C7C1;
}

.mini-btn.danger:hover {
    color: var(--danger);
    border-color: #D8A79E;
    background: #FBF0EE;
}

.admin-form-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
}

.admin-form-row input[type="number"] {
    width: 76px;
    padding: 7px 9px;
    font: inherit;
    color: var(--ink);
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.admin-form-row select,
.admin-form-row input[type="text"],
.admin-form-row input[type="email"] {
    padding: 7px 9px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: #FFFFFF;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.admin-form-row select:focus,
.admin-form-row input[type="text"]:focus,
.admin-form-row input[type="email"]:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.admin-form-row input[type="number"]:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.invite-code {
    display: inline-block;
    margin-right: 6px;
    padding: 3px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    letter-spacing: .06em;
    color: var(--ink);
    background: var(--paper-deep);
    border-radius: 7px;
}

/* ---------- admin operations console ---------- */

.admin-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin: -4px 0 20px;
    padding: 5px;
    background: var(--paper-deep);
    border-radius: 12px;
}

.admin-nav-link {
    padding: 6px 13px;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 12.5px;
    text-decoration: none;
    transition: background .2s ease, color .2s ease;
}

.admin-nav-link:hover { background: rgba(255, 255, 255, .55); color: var(--ink); }
.admin-nav-link.is-active { background: var(--paper-light); color: var(--forest); font-weight: 600; box-shadow: var(--shadow-sm); }
.admin-nav-current { margin-left: 8px; color: var(--ink-faint); font-size: 12px; }

.admin-link {
    color: var(--forest);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.admin-link:hover { border-bottom-color: currentColor; }

.admin-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.admin-card-head h2 { margin: 0; }

.admin-search {
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-search input[type="search"] {
    width: 210px;
    max-width: 46vw;
    padding: 7px 10px;
    font: inherit;
    font-size: 12.5px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
}

.admin-search input[type="search"]:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-filter select,
.admin-filter input[type="search"],
.admin-filter input[type="date"],
.admin-create-form input,
.admin-create-form select,
.admin-memory-form select {
    padding: 7px 10px;
    font: inherit;
    font-size: 12.5px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
}

.admin-filter select:focus,
.admin-filter input[type="search"]:focus,
.admin-filter input[type="date"]:focus,
.admin-create-form input:focus,
.admin-create-form select:focus,
.admin-memory-form select:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.admin-audit-filter {
    margin-bottom: 14px;
}

.admin-audit-filter label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-soft);
}

.admin-create {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, .55);
}

.admin-create summary {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--forest);
}

.admin-create-form {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.admin-create-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
    resize: vertical;
}

.admin-create-form textarea:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.admin-plan-settings {
    display: grid;
    gap: 8px;
    padding: 12px 13px;
    border: 1px dashed var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .5);
}

.admin-plan-settings > strong {
    font-size: 13px;
    color: var(--forest);
}

.admin-settings-save {
    justify-content: flex-start;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
    flex-wrap: wrap;
}

.admin-settings-reset {
    margin-top: 10px;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.admin-form-grid label {
    display: grid;
    gap: 5px;
    font-size: 12px;
    color: var(--ink-soft);
}

.admin-form-grid input,
.admin-form-grid select {
    width: 100%;
    box-sizing: border-box;
}

.admin-create-form .row-actions { align-items: center; }
.admin-memory-form .row-actions { align-items: center; }

.admin-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ink-soft);
    cursor: pointer;
}

.admin-check input { width: auto; }

.admin-model-url {
    display: inline-block;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    padding: 1px 5px;
    background: var(--paper-deep);
    border-radius: 5px;
    font-size: 12px;
}

.admin-log {
    max-height: 280px;
    overflow: auto;
    margin: 0;
    padding: 12px 14px;
    background: #1F2B26;
    color: #DCE7E0;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.65;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.admin-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

.admin-grid-2 > .admin-card { min-width: 0; }

.admin-chart {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    height: 150px;
    padding: 8px 4px 0;
}

.admin-bar {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
}

.admin-bar-fill {
    width: 100%;
    max-width: 44px;
    min-height: 2px;
    background: linear-gradient(180deg, var(--forest-soft), var(--forest));
    border-radius: 8px 8px 4px 4px;
    transition: height .4s var(--ease-out);
}

.admin-bar-value {
    font-size: 11px;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.admin-bar-label {
    font-size: 10.5px;
    color: var(--ink-faint);
    white-space: nowrap;
}

.admin-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 16px;
}

.admin-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 12px;
    text-decoration: none;
}

.admin-page-link:hover { border-color: var(--forest-soft); color: var(--forest); }
.admin-page-link.is-active { background: var(--forest); border-color: var(--forest); color: var(--paper-light); }
.admin-page-gap { color: var(--ink-faint); font-size: 12px; padding: 0 2px; }

.admin-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.admin-detail-name {
    margin: 0;
    font-family: var(--serif);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: .04em;
}

.admin-detail-id { font-family: var(--sans); font-size: 12px; color: var(--ink-faint); letter-spacing: .02em; }
.admin-stat-time { font-size: 15px; line-height: 1.5; }
.admin-stat-bytes { font-size: 18px; line-height: 1.55; white-space: nowrap; }

.admin-action-list { display: flex; flex-direction: column; gap: 0; }

.admin-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 11px 0;
    border-bottom: 1px solid var(--line-soft);
}

.admin-action-row:last-child { border-bottom: 0; padding-bottom: 0; }
.admin-action-row:first-child { padding-top: 0; }
.admin-action-row strong { display: block; font-size: 13px; color: var(--ink); }
.admin-action-row .admin-sub { margin: 2px 0 0; }
.admin-action-row button { flex: none; }
.admin-action-row button:disabled { opacity: .45; cursor: not-allowed; }

.admin-password-form {
    display: grid;
    gap: 7px;
}

.admin-password-form label { font-size: 12px; color: var(--ink-soft); }

.admin-password-form input[type="password"] {
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
}

.admin-password-form input[type="password"]:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.admin-password-form button { justify-self: start; margin-top: 4px; }

.admin-count {
    display: inline-flex;
    align-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 4px;
    border-radius: 999px;
    background: var(--paper-deep);
    color: var(--ink-soft);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 500;
    vertical-align: 1px;
}

.admin-summary {
    margin-bottom: 14px;
    padding: 11px 13px;
    border: 1px dashed var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .55);
}

.admin-summary strong { font-size: 12px; color: var(--ink-soft); }
.admin-summary p { margin: 4px 0 0; font-size: 13px; line-height: 1.7; color: var(--ink); }

.admin-empty {
    margin: 0;
    padding: 24px 10px;
    text-align: center;
    color: var(--ink-faint);
    font-size: 13px;
}

.admin-memory-list { display: flex; flex-direction: column; gap: 10px; }

.admin-memory {
    position: relative;
    padding: 11px 13px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    background: #fff;
}

.admin-memory-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.admin-memory-form textarea {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: 9px;
    resize: vertical;
    outline: none;
}

.admin-memory-form textarea:focus { border-color: var(--forest-soft); box-shadow: var(--focus-ring); }
.admin-memory-form .row-actions { margin-top: 7px; }
.admin-memory-delete { position: absolute; right: 13px; bottom: 13px; }

.admin-records { display: flex; flex-direction: column; gap: 10px; }
.admin-records-more { align-self: center; margin-bottom: 4px; }

.admin-record {
    padding: 11px 13px;
    border: 1px solid var(--line-soft);
    border-radius: 11px;
    background: #fff;
}

.admin-record[data-role="user"] { background: var(--paper-light); }
.admin-record-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; font-size: 11.5px; color: var(--ink-faint); }
.admin-record-head strong { color: var(--forest); font-weight: 600; }
.admin-record p { margin: 0; font-size: 13px; line-height: 1.7; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-record-action { display: inline-block; margin-top: 6px; padding: 1px 7px; border-radius: 999px; background: var(--paper-deep); color: var(--ink-faint); font-size: 11px; }
.admin-record-image { display: block; max-width: 180px; max-height: 220px; margin-top: 7px; border: 1px solid var(--line-soft); border-radius: 9px; }

.admin-kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-kv th, .admin-kv td { padding: 8px 0; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.admin-kv th { width: 36%; color: var(--ink-soft); font-weight: 500; }
.admin-kv tr:last-child th, .admin-kv tr:last-child td { border-bottom: 0; }
.admin-kv td { color: var(--ink); overflow-wrap: anywhere; }

.admin-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.8; color: var(--ink-soft); }
.admin-list code { padding: 1px 5px; background: var(--paper-deep); border-radius: 5px; font-size: 12px; }
.admin-sensitive { color: #8A6A12; }

@media (max-width: 860px) {
    .admin-grid-2 { grid-template-columns: 1fr; gap: 16px; }
    .admin-chart { height: 130px; gap: 6px; }
    .admin-record-image { max-width: 140px; }
}

@media (max-width: 640px) {
    .admin-nav { border-radius: 10px; }
    .admin-nav-link { padding: 5px 9px; font-size: 12px; }
    .admin-card-head { align-items: flex-start; }
    .admin-toolbar { width: 100%; justify-content: flex-start; }
    .admin-filter { width: 100%; }
    .admin-search { width: 100%; }
    .admin-search input[type="search"] { width: 100%; max-width: none; flex: 1; }
    .admin-form-grid { grid-template-columns: 1fr; }
    .admin-audit-filter label { width: 100%; }
    .admin-audit-filter input[type="date"] { flex: 1; }
    .admin-detail-head { flex-direction: column; }
    .admin-action-row { align-items: flex-start; }
    .admin-action-row > div { min-width: 0; }
    .admin-password-form { max-width: 100%; }
}

@media (max-width: 860px) {
    .head-side { gap: 10px; }
    .head-side .mood-chip { display: none; }
    .account { gap: 8px; }
    .account-name { display: none; }

    .auth-page { padding: 24px 16px; }
    .auth-shell { grid-template-columns: minmax(0, 440px); gap: 0; }
    .auth-aside { display: none; }
    .auth-brand { display: flex; }
    .auth-card { padding: 28px 22px; }

    .admin-page { padding: 20px 14px 48px; }
    .admin-head { align-items: flex-start; flex-direction: column; }
    .admin-seal { width: 42px; height: 42px; font-size: 21px; border-radius: 11px; }
    .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-card { padding: 16px; }
    .admin-table .empty-row { padding: 20px 12px; text-align: left; }
}

@media (max-width: 480px) {
    .chat-sub { display: none; }
    .chat-title { font-size: 15px; }
    .mood-chip { padding: 3px 9px; font-size: 11px; }
    .auth-card { padding: 24px 18px; }
    .persona { padding: 12px; gap: 8px; }
    .persona-foot .reset-label { display: none; }
    #resetBtn { padding: 6px 9px; }
    .persona .mood { padding: 3px 8px; font-size: 11px; }
}

/* ---------- motion & polish ---------- */

:root {
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --ease-in: cubic-bezier(.4, 0, 1, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --dur-1: .18s;
    --dur-2: .26s;
    --dur-3: .36s;
    --dur-4: .52s;
}

@view-transition {
    navigation: auto;
}

.seal--shared {
    view-transition-name: xm-seal;
}

::view-transition-group(xm-seal) {
    animation-duration: .44s;
    animation-timing-function: var(--ease-out);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: .26s;
}

.ico {
    flex: none;
    display: block;
}

.messages,
.drawer-body {
    position: relative;
}

/* micro interactions */

.ghost-btn,
.account-link,
.mini-btn,
.mem-act,
.attach,
.drawer-close,
.hint-link,
.auth-tab,
.attach-remove,
.suggest {
    transition: background var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease,
                box-shadow var(--dur-1) ease, transform var(--dur-1) var(--ease-out), opacity var(--dur-1) ease;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ghost-btn:active:not(:disabled) {
    transform: scale(.975);
}

.ghost-btn .ico {
    opacity: .82;
}

.mem-count.is-bump {
    animation: pop-in var(--dur-3) var(--ease-spring) both;
}

.account-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.account-link .ico {
    transition: transform var(--dur-2) var(--ease-out);
}

.account-link:hover .ico {
    transform: translateY(-1px);
}

.account-link:active {
    transform: scale(.96);
}

.mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mini-btn:active:not(:disabled),
.mem-act:active:not(:disabled),
.attach:active:not(:disabled),
.drawer-close:active:not(:disabled),
.hint-link:active {
    transform: scale(.96);
}

.attach-remove:active {
    transform: scale(.94);
}

/* empty state */

.empty {
    animation: empty-in var(--dur-4) var(--ease-out) both;
}

.empty-seal {
    animation: seal-in .58s var(--ease-spring) both, seal-breathe 6s .7s ease-in-out infinite;
}

.empty-quote {
    animation: fade-up .5s .08s var(--ease-out) both;
}

.empty-hint {
    animation: fade-up .5s .14s var(--ease-out) both;
}

.suggest-text {
    min-width: 0;
}

.suggest-arrow {
    opacity: 0;
    translate: -3px 3px;
    transition: opacity var(--dur-2) ease, translate var(--dur-2) var(--ease-out);
}

.suggest:hover .suggest-arrow,
.suggest:focus-visible .suggest-arrow {
    opacity: 1;
    translate: 0 0;
}

.suggests .suggest {
    animation: fade-up .46s var(--ease-out) both;
}

.suggests .suggest:nth-child(1) { animation-delay: .18s; }
.suggests .suggest:nth-child(2) { animation-delay: .23s; }
.suggests .suggest:nth-child(3) { animation-delay: .28s; }
.suggests .suggest:nth-child(4) { animation-delay: .33s; }

.suggest.is-picked {
    animation: chip-pick .3s var(--ease-in) both;
    pointer-events: none;
}

.suggest-ghost {
    position: fixed;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 13px;
    color: var(--forest);
    background: #FFFFFF;
    border: 1px solid var(--forest-soft);
    border-radius: 11px;
    box-shadow: 0 10px 26px rgba(35, 36, 31, .14);
    pointer-events: none;
    transform-origin: center center;
    will-change: transform, opacity;
}

.empty.is-leaving {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    margin: 0 auto;
    transform: translateY(-50%);
    animation: empty-out .32s var(--ease-in) both;
    pointer-events: none;
}

/* messages */

.msg.ai {
    animation-name: msg-in-ai;
}

.msg.user {
    animation-name: msg-in-user;
}

.msg .bubble {
    transition: box-shadow var(--dur-2) ease, border-color var(--dur-2) ease;
}

.msg.ai:hover .bubble {
    box-shadow: 0 6px 18px rgba(35, 36, 31, .07);
}

.msg .action-tag {
    transition: background var(--dur-2) ease, color var(--dur-2) ease;
}

.msg:hover .action-tag {
    background: #EDE8DA;
    color: var(--forest);
}

.msg.is-leaving {
    animation: msg-out .3s var(--ease-in) both;
    pointer-events: none;
}

.msg.system.memory-hint {
    animation: hint-in .4s var(--ease-spring) both;
}

/* composer */

.attach-preview:not([hidden]) {
    animation: pop-in .3s var(--ease-spring) both;
}

.attach-preview.is-closing {
    animation: pop-out .22s var(--ease-in) both;
    pointer-events: none;
}

.send {
    position: relative;
}

.send-icon,
.send-spinner {
    display: grid;
    place-items: center;
    transition: opacity var(--dur-1) ease, scale var(--dur-2) var(--ease-out);
}

.send-spinner {
    position: absolute;
    inset: 0;
    opacity: 0;
    scale: .55;
}

.send.is-busy:disabled {
    opacity: 1;
    cursor: progress;
    box-shadow: 0 4px 12px rgba(36, 71, 61, .18);
}

.send.is-busy .send-icon {
    opacity: 0;
    scale: .5;
}

.send.is-busy .send-spinner {
    opacity: 1;
    scale: 1;
    animation: spin .8s linear infinite;
}

.hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 12px;
}

.hint a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hint-item {
    display: inline-flex;
    align-items: center;
}

.hint-item + .hint-item::before {
    content: "";
    width: 3px;
    height: 3px;
    margin-right: 12px;
    border-radius: 50%;
    background: currentColor;
    opacity: .4;
}

/* memory drawer */

.drawer {
    animation: drawer-fade var(--dur-2) var(--ease-out) both;
}

.drawer.is-closing {
    animation: drawer-out var(--dur-2) var(--ease-in) both;
}

.drawer-mask.is-closing {
    animation: mask-out var(--dur-2) ease both;
}

.drawer-head {
    animation: fade-up .38s var(--ease-out) both;
}

.drawer-body {
    animation: fade-up .4s .04s var(--ease-out) both;
}

.drawer-foot {
    animation: fade-up .4s .08s var(--ease-out) both;
}

.drawer-head-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.drawer-seal {
    flex: none;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-family: var(--serif);
    font-size: 22px;
    line-height: 1;
    color: var(--forest-deep);
    background: linear-gradient(160deg, #DDBA4C 0%, var(--wheat) 58%, #B78F1C 100%);
    border: 1px solid rgba(26, 53, 45, .2);
    border-radius: 12px;
    box-shadow:
        inset 0 0 0 3px rgba(255, 252, 240, .18),
        0 6px 14px rgba(0, 0, 0, .12);
}

.morph-seal {
    position: fixed;
    z-index: 70;
    box-sizing: border-box;
    display: grid;
    place-items: center;
    font-family: var(--serif);
    line-height: 1;
    color: var(--forest-deep);
    background: linear-gradient(160deg, #DDBA4C 0%, var(--wheat) 58%, #B78F1C 100%);
    border: 1px solid rgba(26, 53, 45, .22);
    box-shadow:
        inset 0 0 0 4px rgba(255, 252, 240, .18),
        0 10px 24px rgba(0, 0, 0, .22);
    pointer-events: none;
    transform-origin: center center;
    will-change: transform;
}

.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.danger-btn:active:not(:disabled) {
    transform: scale(.985);
}

.mem-card,
.mem-section-title,
.mem-empty,
.mem-summary {
    animation: fade-up .42s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 34ms);
}

.mem-card {
    transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) ease, border-color var(--dur-2) ease;
}

.mem-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(35, 36, 31, .07);
}

.mem-card .mem-act {
    transition: background var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease,
                transform var(--dur-1) var(--ease-out);
}

.mem-edit {
    animation: pop-in var(--dur-2) var(--ease-spring) both;
}

.drawer-alert {
    animation: alert-in var(--dur-2) var(--ease-out) both;
}

/* auth */

.auth-card {
    animation: fade-up .5s var(--ease-out) both;
}

.auth-aside .auth-quote,
.auth-aside .auth-copy,
.auth-aside .auth-features {
    animation: fade-up .55s var(--ease-out) both;
}

.auth-aside .auth-copy { animation-delay: .08s; }
.auth-aside .auth-features { animation-delay: .16s; }

.auth-tabs {
    position: relative;
}

.auth-tab {
    position: relative;
    z-index: 1;
    background: transparent;
}

.auth-tab.is-active {
    background: transparent;
    box-shadow: none;
}

.auth-tab-pill {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    background: #FFFFFF;
    border-radius: 9px;
    box-shadow: 0 1px 3px rgba(35, 36, 31, .08);
    opacity: 0;
    pointer-events: none;
    transition: transform .32s var(--ease-out), width .32s var(--ease-out),
                height .32s var(--ease-out), opacity var(--dur-2) ease;
}

.auth-tabs.is-ready .auth-tab-pill {
    opacity: 1;
}

.auth-tabs:not(.is-ready) .auth-tab-pill {
    transition: none;
}

.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: alert-in .3s var(--ease-out) both;
}

.auth-alert .ico {
    margin-top: 1px;
}

.auth-alert.is-ok {
    color: var(--forest);
    background: #E8F0EA;
    border-color: #C9D9CD;
}

.auth-alert.is-error {
    animation: alert-in .3s var(--ease-out) both, shake .42s .05s var(--ease-out) both;
}

.auth-form label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field-ico {
    color: var(--ink-faint);
}

.auth-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-submit .submit-spinner {
    display: none;
}

.auth-submit .submit-spinner .ico {
    animation: spin .8s linear infinite;
}

.auth-submit.is-busy {
    cursor: progress;
    opacity: .9;
}

.auth-submit.is-busy .submit-spinner {
    display: inline-flex;
}

.auth-submit:active:not(:disabled) {
    transform: scale(.99);
}

.auth-back::after {
    content: none;
}

.auth-back .ico {
    transition: transform var(--dur-2) var(--ease-out);
}

.auth-back:hover .ico {
    transform: translateX(-3px);
}

.notice {
    animation: fade-up .4s var(--ease-out) both;
}

/* admin */

.admin-head,
.admin-stats,
.admin-card {
    animation: fade-up .5s var(--ease-out) both;
}

.admin-stats { animation-delay: .06s; }
.admin-card { animation-delay: .1s; }

.admin-flash {
    display: flex;
    align-items: center;
    gap: 8px;
    animation: alert-in .3s var(--ease-out) both;
}

.admin-flash.is-error {
    animation: alert-in .3s var(--ease-out) both, shake .42s .05s var(--ease-out) both;
}

.stat {
    transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) ease, border-color var(--dur-2) ease;
}

.stat:hover {
    transform: translateY(-2px);
    border-color: var(--forest-soft);
    box-shadow: 0 10px 24px rgba(35, 36, 31, .08);
}

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

.stat-ico {
    color: #B08A20;
    opacity: .9;
}

.admin-table tbody tr {
    animation: fade-up .42s var(--ease-out) both;
    animation-delay: calc(var(--i, 0) * 32ms);
}

.copy-ico {
    display: inline-flex;
}

.copy-ico-done {
    display: none;
}

.copy-btn.is-done {
    color: var(--forest);
    background: #E8F0EA;
    border-color: #C9D9CD;
}

.copy-btn.is-done .copy-ico-idle {
    display: none;
}

.copy-btn.is-done .copy-ico-done {
    display: inline-flex;
    animation: pop-in var(--dur-2) var(--ease-spring) both;
}

.copy-btn.is-done .copy-text {
    color: var(--forest);
}

.admin-inline-form button {
    transform-origin: center;
}

/* keyframes */

@keyframes fade-up {
    from { opacity: 0; translate: 0 10px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes pop-in {
    from { opacity: 0; scale: .9; }
    to   { opacity: 1; scale: 1; }
}

@keyframes pop-out {
    from { opacity: 1; scale: 1; }
    to   { opacity: 0; scale: .94; }
}

@keyframes empty-in {
    from { opacity: 0; translate: 0 12px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes empty-out {
    from { opacity: 1; scale: 1; }
    to   { opacity: 0; scale: .96; }
}

@keyframes seal-in {
    0%   { opacity: 0; scale: .72; rotate: -8deg; }
    100% { opacity: 1; scale: 1; rotate: 0deg; }
}

@keyframes seal-breathe {
    0%, 100% { translate: 0 0; }
    50%      { translate: 0 -4px; }
}

@keyframes msg-in-ai {
    from { opacity: 0; translate: -8px 6px; scale: .985; }
    to   { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes msg-in-user {
    from { opacity: 0; translate: 8px 6px; scale: .985; }
    to   { opacity: 1; translate: 0 0; scale: 1; }
}

@keyframes msg-out {
    from { opacity: 1; translate: 0 0; scale: 1; }
    to   { opacity: 0; translate: 0 6px; scale: .98; }
}

@keyframes hint-in {
    from { opacity: 0; scale: .9; translate: 0 6px; }
    to   { opacity: 1; scale: 1; translate: 0 0; }
}

@keyframes chip-pick {
    from { opacity: 1; scale: 1; }
    to   { opacity: 0; scale: .92; }
}

@keyframes drawer-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes drawer-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes mask-out {
    from { opacity: 1; }
    to   { opacity: 0; }
}

@keyframes alert-in {
    from { opacity: 0; translate: 0 -5px; }
    to   { opacity: 1; translate: 0 0; }
}

@keyframes shake {
    0%, 100% { translate: 0 0; }
    20%      { translate: -5px 0; }
    40%      { translate: 4px 0; }
    60%      { translate: -3px 0; }
    80%      { translate: 2px 0; }
}

@keyframes spin {
    to { rotate: 360deg; }
}

@media (prefers-reduced-motion: reduce) {
    .morph-seal,
    .suggest-ghost {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- account / billing ---------- */

.account-body {
    background:
        radial-gradient(circle at 88% 0%, rgba(147, 118, 60, .08), transparent 30%),
        radial-gradient(circle at 4% 38%, rgba(32, 88, 62, .06), transparent 32%),
        var(--bg);
}

.account-page,
.reset-page {
    max-width: 1060px;
    margin: 0 auto;
    padding: 36px 24px 64px;
}

.account-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.account-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.account-seal {
    width: 48px;
    height: 48px;
    font-size: 24px;
    border-radius: 13px;
}

.account-brand h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 25px;
    font-weight: 600;
    letter-spacing: .04em;
}

.account-brand p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.account-card {
    min-width: 0;
    padding: 22px 24px;
    background: var(--paper-light);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.account-card h2 {
    margin: 0 0 15px;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: .05em;
}

.account-sub {
    margin: 5px 0 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.account-plan-head,
.account-plan-top,
.account-meter-head,
.account-inline,
.account-links,
.account-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.account-plan-name {
    font-family: var(--serif);
    font-size: 21px;
    color: var(--forest);
}

.account-usage {
    display: grid;
    gap: 12px;
    margin: 16px 0 18px;
}

.account-meter-head {
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--ink-soft);
}

.account-meter-track {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--paper-deep);
}

.account-meter-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--forest-soft), var(--forest));
    transition: width .45s var(--ease-out);
}

.account-plans {
    display: grid;
    gap: 8px;
    margin: 16px 0;
}

.account-plan {
    padding: 11px 13px;
    border: 1px dashed var(--line);
    border-radius: 11px;
    background: rgba(255, 255, 255, .5);
}

.account-plan.is-current {
    border-color: var(--wheat-soft);
    background: #FBF3DA;
}

.account-plan-top strong {
    font-size: 13px;
    color: var(--ink);
}

.account-plan-top span {
    font-size: 12px;
    color: var(--accent2);
}

.account-features {
    margin: 7px 0 0;
    padding-left: 17px;
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.account-form {
    display: grid;
    gap: 7px;
    margin-top: 14px;
}

.account-form label {
    font-size: 12px;
    color: var(--ink-soft);
}

.account-form input[type="text"],
.account-form input[type="email"],
.account-form input[type="password"] {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    outline: none;
}

.account-form input:focus {
    border-color: var(--forest-soft);
    box-shadow: var(--focus-ring);
}

.account-form > button,
.account-form .account-inline button {
    justify-self: start;
}

.account-inline {
    align-items: center;
}

.account-inline input {
    flex: 1;
    min-width: 0;
}

.account-redeem {
    padding-top: 14px;
    border-top: 1px solid var(--line-soft);
}

.account-logout-all {
    padding-top: 13px;
    border-top: 1px solid var(--line-soft);
}

.account-danger {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #E7C7C1;
}

.account-check {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.account-check input {
    margin-top: 3px;
}

.account-links {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 12.5px;
}

.account-flash {
    margin: 0 0 16px;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 11px;
    background: #F7E7E4;
    color: var(--danger);
    border: 1px solid #E7C7C1;
}

.account-flash.ok {
    background: #E8F0EA;
    color: var(--forest);
    border-color: #C9D9CD;
}

.account-footer {
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--ink-faint);
}

.account-footer a,
.legal-footer a {
    color: var(--ink-soft);
    text-decoration: none;
}

.account-footer a:hover,
.legal-footer a:hover {
    color: var(--forest);
}

.account-inline form,
.account-inline .account-form {
    margin: 0;
}

.reset-card {
    max-width: 460px;
    margin: 8vh auto 0;
}

.reset-card h1 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 24px;
    font-weight: 600;
}

/* ---------- legal pages ---------- */

.legal-body {
    background: var(--bg);
}

.legal-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 40px 24px 72px;
    color: var(--ink);
}

.legal-head {
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.legal-head h1 {
    margin: 14px 0 5px;
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 600;
    letter-spacing: .04em;
}

.legal-head p {
    margin: 0;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.legal-note {
    margin-bottom: 24px;
    padding: 13px 16px;
    border-left: 3px solid var(--accent2);
    border-radius: 0 10px 10px 0;
    background: var(--soft2);
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink-soft);
}

.legal-page section {
    margin-bottom: 24px;
}

.legal-page h2 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 600;
}

.legal-page p,
.legal-page li {
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--ink-soft);
}

.legal-page ul {
    margin: 0 0 10px;
    padding-left: 20px;
}

.legal-footer {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 30px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 12px;
}

/* ---------- chat legal / report ---------- */

.chat-legal {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 5px 0 0;
    font-size: 11px;
    color: var(--ink-faint);
}

.site-announcement {
    margin: 0 24px 10px;
    padding: 9px 12px;
    border: 1px solid var(--wheat-soft);
    border-radius: 10px;
    background: #FBF3DA;
    color: #6b5a2a;
    font-size: 12.5px;
    line-height: 1.7;
}

.chat-legal a {
    color: var(--ink-soft);
    text-decoration: none;
}

.chat-legal a:hover {
    color: var(--forest);
}

.report-btn {
    appearance: none;
    padding: 1px 7px;
    font: inherit;
    font-size: 10.5px;
    color: var(--ink-faint);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    opacity: .55;
    transition: opacity .2s ease, color .2s ease, border-color .2s ease;
}

.bubble-wrap:hover .report-btn,
.report-btn:focus-visible {
    opacity: 1;
    color: var(--danger);
    border-color: #E7C7C1;
}

.report-btn:disabled {
    cursor: wait;
    opacity: .4;
}

/* ---------- auth additions ---------- */

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 2px 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--ink-soft);
}

.auth-check input {
    margin-top: 3px;
}

.auth-check a {
    color: var(--forest);
}

.auth-forgot {
    margin: -4px 0 2px;
    text-align: right;
    font-size: 12px;
}

.auth-legal {
    margin: 14px 0 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--ink-faint);
}

.auth-legal a {
    color: var(--ink-soft);
    text-decoration: none;
}

.auth-legal span {
    margin: 0 5px;
}

@media (max-width: 760px) {
    .account-page,
    .reset-page {
        padding: 22px 16px 48px;
    }
    .account-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .account-head {
        align-items: flex-start;
        flex-direction: column;
    }
    .account-head .row-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .legal-page {
        padding: 28px 18px 56px;
    }
}

