:root {
    --bg-page: #f0eaf5;
    --bg-card: #ffffff;
    --bg-card-soft: #f8f4fc;
    --bg-inset: #ede6f5;
    --line: #d5c5e0;
    --line-light: #e3d6eb;
    --text-main: #2e2238;
    --text-dim: #6a5f78;
    --text-light: #8c7e9c;
    --purple: #7b2d8e;
    --purple-deep: #5a1a6e;
    --purple-light: #a855c8;
    --purple-bg: rgba(123, 45, 142, 0.08);
    --gold: #b8860b;
    --gold-deep: #8b6508;
    --ok: #2d8a4e;
    --danger: #c0392b;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll;
    overflow-x: hidden;
}

body {
    width: 100%;
    min-height: 100vh;
    font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
    color: var(--text-main);
    background: var(--bg-page);
    line-height: 1.45;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle at 20% 10%, rgba(123, 45, 142, 0.03) 0%, transparent 50%),
                      radial-gradient(circle at 80% 90%, rgba(90, 26, 110, 0.02) 0%, transparent 50%);
}

.page {
    --sidebar-width: clamp(280px, 24vw, 340px);
    --layout-gap: clamp(12px, 1.5vw, 18px);
    width: 100%;
    max-width: 1440px;
    margin: 12px auto 24px;
    padding: 0 12px;
}

.hero {
    position: relative;
    margin-bottom: 14px;
    padding: clamp(16px, 2vw, 22px) clamp(16px, 2.2vw, 24px) clamp(18px, 2.5vw, 26px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(135deg, #f8f0ff, #f0e6fa);
    box-shadow: var(--shadow);
}

.hero-subtitle {
    color: var(--purple);
    letter-spacing: 0.18em;
    font-size: 0.82rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero h1 {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    margin-bottom: 10px;
    color: #2a1030;
}

.hero-desc {
    color: var(--text-dim);
    max-width: 64ch;
    font-size: 0.95rem;
}

/* Coins */
.coin-display {
    position: absolute;
    top: 52px;
    right: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--purple-bg);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.82rem;
}
.coin-icon { font-size: 1.1rem; }
.coin-balance { font-weight: 600; color: var(--purple); }

/* Layout */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--layout-gap);
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.form-panel {
    padding: clamp(14px, 1.6vw, 18px);
}

.panel-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.panel-title-row.small {
    margin: 0 0 8px;
}

.result-title-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

h2 {
    font-size: 1.15rem;
    color: #3a2050;
}

h3 {
    font-size: 1rem;
    color: #4a3060;
    margin-bottom: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(123, 45, 142, 0.35);
    color: var(--purple);
    border-radius: 99px;
    padding: 3px 10px;
    font-size: 0.72rem;
    white-space: nowrap;
    background: var(--purple-bg);
}

.chip-soft {
    border-color: var(--line);
    color: var(--text-dim);
    background: transparent;
}

/* Form */
.input-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: grid;
    gap: 10px;
}
.split-2 { grid-template-columns: 1fr 1fr; }
.split-4 { grid-template-columns: repeat(2, 1fr); }
.align-end { align-items: end; }

.form-group {
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.form-group input[type="number"],
.form-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg-card);
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--purple-light);
    box-shadow: 0 0 0 3px rgba(123, 45, 142, 0.1);
}

.radio-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    min-height: 40px;
    font-size: 0.88rem;
}
.radio-group label {
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 8px;
}

.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--purple);
    color: #fff;
}
.btn-primary:hover {
    background: var(--purple-deep);
}
.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-inset);
    color: var(--text-dim);
    border: 1px solid var(--line);
}
.btn-secondary:hover {
    background: var(--line-light);
}

/* Export button */
.btn-export {
    padding: 4px 14px;
    border: 1px solid var(--purple);
    border-radius: 14px;
    background: transparent;
    color: var(--purple-deep);
    font-family: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-export:hover {
    background: var(--purple);
    color: #fff;
}

.error-message {
    color: var(--danger);
    font-size: 0.85rem;
    padding: 6px 0;
}

/* ===== History ===== */
.history-box {
    margin-top: 16px;
    border-top: 1px solid var(--line-light);
    padding-top: 12px;
}
.text-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
}
.text-btn:hover {
    color: var(--purple);
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-empty {
    color: var(--text-light);
    font-size: 0.82rem;
    text-align: center;
    padding: 10px 0;
}
.history-item-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.history-item {
    flex: 1;
    min-width: 0;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 5px 8px;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-item span {
    display: block;
    font-size: 0.72rem;
    color: var(--text-light);
}
.history-item:hover {
    background: var(--bg-card-soft);
    border-color: var(--line);
}
.history-del {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    line-height: 1;
}
.history-del:hover {
    color: var(--danger);
    background: rgba(192, 57, 43, 0.08);
}

/* Result area */
.result-area {
    padding: clamp(14px, 1.6vw, 18px);
}

/* Summary grid */
.summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.summary-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-card-soft);
    border: 1px solid var(--line-light);
    border-radius: 8px;
    font-size: 0.85rem;
}
.summary-label {
    color: var(--text-dim);
}
.summary-value {
    font-weight: 600;
    color: var(--purple);
}

/* Result blocks */
.result-block {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line-light);
}
.result-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Palaces grid */
.palaces-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.palace-card {
    background: var(--bg-card-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.palace-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.palace-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 4px;
}
.palace-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 4px;
}
.palace-branch {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.palace-dao {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 4px;
}
.palace-identity {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Dao colors */
.dao-fo { background: #fff3cd; color: #856404; }
.dao-xian { background: #d4edda; color: #155724; }
.dao-ren { background: #cce5ff; color: #004085; }
.dao-xiuluo { background: #f8d7da; color: #721c24; }
.dao-chu { background: #e2e3e5; color: #383d41; }
.dao-gui { background: #d6d8db; color: #1b1e21; }

/* Palace hint (explains what the dao means for this position) */
.palace-hint {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.45;
    padding: 0 4px;
}

/* Palace details */
.palace-details {
    margin-top: 8px;
    text-align: left;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
    display: none;
}
.palace-card.expanded .palace-details {
    display: block;
}
.palace-detail-row {
    margin-bottom: 3px;
}
.palace-detail-label {
    color: var(--purple);
    font-weight: 600;
}
.palace-verse {
    margin-bottom: 8px;
    padding: 6px 10px;
    background: rgba(123, 45, 142, 0.05);
    border-left: 2px solid var(--purple-light);
    border-radius: 0 6px 6px 0;
    font-style: italic;
    line-height: 1.7;
    color: var(--purple-deep);
}

/* Dao wheel */
.dao-wheel-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}
.dao-wheel {
    width: 280px;
    height: 280px;
}
.dao-wheel svg {
    width: 100%;
    height: 100%;
}

/* Dao summary */
.dao-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.dao-card {
    background: var(--bg-card-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}
.dao-card-title {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-bottom: 6px;
}
.dao-card-dao {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--purple);
    margin-bottom: 4px;
}
.dao-card-identity {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.dao-card-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* Sanshi */
.sanshi-info {
    background: var(--bg-card-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
}
.sanshi-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold-deep);
    margin-bottom: 8px;
}
.sanshi-row {
    font-size: 0.88rem;
    color: var(--text-dim);
    margin-bottom: 4px;
    line-height: 1.6;
}
.sanshi-poem {
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(184, 134, 11, 0.06);
    border-left: 3px solid var(--gold);
    border-radius: 0 8px 8px 0;
    font-size: 0.9rem;
    color: var(--gold-deep);
    line-height: 1.7;
    font-style: italic;
}

/* Xiuyao group label */
.xiuyao-group {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: normal;
}
.xiuyao-hint {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

/* Xiuyao relation */
.archetype-block {
    padding: 18px;
    border: 1px solid rgba(184, 134, 11, 0.22);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(184, 134, 11, 0.055), rgba(123, 45, 142, 0.035));
}
.archetype-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.archetype-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--text-dim);
    font-size: .76rem;
    letter-spacing: .08em;
}
.archetype-title { font-size: 1.3rem; font-weight: 750; color: var(--text-main); }
.archetype-realm {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(123, 45, 142, 0.09);
    font-size: .82rem;
    font-weight: 700;
}
.archetype-trace {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 0 14px;
    scrollbar-width: thin;
}
.archetype-trace-step {
    flex: 0 0 auto;
    padding: 5px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: .78rem;
}
.archetype-trace-arrow { color: var(--text-dim); font-size: 1rem; }
.archetype-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.archetype-detail {
    min-width: 0;
    padding: 11px 12px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.48);
}
.archetype-detail span { display: block; margin-bottom: 5px; color: var(--text-dim); font-size: .76rem; }
.archetype-detail strong { display: block; color: var(--text-main); font-size: .9rem; line-height: 1.55; }
.archetype-boundary {
    margin-top: 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    color: var(--text-dim);
    background: rgba(184, 134, 11, 0.06);
    font-size: .82rem;
    line-height: 1.6;
}
.life-stages-block {
    padding: 18px;
    border: 1px solid rgba(123, 45, 142, 0.18);
    border-radius: 16px;
    background: rgba(123, 45, 142, 0.025);
}
.life-stages-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.life-stages-heading h3 { margin-bottom: 4px; }
.life-stages-heading p { color: var(--text-dim); font-size: .84rem; line-height: 1.55; }
.life-stages-badge {
    flex: 0 0 auto;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--purple-deep);
    background: rgba(123, 45, 142, 0.09);
    font-size: .76rem;
    font-weight: 700;
}
.life-stages {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}
.life-stage {
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line-light);
    border-radius: 12px;
    background: var(--bg-card-soft);
}
.life-stage.is-current {
    border-color: rgba(123, 45, 142, 0.42);
    background: linear-gradient(145deg, rgba(123, 45, 142, 0.10), rgba(184, 134, 11, 0.05));
    box-shadow: 0 5px 16px rgba(58, 27, 72, 0.07);
}
.life-stage-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; color: var(--text-light); font-size: .7rem; }
.life-stage-top b { color: var(--purple); font-size: .65rem; }
.life-stage h4 { margin: 7px 0; color: var(--text-main); font-size: .95rem; }
.life-stage-prompt { color: var(--text-main); font-size: .78rem; line-height: 1.5; }
.life-stage-cue { margin-top: 9px; color: var(--text-dim); font-size: .72rem; line-height: 1.5; }
.life-stage-cue strong { display: block; margin-bottom: 2px; color: var(--purple); font-size: .67rem; }
.life-stages-boundary { margin-top: 12px; color: var(--text-light); font-size: .75rem; line-height: 1.55; }
.relation-entry {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 2px 0 18px;
    padding: 14px 16px;
    border: 1px solid rgba(123, 45, 142, 0.22);
    border-radius: 14px;
    color: var(--text-main);
    background: linear-gradient(135deg, rgba(123, 45, 142, 0.09), rgba(184, 134, 11, 0.06));
    text-align: left;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.relation-entry:hover {
    transform: translateY(-1px);
    border-color: rgba(123, 45, 142, 0.42);
    box-shadow: 0 8px 24px rgba(58, 27, 72, 0.09);
}
.relation-entry:focus-visible {
    outline: 3px solid rgba(123, 45, 142, 0.2);
    outline-offset: 2px;
}
.relation-entry-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    color: #fff;
    background: var(--purple);
    font-size: 1.2rem;
    font-weight: 700;
}
.relation-entry-copy { min-width: 0; }
.relation-entry-copy strong { display: block; font-size: .98rem; margin-bottom: 3px; }
.relation-entry-copy small { display: block; color: var(--text-dim); line-height: 1.45; }
.relation-entry-action {
    color: var(--purple);
    font-size: .86rem;
    font-weight: 700;
    white-space: nowrap;
}
.relation-section {
    scroll-margin-top: 20px;
    border: 1px solid rgba(123, 45, 142, 0.18);
    border-radius: 14px;
    padding: 16px;
    background: rgba(123, 45, 142, 0.025);
    transition: border-color .3s ease, box-shadow .3s ease;
}
.relation-section.relation-attention {
    border-color: rgba(123, 45, 142, 0.55);
    box-shadow: 0 0 0 4px rgba(123, 45, 142, 0.08);
}
.xiuyao-rel-cards {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.xiuyao-rel-card {
    flex: 1;
    padding: 12px;
    background: var(--bg-card-soft);
    border-radius: 10px;
    text-align: center;
}
.xiuyao-rel-label {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 4px;
}
.xiuyao-rel-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--purple);
    margin-bottom: 6px;
}
.xiuyao-rel-desc {
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.5;
}
.xiuyao-rel-arrow {
    font-size: 1.5rem;
    color: var(--purple-light);
    flex-shrink: 0;
}
.xiuyao-rel-detail {
    margin-bottom: 12px;
}
.xiuyao-rel-row {
    font-size: 0.88rem;
    margin-bottom: 2px;
}
.xiuyao-rel-row-desc {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 10px;
    padding-left: 12px;
    line-height: 1.6;
}
.xiuyao-rel-summary {
    padding: 10px 14px;
    background: rgba(123, 45, 142, 0.05);
    border-left: 3px solid var(--purple);
    border-radius: 0 8px 8px 0;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--text-main);
    white-space: pre-wrap;
}
.rel-ji {
    color: var(--ok);
    font-weight: bold;
    font-size: 0.8rem;
}
.rel-xiong {
    color: var(--danger);
    font-weight: bold;
    font-size: 0.8rem;
}
.rel-zhong {
    color: var(--gold);
    font-weight: bold;
    font-size: 0.8rem;
}

/* Analysis text */
.analysis-text {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Deep reading trigger */
.deep-trigger-block {
    text-align: center;
    padding: 20px 0;
}
.btn-deep {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(123, 45, 142, 0.3);
}
.btn-deep:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 45, 142, 0.4);
}
.btn-deep:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.deep-icon {
    font-size: 1.2rem;
}

.deep-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.deep-error {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    padding: 10px;
}

/* Deep reading result blocks */
.deep-block {
    background: var(--bg-card-soft);
    border: 1px solid var(--line-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}
.deep-block h3 {
    color: var(--purple);
    font-size: 0.95rem;
    margin-bottom: 8px;
}
.deep-text {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.75;
}

.deep-summary-block {
    background: linear-gradient(135deg, #f8f0ff, #f0e6fa);
    border-color: var(--purple-light);
}

/* Chat section */
.chat-section {
    border-top: 2px solid var(--line);
    padding-top: 18px;
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px 0;
}

.chat-welcome {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.88rem;
}

.chat-bubble {
    margin-bottom: 12px;
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.6;
}
.chat-user {
    margin-left: auto;
    background: var(--purple);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-assistant {
    background: var(--bg-card-soft);
    border: 1px solid var(--line);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

.chat-quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}
.chat-tag {
    padding: 5px 12px;
    background: var(--purple-bg);
    border: 1px solid var(--line);
    border-radius: 99px;
    font-family: inherit;
    font-size: 0.78rem;
    color: var(--purple);
    cursor: pointer;
    transition: all 0.2s;
}
.chat-tag:hover {
    background: var(--purple);
    color: #fff;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-top: 8px;
}
.chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    background: var(--bg-card-soft);
    color: var(--text-main);
}
.chat-input:focus {
    outline: none;
    border-color: var(--purple);
}
.chat-send-btn {
    padding: 8px 16px;
    background: var(--purple);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
.chat-send-btn:hover {
    background: var(--purple-deep);
}
.chat-send-btn:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}
.chat-new-topic-btn {
    padding: 8px 12px;
    background: var(--bg-inset);
    color: var(--text-dim);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
}
.chat-new-topic-btn:hover {
    background: var(--line-light);
}

/* Loading */
.loading-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.loading-card {
    background: #fff;
    border-radius: 16px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.loading-card p {
    margin-top: 12px;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--line);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
.hero-disclaimer {
    max-width: 720px;
    margin: 10px auto 0;
    color: var(--text-muted, #8b8792);
    font-size: 13px;
}

@media (max-width: 600px) {
    .archetype-block { padding: 14px; }
    .archetype-head { display: block; }
    .archetype-realm { display: inline-block; margin-top: 9px; }
    .archetype-grid { grid-template-columns: 1fr; }
    .relation-entry { grid-template-columns: auto minmax(0, 1fr); padding: 12px; }
    .relation-entry-action { grid-column: 2; }
    .relation-section { padding: 13px; }
}

.language-switcher {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 2;
}
.language-switcher select {
    max-width: 150px;
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: rgba(255, 255, 255, .88);
    color: var(--text-main);
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
}
.policy-page > .language-switcher {
    position: fixed;
    top: 14px;
    right: 16px;
}
.source-language-note {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-left: 3px solid var(--purple);
    border-radius: 7px;
    background: var(--purple-bg);
    color: var(--text-dim);
    font-size: .82rem;
    line-height: 1.55;
}

.hero-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 14px;
}
.hero-nav a {
    color: var(--purple-deep);
    font-size: 0.86rem;
    text-decoration: none;
}
.hero-nav a:hover { text-decoration: underline; }

.notice-card {
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid rgba(180, 140, 70, .35);
    border-radius: 10px;
    background: rgba(180, 140, 70, .08);
    color: var(--text-muted, #666);
    font-size: 13px;
    line-height: 1.65;
}

.privacy-consent {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    max-width: 680px;
    margin: 12px auto 0;
    color: var(--text-muted, #777);
    font-size: 13px;
    line-height: 1.55;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 24px 12px 36px;
    font-size: 13px;
}

.site-footer a { color: var(--text-muted, #777); }

.policy-page {
    max-width: 780px;
    margin: 0 auto;
    padding: 48px 20px 80px;
    line-height: 1.85;
}

.policy-page h1 { margin: 8px 0 18px; font-size: clamp(1.8rem, 5vw, 2.6rem); }
.policy-page h2 { margin: 30px 0 8px; font-size: 20px; }
.policy-page p { color: var(--text-muted, #68636f); }
.policy-page a { color: var(--purple-deep); }
.policy-page .lead { font-size: 1.08rem; color: var(--text-main); }

.content-nav,
.content-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}
.content-nav {
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}
.content-nav a,
.content-footer a { text-decoration: none; }
.content-nav a:hover,
.content-footer a:hover { text-decoration: underline; }
.content-footer {
    margin-top: 40px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.eyebrow {
    margin: 30px 0 4px !important;
    color: var(--purple) !important;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.seo-intro {
    max-width: none;
    margin: 22px 0 0 calc(var(--sidebar-width) + var(--layout-gap));
    padding: clamp(22px, 4vw, 42px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .78);
    box-shadow: var(--shadow);
    line-height: 1.75;
}
.seo-intro h2 { margin-bottom: 10px; font-size: clamp(1.35rem, 3vw, 2rem); }
.seo-intro > div > p:not(.eyebrow) { color: var(--text-dim); margin-top: 8px; }
.info-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}
.info-card-grid article {
    padding: 18px;
    border: 1px solid var(--line-light);
    border-radius: 13px;
    background: var(--bg-card-soft);
}
.info-card-grid h3 { margin-bottom: 7px; font-size: 1rem; }
.info-card-grid p { color: var(--text-dim); font-size: .9rem; }
.info-card-grid a { display: inline-block; margin-top: 12px; color: var(--purple-deep); font-size: .87rem; }

.time-table {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 16px 0 24px;
}
.time-table span {
    padding: 9px 6px;
    border: 1px solid var(--line-light);
    border-radius: 8px;
    background: var(--bg-card-soft);
    text-align: center;
    font-size: .86rem;
}
.next-link { margin-top: 30px; }

.faq-list { margin-top: 22px; }
.faq-list details {
    border-top: 1px solid var(--line);
    padding: 16px 2px;
}
.faq-list details:last-child { border-bottom: 1px solid var(--line); }
.faq-list summary {
    cursor: pointer;
    color: var(--text-main);
    font-weight: 700;
}
.faq-list details p { margin-top: 10px; }

.tool-network {
    margin: 24px 0 8px calc(var(--sidebar-width) + var(--layout-gap));
    padding: 16px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px 20px;
    color: var(--text-dim);
    font-size: .86rem;
}
.tool-network strong { color: var(--text-main); }
.tool-network a { color: var(--purple-deep); text-underline-offset: 3px; }

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .palaces-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dao-summary {
        grid-template-columns: 1fr;
    }
    .split-4 {
        grid-template-columns: 1fr;
    }
    .info-card-grid { grid-template-columns: 1fr; }
    .life-stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .seo-intro, .tool-network { margin-left: 0; }
}

@media (max-width: 500px) {
    .split-2 {
        grid-template-columns: 1fr;
    }
    .palaces-grid {
        grid-template-columns: 1fr 1fr;
    }
    .time-table { grid-template-columns: repeat(2, 1fr); }
    .life-stages-heading { display: block; }
    .life-stages-badge { display: inline-block; margin-top: 9px; }
    .life-stages { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
    .life-stage { flex: 0 0 min(78vw, 260px); scroll-snap-align: start; }
    .language-switcher { position: static; display: block; margin-bottom: 12px; }
    .policy-page > .language-switcher { position: static; }
}
