/* 抽屉：沿用世界书的玉色玻璃质感；卷轴两端是木轴，句子是一叠可滑动的卡片。 */
:root { --drawer-rod: #8a6a4a; --drawer-rod-light: #b8946b; --drawer-paper: #fbf7ee; --drawer-paper-edge: #e9dfcb; --drawer-ink: #3b3328; }

/* 入口：三张卡片扇形展开 */
.memory-entry-card:nth-child(1) { --card-x: -62px; --card-angle: -14deg; }
.memory-entry-card:nth-child(2) { --card-x: 0px; --card-angle: 0deg; }
.memory-entry-card:nth-child(3) { --card-x: 62px; --card-angle: 14deg; }
.memory-deck.is-expanded { height: 386px; }
.memory-deck.is-expanded .memory-entry-card:nth-child(3) { top: 260px; }

.drawer { display: grid; gap: 14px; min-width: 0; }
.drawer-motto { margin: 4px 0 0; text-align: center; font-size: 15px; letter-spacing: .14em; color: var(--accent-ink); font-style: italic; }
.drawer-status { min-height: 1em; margin: 0; color: var(--accent-ink); font-size: 13px; white-space: pre-wrap; }
.drawer-status:empty { display: none; }
.drawer-muted, .drawer-meta { color: var(--muted); font-size: 12px; line-height: 1.6; }
.drawer-muted { margin: 4px 0; }
.drawer-body { display: grid; gap: 14px; min-width: 0; }
.drawer-footer { display: flex; justify-content: center; gap: 18px; padding-bottom: 8px; }

.drawer-layers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: #ffffff38; border: 1px solid #ffffff80; }
.drawer-layer { min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--accent-ink); font: inherit; font-size: 14px; cursor: pointer; }
.drawer-layer.is-active { background: #ffffffb0; font-weight: 650; box-shadow: 0 2px 8px #123d3018; }

.drawer-button, .drawer-dialog button.drawer-button { min-height: 40px; padding: 8px 14px; border: 1px solid #ffffff90; border-radius: 12px; background: var(--jade-shade, #dbece2); color: var(--accent-ink); font: inherit; font-size: 14px; cursor: pointer; }
.drawer-button.primary { background: var(--accent-ink); color: #fff; border-color: transparent; }
.drawer-button.danger { color: #9b3b2f; }
.drawer-button:disabled { opacity: .45; cursor: default; }
.drawer-link { min-height: 36px; padding: 6px 4px; border: 0; background: none; color: var(--accent-ink); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.drawer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.drawer-actions.is-small { gap: 2px 12px; }
.drawer-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.drawer select, .drawer-dialog select { min-height: 38px; padding: 6px 10px; border: 1px solid #779c8760; border-radius: 10px; background: #ffffff90; color: inherit; font: inherit; font-size: 14px; }

.drawer-form { display: grid; gap: 12px; padding: 16px; border: 1px solid #ffffffa0; border-radius: 18px; background: #ffffff40; }
.drawer-form h3 { margin: 0; font-size: 17px; }
.drawer-form label, .drawer-dialog label { display: grid; gap: 6px; font-size: 13px; color: var(--accent-ink); }
.drawer-form .drawer-inline label { flex: 1 1 140px; }
.drawer input:not([type=checkbox]):not([type=file]), .drawer textarea, .drawer-dialog input:not([type=checkbox]), .drawer-dialog textarea {
  box-sizing: border-box; width: 100%; padding: 10px; border: 1px solid #779c8760; border-radius: 10px; background: #ffffff90; color: var(--ink); font: inherit; font-size: 15px; }
.drawer textarea, .drawer-dialog textarea { resize: vertical; line-height: 1.7; }
.drawer-check { display: flex !important; grid-template-columns: none; gap: 8px; align-items: flex-start; padding: 8px; border-radius: 10px; background: #ffffff50; }

/* 卷轴列表 */
.drawer-scrolls { display: grid; gap: 12px; }
.drawer-scroll { display: grid; grid-template-columns: 14px 1fr 14px; align-items: stretch; gap: 0; width: 100%; padding: 0; border: 0; background: none; color: var(--drawer-ink); text-align: left; font: inherit; cursor: pointer; }
.drawer-rod { display: block; width: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--drawer-rod), var(--drawer-rod-light) 45%, var(--drawer-rod)); box-shadow: 0 3px 6px #3b2a1a33; }
.drawer-scroll-copy { display: grid; gap: 3px; min-width: 0; margin: 6px 0; padding: 12px 16px; background: linear-gradient(180deg, var(--drawer-paper), var(--drawer-paper-edge)); box-shadow: inset 0 1px #fff, 0 4px 12px #123d3014; }
.drawer-scroll-copy strong { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.drawer-scroll-copy small { font-size: 13px; color: #6b5d48; }
.drawer-scroll:hover .drawer-scroll-copy, .drawer-scroll:focus-visible .drawer-scroll-copy { background: linear-gradient(180deg, #fffdf6, var(--drawer-paper-edge)); }
.drawer-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* 单卷 */
.drawer-scroll-head { display: grid; gap: 6px; }
.drawer-scroll-head > .drawer-link { justify-self: start; }
.drawer-write-bar.is-static { position: static; box-shadow: none; }
.drawer-scroll-head h3 { margin: 0; font-size: 20px; color: var(--drawer-ink); overflow-wrap: anywhere; }
.drawer-bookmark { min-height: 36px; padding: 6px 12px; border: 1px dashed #b8946b; border-radius: 999px; background: #fffaf0b0; color: #6b5d48; font: inherit; font-size: 13px; cursor: pointer; }
.drawer-setting-card { padding: 10px 14px; border: 1px solid #ffffffa0; border-radius: 14px; background: #ffffff38; }
.drawer-setting-card summary { cursor: pointer; font-size: 14px; color: var(--accent-ink); min-height: 28px; }
.drawer-setting-card[open] { display: grid; gap: 10px; }
.drawer-reader { display: grid; gap: 0; padding: 18px 18px 8px; border-radius: 6px; background: linear-gradient(180deg, var(--drawer-paper), #f6efe0); color: var(--drawer-ink); box-shadow: 0 6px 18px #123d3018, inset 0 0 0 1px #e9dfcb; }
.drawer-reader.is-recent { max-height: 46dvh; overflow: auto; }
.drawer-segment { position: relative; padding: 10px 26px 12px 0; border-bottom: 1px dashed #e2d6bf; }
.drawer-segment:last-child { border-bottom: 0; }
.drawer-segment.is-user .drawer-text { color: #2f4a43; }
.drawer-chapter { margin: 10px 0 6px; font-size: 15px; letter-spacing: .08em; text-align: center; color: #6b5d48; }
.drawer-text p { margin: 4px 0; font-size: 16px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.drawer-segment-menu { position: absolute; top: 6px; right: 0; }
.drawer-segment-menu summary { list-style: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #8a7a62; cursor: pointer; }
.drawer-segment-menu summary::-webkit-details-marker { display: none; }
.drawer-menu-list { position: absolute; right: 0; z-index: 5; display: grid; min-width: 140px; padding: 6px; border-radius: 12px; background: #fffdf8; box-shadow: 0 10px 24px #3b2a1a2e; }
.drawer-menu-list button { min-height: 38px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--drawer-ink); text-align: left; font: inherit; font-size: 14px; cursor: pointer; }
.drawer-menu-list button:hover { background: #f3ead8; }
.drawer-write-bar { position: sticky; bottom: 8px; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border: 1px solid #ffffffa0; border-radius: 16px; background: #f4faf6e6; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 8px 22px #123d3018; }
.drawer-usage { flex-basis: 100%; }
.drawer-more { flex-basis: 100%; }
.drawer-more summary { cursor: pointer; min-height: 32px; color: var(--accent-ink); font-size: 14px; }
.drawer-more[open] .drawer-actions { margin-top: 8px; }
.drawer-writing { color: var(--accent-ink); font-size: 14px; }
.drawer-writing::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: drawer-dots 1.2s steps(4) infinite; }
@keyframes drawer-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* 轮流写 */
.drawer-turn { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; color: var(--accent-ink); }
.drawer-turn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #17a89726; }
.drawer-turn.is-assistant .drawer-turn-dot { background: var(--drawer-rod); box-shadow: 0 0 0 4px #8a6a4a26; animation: drawer-pulse 1.4s ease-in-out infinite; }
@keyframes drawer-pulse { 50% { transform: scale(.7); } }

/* 句子 */
.drawer-sentence-top { justify-content: space-between; }
.drawer-chips { display: flex; gap: 6px; overflow-x: auto; flex: 1 1 100%; padding-bottom: 2px; scrollbar-width: none; }
.drawer-chip { flex: none; min-height: 34px; padding: 5px 12px; border: 1px solid #ffffff90; border-radius: 999px; background: #ffffff50; color: var(--accent-ink); font: inherit; font-size: 13px; cursor: pointer; }
.drawer-chip.is-active { background: var(--accent-ink); color: #fff; }
.drawer-deck { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; gap: 6px; padding: 10px 0 18px; }
.drawer-deck::before, .drawer-deck::after { content: ""; position: absolute; left: 50px; right: 50px; height: 70%; top: 18%; border-radius: 18px; background: var(--drawer-paper); box-shadow: 0 6px 16px #123d3014; z-index: 0; }
.drawer-deck::before { transform: rotate(-3deg) translateY(10px); opacity: .7; }
.drawer-deck::after { transform: rotate(2.5deg) translateY(6px); opacity: .85; }
.drawer-card { position: relative; z-index: 1; display: grid; gap: 12px; min-height: 200px; margin: 0; padding: 34px 22px 18px; border-radius: 18px; background: linear-gradient(170deg, #fffdf8, var(--drawer-paper)); color: var(--drawer-ink); box-shadow: 0 12px 28px #123d3022, inset 0 0 0 1px #eadfca; touch-action: pan-y; user-select: text; transition: transform .25s ease, opacity .25s ease; }
.drawer-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.drawer-card.is-leaving-left { transform: translateX(-24px) rotate(-2deg); opacity: .4; }
.drawer-card.is-leaving-right { transform: translateX(24px) rotate(2deg); opacity: .4; }
.drawer-card.is-drawn { animation: drawer-draw .5s ease; }
@keyframes drawer-draw { 0% { transform: rotateY(90deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.drawer-card-themes { position: absolute; top: 10px; right: 12px; max-width: 70%; min-height: 28px; padding: 3px 9px; border: 0; border-radius: 999px; background: #efe5d1; color: #6b5d48; font: inherit; font-size: 12px; text-align: right; overflow-wrap: anywhere; cursor: pointer; }
.drawer-quote { margin: 0; }
.drawer-quote p { margin: 4px 0; font-size: 18px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.drawer-quote p:first-child::before { content: "“"; color: #b8946b; margin-right: 2px; }
.drawer-quote p:last-child::after { content: "”"; color: #b8946b; margin-left: 2px; }
.drawer-card figcaption { color: #8a7a62; font-size: 12px; text-align: right; }
.drawer-arrow { position: relative; z-index: 2; width: 36px; height: 44px; border: 0; border-radius: 12px; background: #ffffff60; color: var(--accent-ink); font-size: 24px; cursor: pointer; }
.drawer-count { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; }
.drawer-reaction-box { display: grid; gap: 10px; }
.drawer-reactions { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.drawer-reactions li { padding: 10px 12px; border-radius: 12px; background: #ffffff50; }
.drawer-reactions li.is-assistant { background: #fbf7eecc; }
.drawer-reactions p { margin: 2px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* 小习惯 */
.drawer-habit-group { display: grid; gap: 10px; }
.drawer-habit-group h3 { margin: 6px 0 0; font-size: 16px; color: var(--accent-ink); }
.drawer-habit { padding: 12px 14px; border-radius: 14px; background: linear-gradient(180deg, #fffdf8, var(--drawer-paper)); color: var(--drawer-ink); box-shadow: 0 4px 12px #123d3012; }
.drawer-habit-text { margin: 0 0 6px; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.drawer-habit-events { display: grid; gap: 2px; margin: 0 0 4px; padding: 0; list-style: none; color: #7d6d55; font-size: 12px; line-height: 1.6; }
.drawer-note { color: #8a7a62; }

/* 回收站与设置 */
.drawer-trash-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #ffffff90; font-size: 14px; }
.drawer-trash-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-toggle { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 14px; background: #ffffff40; cursor: pointer; }
.drawer-toggle input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent-ink); }
.drawer-toggle span { display: grid; gap: 3px; }
.drawer-toggle small { color: var(--muted); font-size: 12px; line-height: 1.5; }

/* 收进抽屉弹窗 */
.drawer-dialog { width: min(520px, calc(100% - 24px)); max-height: 85dvh; overflow: auto; padding: 18px; border: 1px solid #ffffff90; border-radius: 22px; background: var(--jade-light, #eff6f1); color: var(--accent-ink, #25463b); }
.drawer-dialog::backdrop { background: #122c2544; backdrop-filter: blur(5px); }
.drawer-dialog h3 { margin: 0 0 12px; }
.drawer-dialog-body { display: grid; gap: 12px; margin-top: 12px; }

/* 对话里的卷轴卡片与标签 */
.drawer-chat-card { display: grid; grid-template-columns: 12px 1fr 12px; width: min(92%, 460px); margin: 6px auto 12px; color: var(--drawer-ink); }
.drawer-chat-card .drawer-rod { width: 12px; }
.drawer-chat-card-copy { display: grid; gap: 4px; margin: 5px 0; padding: 12px 16px; background: linear-gradient(180deg, var(--drawer-paper), var(--drawer-paper-edge)); box-shadow: 0 4px 12px #123d3014; min-width: 0; }
.drawer-chat-card-copy strong { font-size: 16px; overflow-wrap: anywhere; }
.drawer-chat-card-copy p { margin: 2px 0; font-size: 14px; line-height: 1.7; color: #5a4d3a; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
#drawerBinding { padding: 0 10px 5px; display: flex; flex-wrap: wrap; gap: 6px; }
#drawerBinding[hidden] { display: none; }
#drawerBinding button { border: 1px dashed #b8946b; padding: 7px 12px; border-radius: 12px; background: #fbf7eee6; color: #5a4d3a; font: inherit; font-size: 13px; cursor: pointer; }
.drawer-receipt .message-tool-result { white-space: pre-wrap; }

@media (prefers-reduced-motion: reduce) {
  .drawer-card, .drawer-card.is-drawn, .drawer-turn-dot, .drawer-writing::after { animation: none; transition: none; }
}
