/* RAC – einheitliche Bedienung auf Handy, Tablet und PC. */
:root{--rac-header-height:68px;--rac-control-height:44px;--rac-control-gap:10px}
button,.file-label,[role="button"],summary{touch-action:manipulation}
button:not(.book-dtp-handle):not(.photo-resize-handle),.file-label,[role="button"]{min-height:var(--rac-control-height)}

/* Alte automatische Ergänzungen dürfen keine zweite Aktion mehr anzeigen. */
.ai-share-action,[data-ai-send-button]{display:none!important}
.button-row,.flow-actions,.creative-card-actions,.writer-plan-actions,.writer-cover-main-tools,.photo-main-tools,.completion-actions{gap:var(--rac-control-gap)}

@media(max-width:1023px){
  :root{--rac-header-height:64px;--rac-control-height:48px;--rac-control-gap:12px}
  .appbar{min-height:var(--rac-header-height);padding:8px max(12px,env(safe-area-inset-left));align-items:center!important;flex-wrap:nowrap!important}
  .appbar-brand{flex:1 1 auto;min-width:0}.appbar-brand>div:last-child{min-width:0}.appbar-brand h1{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .header-actions{flex:0 0 auto!important;flex-wrap:nowrap!important;min-width:0}.header-actions>:not(#menuBtn):not(#racSearchButton){display:none!important}
  #menuBtn{display:inline-flex!important;align-items:center;justify-content:center;min-height:48px!important;padding:10px 12px;white-space:nowrap!important}
  .app-history-controls .icon-btn{width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important}
  main{padding-inline:max(14px,env(safe-area-inset-left),env(safe-area-inset-right))}
  .section-head{align-items:flex-start;flex-wrap:wrap}.section-head>div{min-width:0}
  .flow-navigation{top:var(--rac-header-height)!important}.project-switcher{top:var(--rac-header-height)!important}
  .completion-view>.section-head,.calm-project #project>.section-head{top:var(--rac-header-height)!important}

  .view.active .button-row{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--rac-control-gap)!important}
  .view.active .button-row>*{width:100%!important;min-width:0!important;max-width:100%!important;min-height:48px!important;margin:0!important}
  .view.active .button-row>.wide,.view.active .button-row>.success:only-child,.view.active .button-row>label.wide{grid-column:1/-1}
  .flow-actions,.writer-primary-actions,.writer-plan-save,.book-simple-step-actions,.wizard-actions{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:var(--rac-control-gap)!important}
  .flow-actions>*,.writer-primary-actions>*,.writer-plan-save>*,.book-simple-step-actions>*,.wizard-actions>*{width:100%!important;min-width:0!important;min-height:48px!important}

  /* Generische Aktionsleisten bleiben im Dokumentfluss und verdecken nichts. */
  .sticky-actions,.writer-primary-actions,.writer-plan-save,.calm-project .wizard-actions{position:static!important;inset:auto!important;transform:none!important;width:100%!important}
  .sticky-actions{padding-top:14px;background:none!important}.writer-primary-actions,.writer-plan-save{margin-top:14px;background:#0e1723!important}
  .rac-return-bar{align-items:stretch;flex-direction:column}.rac-return-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.rac-return-actions button{white-space:normal!important}

  .studio-head{min-height:64px;height:auto;padding-block:7px}.studio-menu,.studio-pagebar button,.studio-tabs button,.studio-chip,.studio-secondary,.studio-text-actions button,.studio-create-row>*,.studio-layout-actions button,.studio-mode-row button,.studio-reprompt{min-height:48px!important}
  .studio-pagebar{min-height:58px;height:auto;overflow-x:auto;overflow-y:hidden}.studio-pagebar button{flex:0 0 auto}.studio-tabs{gap:7px}.studio-chip-group>div,.studio-element-list>div{gap:10px}
  .studio-mode-row{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.studio-mode-row button:nth-last-child(-n+3){min-width:48px}.studio-layout-actions{gap:10px}
  .studio-text-actions,.studio-import-actions{gap:10px;flex-wrap:wrap}.studio-text-actions>*,.studio-import-actions>*{flex:1 1 150px}
  .photo-resize-handle,.book-dtp-handle{width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important}

  .book-dtp-rail button{min-height:48px!important;flex-basis:48px!important}.book-dtp-page-nav button,.book-dtp-zoom button,.book-dtp-head button,.book-dtp-tool-tabs button,.book-dtp-mobile-bar button{min-height:48px!important}
  .book-dtp-head{align-items:flex-start;flex-wrap:wrap}.book-dtp-head>.button-row{width:100%}.book-dtp-head>.button-row>*{min-width:0!important}.book-dtp-mobile-bar{gap:8px!important}
  .letter-buttons{display:grid;grid-template-columns:repeat(4,minmax(48px,1fr));gap:8px}.letter-buttons button{min-width:48px!important;min-height:48px!important;padding:8px!important}
  .layout-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}.layout-actions select{grid-column:1/-1}
  .menu-group{gap:8px}.menu-group button,.menu-home,.menu-accordion>summary{min-height:48px!important}
}

.ref-original-name {
  display: block;
  padding: 8px;
  overflow-wrap: anywhere;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.flow-ref-item > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  white-space: normal;
}

.flow-ref-item > span b,
.flow-ref-item > span small {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media(max-width:640px){
  .appbar-brand{gap:6px}.appbar-brand h1{font-size:1rem}.appbar-brand .eyebrow{display:none}.app-history-controls{gap:4px}
  .app-history-controls .icon-btn{width:42px!important;height:42px!important;min-width:42px!important;min-height:42px!important}#menuBtn{padding-inline:10px}
  main{padding-top:14px;padding-inline:12px}.panel{padding:15px}.section-head{gap:10px}.section-head>button,.section-head>.primary,.section-head>.secondary{width:100%}
  .view.active .button-row,.flow-actions,.writer-primary-actions,.writer-plan-save,.book-simple-step-actions,.wizard-actions{grid-template-columns:1fr!important}
  .chapter-toolbar .button-row,.layout-actions,.writer-plan-actions,.photo-main-tools,.writer-cover-main-tools{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .flow-navigation{grid-template-columns:76px minmax(0,1fr) 76px!important;gap:6px!important;padding:7px!important}.flow-navigation button{padding:7px 5px!important;font-size:.78rem!important}.flow-navigation>div{min-width:0}.flow-navigation b,.flow-navigation span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.flow-block-title{align-items:flex-start;flex-direction:column}
  .beginner-library-toolbar{grid-template-columns:1fr!important}.beginner-library-toolbar>span{text-align:left!important}.beginner-comic-card{grid-template-columns:auto 62px minmax(0,1fr)!important;gap:10px!important}.beginner-comic-card>img,.beginner-comic-placeholder{width:62px!important}
  .rac-return-actions{grid-template-columns:1fr}.writer-theme-row{display:grid!important;grid-template-columns:1fr!important;overflow:visible!important}.writer-theme-row button{width:100%;min-height:48px}.export-grid{grid-template-columns:1fr!important}
  .studio-head-actions{gap:6px}.studio-save{display:none}.studio-pagebar{gap:6px;padding-inline:8px}.studio-tool span{display:none}.studio-dock{padding-inline:10px}.studio-tabs button{font-size:.74rem}.studio-sfx-presets{grid-template-columns:1fr!important}
  .book-dtp-mobile-bar{grid-template-columns:repeat(2,minmax(0,1fr))!important}.book-dtp-shell{padding-bottom:calc(128px + env(safe-area-inset-bottom))!important}.book-dtp-tools{bottom:calc(120px + env(safe-area-inset-bottom))!important}.book-dtp-head h2{max-width:52vw!important}.book-dtp-page-nav{grid-template-columns:48px minmax(0,1fr) 48px!important}.book-dtp-page-nav .book-dtp-zoom{display:none!important}
  .letter-buttons{grid-template-columns:repeat(3,minmax(48px,1fr))}
}

@media(min-width:1024px){.appbar{min-height:68px}.header-actions{gap:10px}.header-actions button,.button-row>*{min-height:44px}}
@media(prefers-reduced-motion:reduce){.menu-drawer,.menu-backdrop,.book-dtp-tools{transition:none!important}}

/* Smartphone-Seiteneditor: Die Seite nutzt den kompletten freien Bildschirm
   zwischen der festen Navigation oben und den weiterhin erreichbaren Aktionen unten. */
@media(max-width:699px){
  body.studio-active.studio-layout-active{height:100dvh;overflow:hidden}
  body.studio-layout-active .rac-studio{height:100dvh;min-height:100dvh;overflow:hidden}
  body.studio-layout-active .studio-head,body.studio-layout-active .studio-pagebar{position:relative;z-index:55;flex:none}
  body.studio-layout-active .studio-guide{display:none}
  body.studio-layout-active .studio-workspace{height:calc(100dvh - 122px);min-height:0;overflow:hidden}
  body.studio-layout-active .studio-stage{height:100%;min-height:0;padding:4px 0 calc(var(--studio-dock-height,150px) + 4px)!important;overflow-y:auto!important;overflow-x:hidden!important;scroll-padding-bottom:calc(var(--studio-dock-height,150px) + 4px)!important;overscroll-behavior:contain;touch-action:pan-y!important}
  body.studio-layout-active .studio-paper-wrap.editing{display:flex;width:100%!important;max-width:none!important;height:100%;min-height:0;margin:0!important;border-radius:0;overflow:hidden}
  body.studio-layout-active .studio-paper-wrap #canvasViewport{flex:1 1 auto;width:100%!important;height:100%;min-height:0;max-width:none!important;margin:0!important;border-radius:0;overflow:auto!important;-webkit-overflow-scrolling:touch}
  body.studio-layout-active .studio-dock{z-index:60}
  body.studio-layout-active .studio-dock.calm-collapsed{max-height:150px}
  body.studio-layout-active .studio-dock:not(.calm-collapsed){height:min(58dvh,480px);max-height:calc(100dvh - 190px);overflow:hidden}
  body.studio-layout-active .studio-dock:not(.calm-collapsed) .studio-dock-content{flex:1 1 auto;min-height:96px;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;touch-action:pan-y}
  body.studio-layout-active .studio-page-actions{position:relative;z-index:2;flex:0 0 auto;padding-top:8px;background:linear-gradient(transparent,rgba(32,33,39,.995) 24%)}
  body.studio-layout-active .studio-page-actions .studio-secondary[hidden]{display:none!important}

  /* Geöffnete Werkzeuge bilden einen eigenen, ruhigen Arbeitsbereich. */
  body.studio-tools-open .studio-guide,body.studio-tools-open .studio-page-actions{display:none!important}
  body.studio-tools-open .studio-stage{overflow:hidden!important;touch-action:none!important;padding-bottom:calc(min(72dvh,calc(100dvh - 132px)) + 4px)!important}
  body.studio-tools-open .studio-paper-wrap #canvasViewport{overflow:hidden!important;overscroll-behavior:none!important}
  body.studio-tools-open .studio-dock:not(.calm-collapsed){height:min(72dvh,calc(100dvh - 132px));max-height:calc(100dvh - 132px);overflow:hidden}
  body.studio-tools-open .studio-dock:not(.calm-collapsed) .studio-dock-content{flex:1 1 auto;min-height:0;overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;touch-action:pan-y!important}
}
