:root {
  --bg: #f6efe4;
  --card: #fffdf8;
  --ink: #243044;
  --muted: #687386;
  --accent: #f4b642;
  --accent-dark: #a96b00;
  --line: #d8c7a7;
  --danger: #b73535;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #243044;
  color: white;
  border-bottom: 6px solid var(--accent);
}

.topbar h1 {
  margin: 0;
  font-size: 1.8rem;
}

.topbar p {
  margin: .25rem 0 0;
  color: #f8e7bf;
}

.top-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

button,
.file-btn {
  border: 2px solid #1b2637;
  background: var(--accent);
  color: #1b2637;
  border-radius: 10px;
  padding: .55rem .75rem;
  font-weight: bold;
  cursor: pointer;
  display: inline-block;
}

button:hover,
.file-btn:hover {
  filter: brightness(.96);
}

.file-btn input {
  display: none;
}

.app {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 120px);
}

.sidebar {
  padding: 1rem;
  background: #fff7e7;
  border-right: 2px solid var(--line);
  overflow-y: auto;
  max-height: calc(100vh - 100px);
}

.panel {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: .85rem;
  margin-bottom: 1rem;
  box-shadow: 0 3px 0 rgba(0,0,0,.05);
}

.panel h2 {
  margin: 0 0 .75rem;
  font-size: 1.1rem;
}

.panel h3 {
  margin: 1rem 0 .4rem;
  font-size: .95rem;
  color: var(--accent-dark);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
}

.asset {
  min-height: 58px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: white;
  padding: .25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset svg {
  width: 100%;
  height: 50px;
}

.wide {
  width: 100%;
  margin-top: .5rem;
}

.danger {
  background: #ffdada;
  color: var(--danger);
  border-color: var(--danger);
}

.hint {
  font-size: .85rem;
  color: var(--muted);
  line-height: 1.35;
}

textarea {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .5rem;
  font-size: 1rem;
  resize: vertical;
}

input[type="range"] {
  width: 100%;
}

.workspace {
  padding: 1rem;
  overflow: auto;
}

.comic-wrap {
  background: white;
  border: 3px solid #243044;
  border-radius: 16px;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  box-shadow: 0 10px 28px rgba(0,0,0,.16);
}

#comicSvg {
  width: 100%;
  height: auto;
  display: block;
  background: white;
}

.selected .selection-outline {
  display: block;
}

.selection-outline {
  display: none;
  fill: none;
  stroke: #1787ff;
  stroke-width: 3;
  stroke-dasharray: 8 6;
  pointer-events: none;
}

.footer {
  padding: .65rem 1rem;
  color: var(--muted);
  text-align: center;
  font-size: .9rem;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: none;
    border-right: none;
    border-bottom: 2px solid var(--line);
  }
}

/* StoryDoodle asset thumbnail fix */
.asset-preview-wrap {
  width: 100%;
  height: 95px;
  max-height: 95px;
  overflow: hidden;
}

.asset-preview {
  display: block;
  width: 100%;
  height: 85px;
  max-width: 100%;
  max-height: 85px;
  object-fit: contain;
}

/* StoryDoodle v0.2 sidebar and asset picker cleanup */
.app {
  grid-template-columns: 390px minmax(0, 1fr);
}

.sidebar {
  width: 390px;
}

.asset-select {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: .5rem;
}

.asset-preview-wrap {
  display: flex;
  width: 100%;
  height: 130px;
  max-height: 130px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .35rem;
  margin: .4rem 0 .55rem;
}

.asset-preview {
  display: block;
  width: 100%;
  height: 120px;
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}

#backgroundAssets,
#characterAssets,
#propAssets {
  display: block;
}

#backgroundAssets .wide,
#characterAssets .wide,
#propAssets .wide {
  display: block;
  width: 100%;
  margin-top: .35rem;
  white-space: normal;
  line-height: 1.15;
}

/* StoryDoodle server save controls */
.top-actions input[type="text"] {
  border: 2px solid #1b2637;
  border-radius: 10px;
  padding: .55rem .75rem;
  font-size: .95rem;
  min-width: 170px;
}

/* StoryDoodle bubble selector */
.bubble-preview-box {
  width: 100%;
  min-height: 54px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: .5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: .85rem;
  margin: .4rem 0 .55rem;
}

/* StoryDoodle prop thumbnail grid */
.asset-search {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .45rem;
  background: white;
  font-weight: bold;
  margin-bottom: .5rem;
}

.asset-thumb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .45rem;
  max-height: 260px;
  overflow-y: auto;
  padding-right: .25rem;
}

.asset-thumb-button {
  border: 2px solid var(--line);
  border-radius: 10px;
  background: white;
  padding: .25rem;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  cursor: pointer;
}

.asset-thumb-button:hover {
  border-color: #243044;
  background: #fff8e8;
}

.asset-thumb-button img {
  max-width: 100%;
  max-height: 52px;
  object-fit: contain;
  display: block;
}

.asset-thumb-button span {
  font-size: .68rem;
  line-height: 1.05;
  max-width: 100%;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* StoryDoodle resize handle */
.resize-handle {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}

.resize-handle:hover {
  opacity: .85;
}

/* StoryDoodle drag/drop assets */
.asset-draggable-preview {
  cursor: grab;
}

.asset-draggable-preview:active {
  cursor: grabbing;
}

.asset-preview-wrap.drag-help::after {
  content: "Drag to comic";
}

.asset-thumb-button {
  cursor: grab;
}

.asset-thumb-button:active {
  cursor: grabbing;
}

/* StoryDoodle title/text tool */
#titleText {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: .5rem;
  font-size: 1rem;
  resize: vertical;
}

/* StoryDoodle inline text editing */
.inline-text-editor {
  position: fixed;
  z-index: 9999;
  border: 3px solid #1683ff;
  border-radius: 12px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 26px rgba(0,0,0,.22);
  padding: .45rem;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.15;
  resize: none;
  outline: none;
  text-align: center;
}

.bubble-inline-editor {
  font-size: 18px;
}

.title-inline-editor {
  font-size: 24px;
  font-weight: bold;
}

/* Stable inline text editor wrapper */
.inline-text-editor-wrap {
  position: fixed;
  z-index: 99999;
}

.inline-text-editor-wrap .inline-text-editor {
  box-sizing: border-box;
  display: block;
  position: static;
  z-index: 99999;
  border: 3px solid #1683ff;
  border-radius: 12px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 8px 26px rgba(0,0,0,.22);
  padding: .45rem;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.15;
  resize: none;
  outline: none;
  text-align: center;
  pointer-events: auto;
}

.inline-text-help {
  margin-top: .2rem;
  padding: .2rem .35rem;
  border-radius: 8px;
  background: #243044;
  color: #fff;
  font-size: .72rem;
  text-align: center;
}

/* Contenteditable inline text editor fix */
.inline-text-editor-wrap {
  position: fixed !important;
  z-index: 999999 !important;
  pointer-events: auto !important;
}

.inline-text-editor-wrap .inline-text-editor {
  box-sizing: border-box !important;
  display: block !important;
  position: static !important;
  z-index: 999999 !important;
  border: 3px solid #1683ff !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, .99) !important;
  box-shadow: 0 8px 26px rgba(0,0,0,.22) !important;
  padding: .55rem !important;
  font-family: Arial, Helvetica, sans-serif !important;
  line-height: 1.15 !important;
  outline: none !important;
  text-align: center !important;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  white-space: pre-wrap !important;
  overflow-y: auto !important;
  cursor: text !important;
}

.inline-text-editor-wrap .bubble-inline-editor {
  font-size: 18px !important;
  font-weight: normal !important;
}

.inline-text-editor-wrap .title-inline-editor {
  font-size: 24px !important;
  font-weight: bold !important;
}

.inline-text-help {
  margin-top: .2rem;
  padding: .2rem .35rem;
  border-radius: 8px;
  background: #243044;
  color: #fff;
  font-size: .72rem;
  text-align: center;
  pointer-events: none;
}

/* StoryDoodle floating text editor - stable fallback */
.floating-text-editor-wrap {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 40px));
  z-index: 999999;
  background: #fffdf8;
  border: 4px solid #1683ff;
  border-radius: 16px;
  padding: .85rem;
  box-shadow: 0 14px 40px rgba(0,0,0,.28);
  pointer-events: auto;
}

.floating-text-editor-title {
  font-weight: 800;
  color: #243044;
  margin-bottom: .5rem;
  font-size: 1.05rem;
}

.floating-text-editor {
  width: 100%;
  min-height: 130px;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: .65rem;
  font-size: 1.1rem;
  font-family: Arial, Helvetica, sans-serif;
  resize: vertical;
  outline: none;
  background: white;
  color: #111827;
}

.floating-text-editor:focus {
  border-color: #1683ff;
  box-shadow: 0 0 0 3px rgba(22,131,255,.18);
}

.floating-text-editor-buttons {
  display: flex;
  gap: .5rem;
  margin-top: .65rem;
}

.floating-text-editor-buttons button {
  flex: 1;
}

.floating-text-editor-help {
  margin-top: .45rem;
  font-size: .82rem;
  color: #687386;
}

/* Forced visible bubble preview */
#bubbleDragPreviewForced {
  height: 120px !important;
  margin: 8px 0 !important;
  border: 3px dashed #d1a84f !important;
  border-radius: 12px !important;
  background: #fffdf8 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: grab !important;
  overflow: hidden !important;
}

#bubbleDragPreviewForced:hover {
  border-color: #1683ff !important;
  box-shadow: 0 0 0 3px rgba(22,131,255,.12) !important;
}

#bubbleDragPreviewForced:active {
  cursor: grabbing !important;
}

/* Bubbles Panel V2 */
#bubblePanelV2 .asset-select {
  width: 100%;
}

.bubble-preview-v2 {
  height: 120px;
  margin: 8px 0;
  border: 3px dashed #d1a84f;
  border-radius: 12px;
  background: #fffdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  overflow: hidden;
  padding: 4px;
  box-sizing: border-box;
}

.bubble-preview-v2:hover {
  border-color: #1683ff;
  box-shadow: 0 0 0 3px rgba(22,131,255,.12);
}

.bubble-preview-v2:active {
  cursor: grabbing;
}

/* StoryDoodle polished hero/header */
.app-header,
header {
  background: linear-gradient(135deg, #243044 0%, #123e7c 52%, #1683ff 100%);
  border-bottom: 5px solid #f7b733;
  padding: .65rem 1rem;
  min-height: auto;
}

.brand-wrap {
  display: grid;
  grid-template-columns: minmax(260px, 520px) 1fr;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.storydoodle-logo {
  display: block;
  width: min(520px, 48vw);
  height: auto;
  max-height: 120px;
  object-fit: contain;
  object-position: left center;
  padding: .35rem .55rem;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 6px 18px rgba(0,0,0,.24);
}

.brand-subtitle {
  color: #fff7dc;
  font-size: 1rem;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  white-space: normal;
}

/* Keep top action buttons from being crushed by the logo */
.top-actions,
.header-actions {
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}

@media (max-width: 1100px) {
  .brand-wrap {
    grid-template-columns: 1fr;
    gap: .35rem;
  }

  .storydoodle-logo {
    width: min(420px, 90vw);
    max-height: 90px;
  }
}

/* StoryDoodle front-page/header polish */
body {
  background:
    radial-gradient(circle at top left, rgba(22,131,255,.10), transparent 32rem),
    radial-gradient(circle at top right, rgba(247,183,51,.16), transparent 30rem),
    #f7efe1;
}

.app-header,
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background:
    linear-gradient(135deg, rgba(36,48,68,.98) 0%, rgba(18,62,124,.98) 52%, rgba(22,131,255,.95) 100%);
  border-bottom: 5px solid #f7b733;
  box-shadow: 0 5px 18px rgba(0,0,0,.22);
  padding: .65rem .9rem;
}

.app-header-inner,
header > .bar,
header > .topbar,
header {
  gap: 1rem;
}

.brand-wrap {
  display: grid;
  grid-template-columns: auto minmax(150px, 240px);
  align-items: center;
  gap: .8rem;
}

.storydoodle-logo {
  display: block;
  width: clamp(210px, 26vw, 390px);
  height: auto;
  max-height: 82px;
  object-fit: contain;
  object-position: left center;
  padding: .28rem .55rem;
  border-radius: 18px;
  background: rgba(255,255,255,.92);
  box-shadow:
    0 5px 16px rgba(0,0,0,.24),
    inset 0 0 0 2px rgba(255,255,255,.6);
}

.brand-subtitle {
  color: #fff7dc;
  font-size: .95rem;
  font-weight: 900;
  line-height: 1.18;
  text-shadow: 0 1px 2px rgba(0,0,0,.38);
  max-width: 230px;
}

.top-actions,
.header-actions,
.actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
  flex-wrap: wrap;
}

.top-actions input,
.header-actions input,
.actions input,
#projectName {
  height: 2.15rem;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,.45);
  padding: 0 .65rem;
  font-weight: 700;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.12);
}

.top-actions button,
.header-actions button,
.actions button,
header button {
  border-radius: 10px;
  border: 2px solid rgba(31,41,55,.75);
  background: linear-gradient(#ffc85a, #f7b733);
  color: #162238;
  font-weight: 900;
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
}

.top-actions button:hover,
.header-actions button:hover,
.actions button:hover,
header button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.workspace,
.main,
.editor-shell {
  background: rgba(255,255,255,.34);
}

.sidebar,
aside {
  background: #fff7e7;
  border-right: 3px solid rgba(209,168,79,.45);
}

.panel {
  border: 2px solid rgba(209,168,79,.65);
  border-radius: 14px;
  background: rgba(255,253,248,.96);
  box-shadow: 0 3px 10px rgba(80,60,20,.08);
}

.panel h2 {
  color: #123e7c;
  font-size: 1rem;
  border-bottom: 2px solid rgba(247,183,51,.35);
  padding-bottom: .25rem;
}

button.wide,
.panel button {
  border-radius: 10px;
  font-weight: 900;
}

.canvas-wrap,
.preview-wrap,
.stage-wrap {
  background:
    linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,247,220,.72));
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(36,48,68,.12);
}

#comicSvg,
svg#comic,
.comic-canvas {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.10));
}

/* Responsive header polish */
@media (max-width: 1200px) {
  .brand-wrap {
    grid-template-columns: 1fr;
    gap: .25rem;
  }

  .storydoodle-logo {
    width: min(360px, 90vw);
    max-height: 70px;
  }

  .brand-subtitle {
    max-width: none;
  }

  .top-actions,
  .header-actions,
  .actions {
    justify-content: flex-start;
    margin-left: 0;
  }
}

@media (max-width: 800px) {
  .storydoodle-logo {
    width: min(300px, 86vw);
    max-height: 58px;
  }

  .brand-subtitle {
    font-size: .82rem;
  }
}

/* StoryDoodle asset upload panel */
#assetUploadPanel {
  border-color: rgba(22,131,255,.45);
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(239,247,255,.96));
}

#assetUploadPanel h2 {
  color: #123e7c;
}

.upload-label {
  display: block;
  font-weight: 800;
  color: #243044;
  margin-bottom: .45rem;
}

#uploadAssetFile {
  width: 100%;
  box-sizing: border-box;
  border: 2px dashed #d1a84f;
  border-radius: 12px;
  background: #fffdf8;
  padding: .55rem;
  margin: .35rem 0 .55rem;
  font-size: .85rem;
}

#uploadAssetFile:hover {
  border-color: #1683ff;
  box-shadow: 0 0 0 3px rgba(22,131,255,.10);
}

#uploadAssetStatus {
  margin-top: .45rem;
}

/* Safe New Comic button */
#newComicSafeBtn {
  background: linear-gradient(#ffffff, #eaf4ff);
  border: 2px solid #1683ff;
  color: #123e7c;
  border-radius: 10px;
  font-weight: 900;
  padding: .45rem .7rem;
  cursor: pointer;
}

#newComicSafeBtn:hover {
  background: linear-gradient(#eaf4ff, #cfe8ff);
  transform: translateY(-1px);
}

/* StoryDoodle public toolbar cleanup */
#saveProjectBtn,
#loadSavedBtn,
#saveServerPngBtn,
#savedProjectsList {
  display: none !important;
}

/* StoryDoodle public thumbnail grids */
.public-thumb-grid {
  max-height: 230px;
  overflow-y: auto;
  padding-right: 4px;
}

.background-thumb-grid .public-asset-thumb-button img {
  width: 92px;
  height: 58px;
  object-fit: cover;
}

.character-thumb-grid .public-asset-thumb-button img {
  width: 76px;
  height: 92px;
  object-fit: contain;
}

.public-asset-thumb-button span {
  font-size: 0.7rem;
  line-height: 1.05;
}

/* Hide server-side saved projects area for public StoryDoodle */
#savedProjectsList,
#loadSavedBtn,
#saveProjectBtn,
#saveServerPngBtn {
  display: none !important;
}

/* Hide the Saved Projects sidebar card */
.panel:has(#savedProjectsList),
.panel:has(#loadSavedBtn) {
  display: none !important;
}

/* StoryDoodle safe compact edit tools */
#safeEditToolsPanel {
  border-color: #f7b733;
}

.safe-edit-tool-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 6px 0 8px;
}

.safe-edit-tool-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.safe-edit-symbol {
  font-size: 1.1rem;
  font-weight: 900;
  color: #123e7c;
  line-height: 1;
}

.safe-edit-label {
  font-size: 0.62rem;
  font-weight: 800;
  color: #243044;
  line-height: 1.05;
  text-align: center;
}

.safe-edit-button {
  width: 100% !important;
  min-height: 34px !important;
  padding: 4px !important;
  border-radius: 9px !important;
  font-size: 0 !important;
  overflow: hidden;
}

#safeEditToolsPanel #addTitleBtn::after {
  content: "T+";
  font-size: 1rem;
}

#safeEditToolsPanel #editSelectedTextBtn::after {
  content: "✎";
  font-size: 1rem;
}

#safeEditToolsPanel #flipBtn::after {
  content: "⇄";
  font-size: 1rem;
}

#safeEditToolsPanel #deleteBtn::after {
  content: "🗑";
  font-size: 1rem;
}

#safeEditToolsPanel #deleteBtn {
  background: linear-gradient(#fff5f5, #ffd7d7) !important;
  color: #8a1111 !important;
  border-color: #e34848 !important;
}

/* StoryDoodle consistent bubble grid sizing */
.bubble-grid-v3 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 4px;
}

.bubble-choice-btn {
  width: 100%;
  height: 92px;
  min-height: 92px;
  max-height: 92px;
  box-sizing: border-box;
  justify-content: space-between;
}

.bubble-mini-svg {
  width: 88px;
  height: 56px;
  flex: 0 0 56px;
  display: block;
}

.bubble-choice-btn span {
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* StoryDoodle script font */
@font-face {
  font-family: "SD Script";
  src: url("assets/fonts/storydoodle-script.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* StoryDoodle Comic Neue font */
@font-face {
  font-family: "SD Comic Neue";
  src: url("assets/fonts/comic-neue-regular.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Make Add Title tool clearer */
#safeEditToolsPanel .safe-edit-tool-wrap:has(#addTitleBtn) .safe-edit-label {
  font-size: 0;
}

#safeEditToolsPanel .safe-edit-tool-wrap:has(#addTitleBtn) .safe-edit-label::after {
  content: "Add Title";
  font-size: 0.62rem;
}

#safeEditToolsPanel #addTitleBtn::after {
  content: "T+";
  font-size: 1rem;
}

/* StoryDoodle UI overhaul: reduce double scrollbars and polish layout */
html,
body {
  height: 100%;
}

body {
  overflow: hidden;
}

.topbar {
  min-height: 74px;
}

.app {
  height: calc(100vh - 104px);
  overflow: hidden;
}

.sidebar {
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 22px;
}

.workspace {
  overflow: auto;
}

.comic-wrap {
  box-shadow: 0 12px 30px rgba(31, 41, 55, 0.16);
  border-radius: 14px;
  background: #ffffff;
}

.brand-subtitle {
  font-size: 0.9rem;
  line-height: 1.15;
  max-width: 300px;
}

/* Asset tabs */
.sd-asset-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 8px 0 10px;
}

.sd-asset-tabs button {
  border: 2px solid #d1a84f;
  border-radius: 10px;
  background: #fffdf8;
  color: #243044;
  font-weight: 900;
  font-size: 0.72rem;
  padding: 7px 5px;
  cursor: pointer;
}

.sd-asset-tabs button:hover {
  background: #fff3cf;
}

.sd-asset-tabs button.active {
  background: #f7b733;
  border-color: #1f2937;
  color: #111827;
}

.sd-tab-hidden {
  display: none !important;
}

/* Make visible asset sections feel like drawers instead of huge nested panels */
.public-thumb-grid,
.asset-thumb-grid,
.bubble-grid-v3 {
  max-height: none !important;
  overflow-y: visible !important;
}

#backgroundAssets,
#characterAssets,
#propAssets,
#bubblePanelV2,
#assetUploadPanel {
  animation: sdFadeIn .12s ease-out;
}

@keyframes sdFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Slightly more finished buttons without making the UI complicated */
.top-actions button,
.file-btn,
button {
  transition: transform .08s ease, box-shadow .08s ease, background .08s ease;
}

.top-actions button:hover,
.file-btn:hover,
button:hover {
  box-shadow: 0 3px 8px rgba(31, 41, 55, 0.16);
}

/* Keep upload from dominating the sidebar when selected */
#assetUploadPanel {
  margin-top: 8px;
}

/* Hide old speech bubble button now that bubble grid is used */
#addBubbleBtn {
  display: none !important;
}

/* StoryDoodle draggable bubble tail handle */
.bubble-tail-handle {
  filter: drop-shadow(0 2px 3px rgba(31,41,55,.35));
}

.bubble-tail-handle:hover {
  opacity: .9;
}

/* Polished bubble tail handle */
.bubble-tail-handle {
  filter: drop-shadow(0 2px 3px rgba(31,41,55,.28));
}

.bubble-tail-handle:hover {
  opacity: .95;
}
