.stories-workspace {
  height: calc(100vh - 75px);
  padding: clamp(22px, 3vw, 42px);
  overflow: auto;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 10%, rgba(113, 113, 62, 0.16), transparent 30%),
    linear-gradient(rgba(244, 235, 209, 0.55), rgba(229, 209, 166, 0.58)),
    url('/assets/images/parchment.png') center / 630px repeat;
}

.stories-page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  max-width: 1220px;
  margin: 0 auto 24px;
}

.stories-page-header .eyebrow { margin: 0 0 4px; }

.stories-page-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(33px, 4vw, 50px);
  font-weight: 500;
  line-height: 1;
}

.stories-page-header h1:focus { outline: none; }

.stories-page-header p:last-child {
  max-width: 660px;
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.stories-page-header .button {
  flex: 0 0 auto;
  gap: 8px;
  min-height: 43px;
  padding-inline: 19px;
}

.stories-page-header .button svg { width: 17px; height: 17px; }

.stories-layout {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  max-width: 1220px;
  min-height: min(680px, calc(100vh - 210px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(92, 64, 28, 0.38);
  border-radius: 22px;
  background: rgba(244, 225, 183, 0.43);
  box-shadow: 0 18px 48px rgba(70, 49, 21, 0.2), inset 0 0 0 4px rgba(255, 244, 214, 0.2);
}

.stories-browser {
  min-width: 0;
  border-right: 1px solid rgba(92, 64, 28, 0.26);
  background: rgba(229, 204, 154, 0.42);
}

.stories-browser-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 22px 19px 16px;
  border-bottom: 1px solid rgba(92, 64, 28, 0.23);
  background:
    linear-gradient(rgba(235, 213, 170, 0.96), rgba(228, 202, 153, 0.96)),
    url('/assets/images/parchment.png') center / 480px;
}

.stories-browser-heading > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.stories-browser-heading h2 { margin: 0; font-size: 17px; }
.stories-browser-heading > div span { color: #735e3f; font-size: 11px; }

.stories-search { position: relative; display: block; }

.stories-search svg {
  position: absolute;
  top: 11px;
  left: 12px;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.stories-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid rgba(85, 61, 28, 0.34);
  border-radius: 10px;
  outline: none;
  background: rgba(255, 246, 218, 0.48);
}

.stories-search input:focus,
.story-form-grid textarea:focus {
  border-color: #9c762f;
  box-shadow: 0 0 0 3px rgba(156, 118, 47, 0.15);
}

.stories-browser-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 340px);
  padding: 13px;
  overflow-y: auto;
}

.story-browser-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 11px;
  width: 100%;
  min-height: 83px;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #493820;
  text-align: left;
  background: rgba(255, 243, 209, 0.22);
}

.story-browser-card:hover { background: rgba(255, 243, 209, 0.48); }

.story-browser-card.active {
  border-color: rgba(125, 85, 34, 0.45);
  background: rgba(255, 238, 193, 0.72);
  box-shadow: 0 3px 10px rgba(80, 54, 22, 0.12);
}

.story-browser-image,
.story-detail-image {
  background-image: url('/assets/images/memory-sprite.png');
  background-repeat: no-repeat;
  background-size: 600% auto;
}

.story-browser-image { height: 67px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(68, 48, 24, 0.25); }
.story-browser-card > span:last-child { align-self: center; min-width: 0; }
.story-browser-card strong,
.story-browser-card small,
.story-browser-people { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-browser-card strong { font-size: 13px; font-weight: 600; }
.story-browser-card small { margin-top: 4px; color: #735d3e; font-size: 10px; }
.story-browser-people { margin-top: 6px; color: #775837; font-size: 9px; font-style: italic; }
.stories-no-results { margin: 28px 15px; color: #745e3e; font-size: 12px; font-style: italic; text-align: center; }

.story-detail {
  min-width: 0;
  padding: clamp(24px, 4vw, 52px);
  overflow-y: auto;
  background:
    radial-gradient(circle at 90% 8%, rgba(112, 118, 68, 0.1), transparent 28%),
    rgba(247, 232, 197, 0.35);
}

.story-detail-hero {
  display: grid;
  grid-template-columns: minmax(180px, 255px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(22px, 4vw, 42px);
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(100, 71, 31, 0.24);
}

.story-detail-image {
  aspect-ratio: 1.55;
  border: 6px solid rgba(242, 222, 178, 0.88);
  border-radius: 4px;
  box-shadow: 0 9px 22px rgba(72, 49, 20, 0.24), inset 0 0 0 1px rgba(68, 48, 24, 0.34);
  transform: rotate(-1deg);
}

.story-detail-hero .eyebrow { margin: 0 0 6px; }

.story-detail-hero h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(31px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.03;
}

.story-detail-subtitle { margin: 10px 0 0; color: #735d3e; font-size: 15px; font-style: italic; }

.story-detail-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 17px 0 9px; }

.story-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(89, 62, 29, 0.28);
  border-radius: 8px;
  color: #574126;
  font-size: 11px;
  background: rgba(255, 243, 209, 0.27);
}

.story-action:hover { background: rgba(255, 243, 209, 0.62); }
.story-action svg { width: 14px; height: 14px; }
.story-action-danger { color: #7f3d31; }

.story-detail-people,
.story-narrative-copy { margin-top: 26px; }
.story-detail-people h3,
.story-narrative-copy h3 { margin: 0 0 11px; color: #664d2d; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; }
.story-detail-people > div { display: flex; flex-wrap: wrap; gap: 8px; }

.story-detail-people button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 11px 4px 5px;
  border: 1px solid rgba(92, 65, 29, 0.3);
  border-radius: 20px;
  color: #4f3b22;
  font-size: 11px;
  background: rgba(255, 241, 204, 0.43);
}

.story-detail-people button:hover { background: rgba(255, 241, 204, 0.78); }

.story-person-portrait {
  display: inline-block;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  border-radius: 50%;
  background-image: url('/assets/images/portrait-sprite.png');
  background-size: 400% 400%;
  box-shadow: inset 0 0 0 1px rgba(75, 52, 25, 0.34);
}

.story-narrative-copy p {
  margin: 0;
  color: #493820;
  font-family: var(--font-display);
  font-size: clamp(16px, 1.7vw, 19px);
  line-height: 1.72;
  white-space: pre-wrap;
}

.story-detail-empty {
  display: grid;
  place-items: center;
  max-width: 520px;
  min-height: 480px;
  margin: auto;
  align-content: center;
  text-align: center;
}

.story-empty-flourish { color: #8d713e; font-size: 48px; }
.story-detail-empty h2 { margin: 5px 0 9px; font-family: var(--font-display); font-size: 31px; font-weight: 500; }
.story-detail-empty p { margin: 0 0 20px; color: #715b3b; }

.story-card { padding: 0; color: #4a3821; text-align: left; }
.story-card:focus-visible { outline: 3px solid rgba(106, 76, 31, 0.52); outline-offset: 2px; }
.story-card .story-image { display: block; width: 100%; }
.story-dock-empty { align-self: center; margin: 0; color: #6d5739; font-size: 12px; font-style: italic; text-align: center; }
.add-story:disabled { cursor: not-allowed; opacity: 0.55; }

.story-browser-image.memory-0,
.story-detail-image.memory-0 { background-position: 0 48%; }
.story-browser-image.memory-1,
.story-detail-image.memory-1 { background-position: 20% 38%; }
.story-browser-image.memory-2,
.story-detail-image.memory-2 { background-position: 40% 48%; }
.story-browser-image.memory-3,
.story-detail-image.memory-3 { background-position: 60% 48%; }
.story-browser-image.memory-4,
.story-detail-image.memory-4 { background-position: 80% 35%; }
.story-browser-image.memory-5,
.story-detail-image.memory-5 { background-position: 100% 45%; }

.story-editor-dialog { width: min(760px, calc(100vw - 30px)); }
.story-editor-dialog form { gap: 17px; }
.story-form-grid { display: grid; grid-template-columns: 1fr 210px; gap: 14px; }
.story-form-grid > label:first-child,
.story-narrative,
.story-people-fieldset { grid-column: 1 / -1; }
.story-form-grid label small,
.story-people-fieldset small { color: #786143; font-size: 10px; font-weight: 400; }

.story-form-grid textarea {
  width: 100%;
  min-height: 170px;
  padding: 12px 13px;
  resize: vertical;
  border: 1px solid rgba(86, 63, 27, 0.38);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
  background: rgba(255, 248, 222, 0.58);
  box-shadow: inset 0 2px 4px rgba(71, 50, 23, 0.08);
}

.story-people-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.story-people-fieldset legend { margin-bottom: 8px; color: #58452d; font-size: 13px; }

.story-people-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  max-height: 174px;
  padding: 2px;
  overflow-y: auto;
}

.parchment-dialog .story-people-options label {
  display: grid;
  grid-template-columns: 18px 29px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(91, 64, 29, 0.24);
  border-radius: 9px;
  font-size: 11px;
  background: rgba(255, 244, 212, 0.24);
}

.parchment-dialog .story-people-options label:has(input:checked) {
  border-color: rgba(123, 88, 35, 0.5);
  background: rgba(255, 239, 197, 0.7);
}

.parchment-dialog .story-people-options input { width: 16px; height: 16px; padding: 0; accent-color: #7d6d3a; }
.parchment-dialog .story-people-options label > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-delete-dialog { width: min(460px, calc(100vw - 30px)); }
.story-delete-dialog p:not(.eyebrow):not(.form-error) { margin: 0; color: #624c30; line-height: 1.5; }

@media (max-width: 900px) {
  .stories-workspace { padding: 24px 18px; }
  .stories-layout { grid-template-columns: 285px minmax(0, 1fr); }
  .story-detail { padding: 27px; }
  .story-detail-hero { grid-template-columns: 1fr; }
  .story-detail-image { width: min(100%, 300px); }
  .story-people-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .stories-workspace { height: calc(100vh - 64px); padding: 18px 10px; }
  .stories-page-header { align-items: start; margin-bottom: 16px; }
  .stories-page-header p:last-child { display: none; }
  .stories-page-header .button { min-height: 39px; padding-inline: 12px; }
  .stories-layout { display: block; min-height: 0; overflow: visible; border-radius: 16px; }
  .stories-browser { border-right: 0; border-bottom: 1px solid rgba(92, 64, 28, 0.26); }
  .stories-browser-heading { position: static; padding: 16px 14px 12px; }
  .stories-browser-list { display: flex; max-height: none; padding: 10px; overflow-x: auto; overflow-y: hidden; }
  .story-browser-card { grid-template-columns: 58px 148px; flex: 0 0 225px; min-height: 70px; }
  .story-browser-image { height: 54px; }
  .story-detail { min-height: 420px; padding: 24px 18px 32px; }
  .story-detail-hero { gap: 22px; }
  .story-detail-actions { justify-content: flex-start; }
  .story-form-grid { grid-template-columns: 1fr; }
  .story-form-grid > label,
  .story-narrative,
  .story-people-fieldset { grid-column: auto; }
  .story-people-options { grid-template-columns: 1fr; }
  .story-editor-dialog form { padding: 28px 21px 24px; }
}
