/* UI fixes from the demo walk-through: backgrounds, header alignment, floating button, button grids, icons, small motion.
   Loaded last so it wins over the older layers. */

/* 1. Page background follows the theme (no light strips beside dark pages) */
html body.st-app{background:var(--c-bg)!important}
html:has(body.st-dark){background:#0C1312}
html:has(body.st-app:not(.st-dark)){background:#F1F5F4}
body.st-app.st-dark #loginScreen.login-screen{background:var(--c-bg)!important;min-height:100%}

/* 2. Header: title block takes the free space, search + avatar always sit at the right edge, subtitle wraps to 2 lines */
body.st-app .appbar-row{display:flex;align-items:center;gap:10px}
body.st-app .appbar-left{flex:1 1 auto;min-width:0}
body.st-app .appbar .st-search-btn{flex:none;margin:0!important;width:40px;height:40px}
body.st-app .appbar .avatar{flex:none}
body.st-app .appbar .sub{white-space:normal!important;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.35}

/* 3. Floating + button: smaller, and the page always scrolls far enough that nothing stays hidden behind it */
#stFab{width:54px!important;height:54px!important;border-radius:18px!important}
body.st-app #phoneScreens .content{padding-bottom:calc(var(--nav-h,64px) + var(--safe-b,0px) + 92px)!important}

/* 4. Same gap above every two-column form row */
body.st-app .form-grid{margin-top:0!important;row-gap:0!important;gap:0 12px!important}
body.st-app .form-grid>div>label.f{margin-top:14px!important}
body.st-app .card>.form-grid:first-child>div>label.f,body.st-app .form-grid:first-child>div:first-child>label.f{margin-top:0!important}

/* 5. Report buttons: Apply full width, the other three equal in a row of their own */
body.st-app .report-actions{display:grid!important;grid-template-columns:repeat(3,1fr);gap:8px}
body.st-app .report-actions .small-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;padding:0 8px;font-size:13px;white-space:nowrap}
body.st-app .report-actions .small-btn.primary{grid-column:1/-1;min-height:48px;font-size:15px}
body.st-app .report-actions .small-btn i{font-size:17px}

/* 6. Route stop buttons: even grid instead of ragged wrapping */
body.st-app .st-stop .st-docs{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
body.st-app .st-stop .st-docs .small-btn{display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:0 6px}

/* 7. Forms screen: brighter icons in dark mode, two equal columns */
body.st-app .form-card-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
body.st-app .form-launch{display:flex;flex-direction:column;gap:6px;align-items:flex-start}
body.st-app .form-launch>i{color:var(--c-primary);font-size:28px;margin-bottom:6px}
body.st-app.st-dark .form-launch>i{color:#2CC7A8}

/* 8. Buttons with an icon: icon and text on one line with an even gap */
body.st-app .small-btn,body.st-app .btn-primary,body.st-app .btn-outline{display:inline-flex;align-items:center;justify-content:center;gap:6px}
body.st-app .inline-actions .small-btn i{font-size:16px}

/* 9. Motion: press feedback, tab icon pop, gentle card entrance */
@media (prefers-reduced-motion:no-preference){
  body.st-app .small-btn,body.st-app .btn-primary,body.st-app .btn-outline,body.st-app .card.clickable,body.st-app .form-launch,body.st-app #stFab{transition:transform .16s cubic-bezier(.2,.8,.2,1),box-shadow .2s,background-color .2s}
  body.st-app .small-btn:active,body.st-app .btn-primary:active,body.st-app .btn-outline:active{transform:scale(.96)}
  body.st-app .card.clickable:active,body.st-app .form-launch:active{transform:scale(.985)}
  body.st-app #stTabBar button.on i,body.st-app #stTabBar button.active i{animation:stFixPop .38s cubic-bezier(.2,.9,.3,1.3)}
  body.st-app .form-card-grid>.card{animation:stFixIn .42s cubic-bezier(.2,.8,.2,1) both}
  body.st-app .form-card-grid>.card:nth-child(2){animation-delay:.05s}
  body.st-app .form-card-grid>.card:nth-child(3){animation-delay:.1s}
  body.st-app .form-card-grid>.card:nth-child(4){animation-delay:.15s}
  body.st-app .form-card-grid>.card:nth-child(5){animation-delay:.2s}
  body.st-app .form-card-grid>.card:nth-child(6){animation-delay:.25s}
  body.st-app .report-actions .small-btn{animation:stFixIn .35s cubic-bezier(.2,.8,.2,1) both}
  body.st-app .report-actions .small-btn:nth-child(2){animation-delay:.05s}
  body.st-app .report-actions .small-btn:nth-child(3){animation-delay:.1s}
  body.st-app .report-actions .small-btn:nth-child(4){animation-delay:.15s}
}
@keyframes stFixPop{0%{transform:scale(.7)}60%{transform:scale(1.18)}100%{transform:scale(1)}}
@keyframes stFixIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}

/* 10. List rows with action buttons: buttons drop under the text when there is no room, instead of squeezing it */
body.st-app .card-row:has(>.inline-actions){flex-wrap:wrap;gap:10px}
body.st-app .card-row:has(>.inline-actions)>div:first-child{flex:1 1 190px;min-width:0}
body.st-app .card-row:has(>.inline-actions)>.inline-actions{margin-left:auto;flex:none}

/* 11. Reveal fix: list items that scrolled into view must become visible. The "entering screen" rule used to be more
   specific than the "shown" rule, so items stayed at opacity 0 (looked like a blank page). */
body.st-app .st-reveal.st-shown,body.st-app #phoneScreens .content.st-enter>.st-reveal.st-shown{opacity:1!important;transform:none!important}
