main:has(.story-shell) { align-content: start; }
.story-shell {
  --evergreen:#102c1e; --snow:#f1f2ee; --metal:#a4a9a6; --red:#801b12;
  display:grid; grid-template-columns:minmax(9rem,16.2%) 1fr; grid-template-rows:auto auto 1fr auto;
  gap:.32rem; min-height:100vh; min-height:100dvh; padding:.35rem; color:#151917;
  background:radial-gradient(ellipse at 20% 0%,#234f37,#091a14 65%);
  font:600 clamp(.83rem,1.22vw,1.2rem)/1.2 "Arial Narrow", Arial, sans-serif;
}
.story-icon { width:1.28em; height:1.28em; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; flex:none; }
.story-sidebar {
  position:relative; grid-row:1 / 4; display:flex; flex-direction:column; justify-content:flex-start;
  overflow:hidden; background:linear-gradient(90deg,#102b1f,#1b3b2b 50%,#091c15); border-radius:.8rem;
}
.story-sign {
  position:relative; z-index:1; text-align:center; padding:clamp(.55rem,1vw,1rem) .22rem;
  width:96%; margin:.3rem auto 0; border:4px double #e1ab61; border-top:7px solid #f2f7ff;
  border-radius:39% 38% .9rem .9rem / 24% 22% .9rem .9rem;
  background:radial-gradient(ellipse at 45% 15%,#96372e,#66170d 66%,#3d120e); box-shadow:0 3px 5px #101718;
  text-transform:uppercase; color:#fff2d3; font:bold clamp(.92rem,1.93vw,2.1rem)/1.01 Georgia,serif; text-shadow:0 2px #541d13;
}
.story-santa { display:block; width:73%; aspect-ratio:1.2; object-fit:contain; object-position:bottom left; margin-top:-.65rem; mask-image:linear-gradient(90deg,#000 89%,transparent); }
.story-gifts { margin-top:auto; width:100%; max-height:22vh; object-fit:cover; object-position:center bottom; }
.story-sidebar nav { display:grid; gap:.1rem; padding:0 .15rem .3rem; }
.story-sidebar nav a {
  display:flex; gap:.65em; align-items:center; color:white; text-decoration:none; padding:.38rem .48rem;
  min-height:2.05rem; border:1px solid #91b89c35; border-radius:.28rem;
  background:linear-gradient(#234a37,#102b1e 78%); text-shadow:0 1px #102018;
}
.story-sidebar nav a:hover, .story-sidebar nav a[aria-current="page"] {
  background:linear-gradient(#c85e46,#9c2013 47%,#65170d); border-color:#e49d76;
  box-shadow:inset 0 1px 3px #ffebbe88,0 1px 3px #0007;
}
.story-header {
  position:relative; isolation:isolate; min-height:clamp(5rem,8.25vw,8.6rem); overflow:hidden;
  display:flex; flex-direction:column; align-items:center; gap:.22rem;
  padding:.32rem 10% 2.2rem; color:#fff; text-align:center;
  background:url("./art/story/village.png") center bottom / 100% 52% no-repeat,radial-gradient(ellipse at 65% -40%,#295e67,#0a2248 55%,#061026);
}
.story-header h1 { z-index:1; text-shadow:0 2px 2px #122143; font:bold clamp(1.25rem,2.65vw,3rem)/1.05 Georgia,serif; }
.story-header p { z-index:1; font-size:clamp(.73rem,1.45vw,1.42rem); text-shadow:0 2px #122143; }
.story-top-action, .story-wood {
  position:absolute; z-index:2; border-radius:.35rem; border:1px solid #cfa18b; padding:.25rem .45rem;
  background:linear-gradient(#ad3f31,#6e1b17); color:white; text-decoration:none; font-size:.79em; white-space:nowrap;
}
.story-top-action { right:.25rem; top:.2rem; display:flex; align-items:center; gap:.25rem; min-height:0; }
.story-wood { bottom:31%; left:5%; background:linear-gradient(#933e28,#542219); transform:rotate(-5deg); border:2px solid #d8ae83; }
.story-weather,.story-weather::before,.story-weather::after { position:absolute; inset:0; pointer-events:none; }
.story-weather { background:radial-gradient(ellipse at 89% -5%,#50ebae90,transparent 35%),radial-gradient(ellipse at 28% 10%,#44a6ed60,transparent 28%); animation:story-aurora 19s ease-in-out infinite alternate; }
.story-weather::before { content:""; background:radial-gradient(circle at 14% 24%,#fff 0 1px,transparent 2px),radial-gradient(circle at 43% 4%,#fff 0 1px,transparent 2px),radial-gradient(circle at 92% 31%,#fff 0 1px,transparent 2px); background-size:173px 70px; animation:story-snow 17s linear infinite; }
.story-weather::after { content:""; background:radial-gradient(circle at 6% 74%,#ffc8758a,transparent 6%),radial-gradient(circle at 81% 75%,#ffbe5480,transparent 7%); animation:story-pulse 7s ease-in-out infinite alternate; }
.story-alert { display:grid; grid-template-columns:minmax(0,3fr) minmax(0,1fr); gap:.4rem; }
.story-security,.story-camera {
  display:flex; gap:clamp(.25rem,1vw,.9rem); align-items:center; justify-content:center; text-align:center; min-height:clamp(3.15rem,6vw,5.9rem);
  border:5px solid transparent; border-radius:.85rem; padding:.25rem .32rem; color:#fff1cf;
  background:linear-gradient(#a63629,#791d14 54%,#5b160f) padding-box,repeating-linear-gradient(-45deg,#d3392c 0 7px,#fff2df 7px 14px) border-box;
  box-shadow:inset 0 0 0 2px #c28059,inset 0 0 13px #42100b,0 2px 4px #0008;
}
.story-security strong,.story-camera strong { display:block; text-transform:uppercase; font-size:clamp(.86rem,1.86vw,1.95rem); letter-spacing:.035em; }
.story-security small { display:block; font-size:clamp(.69rem,1.1vw,1.15rem); font-weight:400; }
.story-security .story-icon { color:#ffde83; width:1.6em; height:1.6em; }
.story-camera img { width:clamp(2rem,4.5vw,4.3rem); border-radius:.3rem; mix-blend-mode:lighten; }
.story-camera strong { font-size:clamp(.76rem,1.65vw,1.78rem); }
.story-workspace { grid-column:2; background:#eef1e9; border:2px solid #aeb6ae; border-radius:.55rem; }
[data-story-page="story-dashboard"] .story-workspace { display:grid; background:none; border:0; overflow:visible; }
.story-workspace > h2 { background:linear-gradient(#ac493c,#721b15); }
.story-shell #workspace-body { padding:0; }
.story-shell #workspace-body { min-width:0; }
.story-shell:not([data-story-page="story-dashboard"]) #workspace-body { padding:.55rem; }
.story-grid { display:grid; min-height:100%; grid-template-columns:minmax(0,38fr) minmax(0,5fr) minmax(0,27fr) minmax(0,30fr); grid-template-rows:minmax(0,1.16fr) minmax(0,1fr); gap:.32rem; }
.story-panel {
  min-width:0; overflow:hidden; border:5px double #a5aba8; border-radius:.79rem; color:#131816;
  background:linear-gradient(#fff,#e4e7e3); box-shadow:inset 0 0 0 1px white,0 2px 3px #081511;
}
.story-panel h2 {
  display:flex; align-items:center; gap:.36em; margin:0; padding:.24rem .4rem; border-radius:.3rem .3rem .45rem .45rem;
  background:linear-gradient(#c45a49,#8a2017 48%,#5b130d); color:white; border:1px solid #8e5148;
  text-shadow:0 1px #421713; box-shadow:inset 0 1px 4px #ffffff7a;
  font:bold clamp(.82rem,1.43vw,1.48rem)/1.12 "Arial Narrow",Arial,sans-serif;
}
.story-behavior-panel h2,.story-comms-panel h2 { background:linear-gradient(#4d7959,#1b492d 50%,#0d2d20); border-color:#557461; }
.story-nice-panel { grid-column:1/3; grid-row:1; }
.story-gauge-panel { grid-column:3; grid-row:1; }
.story-behavior-panel { grid-column:1; grid-row:2; }
.story-stats-panel { grid-column:2/4; grid-row:2; }
.story-comms-panel { grid-column:4; grid-row:1/3; display:flex; flex-direction:column; }
.story-rows { margin:0; padding:0 .38rem; list-style:none; }
.story-rows li { display:grid; align-items:center; gap:.34rem; padding:.26rem .09rem; border-bottom:1px solid #b3b8b5; }
.story-rows li:last-child { border-bottom:0; }
.story-nice li { grid-template-columns:minmax(0,1fr) auto 3em minmax(0,1.15fr); }
.story-behavior li { grid-template-columns:minmax(0,1fr) minmax(0,1.65fr) 3em; padding-block:.18rem; }
.story-rows li strong { font:bold clamp(.92rem,1.65vw,1.85rem)/1 Georgia,serif; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.story-behavior li strong { font-size:clamp(.87rem,1.35vw,1.38rem); }
.story-rows .story-empty { display:block; padding:.5rem; font-weight:400; }
.story-badge,.story-stats [data-stat="ready"] {
  color:white; border:1px solid #648655; border-radius:999px; padding:.16rem .3rem; font-size:.65em; white-space:nowrap; text-transform:uppercase;
  background:linear-gradient(#618c4f,#25571d 52%,#164214); text-shadow:0 1px #143f12; box-shadow:inset 0 1px 2px #fff6;
}
.story-value { text-align:right; font-variant-numeric:tabular-nums; }
.story-meter { display:block; height:clamp(.65rem,1.25vw,1.25rem); border:1px solid #535b56; border-radius:999px; overflow:hidden; background:linear-gradient(#aeb4ae,#f8fbf8 46%,#bdc4bd); box-shadow:inset 0 1px 3px #30363238; }
.story-meter svg { display:block; width:100%; height:100%; }
.story-fill,.story-mask-width { transition:width 1.12s cubic-bezier(.24,.65,.34,1); }
.story-reflection { animation:story-shine 6.7s ease-in-out infinite; }
.story-rows li:nth-child(2n) .story-reflection { animation-delay:-3s; }
.story-rows li:nth-child(3n) .story-reflection { animation-delay:-4.5s; }
.story-new { animation:story-new 2s ease-out both; }
.story-rows-label { display:flex; justify-content:space-around; background:#d8ddda; font-size:.76em; padding:.2rem; }
.story-gauge { position:relative; margin:auto; height:clamp(8rem,22vh,14rem); max-width:21rem; display:grid; place-items:center; text-align:center; color:#173e27; }
.story-gauge svg { position:absolute; width:74%; height:91%; color:#c9cfca; }
.story-gauge circle { stroke:currentColor; fill:none; stroke-width:13; }
.story-gauge .story-arc { color:#82ca52; stroke-linecap:round; transform:rotate(-90deg); transform-origin:center; transition:stroke-dasharray 1.15s ease; }
.story-gauge > div { z-index:1; display:grid; line-height:.95; text-transform:uppercase; }
.story-gauge strong { font-size:clamp(2rem,4.4vw,4.7rem); font-variant-numeric:tabular-nums; }
.story-gauge > div > span { margin-top:.26rem; }
.story-gauge-flake { position:absolute; top:10%; left:7%; color:#7ebada; }
.story-gauge img { position:absolute; bottom:0; left:9%; width:82%; max-height:27%; object-fit:contain; mask-image:radial-gradient(ellipse,#000 54%,transparent 75%); }
.story-stats { padding:.25rem .38rem; }
.story-stats > div { display:flex; justify-content:space-between; gap:.28rem; align-items:center; padding:.28rem .1rem; border-bottom:1px solid #bac0ba; }
.story-stats > div:last-child { border:0; }
.story-stats dt { display:flex; gap:.35rem; align-items:center; }
.story-stats .story-icon { color:#a52518; }
.story-stats dd { margin:0; font-weight:800; white-space:nowrap; }
.story-stats [data-stat="level"] { color:#33632f; }
.story-communications { flex:1; min-height:0; display:grid; grid-template-rows:auto minmax(4.2rem,.66fr) minmax(4.4rem,1fr) auto; gap:.22rem; padding:.18rem; }
.story-tabs,.story-comm-actions { display:flex; gap:.22rem; }
.story-tabs button,.story-comm-actions button,.story-comm-detail button,.story-notes button {
  flex:1; min-height:1.8rem; padding:.2em .26em; border:1px solid #87918b; border-radius:.35rem;
  background:linear-gradient(#fff,#d0d6d2); text-shadow:none; font-size:.74em; color:#18221b; box-shadow:inset 0 1px 3px #fff8;
}
.story-tabs button[aria-pressed="true"] { color:white; background:linear-gradient(#ca5748,#9a2318); }
.story-comm-actions button:first-child,.story-comm-detail button,.story-notes button { color:#fff; background:linear-gradient(#83c850,#387a2c); }
.story-comm-messages,.story-comm-detail { border:3px double #a8b1ac; border-radius:.45rem; background:#f5f6f4; padding:.32rem; overflow:auto; font-size:.82em; }
.story-comm-messages p,.story-comm-detail p { padding:.23rem; overflow-wrap:anywhere; }
.story-comm-messages button { display:flex; justify-content:space-between; width:100%; min-height:1.65rem; border:0; border-bottom:1px solid #c4ccc6; color:#173b27; padding:.18rem .25rem; background:none; box-shadow:none; text-shadow:none; border-radius:0; font-size:inherit; }
.story-comm-messages time { white-space:nowrap; }
.story-comm-detail label,.story-notes label { display:grid; gap:.4rem; }
.story-comm-detail textarea,.story-notes textarea { width:100%; min-height:4rem; font:inherit; resize:vertical; }
.story-notes textarea { min-height:12rem; margin:.55rem 0; }
.story-magic { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.5rem; }
.story-magic figure { margin:0; background:#fff; border:1px solid #bbc2bb; }
.story-magic img { width:100%; display:block; }
.story-magic figcaption { padding:.5rem; }
.story-magic small { display:block; }
.story-status {
  position:relative; grid-column:1/-1; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:.35rem;
  padding:.3rem .4rem; color:white; background:linear-gradient(#264a32,#0c2919); border:3px double #8ca999; border-top-color:#eef9ff; border-radius:.7rem;
}
.story-status::before { content:""; position:absolute; pointer-events:none; inset:-7px 0 auto; height:7px; background:url("./art/story/snow.png") center top / auto 100% repeat-x; }
.story-connection,.story-active,.story-checks { display:flex; align-items:center; gap:.45rem; }
.story-connection small { display:block; font-size:.69em; }
.story-connection .story-icon,.story-active strong { color:#8fea5b; animation:story-pulse 4.4s ease-in-out infinite alternate; }
.story-active .story-icon { color:#f1b2a6; }
.story-checks { font-size:.76em; gap:.65em; }
.story-checks span::first-letter { color:#ffdb75; }
.story-menu { position:relative; }
.story-menu summary { cursor:pointer; border:2px double #f1ae89; border-radius:.35rem; padding:.23rem .5rem; background:linear-gradient(#bf5240,#7c1912); display:flex; align-items:center; gap:.3rem; }
.story-menu div { position:absolute; bottom:100%; right:0; z-index:4; width:13rem; display:grid; background:#143c27; border:1px solid #bbd4bf; border-radius:.4rem; padding:.4rem; box-shadow:0 4px 13px #0008; }
.story-menu a { padding:.36rem .2rem; }
@keyframes story-aurora { to { transform:translateX(2%); opacity:.5; } }
@keyframes story-snow { from { background-position:0 -70px; opacity:.35; } to { background-position:9px 0; opacity:.75; } }
@keyframes story-pulse { to { filter:brightness(1.26); } }
@keyframes story-shine { 0%,25% { transform:translateX(0); opacity:0; } 36% { opacity:.75; } 78%,100% { transform:translateX(125px); opacity:0; } }
@keyframes story-new { from { background:#b4ed98; box-shadow:inset 0 0 8px #72ce61; } to { background:transparent; box-shadow:none; } }
@media (prefers-reduced-motion: reduce) { .story-shell *, .story-shell *::before, .story-shell *::after { transition:none !important; } }
.idle-off .story-shell * { transition:none !important; }
@media (max-width:920px) { .story-sidebar nav a { gap:.35rem; padding-inline:.27rem; } .story-nice li { gap:.25rem; grid-template-columns:minmax(1em,1fr) auto 2.7em minmax(2em,.95fr); } }
@media (orientation:portrait), (max-width:720px) {
  .story-shell { display:flex; flex-direction:column; font-size:.95rem; }
  .story-header { order:-2; padding:.4rem .3rem 2.3rem; min-height:7.4rem; }
  .story-header p { max-width:77%; }.story-top-action { top:auto; bottom:.15rem; }.story-wood { bottom:.2rem; left:.5rem; }
  .story-sidebar { display:block; }.story-sidebar nav { display:flex; flex-wrap:wrap; gap:.25rem; padding:.35rem; }
  .story-sidebar nav a { min-height:2.6rem; padding:.37rem .42rem; }.story-sign,.story-santa,.story-gifts { display:none; }
  .story-alert { grid-template-columns:minmax(0,2.35fr) minmax(0,1fr); }.story-security small { font-size:.64rem; }.story-camera img { display:none; }
  .story-grid { grid-template-columns:minmax(0,1.25fr) minmax(0,1fr); grid-template-rows:auto; }
  .story-grid > .story-panel { grid-column:auto; grid-row:auto; }.story-grid > .story-comms-panel { grid-column:1/-1; }.story-communications { min-height:15rem; }
  .story-badge { display:none; }.story-nice li { grid-template-columns:minmax(1em,1fr) 2.3em minmax(1.6em,.64fr); gap:.16rem; }.story-behavior li { grid-template-columns:minmax(1em,1fr) minmax(1.5em,1fr) 2.4em; gap:.15rem; }
  .story-stats { font-size:.78rem; }.story-gauge { min-height:8rem; }.story-checks { flex-wrap:wrap; }
}
