:root{
  --pink:#ef5ca7;
  --pink-mid:#f58abb;
  --pink-light:#ffd8e9;
  --lav:#d9c9ff;
  --ink:#513244;
  --muted:#826779;
  --paper:#fffdfd;
  --line:#d8b5c7;
  --shell:#f6edf3;
  --shadow:rgba(74,35,59,.16);
}

*{box-sizing:border-box}

html,body{
  margin:0;
  min-height:100%;
  background:var(--shell);
  color:var(--ink);
  font-family:Tahoma,Verdana,sans-serif;
}

body{
  min-height:100vh;
  overflow:hidden;
}

button{font:inherit}

.writing-app{
  height:100vh;
  padding:10px;
  display:grid;
  grid-template-columns:minmax(190px,22%) minmax(0,1fr) minmax(235px,27%);
  gap:9px;
  background:
    linear-gradient(rgba(255,255,255,.42),rgba(255,255,255,.42)),
    linear-gradient(135deg,#f7edf4,#ffeaf4 55%,#f1e8ff);
}

.panel{
  min-width:0;
  min-height:0;
  overflow:hidden;
  border:1px solid #b98ca3;
  background:#fffafd;
  box-shadow:2px 3px 0 var(--shadow);
}

.panel-heading{
  min-height:34px;
  display:flex;
  align-items:center;
  padding:7px 10px;
  border-bottom:1px solid #ba84a0;
  color:#6c2148;
  font-weight:bold;
  font-size:12px;
  background:linear-gradient(#fff,#ffd5e8 45%,#f6a6ca);
  text-transform:uppercase;
  letter-spacing:.6px;
}

.library-panel,
.properties-panel{
  display:flex;
  flex-direction:column;
}

.library-tree{
  flex:1;
  overflow:auto;
  padding:8px 7px 14px;
}

.library-section{
  margin-bottom:9px;
}

.category-button{
  width:100%;
  display:flex;
  align-items:center;
  gap:7px;
  border:0;
  padding:7px 8px;
  background:transparent;
  color:#6e3652;
  font-weight:bold;
  font-size:11px;
  text-align:left;
  cursor:pointer;
}

.category-button:hover{background:#fff0f7}
.category-arrow{width:12px;text-align:center}
.category-name{flex:1}
.category-count{color:#a27c90;font-weight:normal;font-size:9px}

.work-list{
  display:grid;
  gap:2px;
  padding:0 0 2px 15px;
}

.work-list.collapsed{display:none}

.work-button{
  width:100%;
  border:1px solid transparent;
  border-radius:3px;
  padding:7px 8px;
  background:transparent;
  color:#5e4653;
  font-size:11px;
  text-align:left;
  line-height:1.25;
  cursor:pointer;
}

.work-button::before{
  content:"▤";
  margin-right:7px;
  color:#d35895;
}

.work-button:hover{
  border-color:#efb6d2;
  background:#fff3f9;
}

.work-button.active{
  border-color:#d878a7;
  color:#7b2350;
  background:linear-gradient(90deg,#ffd9ea,#fff7fb);
  font-weight:bold;
}

.reader-panel{
  display:flex;
  flex-direction:column;
  background:#f5f1f3;
}

.reader-toolbar{
  flex:0 0 auto;
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:16px;
  padding:12px 14px 10px;
  border-bottom:1px solid #cbb6c1;
  background:linear-gradient(#fff,#f7edf2);
}

.eyebrow{
  margin-bottom:3px;
  color:#b55b87;
  font-size:9px;
  font-weight:bold;
  letter-spacing:1.1px;
  text-transform:uppercase;
}

.reader-toolbar h1{
  margin:0;
  color:#4c2b3d;
  font:normal 24px Georgia,"Times New Roman",serif;
}

.reader-controls{
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:5px;
}

.view-btn{
  border:1px solid #b88aa2;
  border-radius:3px;
  padding:5px 8px;
  color:#684158;
  background:linear-gradient(#fff,#eee4e9);
  font-size:9px;
  cursor:pointer;
}

.view-btn.active{
  border-color:#d15c94;
  color:#781f4b;
  background:linear-gradient(#fff,#ffcfe4);
  font-weight:bold;
}

.reader-scroll{
  flex:1;
  min-height:0;
  overflow:auto;
  padding:14px;
}

.reader-content{
  width:min(920px,100%);
  min-height:100%;
  margin:0 auto;
  padding:30px clamp(20px,4vw,48px) 38px;
  border:1px solid #d8d0d4;
  background:var(--paper);
  box-shadow:0 5px 16px rgba(55,34,46,.10);
  font:16px/1.55 Georgia,"Times New Roman",serif;
}

.reader-content p{margin:0 0 1em}
.reader-content em{font-style:italic}

.poem-single{
  max-width:610px;
  margin:0 auto;
  white-space:pre-wrap;
}

.poem-sections{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:46px;
  align-items:start;
}

.poem-column{
  min-width:0;
  white-space:pre-wrap;
}

.poem-column + .poem-column{
  position:relative;
  padding-left:34px;
  border-left:1px solid #ead8e1;
}

.poem-signature-wrap{
  width:100%;
  margin-top:30px;
  padding-top:8px;
  text-align:right;
}

.poem-signature{
  display:inline-block;
  width:145px;
  max-width:42%;
  height:auto;
  object-fit:contain;
  opacity:.92;
  user-select:none;
  pointer-events:none;
}

.continue-marker,
.continued-marker{
  font-family:Tahoma,Verdana,sans-serif;
  font-size:9px;
  font-weight:bold;
  letter-spacing:.8px;
  text-transform:uppercase;
  color:#c34d84;
}

.continue-marker{
  margin-top:26px;
  text-align:right;
}

.continued-marker{
  margin:-2px 0 15px;
}

.properties-inner{
  flex:1;
  overflow:auto;
  padding:14px 13px 22px;
}

.properties-inner h2{
  margin:0 0 8px;
  color:#69304e;
  font:normal 20px Georgia,"Times New Roman",serif;
}

.properties-inner h3{
  margin:0 0 10px;
  color:#9a3f6c;
  font-size:12px;
}

.property-meta{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}

.meta-pill{
  display:inline-block;
  padding:4px 7px;
  border:1px solid #dfb1c8;
  border-radius:10px;
  color:#785367;
  background:#fff;
  font-size:9px;
}

.divider{
  height:1px;
  margin:14px 0;
  background:linear-gradient(90deg,#d8a6bf,transparent);
}

.property-notes{
  color:#614a57;
  font-size:11px;
  line-height:1.55;
}

.property-notes p{margin:0 0 11px}
.property-notes em{color:#713b57}

.truth-list{
  margin:6px 0 12px;
  padding-left:19px;
}

.truth-list li{margin-bottom:7px}

.empty-state{
  padding:20px;
  color:#876f7c;
  text-align:center;
  font-size:11px;
}


/* -------------------------------------------------
   WRITING REACTIONS
------------------------------------------------- */

.writing-reactions{
  width:min(920px,100%);
  margin:10px auto 4px;
  padding:13px 18px 15px;
  border:1px solid #dfc5d2;
  background:
    linear-gradient(rgba(255,255,255,.88),rgba(255,255,255,.88)),
    linear-gradient(135deg,#ffe7f2,#f3ecff);
  box-shadow:0 3px 10px rgba(55,34,46,.07);
}

.reaction-heading{
  margin-bottom:11px;
  color:#98617e;
  font:italic 12px Georgia,"Times New Roman",serif;
}

.reaction-buttons{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
}

.reaction-button{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;

  min-height:42px;
  padding:5px 8px;

  border:1px solid transparent;
  border-radius:8px;

  color:var(--ink);
  background:transparent;

  cursor:pointer;

  transition:
    transform .12s ease,
    background .12s ease,
    border-color .12s ease,
    box-shadow .12s ease;
}

.reaction-button:hover{
  border-color:#e6b9cf;
  background:#fff6fa;
  box-shadow:0 2px 5px rgba(91,52,72,.08);
  transform:translateY(-1px);
}

.reaction-button:active{
  transform:translateY(1px) scale(.97);
}

.reaction-button.reacted{
  border-color:#dc8eb3;
  background:linear-gradient(#fff,#ffe4f0);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,.8),
    0 2px 5px rgba(111,53,82,.08);
}

.reaction-button.reacted .reaction-icon{
  opacity:1;
}

.reaction-button:focus-visible{
  outline:2px solid var(--pink);
  outline-offset:2px;
}

.reaction-icon{
  display:block;
  width:auto;
  height:31px;
  max-width:108px;
  object-fit:contain;

  opacity:.78;

  transition:
    opacity .12s ease,
    transform .12s ease;

  user-select:none;
  pointer-events:none;
}

.reaction-button:hover .reaction-icon{
  opacity:1;
  transform:rotate(-1deg);
}

.reaction-count{
  min-width:14px;
  color:#956d82;
  font:10px Tahoma,Verdana,sans-serif;
  line-height:1;
  text-align:center;
}

.reaction-button.reacted .reaction-count{
  color:#a3386d;
  font-weight:bold;
}

.writing-reactions.loading{
  opacity:.65;
  pointer-events:none;
}

.writing-reactions.error .reaction-heading::after{
  content:"  (reactions are being shy right now)";
  color:#b987a1;
  font-size:10px;
}


/* Handwritten poems: force the whole page to fit inside the reader */

.handwritten-poem-wrap{
  width:100%;
  height:100%;
  min-height:0;
  display:flex;
  justify-content:center;
  align-items:flex-start;
  overflow:hidden;
}

.reader-content:has(.handwritten-poem-wrap){
  padding:16px !important;
  min-height:0;
}

.handwritten-poem-image{
  display:block !important;
  width:auto !important;
  height:auto !important;
  max-width:100% !important;
  max-height:calc(100vh - 210px) !important;
  object-fit:contain !important;
  margin:0 auto !important;
}


@media (max-width:980px){
  body{overflow:auto}

  .writing-app{
    height:auto;
    min-height:100vh;
    grid-template-columns:190px minmax(0,1fr);
  }

  .properties-panel{
    grid-column:1/-1;
    min-height:260px;
  }
}


@media (max-width:720px){
  .writing-app{
    display:block;
    padding:6px;
  }

  .panel{margin-bottom:7px}

  .library-panel{
    max-height:260px;
  }

  .reader-panel{
    height:auto;
    min-height:70vh;
  }

  .reader-toolbar{
    align-items:flex-start;
    flex-direction:column;
  }

  .reader-content{
    padding:24px 18px 30px;
    font-size:15px;
  }

  .poem-sections{
    grid-template-columns:1fr;
    gap:26px;
  }

  .poem-column + .poem-column{
    padding-left:0;
    padding-top:24px;
    border-left:0;
    border-top:1px solid #ead8e1;
  }

  .continue-marker{
    text-align:left;
  }

  .writing-reactions{
    padding:12px 10px 13px;
  }

  .reaction-buttons{
    gap:4px;
  }

  .reaction-button{
    min-height:38px;
    padding:4px 6px;
  }

  .reaction-icon{
    height:27px;
    max-width:94px;
  }

  .reaction-count{
    font-size:9px;
  }
}