#workspace[hidden], #library-view[hidden] { display: none !important; }
#library-view { width: min(100% - 64px, 1280px); margin: 42px auto 64px; }
.shelf-heading, .shelf-card-top, .shelf-card-meta, .script-dialog-header, .script-section-bar, .script-dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.shelf-heading { margin: 0 0 28px; }
.shelf-title { margin: 0; font-size: clamp(1.65rem, 3vw, 2rem); line-height: 1.35; letter-spacing: -.04em; color: #25232d; }
.shelf-count { margin: 6px 0 0; color: #656370; font-size: .875rem; }
.script-button, .script-add, .script-mark, .script-icon-button, .shelf-card { appearance: none; font: inherit; cursor: pointer; }
.script-button, .script-add, .script-mark, .script-icon-button, .script-icon-tile, .script-footer-buttons, .script-section-actions, .script-dialog-heading { display: inline-flex; align-items: center; justify-content: center; }
.script-button { flex: none; gap: 7px; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 10px; font-size: .9rem; font-weight: 600; line-height: 1.2; }
.script-primary { color: #fff; background: var(--accent, #7354dc); }
.script-primary:hover { filter: brightness(.93); }
.script-secondary { color: #504b58; background: #fff; border-color: #e0dde7; }
.script-secondary:hover, .script-icon-button:hover { background: #f5f3fa; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 295px), 1fr)); gap: 18px; }
.shelf-card { min-width: 0; max-width: 480px; display: flex; flex-direction: column; align-items: stretch; padding: 22px; border: 1px solid #e5e2e9; border-radius: 16px; text-align: start; background: white; color: #292532; transition: border-color .18s ease, box-shadow .18s ease; }
.shelf-card:hover { border-color: #b6a4e0; box-shadow: 0 4px 14px #3a2a650a; }
.script-icon-tile { flex: 0 0 auto; width: 41px; height: 41px; border-radius: 12px; background: #f1ecfc; color: #7855c9; }
.shelf-current { padding: 4px 9px; border-radius: 6px; background: #f1ecfc; color: #6448a6; font-size: .77rem; font-weight: 600; }
.shelf-card-title { margin: 17px 0 8px; font-size: 1.16rem; line-height: 1.5; overflow-wrap: anywhere; }
.shelf-preview { min-height: 3.2em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; line-height: 1.6; font-size: .925rem; color: #706b79; }
.shelf-card-meta { margin-top: 20px; padding-top: 14px; border-top: 1px solid #efedf2; font-size: .8125rem; color: #736f7b; }

.script-dialog { position: fixed; inset: 0; box-sizing: border-box; width: min(640px, calc(100vw - 40px)); max-width: none; max-height: none; margin: auto; border: 1px solid #e4e0ea; border-radius: 20px; padding: 0; overflow: hidden; background: #fff; color: #25222d; box-shadow: 0 24px 80px #19122230; font: inherit; }
.script-dialog:not([open]) { display: none; }
.script-dialog::backdrop { background: #1c17256b; backdrop-filter: blur(3px); }
body:has(.script-dialog[open]) { overflow: hidden; }
.script-form { display: flex; flex-direction: column; max-height: min(84vh, 910px); max-height: min(84dvh, 910px); margin: 0; }
.script-dialog-header { flex: none; padding: 20px 25px; border-bottom: 1px solid #eae7ef; }
.script-dialog-heading { gap: 11px; }
.script-dialog-heading h2 { margin: 0; color: #28242e; font-size: 1.23rem; line-height: 1.4; font-weight: 700; }
.script-editor-count { color: #726a7c; font-size: .83rem; }
.script-dialog-heading .script-icon-tile { width: 36px; height: 36px; border-radius: 10px; }
.script-icon-button { padding: 0; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: #716a7c; }
.script-icon-button:disabled { cursor: default; color: #bdb9c3; background: transparent; }
.script-dialog-body { overflow-y: auto; overscroll-behavior: contain; padding: 22px 25px; }
.script-editor-panel { min-width: 0; margin: 0; padding: 0; border: 0; }
.script-editor-panel[hidden], .script-alternate[hidden] { display: none; }
.script-intake-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.script-intake-bar .script-field-label { margin: 0; }
.script-file { min-height: 38px; padding: 0 12px; }
.script-source { min-height: 11rem; line-height: 1.75; resize: vertical; }
.script-intake-status { margin: 10px 0 0; color: #6d6479; font-size: .86rem; overflow-wrap: anywhere; }
.script-intake-status:empty { display: none; }
.script-notes { margin-top: 10px; }
.script-notes summary { width: fit-content; min-height: 36px; padding: 8px 0; box-sizing: border-box; color: #6d6479; cursor: pointer; font-size: .875rem; }
.script-notes textarea { margin-top: 4px; resize: vertical; }
.script-alternate { padding-inline: 0; color: #6e54a3; background: transparent; }
.script-alternate:hover { text-decoration: underline; }
.script-dialog-heading h2:focus { outline: none; }
.script-field-label { display: block; margin-bottom: 8px; font-size: .9rem; font-weight: 650; }
.script-input { display: block; box-sizing: border-box; width: 100%; min-width: 0; padding: 10px 12px; color: #302a38; background: #fff; border: 1px solid #dedbe5; border-radius: 9px; font: inherit; font-size: 1rem; line-height: 1.5; }
.script-input::placeholder { color: #827b8b; }
.script-input:focus { outline: 2px solid #b4a0ea; outline-offset: 1px; border-color: #9e83e0; }
.script-sections { display: grid; gap: 20px; margin-top: 22px; }
.script-section { min-width: 0; margin: 0; }
.script-section-bar { margin-bottom: 6px; }
.script-section-label { color: #594d70; font-size: .88rem; font-weight: 650; }
.script-section-actions { gap: 4px; }
.script-mark { padding: 5px 7px; min-height: 34px; gap: 5px; color: #6e54a3; background: transparent; border: 0; border-radius: 7px; font-size: .8rem; }
.script-mark svg { width: 15px; height: 15px; }
.script-mark:hover { background: #f3eff9; }
.script-body { margin-top: 7px; line-height: 1.65; resize: vertical; min-height: 5.5em; }
.script-add { box-sizing: border-box; justify-content: center; width: 100%; margin-top: 16px; padding: 11px 14px; border: 1px dashed #c8bbde; border-radius: 9px; gap: 6px; color: #7157a3; background: #fcfbfe; font-size: .9rem; font-weight: 600; }
.script-add:hover { background: #f5f0fb; }
.script-dialog-footer { flex: none; justify-content: space-between; flex-wrap: wrap; padding: 15px 25px; border-top: 1px solid #eae7ef; }
.script-dialog-footer .script-error:not(:empty) { width: 100%; }
.script-footer-buttons { gap: 9px; margin-inline-start: auto; }
.script-error { margin: 0; font-size: .86rem; color: #ab3249; }
.script-error:empty { display: none; }
:where(.shelf-card, .script-button, .script-add, .script-mark, .script-icon-button):focus-visible { outline: 3px solid #a58bdf; outline-offset: 3px; }

@media (max-width: 640px) {
  #library-view { width: calc(100% - 32px); margin-top: 25px; }
  .shelf-heading { margin-bottom: 20px; }
  .shelf-grid { grid-template-columns: 1fr; gap: 12px; }
  .shelf-card { max-width: none; padding: 18px; }
  .script-dialog { inset: 0; margin: auto auto 0; width: 100%; border-radius: 18px 18px 0 0; border-bottom: 0; }
  .script-form { max-height: calc(100vh - 15px); max-height: calc(100dvh - 15px - env(safe-area-inset-top)); }
  .script-dialog-header { padding: 14px 17px; }
  .script-dialog-body { padding: 18px 17px; }
  .script-dialog-footer { padding: 13px 17px max(13px, env(safe-area-inset-bottom)); }
  .script-icon-button { width: 42px; height: 42px; }
  .script-mark, .script-button, .script-add { min-height: 44px; }
  .script-section-actions { gap: 7px; }
}
