/* Same documents and coordinates; only their material changes. */
body.trace-altered {
  --paper:#d1c6b7; --paper-edge:#b9ad9f; --line:#a99d9470; --ink:#312c35;
  --pencil:#5b515b; --pencil-light:#82737c; --red-line:#865563; --pink:#c4a0aa; --pink-deep:#a87586;
  --desk:#6c626c; --desk-mid:#5c535e; --desk-dark:#352e3b; --shadow:#150f1c80;
  --trace-folds:linear-gradient(103deg,transparent 37.3%,#49374325 37.7%,#f8e6c66b 37.9%,transparent 38.5%),linear-gradient(174deg,transparent 67.4%,#41323d25 67.7%,#fff0d055 67.9%,transparent 68.5%);
  background:var(--desk);color:var(--ink);
}
body.trace-altered .desk-surface {
  background:radial-gradient(ellipse at 50% 48%,#958b8d70,transparent 65%),repeating-linear-gradient(0deg,transparent 0 3px,#c9b3bd09 3px 4px),repeating-linear-gradient(90deg,transparent 0 3px,#100c1b0c 3px 4px),linear-gradient(160deg,#746774,#514553 56%,#70636c);
}
.trace-ruptures { position:absolute;inset:0;pointer-events:none;overflow:hidden; }
.trace-ruptures span { position:absolute;left:2%;top:6%;width:clamp(80px,11vw,190px);height:37%;background:linear-gradient(95deg,#baab9a,#574252 13%,#100d16 21%,#08080e 62%,#6c4f60 85%,#afa190);rotate:-14deg;filter:drop-shadow(2px 4px 3px #15101d);animation:trace-wound 12s ease-in-out infinite; }
.trace-ruptures span::after { content:'';position:absolute;inset:10% 17%;background:repeating-linear-gradient(31deg,transparent 0 38px,#a78c8445 39px,#382b3d66 40px,transparent 42px 67px); }
.trace-ruptures span:nth-of-type(2) { left:auto;right:0;top:58%;height:33%;rotate:28deg;animation-delay:-6s; }
.trace-ruptures span:nth-of-type(3) { left:17%;top:85%;width:120px;height:14%;rotate:54deg;animation-delay:-3s; }
body.trace-altered .notebook-page { background:var(--trace-folds),repeating-linear-gradient(180deg,transparent 0 calc(var(--line-h) - 1px),var(--line) calc(var(--line-h) - 1px) var(--line-h)),linear-gradient(125deg,#ded5c5,#c4b6ab 68%,#b6a7a4);animation:none; }
body.trace-altered:not(.is-truth):not(.is-collapsing):not(.is-restoring) .notebook-page { animation:trace-breathe 12s ease-in-out infinite; }
body.trace-altered .paper-glow { opacity:.65;background:radial-gradient(ellipse at var(--trace-x,60%) var(--trace-y,65%),#b47d9540,transparent 32%),linear-gradient(168deg,transparent 36%,#55404d13 36.6%,#fff2dc4d 37%,transparent 37.7%);mix-blend-mode:multiply; }
body.trace-altered .page-holes span { background:#25202c;box-shadow:inset 2px 2px 5px #08060c,1px 2px 1px #dfc9b0;animation:trace-pulse 12s ease-in-out infinite; }
body.trace-altered .title-text { background:linear-gradient(transparent 70%,#a77d8840 70%,#a77d8840 95%,transparent 95%); }
body.trace-altered .side-note,body.trace-altered .sticky-note { background:var(--trace-folds),repeating-linear-gradient(180deg,transparent 0 23px,#6f5f6b22 23px 24px),linear-gradient(130deg,#bfb0a7,#9c8b91);color:#332a37;border-color:#5f405b66;box-shadow:2px 6px 16px #1a11234d,inset 0 1px #e7d8bd88; }
body.trace-altered .sticky-text { color:#392f3c; }
body.trace-altered :is(.side-note-tear,.side-note::before,.letter-tape,.tape,.services-note::before) { background:linear-gradient(100deg,#a38d7b55,#b5a187b0,#a38d7b66);color:#423345;border-color:#654b59; }
body.trace-altered :is(.sticky-pin,.profile-pin,.letter-pin) { background:radial-gradient(circle at 35% 30%,#d4adb2,#633d59 70%); }
body.trace-altered .sayori-sketch { filter:drop-shadow(2px 3px 2px #20132666); }
body.trace-altered .sayori-art-ghost { filter:blur(1px); }
body.trace-altered .sticker-heart { color:#ba8294; }
body.trace-altered .entry:hover { background:#4a263910; }
body.trace-altered :is(.services-note,.letter-paper) { background-image:var(--trace-folds),repeating-linear-gradient(180deg,transparent 0 33px,#85758235 33px 34px),linear-gradient(130deg,#d9cfc0,#b7a6a3);box-shadow:0 26px 60px #100c1a80,inset 0 2px #ecddc8; }
body.trace-altered :is(.service-note,.social-link) { background:var(--trace-folds),linear-gradient(145deg,#e1d4c4a3,#a5929d70);border-color:#846a7c66;box-shadow:2px 5px 12px #3e273326; }
body.trace-altered :is(.services-head h2,.service-note h3,.social-platform,.social-heading h1,.letter-title,.letter-section a) { color:#473746; }
body.trace-altered :is(.service-note p,.services-head p,.social-handle,.social-heading>p:last-child,.social-footer) { color:#594956; }
body.trace-altered :is(.profile-back,.desk-back,.social-back,.social-toolbar select,.social-name,.social-footer a,.letter-stamp) { background:#c1afaaba;color:#5b354b;border-color:#8a6473; }
body.trace-altered .trace-recoil { animation:trace-recoil 2.5s ease-out; }
.trace-window { position:fixed;inset:0;margin:auto;padding:0;width:min(1080px,calc(100vw - 48px));height:min(820px,calc(100dvh - 64px));max-width:none;max-height:none;border:0;border-radius:2px;background:#eee5d9;color:#343039;box-shadow:6px 18px 70px #120b2966; }
.trace-window::backdrop { background:#1d142b70;backdrop-filter:blur(2px); }
.trace-window>header { height:48px;display:flex;align-items:center;justify-content:space-between;padding:0 20px;border-bottom:1px solid #b8a3aa;font-size:14px; }
.trace-window header button { width:44px;height:44px;font-size:28px; }
.trace-window iframe { display:block;width:100%;height:calc(100% - 48px);border:0; }
.trace-loading,.trace-load-error { margin:30px; }
.trace-load-error button { text-decoration:underline; }
.trace-version[hidden],.trace-window [hidden] { display:none!important; }
.trace-version { width:100%;text-align:left; }
body.trace-awake .page-title { text-shadow:1px 0 #a3627770,-1px 0 #83a69c60; }
body.trace-awake .notebook-extras { min-height:140px; }
/* The living boundary is separate from the text, so it cannot warp input or hit targets. */
body.trace-altered .truth-layer { --terminal-text:#ded0c3;--cyan:#d7b8ca;--green:#b9b99e;--amber:#cba196;background:radial-gradient(ellipse at 54% 62%,#58414d,#2c2736 57%,#13131f); }
body.trace-altered .truth-grid { opacity:.12;background:repeating-linear-gradient(63deg,transparent 0 77px,#b18a9940 78px,transparent 80px 131px); }
body.trace-altered .terminal-window { isolation:isolate;overflow:visible;background:transparent;border:0;box-shadow:none; }
body.trace-altered .terminal-window:not(.is-minimized) { animation:none; }
body.trace-altered .terminal-title { background:transparent;border-color:#b28d7e24;border-radius:0; }
body.trace-altered .terminal-title span:nth-child(1) { background:#a66680; }
body.trace-altered .terminal-title span:nth-child(2) { background:#b89d83; }
body.trace-altered .terminal-title span:nth-child(3) { background:#8a957c; }
body.trace-altered .terminal-input-line { background:transparent;border-color:#a983893d; }
body.trace-altered #terminal-output p { white-space:pre-wrap; }
body.trace-altered .truth-ambient { filter:saturate(.25) hue-rotate(95deg); }
body.trace-altered .noise-overlay { opacity:.055; }
@keyframes trace-breathe { 0%,100% { scale:1;box-shadow:4px 8px 22px #100c1a66; } 54% { scale:1.002 1.006;box-shadow:7px 14px 32px #170e2475; } }
@keyframes trace-wound { 0%,100% { scale:1; } 53% { scale:1.045 .99; } }
@keyframes trace-pulse { 0%,100% { translate:0 0; } 54% { translate:1px 2px; } }
@keyframes trace-recoil { 0%,100% { translate:0 0; } 13% { translate:-3px 1px;filter:blur(.4px); } 30% { translate:2px -1px; } 54% { translate:-1px 0; } }
body.trace-still *,body.trace-still *::before,body.trace-still *::after { animation:none!important;transition:none!important; }
@media(prefers-reduced-motion:reduce) { body.trace-altered *,body.trace-altered *::before,body.trace-altered *::after { animation:none!important;transition:none!important; } }
@media(max-width:640px) { .trace-window { width:calc(100vw - 16px);height:calc(100dvh - 24px); }.trace-ruptures span { width:80px;left:-22px; }.trace-ruptures span:nth-of-type(2) { right:-20px; } }
body.trace-altered .terminal-output .muted { color:#d1bdc7;font-style:normal; }
body.trace-altered .trace-audio iframe { display:none; }
body.trace-altered .trace-audio { background:#c8b7b8;color:#382d3b; }
body.trace-altered .trace-audio.is-open:not(.is-hidden-player) { height:130px;padding:18px 12px; }
.trace-audio audio { width:100%;height:38px; }
.trace-music-credit { font:12px/1.7 system-ui;margin:10px 0 0; }
.trace-music-credit a { text-decoration:underline; }
body.trace-altered .trace-ruptures span { clip-path:url(#trace-rift); }
/* Fibers and branching creases sit under the ink, not over the readable content. */
body.trace-altered :is(.notebook-page,.letter-paper,.services-note,.side-note,.sticky-note,.service-note,.social-link) {
  background-image:url('/assets/generated/paper-fibers.svg'),url('/assets/generated/paper-creases.svg'),
    radial-gradient(ellipse at 1% 2%,#674c364d,transparent 27%),
    radial-gradient(ellipse at 99% 96%,#5a33494a,transparent 32%),
    radial-gradient(ellipse at 35% 68%,#c1a07333,transparent 46%),
    var(--trace-folds),
    repeating-linear-gradient(180deg,transparent 0 33px,#786b6138 33px 34px),
    linear-gradient(128deg,#d7cdb6,#cbbca4 50%,#bdad9e);
  background-size:240px 240px,100% 100%,auto,auto,auto,auto,auto,auto,auto;
  box-shadow:inset 0 0 3px 1px #48382c70,inset 0 0 26px #75533c3d,3px 9px 23px #17101d50;
}
body.trace-altered .notebook-page {
  background-image:url('/assets/generated/paper-fibers.svg'),url('/assets/generated/paper-creases.svg'),
    radial-gradient(ellipse at 0 0,#61443055,transparent 28%),radial-gradient(ellipse at 100% 90%,#683f4c50,transparent 32%),
    var(--trace-folds),repeating-linear-gradient(180deg,transparent 0 calc(var(--line-h) - 1px),var(--line) calc(var(--line-h) - 1px) var(--line-h)),linear-gradient(125deg,#d8cdb4,#c7b59f 68%,#bba6a0);
  background-size:240px 240px,100% 100%,auto,auto,auto,auto,auto,auto;
}
body.trace-altered :is(.side-note,.sticky-note,.service-note,.social-link) {
  background-size:160px 160px,100% 100%,auto,auto,auto,auto,auto,auto,auto;
  border-color:#74594880;
  border-radius:2px 5px 2px 4px;
}
body.trace-altered .service-note:nth-child(even),body.trace-altered .social-links li:nth-child(even) .social-link {
  background-position:31px 17px,100% 100%;
  --trace-folds:linear-gradient(24deg,transparent 23%,#50364630 23.3%,#f1dab667 23.5%,transparent 24.2%);
}
body.trace-altered :is(.service-note strong,.social-platform) { color:#46323e; }
body.trace-altered :is(.service-note em,.services-footnote) { color:#664b50; }
body.trace-altered .service-note::before { background:linear-gradient(100deg,#947c5f77,#c4b38dbf,#9b826b99); }
body.trace-altered .letter-paper { background-position:0 0; }
body.trace-altered .letter-paper::after,body.trace-altered .services-note::after {
  content:'';position:absolute;inset:0;pointer-events:none;border-radius:inherit;
  background:radial-gradient(ellipse at var(--trace-x,85%) var(--trace-y,75%),#66384824,transparent 26%),
    radial-gradient(ellipse at 98% 40%,#62405438,transparent 16%);
  box-shadow:inset 0 0 14px #543f3533;animation:trace-skin 11s ease-in-out infinite;
}
body.trace-altered .letter-paper { animation:trace-arrive 480ms cubic-bezier(.16,1,.3,1) both; }
body.trace-altered .social-paper { animation:trace-arrive 480ms cubic-bezier(.16,1,.3,1) both; }
body.trace-altered .social-link { transition:transform 260ms cubic-bezier(.2,.8,.2,1),box-shadow 260ms ease; }
body.trace-altered .social-link:hover,body.trace-altered .social-link:focus-visible {
  transform:translateY(-3px) rotate(-.45deg);
  box-shadow:inset 0 0 18px #9f69754d,2px 9px 16px #33233340;
}
body.trace-altered .social-link:focus-visible { outline:2px solid #704153;outline-offset:4px; }
.trace-ruptures span { box-shadow:inset 9px 0 9px #c3ac8a66,inset -9px 0 15px #8f657050; }
.trace-ruptures span::after { inset:4% 10%;opacity:.65;background:repeating-linear-gradient(38deg,transparent 0 37px,#a4897f50 38px,transparent 40px 57px),radial-gradient(ellipse at 60% 54%,#66364870,transparent 65%); }
@keyframes trace-skin { 0%,100% { opacity:.38; } 52% { opacity:1; } }
@keyframes trace-arrive { from { opacity:0;translate:0 12px; } to { opacity:1;translate:0 0; } }
.trace-terminal-skin { position:absolute;inset:-34px -40px;width:calc(100% + 80px);height:calc(100% + 68px);z-index:-1;pointer-events:none;overflow:visible;filter:drop-shadow(0 15px 22px #100b1dbb); }
.trace-membrane { filter:url(#trace-tissue);animation:trace-contour 13s ease-in-out infinite alternate; }
.trace-cavity { transform-origin:50% 50%;animation:trace-cavity 17s ease-in-out -7s infinite alternate; }
.trace-cavity { stroke:#c0a1b5;stroke-opacity:.36;stroke-width:2;filter:drop-shadow(0 2px 5px #221427); }
.trace-cell { transform-box:fill-box;transform-origin:center;animation:trace-cell 9s ease-in-out infinite alternate; }
@keyframes trace-cell { to { transform:scale(.87,1.16) rotate(9deg);opacity:.72; } }
body.trace-altered .terminal-title { order:0;padding:54px clamp(48px,9vw,84px) 18px;border:0; }
body.trace-altered .terminal-input-line {
  order:1;margin:0 clamp(48px,9vw,84px) 12px;padding:12px 16px;min-height:48px;
  background:#15131f;border:1px solid #a38caa77;border-radius:5px;
  box-shadow:0 3px 12px #100a1d55,inset 0 1px #ddc9e111;
}
body.trace-altered .terminal-input-line:focus-within { border-color:#c7afcb;outline:2px solid #ad8eb126;outline-offset:2px; }
body.trace-altered .terminal-input-line input { min-width:0; }
body.trace-altered .terminal-input-line input::placeholder { color:#a99dac; }
body.trace-altered .terminal-body { order:2;padding:12px clamp(48px,9vw,84px) 100px; }
@media(max-width:640px) {
  body.trace-altered .terminal-title { padding:62px 42px 16px; }
  body.trace-altered .terminal-title p { font-size:.65rem; }
  body.trace-altered .terminal-input-line { margin-inline:42px; }
  body.trace-altered .terminal-body { padding:8px 42px 100px; }
}
@media(max-width:640px) { .trace-terminal-skin { inset:-22px -18px;width:calc(100% + 36px);height:calc(100% + 44px); } }

@keyframes trace-contour { to { d:path('M112 68 C176 47 222 7 289 42 C355 77 411 1 487 35 C556 65 603 2 675 43 C735 78 778 11 837 67 C895 121 930 70 941 142 C955 209 904 229 963 283 C1005 327 909 358 950 410 C982 454 899 494 937 555 C970 610 858 684 800 643 C742 602 699 720 626 672 C557 627 507 717 440 668 C376 621 322 713 258 654 C203 603 145 695 104 622 C66 553 136 531 75 480 C17 431 87 394 49 340 C8 284 96 253 74 207 C47 149 115 145 96 99 C90 80 102 73 112 68Z'); } }
@keyframes trace-cavity { 0% { transform:scale(1) translate(0,0); } 100% { transform:scale(1.025,.98) translate(-5px,4px); } }

/* Sub-paper breathing organism canvas & mouse proximity reaction */
.trace-organism-canvas {
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  pointer-events:none;
  z-index:0;
  mix-blend-mode:multiply;
}
body.trace-altered .notebook-page,
body.trace-altered .letter-paper,
body.trace-altered .social-paper {
  transform:skew(var(--trace-skew-x,0deg),var(--trace-skew-y,0deg));
  transition:transform 260ms ease-out,box-shadow 400ms ease;
}
body.trace-altered .entry {
  transition:transform 220ms cubic-bezier(.2,.8,.2,1),background 220ms ease;
}
body.trace-altered .entry:hover {
  transform:translateX(4px) skewX(-.6deg);
  background:linear-gradient(90deg,#6b3d5418,transparent);
}
body.trace-altered[data-erosion="3"] .notebook-page,
body.trace-altered[data-erosion="4"] .notebook-page {
  box-shadow:inset 0 0 6px 2px #58314288,inset 0 0 38px #783e544d,5px 14px 36px #120a1888;
}
.trace-win-actions {
  display:flex;
  align-items:center;
  gap:14px;
}
.trace-win-actions a {
  font-size:12.5px;
  color:#6c394d;
  text-decoration:underline;
}

/* Paper Backside Clue Dock */
.trace-clue-dock {
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:35;
  width:min(310px,calc(100vw - 32px));
  padding:12px 14px;
  border-radius:3px 6px 3px 5px;
  background:linear-gradient(135deg,#d6cbbd,#bba9a3);
  border:1px solid #6f5260;
  box-shadow:3px 8px 24px #120c1a80,inset 0 1px #efe3d2;
  color:#312633;
  font:12.5px/1.55 system-ui,-apple-system,sans-serif;
}
body.is-truth .trace-clue-dock {
  background:rgba(28,22,36,.92);
  color:#dfd0d9;
  border-color:#936b84;
  box-shadow:0 12px 30px #09060ecc;
}
.trace-dock-head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  margin-bottom:8px;
}
.trace-dock-flip {
  padding:3px 8px;
  font-size:11.5px;
  border:1px solid #754c5e;
  border-radius:3px;
  background:#5c3a4b;
  color:#f5ebe6;
  cursor:pointer;
}
.trace-dock-list {
  list-style:none;
  padding:0;
  margin:0 0 8px;
  display:grid;
  gap:4px;
}
.trace-dock-list li {
  display:flex;
  flex-direction:column;
  padding:4px 7px;
  border-radius:3px;
  background:rgba(255,255,255,.36);
  border-left:2px solid #8a6474;
}
body.is-truth .trace-dock-list li {
  background:rgba(255,255,255,.06);
}
.trace-dock-list li.done {
  border-left-color:#446b57;
}
.trace-dock-list small {
  font-size:11px;
  opacity:.82;
}
.trace-dock-links {
  display:flex;
  justify-content:space-between;
  gap:8px;
  padding-top:6px;
  border-top:1px dashed #82677466;
  font-size:11.5px;
}
.trace-dock-links a {
  color:inherit;
  text-decoration:underline;
}
@media(max-width:640px) {
  .trace-clue-dock {
    position:static;
    width:calc(100% - 24px);
    margin:12px auto 20px;
  }
}
