:root {
    --dream-purple: #6f3fb0;
    --dream-purple-deep: #432066;
    --dream-lilac: #f4edff;
    --dream-gold: #bd8428;
}

.dream-shell {
    box-sizing: border-box;
    width: 100%;
    max-width: 880px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

body:has(.dream-shell) > .topbar { max-width: 880px; }
.dream-page-head { display: flex; align-items: center; gap: 14px; padding: 4px 2px 2px; }
.dream-back {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--text);
    background: var(--surface);
    text-decoration: none;
}

.dream-page-head span, .dream-section-title small, .dream-result-hero > span {
    color: #8e58c9;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .16em;
}

.dream-page-head h1 { margin: 3px 0 2px; font-size: 22px; }
.dream-page-head p { margin: 0; color: var(--text-soft); font-size: 11px; line-height: 1.45; }

.dream-chat-card, .dream-result-card, .dream-result-hero, .dream-history {
    box-sizing: border-box;
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--line) 76%, #b68be3 24%);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: 0 14px 35px rgba(68, 40, 96, .08);
}

.dream-chat-card { overflow: hidden; padding: 24px; }
.dream-chat-intro {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.dream-chat-intro > span {
    display: grid;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #9665d1, #43206b);
    box-shadow: 0 8px 18px rgba(84, 37, 126, .24);
    font-size: 24px;
}

.dream-chat-intro h2 { margin: 0 0 4px; font-size: 18px; }
.dream-chat-intro p { margin: 0; color: var(--text-soft); font-size: 11px; line-height: 1.5; }
.dream-step { display: grid; gap: 14px; margin-top: 14px; opacity: 1; }
.dream-step[hidden] { display: none; }
.dream-step.is-complete { opacity: .64; }
.dream-step.is-complete .dream-step-actions { display: none; }
.dream-question-progress {
    margin: 2px 0 -7px min(10%, 56px);
    color: var(--dream-purple);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.dream-bubble {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 4px 15px 15px;
    background: var(--dream-lilac);
}

.dream-bubble span { color: var(--dream-purple); font-size: 15px; }
.dream-bubble p { margin: 0; color: #45295f; font-size: 12px; font-weight: 700; line-height: 1.55; }
.dream-choice-grid, .dream-option-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-left: min(10%, 56px);
}

.dream-entry-choice button, .dream-option-grid span {
    box-sizing: border-box;
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface-soft);
    font: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.35;
    text-align: center;
    cursor: pointer;
    transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.dream-entry-choice button:hover, .dream-entry-choice button.is-selected, .dream-option-grid input:checked + span {
    border-color: #8e58cf;
    color: #5b2d8e;
    background: #f3eaff;
    box-shadow: inset 0 0 0 1px rgba(126, 73, 184, .13);
}

.dream-entry-choice button:hover, .dream-option-grid label:hover span { transform: translateY(-1px); }
.dream-option-grid label { position: relative; }
.dream-option-grid input { position: absolute; opacity: 0; pointer-events: none; }
.dream-option-grid input:focus-visible + span { outline: 2px solid #8e58cf; outline-offset: 2px; }
.dream-answer-ack {
    margin: -2px 0 0 min(10%, 56px);
    padding: 9px 12px;
    border-left: 3px solid #9b67d0;
    border-radius: 0 10px 10px 0;
    color: #67427f;
    background: color-mix(in srgb, var(--surface) 76%, #ead9ff 24%);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.5;
    animation: dream-ack-in .2s ease-out;
}
.dream-answer-ack[hidden] { display: none; }
.dream-option-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dream-text-answer { position: relative; display: block; margin-left: min(10%, 56px); }

.dream-text-answer textarea {
    box-sizing: border-box;
    width: 100%;
    resize: vertical;
    min-height: 120px;
    padding: 13px 15px 28px;
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    color: var(--text);
    background: var(--surface-soft);
    font: inherit;
    font-size: 12px;
    line-height: 1.55;
}

.dream-text-answer textarea:focus { border-color: #8e58cf; box-shadow: 0 0 0 3px rgba(142, 88, 207, .1); }
.dream-text-answer small { position: absolute; right: 11px; bottom: 9px; color: var(--text-soft); font-size: 9px; }
.dream-step-actions { display: flex; justify-content: flex-end; gap: 8px; margin-left: min(10%, 56px); }
.dream-step-actions button, .dream-real-help a, .dream-number-card a {
    min-height: 40px;
    padding: 0 18px;
    border-radius: 999px;
    font: inherit;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
}

.dream-primary { border: 0; color: #fff; background: linear-gradient(135deg, #8250bd, #452065); box-shadow: 0 7px 16px rgba(72, 31, 103, .2); }
.dream-primary:disabled { cursor: wait; opacity: .65; }
.dream-secondary { border: 1px solid var(--line); color: var(--text-soft); background: var(--surface); }
.dream-real-help {
    margin-left: min(10%, 56px);
    padding: 15px;
    border: 1px solid rgba(188, 129, 39, .28);
    border-radius: 14px;
    background: #fff8e7;
}

.dream-real-help[hidden] { display: none; }
.dream-real-help strong { color: #83541b; font-size: 12px; }
.dream-real-help p { margin: 6px 0 11px; color: #705b40; font-size: 11px; line-height: 1.55; }
.dream-real-help a { display: inline-grid; min-height: 34px; place-items: center; color: #fff; background: #8a5c22; text-decoration: none; }
.dream-message, .dream-inline-error { padding: 10px 12px; border-radius: 11px; font-size: 11px; line-height: 1.45; }
.dream-message { margin-bottom: 14px; }
.dream-message.is-error, .dream-inline-error { border: 1px solid rgba(197, 58, 68, .28); color: #af3540; background: rgba(197, 58, 68, .07); }
.dream-message.is-warning { border: 1px solid rgba(188, 129, 39, .28); color: #86591c; background: rgba(218, 160, 55, .1); }
.dream-inline-error { margin: 0 0 0 min(10%, 56px); }
.dream-owner-note { margin: 2px 0 0 min(10%, 56px); color: var(--text-soft); font-size: 9px; line-height: 1.45; text-align: right; }
.dream-reading, .dream-recognition {
    margin: 14px 0 4px min(10%, 56px);
    border: 1px solid rgba(142, 88, 207, .24);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 82%, #efe3ff 18%);
}
.dream-reading[hidden], .dream-recognition[hidden] { display: none; }
.dream-reading { display: flex; align-items: center; gap: 9px; padding: 11px 13px; color: var(--dream-purple); }
.dream-reading span { animation: dream-reading-pulse 1.1s ease-in-out infinite alternate; font-size: 16px; }
.dream-reading p { margin: 0; font-size: 11px; font-weight: 800; }
.dream-recognition { display: grid; gap: 10px; padding: 13px 14px; }
.dream-recognition strong { color: var(--dream-purple); font-size: 10px; }
.dream-recognition p { margin: 4px 0 0; color: var(--text-soft); font-size: 10px; line-height: 1.55; }
.dream-recognition-signals, .dream-result-recognition div { display: flex; flex-wrap: wrap; gap: 6px; }
.dream-recognition-signals span, .dream-result-recognition div span {
    padding: 5px 8px;
    border: 1px solid rgba(142, 88, 207, .22);
    border-radius: 999px;
    color: #6b3595;
    background: color-mix(in srgb, var(--surface) 72%, #ead9ff 28%);
    font-size: 9px;
    font-weight: 800;
}
@keyframes dream-reading-pulse { to { opacity: .35; transform: rotate(12deg) scale(.88); } }
@keyframes dream-ack-in { from { opacity: 0; transform: translateY(-3px); } }

.dream-results { display: grid; min-width: 0; gap: 14px; scroll-margin-top: 12px; outline: none; }
.dream-result-hero { padding: 24px; background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface) 84%, #ead9ff 16%)); }
.dream-result-hero h2 { margin: 6px 0; font-family: Georgia, "Times New Roman", serif; font-size: 25px; }
.dream-result-hero p { margin: 0; color: var(--text-soft); font-size: 12px; line-height: 1.6; }
.dream-result-hero blockquote { margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid #a574d2; border-radius: 0 10px 10px 0; color: var(--text); background: color-mix(in srgb, var(--surface) 72%, #ead9ff 28%); font-size: 10px; line-height: 1.55; }
.dream-result-recognition { display: grid; gap: 7px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.dream-result-recognition > strong { color: var(--dream-purple); font-size: 10px; }
.dream-result-recognition > p { font-size: 10px; }
.dream-result-recognition div { margin-top: 1px; }
.dream-result-card, .dream-history { padding: 20px; }
.dream-section-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.dream-section-title > span {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #a56add, #573080);
    font-size: 10px;
    font-weight: 900;
}

.dream-section-title h2 { margin: 2px 0 0; font-size: 17px; }
.dream-section-compact { align-items: center; }
.dream-character-card { border-color: rgba(150, 93, 203, .36); background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface) 86%, #efe1ff 14%)); }
.dream-character-lead { margin: 0 0 12px; color: var(--text); font-size: 13px; font-weight: 700; line-height: 1.65; }
.dream-result-card ul, .dream-numbered-list { display: grid; gap: 9px; margin: 0; padding-left: 19px; }
.dream-result-card li { color: var(--text-soft); font-size: 11px; line-height: 1.6; }
.dream-result-card li::marker { color: var(--dream-purple); font-weight: 900; }
.dream-theme-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dream-theme-list article { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.dream-theme-list header { display: flex; justify-content: space-between; gap: 8px; color: var(--text); font-size: 11px; }
.dream-theme-list header span { color: var(--dream-purple); font-weight: 900; }
.dream-theme-list i { display: block; height: 6px; margin: 8px 0; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--line) 70%, transparent); }
.dream-theme-list b { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8150bb, #d7a4f2); }
.dream-theme-list p { margin: 0; color: var(--text-soft); font-size: 10px; line-height: 1.5; }
.dream-result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dream-result-grid .dream-result-card { height: 100%; }
.dream-safety-note { padding: 15px 17px; border: 1px solid rgba(197, 111, 44, .3); border-radius: 15px; color: #744619; background: #fff7e6; }
.dream-safety-note strong { font-size: 12px; }
.dream-safety-note p { margin: 5px 0 0; font-size: 11px; line-height: 1.55; }
.dream-number-card { text-align: center; }
.dream-number-card .dream-section-title { justify-content: center; text-align: left; }
.dream-number-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0 10px; }
.dream-number-grid strong { padding: 12px 4px; border: 1px solid rgba(154, 94, 199, .26); border-radius: 12px; color: #6b3595; background: linear-gradient(145deg, #fbf7ff, #f0e2ff); font-size: 17px; letter-spacing: .08em; }
.dream-number-card > p { margin: 0 0 12px; color: var(--text-soft); font-size: 9px; }
.dream-number-card a { display: inline-grid; min-height: 36px; place-items: center; color: #fff; background: linear-gradient(135deg, #8250bd, #452065); text-decoration: none; }
.real-fact-hero { background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface) 84%, #fff0c9 16%)); }
.real-fact-match-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.real-fact-match-grid article { position: relative; display: grid; min-width: 0; gap: 7px; padding: 14px; border: 1px solid rgba(190, 132, 40, .25); border-radius: 14px; background: color-mix(in srgb, var(--surface) 83%, #fff2ce 17%); }
.real-fact-match-grid article > strong { color: #8c5b12; font-size: 24px; letter-spacing: .1em; }
.real-fact-match-grid em { position: absolute; top: 11px; right: 11px; padding: 4px 7px; border-radius: 999px; color: #7b4b08; background: rgba(220, 162, 54, .16); font-size: 8px; font-style: normal; font-weight: 900; }
.real-fact-match-grid p { display: grid; gap: 2px; margin: 0; color: var(--text); font-size: 10px; line-height: 1.45; }
.real-fact-match-grid p span:first-child { font-size: 12px; font-weight: 900; }
.real-fact-match-grid small { color: var(--text-soft); font-size: 8px; font-weight: 800; }
.real-fact-source-note { margin: 13px 0 10px; color: var(--text-soft); font-size: 9px; line-height: 1.5; text-align: center; }
.dream-fact-predict-link { display: grid; width: fit-content; min-height: 36px; margin: 0 auto; padding: 0 18px; place-items: center; border-radius: 999px; color: #fff; background: linear-gradient(135deg, #b47a1d, #75450b); font-size: 10px; font-weight: 900; text-decoration: none; }
.dream-history-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.dream-history-grid a { display: grid; min-width: 0; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; color: inherit; background: var(--surface-soft); text-decoration: none; }
.dream-history-grid a:hover { border-color: rgba(142, 88, 207, .55); }
.dream-history-grid span { overflow: hidden; font-size: 11px; font-weight: 900; text-overflow: ellipsis; white-space: nowrap; }
.dream-history-grid strong { color: #7542a3; font-size: 10px; }
.dream-history-grid small { overflow: hidden; color: var(--text-soft); font-size: 8px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.dream-disclaimer { margin: 0; color: var(--text-soft); font-size: 9px; line-height: 1.55; text-align: center; }

body.dark .dream-bubble { background: rgba(96, 52, 133, .36); }
body.dark .dream-bubble p { color: #eadcff; }
body.dark .dream-entry-choice button:hover, body.dark .dream-entry-choice button.is-selected, body.dark .dream-option-grid input:checked + span { color: #ead8ff; background: rgba(124, 70, 171, .34); }
body.dark .dream-answer-ack { color: #e0c9f4; background: rgba(96, 52, 133, .24); }
body.dark .dream-real-help, body.dark .dream-safety-note { color: #f2d6a1; background: rgba(105, 66, 17, .28); }
body.dark .dream-real-help p { color: #ddc9a5; }
body.dark .dream-number-grid strong { color: #e0bcff; background: rgba(102, 53, 142, .3); }
body.dark .dream-recognition-signals span, body.dark .dream-result-recognition div span { color: #e0bcff; }

@media (max-width: 640px) {
    .dream-shell { padding-right: 10px; padding-left: 10px; }
    .dream-chat-card, .dream-result-card, .dream-history { padding: 16px; border-radius: 17px; }
    .dream-result-hero { padding: 19px; border-radius: 17px; }
    .dream-choice-grid, .dream-option-grid, .dream-text-answer, .dream-step-actions, .dream-real-help, .dream-reading, .dream-recognition, .dream-question-progress, .dream-answer-ack { margin-left: 0; }
    .dream-bubble { max-width: 94%; }
    .dream-option-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dream-theme-list, .dream-result-grid, .dream-history-grid, .real-fact-match-grid { grid-template-columns: 1fr; }
    .dream-number-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dream-owner-note, .dream-inline-error { margin-left: 0; }
}

@media (max-width: 380px) {
    .dream-choice-grid, .dream-option-grid { grid-template-columns: 1fr; }
    .dream-page-head h1 { font-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
    .dream-entry-choice button, .dream-option-grid span { transition: none; }
    .dream-reading span, .dream-answer-ack { animation: none; }
}
