.planning-stack { display: grid; gap: 20px; min-width: 0; }
.planning-stack > .bar { margin: 0; }
.planning-card {
  display: grid;
  min-width: 0;
  gap: 14px;
  padding: var(--sheet-padding);
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius);
  background: var(--sheet-background);
  box-shadow: var(--sheet-shadow);
}
.planning-card:focus-within, .profile-study:focus-within { border-color: #ba8979; }
.planning-card h3, .profile-study h3 { font: 400 23px/1.1 var(--display-font); }
.planning-card > button.writing-entry:not(.writing-entry-note) { box-shadow: none; }
.planning-card > button:not(.writing-entry) { justify-self: start; }
.planning-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.planning-form-grid label, .planning-card > label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: .9375rem;
}
.character-roster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.character-roster .planning-form-grid { grid-template-columns: minmax(0, 1fr); }
.character-card { align-content: start; }
.character-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.character-card-heading h3, .character-card-heading p { margin: 0; }
.character-card-heading h3 { font-size: clamp(25px, 2.6vw, 34px); overflow-wrap: anywhere; }
.character-card-notes { max-width: 62ch; margin: 0; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.cast-group-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.cast-group-heading h3 { margin: 0 0 3px; overflow-wrap: anywhere; }
.corkboard-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.character-art { display: flex; align-items: start; flex-wrap: wrap; gap: 10px; }
button.image-preview-trigger {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #eae0ea;
  cursor: zoom-in;
}
.character-art .image-preview-trigger { width: min(100%, 160px); }
.image-preview-trigger img { display: block; width: 100%; object-fit: contain; border-radius: inherit; }
.character-art .image-preview-trigger img { height: 160px; }
.studio-image-preview {
  max-width: 92vw;
  max-height: 92dvh;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius);
  background: var(--sheet-background);
  color: var(--text);
  box-shadow: var(--sheet-shadow);
}
.studio-image-preview::backdrop { background: #302936b8; }
.studio-image-preview-frame { display: grid; gap: 8px; padding: 12px; }
.studio-image-preview-frame form { justify-self: end; margin: 0; }
.studio-image-preview-frame img { display: block; margin: auto; max-width: 100%; max-height: calc(92dvh - 4.5rem); object-fit: contain; }
.character-art > div { flex: 1 1 150px; min-width: 0; }
.character-art-upload { display: grid; gap: 4px; color: var(--muted); font-size: .9375rem; }
.character-art-upload input { width: 100%; padding: 4px; font-size: .9375rem; }
.character-art > div button { margin-top: 6px; }
.character-art p { margin: 5px 0 0; font-size: .9375rem; }
.cast-workspace, .cast-workspace > section { gap: 12px; }
.cast-motives { padding-top: 12px; border-top: 1px solid var(--line); }
.cast-motives h2, .cast-motives h3 { margin: 0; }
.cast-motive-card { align-content: start; }
.cast-motive-heading { display: grid; gap: 6px; align-content: start; overflow-wrap: anywhere; }
.cast-motive-heading p { margin: 0; }
@media (min-width: 761px) {
  .cast-motive-card { grid-row: span 3; grid-template-rows: subgrid; }
}
.cast-members { display: grid; gap: 6px; }
.cast-members label { display: grid; gap: 4px; max-width: 320px; color: var(--muted); font-size: .9375rem; }
.cast-members ul { display: flex; gap: 6px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.cast-members li { display: flex; gap: 7px; align-items: center; padding: 3px 4px 3px 10px; border-radius: 18px; background: var(--panel); }
.cast-members li button { padding: 2px 7px; font-size: .9375rem; }
.brief-prompts { display: grid; gap: 8px; }
.brief-tabs { margin: 0; }

.board-workspace .worksheet { max-width: none; grid-template-columns: minmax(0, 1fr); }
.profile-fieldset, .profile-guidance, .profile-study {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius);
  background: var(--sheet-background);
  padding: var(--sheet-padding);
}
.profile-study { box-shadow: var(--sheet-shadow); }
.profile-fieldset { margin: 0; }
.profile-fieldset legend { padding-inline: 6px; font-weight: 700; }
.profile-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.profile-choices label, .profile-study label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  font-size: .9375rem;
}
.profile-choices label { border: 1px solid var(--line); border-radius: 18px; padding: 4px 9px; background: var(--chip); cursor: pointer; }
.profile-choices label:has(input:checked), .profile-choices button[aria-pressed='true'] { background: var(--selected); border-color: var(--accent); }
.profile-custom { display: grid; gap: 4px; max-width: 240px; margin-top: 10px; font-size: .9375rem; }
.profile-studies { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 305px), 1fr)); gap: 16px; }
.profile-study { display: flex; justify-content: space-between; text-align: start; gap: 14px; }
.profile-study > span { display: grid; gap: 3px; }
.profile-study strong { font-size: 1.0625rem; }
.profile-study > span > :is(span, small) { color: var(--muted); font-size: .9375rem; }
.profile-study .studio-icon { color: var(--wine); }
.profile-guidance p { margin: 0; }
.profile-guidance a { color: var(--wine-dark); }
.game-study-window {
  width: min(700px, calc(100vw - 24px));
  max-height: min(85dvh, 760px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--control);
  border-radius: 22px;
  background: var(--paper);
  color: var(--text);
  box-shadow: var(--sheet-lift);
}
.game-study-window::backdrop { background: #302936a8; }
.game-study-sheet { padding: 0 clamp(16px, 5vw, 30px) 22px; }
.game-study-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  padding-block: 20px 14px;
  background: var(--paper);
}
.game-study-header h2, .game-study-header p { margin: 0; overflow-wrap: anywhere; }
.game-study-header button { flex: none; }
.game-study-sections details { border-block-start: 1px solid var(--line); }
.game-study-sections summary { min-height: 44px; padding: 9px 3px; font-weight: 600; color: var(--text); }
.game-study-sections p { margin-block: 0 14px; }
.game-study-sections dd { color: var(--text); }
.game-study-sources { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-bottom: 12px; }
.game-study-sources a { color: var(--wine-dark); }
.game-study-use { display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.game-study-use label { display: flex; align-items: center; gap: 8px; }
.game-study-use .bar { margin: 0; }
.profile-guidance { display: grid; gap: 7px; background: var(--studio-grain), #efe5ef; box-shadow: inset 3px 0 #c9907b; }
.profile-guidance-heading { display: flex; gap: 6px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.profile-guidance button, .profile-restore { justify-self: start; font-size: .9375rem; }
.compose-study, .compose-study-preview { min-width: 0; }
.compose-study { padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--sheet-radius); background: var(--studio-grain), #eee4ec; }
.compose-study-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 8px 12px; }
.compose-study-toolbar label { display: grid; flex: 1 1 240px; min-width: 0; gap: 4px; max-width: 360px; font-size: .9375rem; }
.compose-study-toolbar select { min-width: 0; }
.compose-study > details { margin-top: 9px; }
.compose-study summary, .compose-study-preview summary { cursor: pointer; font-weight: 700; }
.compose-study dl, .compose-study-preview dl { display: grid; gap: 7px 14px; margin: 8px 0; }
.compose-study dl { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
.compose-study dt, .compose-study-preview dt { font-weight: 700; }
.compose-study dd, .compose-study-preview dd { margin: 2px 0 0; }
.compose-study dd { font-size: .9375rem; }
.compose-study-actions { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.compose-study-actions a { color: var(--wine-dark); font-size: .9375rem; }
.compose-study-status { margin: 4px 0 0; }
.compose-study-status:empty { display: none; }
.narrative-studies summary .muted { font-weight: 500; }
.narrative-study-example h2 { margin-block: 16px 8px; }
.narrative-study-example dd { max-width: 70ch; }
.narrative-study-example > a { display: inline-block; margin-block-start: 12px; }
.story-beats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-bottom: 12px; }
.music-section { padding-top: 8px; border-top: 1px solid var(--line); }
.music-add { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; align-items: end; }
.music-reference .bar { margin: 0; }
.music-reference audio { width: 100%; }
.music-embed { display: block; width: 100%; border: 0; border-radius: 9px; }

.macro-workspace { gap: 10px; }
.macro-scroll {
  overflow: auto;
  min-height: min(64vh, 585px);
  max-height: 74vh;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--studio-grain), linear-gradient(150deg, #efe8ef, #dfd1e2);
  box-shadow: var(--recessed-edge);
}
.macro-board { position: relative; min-width: 100%; }
.macro-lines { position: absolute; inset: 0; pointer-events: none; }
.macro-lines g > path { fill: none; stroke: var(--accent); stroke-width: 2; }
.macro-lines marker path { fill: var(--accent); }
.macro-lines text { fill: #69483c; font: 15px var(--body-font); paint-order: stroke; stroke: #e9dfe9; stroke-width: 4; }
.macro-empty { margin: 16px; }
.macro-card {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #b5a1aa;
  --sheet-padding: 8px;
  padding: var(--sheet-padding);
  border-radius: var(--sheet-radius);
  background: var(--sheet-background);
  box-shadow: var(--sheet-shadow);
}
.macro-card:is(:focus-within, .macro-card-dragged) { border-color: var(--accent); box-shadow: var(--sheet-lift); }
.macro-card:focus-within, .macro-card-dragged, :is(.note, .macro-card):has(.board-card-menu[open]) { z-index: 1; }
:is(.note, .macro-card) {
  cursor: grab;
  touch-action: none;
}
.macro-card-dragged { cursor: grabbing; }
.board-card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: none; font-size: .9375rem; font-weight: 600; }
.board-card-menu { position: relative; }
.board-card-menu summary { padding: 5px 8px; min-height: 36px; color: var(--wine-dark); font-size: .9375rem; }
.board-card-menu summary:hover { background: var(--selected); border-radius: var(--button-radius); }
.board-card-menu-panel {
  position: absolute;
  z-index: 2;
  inset-block-start: 100%;
  inset-inline-end: 0;
  width: 198px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--control);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--sheet-lift);
  font-size: .9375rem;
}
.board-card-menu-panel label { display: grid; gap: 4px; }
.board-card-menu-panel .macro-title { font: inherit; min-height: 40px; }
.board-card-menu-panel .delete-map-action { justify-self: end; }
.macro-title { min-height: 32px; height: 32px; padding: 4px 7px; border: 1px solid #e3d4d9; border-radius: var(--sheet-inside); font: 19px var(--display-font); }
button.writing-entry-note {
  flex: 1;
  min-height: 0;
  padding: 4px 6px;
  border-color: #e1d4dc;
  border-radius: var(--sheet-inside);
  background: #f8eff6;
  align-items: start;
  overflow: hidden;
}
button.writing-entry-note:hover:not(:disabled) { border-color: var(--control); background: #fff8f366; }
.writing-entry-note .writing-entry-value {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font: .9375rem/1.4 var(--body-font);
}
button.writing-entry-note[data-filled='true']:not(.writing-entry-action) { background: transparent; border-color: transparent; }
.macro-card-actions { display: flex; flex-shrink: 0; align-items: center; justify-content: end; gap: 8px; }
.macro-card-actions a { color: var(--wine-dark); font-size: .9375rem; margin-inline-end: auto; }
.macro-card-actions button { padding: 3px 5px; font-size: .9375rem; }
.macro-card-actions button[aria-pressed='true'] { background: var(--wine-dark); color: #fff; }
.narrative-corkboards { display: grid; gap: 28px; min-width: 0; }
.narrative-corkboard { min-width: 0; }
.narrative-corkboard + .narrative-corkboard { border-top: 1px solid var(--line); padding-top: 20px; }
.narrative-corkboards > .bar { margin: 0; }
.moodboard-image { width: 100%; flex-shrink: 0; }
.moodboard-image img { height: 165px; }

.rhythm-template {
  display: grid;
  grid-template-columns: minmax(160px, 260px) minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--sheet-radius);
  background: var(--sheet-background);
}
.rhythm-template label, .rhythm-pin-tools label { display: grid; gap: 3px; color: var(--muted); font-size: .9375rem; }
.rhythm-template .bar { margin: 7px 0 0; }
.rhythm-template-guide {
  display: grid;
  grid-template-columns: minmax(100px, 185px) minmax(0, 1fr);
  align-items: center;
  gap: 13px;
}
.rhythm-template-guide svg { width: 100%; max-height: 58px; }
.rhythm-template-guide:has(.rhythm-phase-preview) { grid-template-columns: minmax(90px, 155px) minmax(0, 1fr); }
.rhythm-template-guide svg[role='img'] { background: #f5eaf3; border-radius: 5px; }
.rhythm-phase-preview .rhythm-bands { margin: 7px 0 0; }
.rhythm-phase-preview .rhythm-band span { font-size: .9375rem; }
.rhythm-template-guide a { color: var(--wine-dark); }
.rhythm-template-guide p { margin: 4px 0 0; font-size: .9375rem; }
.rhythm-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--studio-grain), linear-gradient(150deg, #fff9f0, #f4e9e8);
  box-shadow: var(--recessed-edge);
}
.rhythm-section { min-width: 0; }
.rhythm-board { min-width: 760px; padding-bottom: 12px; }
.rhythm-bands { display: flex; margin: 12px 4.8% 0 5.8%; border: 1px solid #ad91a7; border-radius: 6px; }
.rhythm-band { position: relative; min-width: 0; background: #e7d6e6; }
.rhythm-band:nth-child(even) { background: #f2e6d5; }
.rhythm-band:first-child { border-radius: 5px 0 0 5px; }
.rhythm-band:last-child { border-radius: 0 5px 5px 0; }
.rhythm-band span { display: block; padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9375rem; }
button.rhythm-band-boundary {
  position: absolute;
  z-index: 1;
  inset: 0 -8px 0 auto;
  width: 16px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
}
.rhythm-band-boundary::before { content: ''; display: block; margin: auto; width: 2px; height: 64%; border-radius: 2px; background: #77536b; }
.rhythm-band-boundary:focus-visible { outline: 2px solid var(--wine-dark); }
.rhythm-curve { display: block; width: 100%; user-select: none; }
.rhythm-curve text { fill: #503c50; font: 15px var(--body-font); }
.rhythm-grid { stroke: #dbc4c4; stroke-width: 1; }
.rhythm-active-line {
  fill: none;
  stroke: #70485e;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.rhythm-reference-line { fill: none; stroke: #96788f; stroke-width: 1.5; stroke-dasharray: 7 5; }
.rhythm-point { cursor: grab; touch-action: none; outline: none; }
.rhythm-point:active { cursor: grabbing; }
.rhythm-point-target { fill: transparent; }
.rhythm-point-mark { fill: var(--accent); stroke: var(--paper); stroke-width: 2; pointer-events: none; }
.rhythm-point:focus-visible .rhythm-point-mark, .rhythm-point:hover .rhythm-point-mark { stroke: #edd1be; stroke-width: 4; }
.rhythm-beat-tracks {
  position: relative;
  margin-inline: 5.8% 4.8%;
  border-top: 1px solid #ae93a8;
  background: repeating-linear-gradient(90deg, #b99bb04f 0 1px, transparent 1px 25%);
}
.rhythm-track { position: relative; height: var(--lane-size); border-bottom: 1px solid #b99bb04f; }
.rhythm-track button {
  position: relative;
  z-index: 2;
  margin: 3px 0 0 4px;
  padding: 1px 8px;
  font-size: .9375rem;
}
.rhythm-track button[aria-pressed='true'] { background: var(--wine-dark); color: #fff; }
.rhythm-track svg { position: absolute; inset: 26px 0 4px; width: 100%; height: calc(var(--lane-size) - 30px); }
.rhythm-track polyline { fill: none; stroke: #916582; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.rhythm-track-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.rhythm-track-picker select { width: min(100%, 240px); }
.rhythm-track-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.rhythm-track-controls .rhythm-track-picker { margin: 5px 0; }
.rhythm-track-controls button[aria-pressed='true'] { background: var(--wine); color: #fff8f5; }
.rhythm-harmony { padding: 11px 14px; margin: 6px 0 10px; border: 1px solid var(--line); border-radius: 12px; background: #eee4ed; }
.rhythm-harmony p { margin: 4px 0 7px; font-size: .9375rem; }
.rhythm-harmony ul { display: flex; gap: 4px 16px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.rhythm-harmony li { display: flex; align-items: center; gap: 6px; font-size: .9375rem; }
.rhythm-harmony svg { width: 28px; height: 6px; }
.rhythm-overlay-line { fill: none; stroke-width: 2.5px; vector-effect: non-scaling-stroke; pointer-events: none; }
.rhythm-harmony-narrative { stroke: #70485e; }
.rhythm-harmony-combat { stroke: #a35d47; stroke-dasharray: 9 4; }
.rhythm-harmony-exploration { stroke: #38686a; stroke-dasharray: 2 4; stroke-linecap: round; }
.rhythm-pin { position: absolute; inset: 0; pointer-events: none; }
.rhythm-pin-line {
  position: absolute;
  left: var(--beat-time);
  top: 0;
  height: calc(29px + var(--lane-size) * var(--beat-lane));
  border-inline-start: 1px solid #8b5976;
}
.rhythm-pin-card {
  --pin-width: 134px;
  position: absolute;
  z-index: 1;
  top: calc(27px + var(--lane-size) * var(--beat-lane));
  left: clamp(0px, calc(var(--beat-time) - var(--pin-width) / 2), calc(100% - var(--pin-width)));
  display: flex;
  align-items: start;
  width: var(--pin-width);
  border: 1px solid #9c7990;
  border-radius: 7px;
  background: #fff5da;
  box-shadow: 0 2px 4px #603d362b;
  pointer-events: auto;
}
button.rhythm-pin-handle {
  display: grid;
  justify-content: stretch;
  gap: 2px;
  min-width: 0;
  flex: 1;
  padding: 4px 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  text-align: left;
  font-size: .9375rem;
  touch-action: none;
  cursor: grab;
}
.rhythm-pin-handle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rhythm-pin-handle small { color: var(--muted); }
button.rhythm-pin-remove { padding: 0 6px; border: 0; background: transparent; font-size: .9375rem; }
.rhythm-pin-tools { display: flex; align-items: end; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.rhythm-pin-tools .bar { margin: 0; align-items: end; }
.rhythm-pin-tools :is(input, select) { max-width: min(230px, 60vw); }
.rhythm-phase-notes { margin-top: 12px; }
.rhythm-phase-notes .story-beats { margin-top: 8px; }

@media (max-width: 640px) {
  .profile-settings { grid-template-columns: minmax(0, 1fr); }
  .character-roster { grid-template-columns: minmax(0, 1fr); }
  .story-beats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rhythm-template { grid-template-columns: minmax(0, 1fr); }
  .rhythm-template-guide { grid-template-columns: 85px minmax(0, 1fr); }
  .rhythm-template-guide:has(.rhythm-phase-preview) { grid-template-columns: minmax(0, 1fr); }
  .rhythm-template-guide svg[role='img'] { width: min(180px, 100%); }
  .music-add { grid-template-columns: minmax(0, 1fr); }
  .music-add button { justify-self: start; }
}
