:root { --bg: #111317; --panel: #181a1f; --fg: #f2efe9; --dim: #8a8d94; --line: #3a3d44; --accent: #e0563b; --quote: #e0b03b; --mark: rgba(224, 176, 59, 0.28); --active: rgba(224, 86, 59, 0.45); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: 'Noto Sans', 'Noto Sans Bengali', 'Kohinoor Bangla', sans-serif; }
a { color: var(--fg); }
button, .button { display: inline-block; background: #1d2026; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
button:hover, .button:hover { background: #2a2d33; }
.primary { border-color: var(--accent); }
.armed { border-color: var(--accent); color: var(--accent); }
textarea { width: 100%; background: #1d2026; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: inherit; font-size: 15px; resize: vertical; }
.hint { color: var(--dim); font-size: 14px; }
.hint b { color: var(--fg); }
.warn { color: var(--accent); }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; align-items: center; }
.row.start { justify-content: flex-start; margin: 0; }

/* Library */
#library { max-width: 760px; margin: 0 auto; padding: 32px 16px 80px; }
#library header { display: flex; align-items: center; gap: 12px; }
#library h1 { font-size: 26px; margin: 0 auto 0 0; }
#docs { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
#docs li { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel); }
#docs li > div { flex: 1; min-width: 0; }
#docs .name { font-size: 17px; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
#docs .name:hover { text-decoration: underline; }
#docs .info { color: var(--dim); font-size: 13px; margin-top: 2px; }
#dropzone { display: none; position: fixed; inset: 12px; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(17, 19, 23, 0.85);
  align-items: center; justify-content: center; font-size: 22px; pointer-events: none; z-index: 10; }
body.dragging #dropzone { display: flex; }

/* Reader */
#reader { display: grid; grid-template-columns: 1fr 380px; height: 100vh; height: 100dvh; }
#script { overflow-y: auto; padding: 24px 56px 120px; font-size: 20px; line-height: 1.8; }
#script .back { font-size: 14px; color: var(--dim); text-decoration: none; }
#script .back:hover { color: var(--fg); }
#script h1 { font-size: 26px; margin: 8px 0 4px; overflow-wrap: anywhere; }
#script #subtitle { margin: 0; }
#script h2 { font-size: 18px; color: var(--dim); font-weight: 600; margin: 36px 0 8px; letter-spacing: 0.02em; }
#script p { margin: 0 0 14px; max-width: 46em; }
.s:hover { background: rgba(255, 255, 255, 0.04); }
mark { background: var(--mark); color: inherit; border-radius: 2px; cursor: pointer; }
mark.active { background: var(--active); }

#side { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel); overflow: hidden; }
#side label { color: var(--dim); font-size: 13px; }
#top { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--dim); }
#top #clear { margin-left: auto; }
#comments { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
#comments li { border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 14px; }
#comments li.active { border-color: var(--accent); }
#comments .ref { color: var(--dim); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; }
#comments .quote { margin: 4px 0 6px; color: var(--quote); cursor: pointer; }
#comments .del { padding: 0 6px; font-size: 12px; color: var(--dim); }

#add { position: fixed; z-index: 5; border-color: var(--accent); }
#pop { position: fixed; z-index: 6; width: min(380px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); }
#popQuote { color: var(--quote); font-size: 14px; margin-bottom: 8px; max-height: 5em; overflow: auto; }
#error { position: fixed; bottom: 12px; left: 12px; right: 12px; margin: 0; padding: 8px 12px; color: var(--accent); background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; z-index: 20; cursor: pointer; }

#toggleSide, #hideSide { display: none; }

/* Phones and narrow tablets: the text fills the screen; comments open as a sheet from a floating button. */
@media (max-width: 820px) {
  #reader { grid-template-columns: 1fr; }
  #script { padding: 16px 16px 90px; font-size: 18px; line-height: 1.75; }
  #script h1 { font-size: 21px; }
  #side { position: fixed; left: 0; right: 0; bottom: 0; height: 75dvh; z-index: 7; border-top: 1px solid var(--line);
    border-radius: 14px 14px 0 0; padding: 12px; gap: 8px; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
    transform: translateY(100%); transition: transform 0.2s; }
  body.show-side #side { transform: none; }
  #top { flex-wrap: wrap; }
  #hideSide { display: inline-block; }
  #toggleSide { display: block; position: fixed; right: 16px; bottom: 16px; z-index: 6; border-radius: 24px;
    padding: 10px 16px; border-color: var(--accent); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5); }
  body.show-side #toggleSide { display: none; }
  #pop { z-index: 8; }
  button, .button { padding: 8px 12px; }
  #docs li { flex-wrap: wrap; }
  #docs li > div { flex-basis: 100%; }
}
