/* ─── 便签墙：取自 dwell 的暖纸、深墨与克制色彩语言 ─── */
.creative-space {
    --notes-bg: var(--bg);
    --notes-card: #ffffff;
    --notes-panel: #f0eee6;
    --notes-line: #e8e5dc;
    --notes-ink: #2b2a27;
    --notes-dim: #8a867c;
    --notes-accent: #c96442;
    --notes-accent-soft: #d97757;
    --notes-overlay: rgba(40, 38, 34, .38);
    position: relative;
    width: 100%;
    min-height: calc(100dvh - 52px - env(safe-area-inset-top, 0px));
    overflow: visible;
    color: var(--notes-ink);
    background:
        radial-gradient(circle at 18% 24%, rgba(43, 42, 39, .022), transparent 38%),
        radial-gradient(circle at 82% 76%, rgba(43, 42, 39, .018), transparent 42%),
        var(--notes-bg);
}

[data-theme="dark"] .creative-space {
    --notes-bg: var(--bg);
    --notes-card: #30302e;
    --notes-panel: #383836;
    --notes-line: #3d3d3a;
    --notes-ink: #f5f4ef;
    --notes-dim: #a3a099;
    --notes-accent: #d97757;
    --notes-accent-soft: #e28b6e;
    --notes-overlay: rgba(0, 0, 0, .56);
}

/* The header dissolves into the paper instead of becoming a separate app bar. */
.creative-space-header {
    position: sticky;
    z-index: 8;
    top: calc(52px + env(safe-area-inset-top, 0px));
    min-height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px max(18px, calc((100vw - 920px) / 2 + 18px)) 0;
    background: linear-gradient(to bottom, var(--notes-bg) 0%, color-mix(in srgb, var(--notes-bg) 86%, transparent) 62%, transparent 100%);
    pointer-events: none;
}

.creative-space-back {
    position: absolute;
    left: max(18px, calc((100vw - 920px) / 2 + 18px));
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--notes-dim);
    background: color-mix(in srgb, var(--notes-bg) 78%, transparent);
    border-radius: 50%;
    pointer-events: auto;
    transition: color var(--transition), background var(--transition), transform var(--transition);
}

.creative-space-back:hover,
.creative-space-back:focus-visible {
    color: var(--notes-ink);
    background: var(--notes-panel);
}

.creative-space-back:active {
    transform: scale(.94);
}

.creative-space-back svg {
    width: 18px;
    height: 18px;
}

.creative-space-heading {
    min-width: 0;
    text-align: center;
    pointer-events: none;
}

.creative-space-heading h1 {
    margin: 0;
    color: var(--notes-ink);
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .08em;
}

.creative-space-heading p {
    margin: 4px 0 0;
    color: var(--notes-dim);
    font-size: 10px;
    line-height: 1.25;
    letter-spacing: .08em;
}

.creative-companion-area {
    position: absolute;
    right: max(18px, calc((100vw - 920px) / 2 + 18px));
    width: 40px;
    height: 40px;
    pointer-events: auto;
}

.creative-companion-slot {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.creative-companion-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--notes-dim);
    background: color-mix(in srgb, var(--notes-panel) 72%, transparent);
    border: 1px dashed color-mix(in srgb, var(--notes-dim) 42%, transparent);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 13px;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.creative-companion-slot:hover .creative-companion-avatar,
.creative-companion-slot:focus-visible .creative-companion-avatar {
    background: var(--notes-panel);
    border-color: var(--notes-dim);
    transform: translateY(-1px);
}

.creative-companion-avatar.has-companion {
    color: var(--notes-ink);
    background: var(--notes-card);
    border-color: var(--notes-line);
    border-style: solid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .09);
}

.creative-companion-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.creative-companion-change {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 17px;
    height: 17px;
    display: grid;
    place-items: center;
    color: var(--notes-dim);
    background: var(--notes-card);
    border: 1px solid var(--notes-line);
    border-radius: 50%;
}

.creative-companion-change[hidden] {
    display: none;
}

.creative-companion-change svg {
    width: 11px;
    height: 11px;
}

.creative-companion-avatar.is-looking-together {
    animation: creativeCompanionLookTogether 1.08s cubic-bezier(.18, .82, .3, 1);
}

@keyframes creativeCompanionLookTogether {
    0%, 100% { transform: rotate(0) scale(1); }
    28%, 78% { transform: translateX(-2px) rotate(-3deg) scale(1.025); }
}

.creative-desk-scroll {
    position: relative;
    z-index: 1;
    min-height: 660px;
    overflow-x: hidden;
    overflow-y: visible;
}

.creative-desk-scroll::-webkit-scrollbar {
    display: none;
}

.creative-desk-surface {
    position: relative;
    width: min(100%, 920px);
    min-height: var(--creative-board-height, 660px);
    margin: 0 auto;
    overflow: hidden;
    background: transparent;
}

.creative-desk-surface::before {
    content: '';
    position: absolute;
    z-index: 0;
    inset: 0;
    opacity: .42;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(43, 42, 39, .075) .42px, transparent .65px),
        radial-gradient(circle at 78% 68%, rgba(43, 42, 39, .055) .36px, transparent .62px);
    background-size: 23px 19px, 31px 27px;
    pointer-events: none;
}

[data-theme="dark"] .creative-desk-surface::before {
    opacity: .18;
    filter: invert(1);
}

.creative-desk-surface::after {
    content: '';
    position: absolute;
    z-index: 0;
    inset: 0;
    box-shadow: inset 0 -76px 110px color-mix(in srgb, var(--notes-bg) 82%, transparent);
    pointer-events: none;
}

.creative-notes-layer {
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
}

/* Notes stay light in dark mode, like real paper on a dark desk. */
.creative-note {
    --note-paper: #f8e5de;
    --note-ink: #3d3830;
    --note-muted: rgba(61, 56, 48, .62);
    --note-tape: rgba(240, 232, 212, .9);
    position: absolute;
    width: 46%;
    min-width: 174px;
    max-width: 220px;
    min-height: 146px;
    display: flex;
    flex-direction: column;
    padding: 20px 16px 13px;
    overflow: visible;
    color: var(--note-ink);
    background-color: var(--note-paper);
    border: 0;
    border-radius: 6px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .13);
    cursor: grab;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transform: rotate(var(--note-rotation, 0deg));
    transform-origin: 50% 8%;
    transition: box-shadow .18s ease, transform .18s ease;
}

.creative-note.paper-amber {
    --note-paper: #f5e6c8;
}

.creative-note.paper-sage {
    --note-paper: #e7ede2;
}

.creative-note.paper-linen {
    --note-paper: #f0eee6;
}

.creative-note.shape-square {
    width: 40%;
    min-width: 166px;
    max-width: 190px;
    min-height: 158px;
}

.creative-note.shape-wide {
    width: 58%;
    min-width: 196px;
    max-width: 270px;
    min-height: 116px;
}

.creative-note.note-lined {
    background-image: repeating-linear-gradient(to bottom, transparent 0 21px, rgba(70, 90, 130, .12) 21px 22px);
    background-position: 0 37px;
}

.creative-note-author {
    position: absolute;
    z-index: 4;
    top: 8px;
    right: 10px;
    min-width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    color: color-mix(in srgb, var(--note-ink) 58%, transparent);
    background: color-mix(in srgb, var(--note-paper) 72%, white 28%);
    border: 1px solid color-mix(in srgb, var(--note-ink) 12%, transparent);
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
    font-family: var(--font-body);
    font-size: 9px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0;
    pointer-events: none;
}

.creative-note.author-assistant .creative-note-author {
    color: var(--note-ink);
    background: color-mix(in srgb, #e7ede2 80%, white 20%);
    font-size: 13px;
}

.creative-note h2 {
    padding-right: 25px;
}

.creative-note::before,
.creative-note::after {
    content: '';
    position: absolute;
    z-index: 3;
    background: var(--note-tape);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
    pointer-events: none;
}

.creative-note::before {
    top: -12px;
    left: 50%;
    width: 14px;
    height: 30px;
    margin-left: -7px;
    transform: rotate(2deg);
}

.creative-note::after {
    display: none;
}

.creative-note.tape-horizontal::before {
    top: -7px;
    left: 50%;
    width: 48px;
    height: 15px;
    margin-left: -24px;
    transform: rotate(-2deg);
}

.creative-note.tape-left::before {
    top: -8px;
    left: -12px;
    width: 44px;
    height: 14px;
    margin: 0;
    transform: rotate(-38deg);
}

.creative-note.tape-right::before,
.creative-note.tape-double::before {
    top: -8px;
    right: -12px;
    left: auto;
    width: 44px;
    height: 14px;
    margin: 0;
    transform: rotate(38deg);
}

.creative-note.tape-double::after {
    right: auto;
    bottom: -7px;
    left: -13px;
    width: 44px;
    height: 14px;
    display: block;
    transform: rotate(38deg);
}

.creative-note:hover,
.creative-note:focus-visible {
    box-shadow: 0 8px 22px rgba(0, 0, 0, .19);
    outline: none;
    transform: translateY(-2px) rotate(var(--note-rotation, 0deg));
}

.creative-note.is-dragging {
    cursor: grabbing;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
    transform: translateY(-4px) rotate(0deg) scale(1.018);
    transition: box-shadow .12s ease, transform .12s ease;
}

[data-theme="dark"] .creative-note {
    box-shadow: 0 3px 14px rgba(0, 0, 0, .48);
}

.creative-note.is-being-shared {
    animation: creativeNoteShared 1.16s ease both;
}

.creative-note-shared-view {
    position: absolute;
    z-index: 40 !important;
    margin: 0;
    pointer-events: none;
    touch-action: none;
    transition: none !important;
    will-change: transform, opacity;
}

@keyframes creativeNoteShared {
    0%, 22% { opacity: 1; transform: rotate(var(--note-rotation, 0deg)) scale(1); }
    48%, 82% { opacity: .36; transform: rotate(0) scale(.985); }
    100% { opacity: 1; transform: rotate(var(--note-rotation, 0deg)) scale(1); }
}

.creative-note h2 {
    margin: 0 0 7px;
    overflow: hidden;
    color: var(--note-ink);
    font-family: var(--font-display);
    font-size: 15.5px;
    font-weight: 600;
    line-height: 1.55;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.creative-note-copy {
    margin: 0;
    overflow: hidden;
    color: var(--note-muted);
    font-family: var(--font-body);
    font-size: 11.5px;
    line-height: 1.72;
    white-space: pre-line;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.creative-note.shape-wide .creative-note-copy {
    -webkit-line-clamp: 3;
}

.creative-note time {
    margin-top: auto;
    padding-top: 11px;
    color: color-mix(in srgb, var(--note-ink) 47%, transparent);
    font-family: var(--font-mono);
    font-size: 8.5px;
    line-height: 1.2;
    letter-spacing: .04em;
}

.creative-empty {
    position: absolute;
    z-index: 1;
    top: 43%;
    left: 50%;
    display: grid;
    justify-items: center;
    gap: 18px;
    color: var(--notes-dim);
    text-align: center;
    transform: translate(-50%, -50%);
    transition: opacity .2s ease;
}

.creative-empty[hidden] {
    display: none;
}

.creative-empty span {
    position: relative;
    width: 78px;
    height: 62px;
    background: var(--notes-panel);
    border-radius: 4px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .08);
    transform: rotate(-2deg);
}

.creative-empty span::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 50%;
    width: 32px;
    height: 12px;
    margin-left: -16px;
    background: rgba(224, 216, 196, .78);
    border-radius: 2px;
    transform: rotate(2deg);
}

.creative-empty span::after {
    content: '+';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--notes-dim);
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 300;
}

.creative-empty p {
    margin: 0;
    font-family: var(--font-display);
    font-size: 13px;
    line-height: 1.4;
}

.creative-companion-whisper {
    position: absolute;
    z-index: 4;
    top: 16px;
    right: 18px;
    max-width: 230px;
    margin: 0;
    padding: 9px 12px;
    color: var(--notes-dim);
    background: color-mix(in srgb, var(--notes-card) 86%, transparent);
    border: 1px solid var(--notes-line);
    border-radius: 13px 4px 13px 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .06);
    font-size: 11px;
    line-height: 1.55;
}

.creative-companion-whisper[hidden] {
    display: none;
}

.creative-scatter {
    position: absolute;
    z-index: 5;
    left: max(18px, calc((100vw - 920px) / 2 + 18px));
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 14px));
    min-width: 72px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 13px;
    color: var(--notes-dim);
    background: color-mix(in srgb, var(--notes-card) 72%, transparent);
    border: 1px solid var(--notes-line);
    border-radius: 999px;
    -webkit-backdrop-filter: blur(14px) saturate(1.25);
    backdrop-filter: blur(14px) saturate(1.25);
    box-shadow: 0 3px 14px rgba(0, 0, 0, .08), inset 0 1px rgba(255, 255, 255, .45);
    font-size: 11px;
    transition: color var(--transition), background var(--transition), transform var(--transition);
}

.creative-scatter[hidden] {
    display: none;
}

.creative-scatter:hover,
.creative-scatter:focus-visible {
    color: var(--notes-ink);
    background: var(--notes-card);
}

.creative-scatter:active {
    transform: scale(.96);
}

.creative-scatter svg {
    width: 14px;
    height: 14px;
}

.creative-compose-dock {
    position: fixed;
    z-index: 65;
    right: max(18px, calc((100vw - 920px) / 2 + 18px));
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 14px));
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
}

#page-mood.active .creative-space.is-controls-visible .creative-compose-dock {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.creative-add {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--notes-accent);
    border-radius: 50%;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--notes-accent) 24%, transparent), inset 0 1px rgba(255, 255, 255, .24);
    transition: transform .2s ease, background var(--transition), box-shadow var(--transition);
}

.creative-add:hover,
.creative-add:focus-visible {
    background: var(--notes-accent-soft);
    box-shadow: 0 10px 25px color-mix(in srgb, var(--notes-accent) 30%, transparent), inset 0 1px rgba(255, 255, 255, .28);
    transform: translateY(-2px);
}

.creative-add:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--notes-accent) 42%, transparent);
    outline-offset: 3px;
}

.creative-add:active {
    transform: translateY(0) scale(.94);
}

.creative-add svg {
    width: 21px;
    height: 21px;
}

/* Editor and companion picker share the same warm card and ink system. */
.creative-sheet-backdrop {
    position: fixed;
    z-index: 80;
    inset: 0;
    background: var(--notes-overlay);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.creative-sheet-backdrop[hidden],
.creative-note-sheet[hidden],
.creative-companion-picker[hidden] {
    display: none;
}

.creative-note-sheet,
.creative-companion-picker {
    position: fixed;
    z-index: 81;
    right: 0;
    bottom: 0;
    left: 0;
    width: min(calc(100% - 24px), 620px);
    max-height: min(88dvh, 760px);
    margin: 0 auto;
    padding: 24px 24px max(24px, calc(env(safe-area-inset-bottom, 0px) + 18px));
    overflow-y: auto;
    color: var(--notes-ink);
    background: var(--notes-card);
    border: 1px solid var(--notes-line);
    border-bottom: 0;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -18px 54px rgba(30, 28, 24, .16);
}

[data-theme="dark"] .creative-note-sheet,
[data-theme="dark"] .creative-companion-picker {
    box-shadow: 0 -18px 54px rgba(0, 0, 0, .42);
}

.creative-sheet-handle {
    width: 36px;
    height: 4px;
    margin: -11px auto 18px;
    background: color-mix(in srgb, var(--notes-dim) 26%, transparent);
    border-radius: 3px;
}

.creative-note-sheet header,
.creative-companion-picker header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.creative-note-sheet header h2,
.creative-companion-picker header h2 {
    margin: 0;
    color: var(--notes-ink);
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
}

.creative-note-sheet header button,
.creative-companion-picker header button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: var(--notes-dim);
    background: var(--notes-panel);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 18px;
    transition: color var(--transition), background var(--transition), transform var(--transition);
}

.creative-note-sheet header button:hover,
.creative-note-sheet header button:focus-visible,
.creative-companion-picker header button:hover,
.creative-companion-picker header button:focus-visible {
    color: var(--notes-ink);
    background: color-mix(in srgb, var(--notes-panel) 72%, var(--notes-line));
}

.creative-note-sheet header button:active,
.creative-companion-picker header button:active {
    transform: scale(.94);
}

.creative-editor-title,
.creative-editor-body {
    display: block;
}

.creative-editor-title > span,
.creative-editor-body > span {
    display: block;
    margin: 0 0 8px;
    color: var(--notes-dim);
    font-size: 11px;
    letter-spacing: .12em;
}

.creative-editor-title input,
.creative-editor-body textarea {
    background: transparent;
    border: 0;
    outline: 0;
}

.creative-editor-title input {
    width: 100%;
    padding: 4px 0 13px;
    color: var(--notes-ink);
    border-bottom: 1px solid var(--notes-line);
    font-family: var(--font-display);
    font-size: 21px;
    line-height: 1.5;
}

.creative-editor-title input::placeholder,
.creative-editor-body textarea::placeholder {
    color: color-mix(in srgb, var(--notes-dim) 56%, transparent);
}

.creative-editor-body {
    margin-top: 20px;
}

.creative-editor-body textarea {
    width: 100%;
    min-height: 220px;
    max-height: 42vh;
    padding: 0;
    resize: none;
    color: var(--notes-ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.9;
}

.creative-note-sheet footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 18px;
}

.creative-save {
    min-width: 96px;
    min-height: 42px;
    padding: 9px 18px;
    color: #fff;
    background: var(--notes-accent);
    border-radius: 999px;
    font-size: 13px;
    box-shadow: 0 5px 15px color-mix(in srgb, var(--notes-accent) 20%, transparent);
}

.creative-save:hover,
.creative-save:focus-visible {
    background: var(--notes-accent-soft);
}

.creative-delete {
    margin-right: auto;
    padding: 9px 0;
    color: color-mix(in srgb, #c0392b 78%, var(--notes-ink));
    font-size: 12px;
}

.creative-companion-note {
    margin: -10px 0 16px;
    color: var(--notes-dim);
    font-size: 12px;
    line-height: 1.6;
}

.creative-companion-list {
    display: grid;
    gap: 7px;
}

.creative-companion-option {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    padding: 7px 10px;
    color: var(--notes-ink);
    border: 1px solid transparent;
    border-radius: 13px;
    text-align: left;
    transition: background var(--transition), border-color var(--transition);
}

.creative-companion-option:hover,
.creative-companion-option:focus-visible {
    background: var(--notes-panel);
}

.creative-companion-option.is-selected {
    background: color-mix(in srgb, var(--notes-panel) 72%, transparent);
    border-color: var(--notes-line);
}

.creative-companion-option-avatar {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--notes-dim);
    background: var(--notes-panel);
    border: 1px solid var(--notes-line);
    border-radius: 50%;
    font-size: 13px;
}

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

.creative-companion-option-copy {
    min-width: 0;
}

.creative-companion-option-copy strong {
    display: block;
    overflow: hidden;
    font-size: 13px;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.creative-companion-option > b {
    color: var(--notes-accent);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

@media (max-width: 920px) {
    .creative-desk-surface { width: 100%; }
}

@media (max-width: 620px) {
    .creative-space-header {
        padding-inline: 14px;
    }

    .creative-space-back {
        left: 12px;
    }

    .creative-companion-area {
        right: 12px;
    }

    .creative-note {
        width: 44vw;
        min-width: 152px;
        max-width: 184px;
        min-height: 140px;
        padding: 19px 14px 12px;
    }

    .creative-note.shape-square {
        width: 41vw;
        min-width: 146px;
        max-width: 172px;
        min-height: 148px;
    }

    .creative-note.shape-wide {
        width: 56vw;
        min-width: 184px;
        max-width: 222px;
        min-height: 112px;
    }

    .creative-compose-dock {
        right: max(16px, env(safe-area-inset-right, 0px));
    }

    .creative-scatter {
        left: max(16px, env(safe-area-inset-left, 0px));
    }

    .creative-note-sheet,
    .creative-companion-picker {
        width: 100%;
        padding-inline: 20px;
        border-inline: 0;
        border-radius: 22px 22px 0 0;
    }

    .creative-editor-body textarea {
        min-height: 210px;
    }
}

@media (max-width: 360px) {
    .creative-note {
        min-width: 146px;
    }

    .creative-note.shape-wide {
        min-width: 176px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .creative-note,
    .creative-add {
        transition-duration: .01ms !important;
    }

    .creative-companion-avatar.is-looking-together,
    .creative-note.is-being-shared {
        animation: none;
    }
}
