/* Interaction motion only. Geometry and colour use the app/theme tokens. */
:where(button, [role="button"], .sk-btn, .sk-rail-row, .sk-chat-row, .nav-item, .sk-fly-item, tbody tr) {
  transition: color var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), background-color var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), border-color var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), scale var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1));
}
button:active:not(:disabled), .sk-btn:active { scale: .98; }
.app-layout .sidebar-shell {
  opacity: 1 !important;
  transition: width var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), transform var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)) !important;
}
.app-layout > .flex-1, .app-layout > .ml-80 {
  transition: margin-left var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)) !important;
}
.sk-rail-label { white-space: nowrap; transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
.sidebar-shell .sk-fly {
  transform: translateY(4px) scale(.98); transform-origin: top left;
  transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), transform var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), visibility 0s var(--sk-dur-fast, 120ms);
}
.sidebar-shell .group\/menu:is(:hover, :focus-within) > .sk-fly {
  transform: none; transition-duration: var(--sk-dur, 180ms); transition-delay: 0s;
}
.sk-pop-enter { transition: opacity var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), transform var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
.sk-pop-leave { transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), transform var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
.sk-pop-from { opacity: 0; transform: translateY(4px) scale(.98); }
.sk-pop-to { opacity: 1; transform: translateY(0) scale(1); }
/* Discrete display transitions retain the welcome flyout through its exit. */
.sk-rail-fly, .sk-recents-filter {
  transform-origin: top left;
  transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), transform var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)), display var(--sk-dur-fast, 120ms) allow-discrete;
}
.sk-rail-fly:not([hidden]), .sk-recents-filter:not([hidden]) { transition-duration: var(--sk-dur, 180ms); }
.sk-rail-fly[hidden], .sk-recents-filter[hidden] { opacity: 0; transform: translateY(4px) scale(.98); }
@starting-style { .sk-rail-fly:not([hidden]), .sk-recents-filter:not([hidden]) { opacity: 0; transform: translateY(4px) scale(.98); } }
.sk-skeleton { display: grid; gap: 12px; padding: 12px; width: 100%; box-sizing: border-box; }
.sk-skeleton__line {
  display: block; height: 20px; width: 100%;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--sk-ink, var(--ht-ink)) 3%, transparent) 50%, transparent 80%), color-mix(in srgb, var(--sk-ink, var(--ht-ink)) 6%, var(--sk-surface-2, var(--ht-surface-2)));
  background-size: 200% 100%;
  animation: sk-shimmer var(--sk-dur-slow, 260ms) var(--sk-ease-in-out, cubic-bezier(.4,0,.2,1)) infinite alternate;
}
.sk-skeleton__line:last-child { width: 72%; }
.sk-skeleton--cell { padding: 0; }
.sk-skeleton--cell .sk-skeleton__line { height: 20px; width: 80%; }
@keyframes sk-shimmer { from { background-position: 45% 0; } to { background-position: 55% 0; } }
.sk-message-arrival { animation: sk-message-arrival var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
@keyframes sk-message-arrival { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* Branding rests on page load; only an active thinking mark moves. */
.sky-loader .sky-loader__cube { animation: none; opacity: 1; }
#toast-container { display: flex; flex-direction: column; gap: 8px; max-width: min(360px, calc(100vw - 40px)); }
.sk-toast {
  position: relative; overflow: hidden; padding: 12px 36px 14px 16px; margin: 0 !important;
  background: var(--ht-surface, var(--sk-surface)); color: var(--ht-ink, var(--sk-ink));
  border: 1px solid var(--ht-hair, var(--sk-hair)); box-shadow: 0 4px 16px #0001;
  font: 400 13px/1.5 var(--sk-font-sans); pointer-events: auto;
  animation: sk-toast-enter var(--sk-dur, 180ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1));
}
.sk-toast[data-leaving] { animation: sk-toast-exit var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)) forwards; }
.sk-toast__close { position: absolute; top: 8px; right: 10px; border: 0; background: transparent; color: inherit; }
.sk-toast__progress { position: absolute; height: 2px; inset: auto 0 0; background: var(--ht-muted, var(--sk-muted)); transform-origin: left; }
@keyframes sk-toast-enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes sk-toast-exit { to { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .sk-toast__progress { display: none; } }

.sidebar-shell [data-rail-label] { white-space: nowrap; transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
.sk-mode-switch .sk-mode-ico { display: none; width: 15px; height: 15px; }
@media (min-width: 1024px) {
  .sidebar-shell nav :is(.sk-rail-row, .sk-staff-nav > button, .sk-rail-menu > button, .nav-item) { justify-content: flex-start !important; position: relative; padding-left: 12px !important; }
  .sidebar-shell nav [data-rail-label], .sidebar-shell nav [data-rail] > span:not(.holly-review-desk__count) { position: absolute; left: 38px; max-width: calc(var(--sk-sidebar-width) - 62px); }
  .app-layout[data-rail-state="collapsed"] .sidebar-shell nav [data-rail] > span { display: block !important; opacity: 0; pointer-events: none; }
  .sidebar-shell nav [data-rail] > span { transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)); }
  .app-layout[data-rail-state="collapsed"] .sidebar-shell nav [data-rail] { justify-content: flex-start !important; }
}
/* App buttons and rows share the same fast colour response, including utilities. */
.app-layout :is(button, [role="button"], tbody tr, .sk-rail-row, .sk-chat-row, .nav-item, .sk-fly-item),
.sk-panel button {
  transition-property: color, background-color, border-color, opacity, scale !important;
  transition-duration: var(--sk-dur-fast, 120ms) !important;
  transition-timing-function: var(--sk-ease-out, cubic-bezier(.2,.8,.2,1)) !important;
}
@media (min-width: 1024px) {
  .app-layout .sidebar-shell .sk-rail-header { position: relative; height: 52px; min-height: 52px; flex-wrap: nowrap; padding: 0 12px; }
  .app-layout .sidebar-shell .sk-rail-brand { position: absolute; left: 12px; top: 11px; width: calc(100% - 58px); height: 30px; justify-content: flex-start; overflow: hidden; }
  .app-layout .sidebar-shell .sk-rail-brand > .sky-loader { flex: 0 0 30px; }
  .app-layout .sidebar-shell .sk-rail-header > .sk-rail-icon { position: absolute; right: 34px; top: 12px; }
  .app-layout .sidebar-shell .sk-rail-header > .sidebar-collapse-btn { right: 6px; }
  .app-layout[data-rail-state="collapsed"] .sidebar-shell .sk-rail-brand > .sk-rail-open { display: block !important; opacity: 0 !important; }
}
.app-layout .sidebar-shell .sk-rail-brand { justify-content: flex-start !important; width: max(30px, calc(100% - 58px)); }
.sidebar-shell nav [data-rail-label].ml-auto { left: auto; right: 12px; }
.sk-rail-fly.sk-pop-leave, .sk-recents-filter.sk-pop-leave { transition-duration: var(--sk-dur-fast, 120ms); }
@media (prefers-reduced-motion: reduce) { button:active:not(:disabled), .sk-btn:active { scale: 1; } }
@media (min-width: 1024px) {
  /* App | Chat keeps ONE 30px row in both widths (collapsed = two icons), so
     nothing under it ever moves vertically when the rail opens or closes. */
  .app-layout .sidebar-shell .sk-mode-switch { height: 30px; flex-shrink: 0; flex-direction: row !important; margin-bottom: 8px !important; overflow: hidden; }
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-mode-switch { margin-left: 8px !important; margin-right: 8px !important; }
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-mode-switch button { display: grid; place-items: center; padding: 0 !important; }
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-mode-switch button + button { border-top: 0 !important; border-left: 1px solid var(--sk-hair) !important; }
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-mode-switch .sk-mode-text { display: none; }
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-mode-switch .sk-mode-ico { display: block; }
  .app-layout[data-rail-state] .sidebar-shell.sidebar-shell nav { padding-left: 8px !important; padding-right: 8px !important; }
}

/* ── THE RAIL'S FIRST FRAME (09-30) ─────────────────────────────────────────
   base.html's head script stamps <html data-sk-rail="collapsed|expanded"> from
   the saved state before any stylesheet loads, plus html.sk-preload until two
   frames after Alpine has started. Everything that differs between the two
   rails is keyed off that attribute here, never off an Alpine-only class, so
   the markup paints in its final state on frame one and a refresh never moves.
   The store keeps the attribute in step with `collapsed` afterwards. */
html.sk-preload .sidebar-shell, html.sk-preload .sidebar-shell *,
html.sk-preload .app-layout > .flex-1, html.sk-preload .app-layout > .flex-1 > header,
html.sk-preload #holly-curtain { transition: none !important; }
html[data-sk-rail="collapsed"] .sidebar-shell [data-rail-label] { opacity: 0; pointer-events: none; }
html[data-sk-rail="collapsed"] .sidebar-shell .sk-when-expanded,
html[data-sk-rail="expanded"] .sidebar-shell .sk-when-collapsed { display: none !important; }
html[data-sk-rail="collapsed"] .sidebar-shell .sk-rail-icons { flex-direction: column; }
html[data-sk-rail="expanded"] .sidebar-shell .sk-rail-icons { flex-direction: row; justify-content: center; }
html[data-theme="dark"] .sidebar-shell .sk-ico-go-dark,
html:not([data-theme="dark"]) .sidebar-shell .sk-ico-go-light { display: none; }
@media (min-width: 1024px) {
  html[data-sk-rail="collapsed"] .app-layout > .sk-rail-offset { margin-left: 5rem !important; }
  html[data-sk-rail="expanded"] .app-layout > .sk-rail-offset { margin-left: var(--sk-sidebar-width) !important; }
  /* Holly's sheet is glued to the rail's edge; this is its edge before the shell measures. */
  html[data-sk-rail="collapsed"] { --sk-rail-edge: 5rem; }
  html[data-sk-rail="expanded"] { --sk-rail-edge: var(--sk-sidebar-width); }
}
/* Pupils keep their md: offsets (the rail floats with a 1rem margin below 1024px). */
@media (min-width: 768px) {
  /* The staff phone drawer (<1024px, base.html) overrides the width with !important. */
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell { width: 5rem; --sidebar-target-w: 5rem; }
  html[data-sk-rail="expanded"] .app-layout .sidebar-shell { width: var(--sk-sidebar-width); --sidebar-target-w: var(--sk-sidebar-width); }
  html[data-sk-rail="collapsed"] .app-layout > .sk-rail-offset-student { margin-left: 7rem; }
  html[data-sk-rail="expanded"] .app-layout > .sk-rail-offset-student { margin-left: 20rem; }
  html[data-sk-rail="collapsed"] .sk-rail-pad-student { padding-left: 8rem; }
  html[data-sk-rail="expanded"] .sk-rail-pad-student { padding-left: 21.5rem; }
}

/* ── RAIL OPEN/CLOSE, IN THREE BEATS (09-30) ────────────────────────────────
   The store sets data-rail-phase on the rail: "out" (words fade, width still),
   then "move" (width animates with only icons showing), then removes it (the
   new layout's words fade in). Everything whose layout differs between the
   two widths is a fade target, so no re-layout is ever seen mid-flight. The
   rail stays opaque, above the Holly sheet and clipped for the whole motion. */
.sidebar-shell :is([data-rail-label], .sk-mode-switch, .sk-rail-recents, .sk-rail-recents-icon, .sk-class-list,
  .holly-review-desk__count, [data-needs-me-badge], .rail-footer-app, .nav-item > svg:last-child,
  .sk-rail-header > .sk-rail-icon:not(.sidebar-collapse-btn)) {
  transition: opacity var(--sk-dur-fast, 120ms) var(--sk-ease-out, cubic-bezier(.2,.8,.2,1));
}
.sidebar-shell[data-rail-phase] :is([data-rail-label], .sk-mode-switch, .sk-rail-recents, .sk-rail-recents-icon, .sk-class-list,
  .holly-review-desk__count, [data-needs-me-badge], .rail-footer-app, .nav-item > svg:last-child,
  .sk-rail-header > .sk-rail-icon:not(.sidebar-collapse-btn)) {
  opacity: 0 !important; pointer-events: none;
}
.sidebar-shell[data-rail-phase="out"] :is([data-rail-label], .sk-mode-switch, .sk-rail-recents, .sk-rail-recents-icon, .sk-class-list,
  .holly-review-desk__count, [data-needs-me-badge], .rail-footer-app, .nav-item > svg:last-child,
  .sk-rail-header > .sk-rail-icon:not(.sidebar-collapse-btn)) {
  transition-duration: calc(var(--sk-dur-fast, 120ms) * .75);
}
.sidebar-shell[data-rail-phase], .sidebar-shell[data-rail-phase] nav { overflow: hidden !important; }
.sidebar-shell[data-rail-phase] .sk-rail-fly { display: none !important; }
@media (min-width: 1024px) {
  .app-layout .sidebar-shell[data-rail-phase] { z-index: 121 !important; }
  /* The search icon has no room in the 80px rail (it sits on the logo). Cmd+K still opens it. */
  html[data-sk-rail="collapsed"] .app-layout .sidebar-shell .sk-rail-header > .sk-rail-icon:not(.sidebar-collapse-btn) { visibility: hidden; }
  /* A frosted footer over an opaque rail buys nothing, and a resizing
     backdrop-filter layer is exactly what GPU Chrome repaints white. */
  .app-layout .sidebar-shell .rail-footer-app { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}

/* ── HOLLY IS THINKING (09-30) ─────────────────────────────────────────────
   The whole SKYONOMY mark turns over, calmly, next to the status line, from
   send until the first words of the answer. (The first cut tilted one 6px
   sub-cube by 35deg, which nobody could see.) Plain seconds, not tokens: the
   reduced-motion block zeroes the tokens, and that case gets a soft breathe. */
.sky-loader.sky-loader--thinking {
  width: 18px; flex: 0 0 18px; transform-origin: 50% 50%; backface-visibility: visible;
  animation: sk-mark-flip 1.8s cubic-bezier(.45,0,.2,1) infinite;
}
@keyframes sk-mark-flip {
  0%, 18% { transform: perspective(80px) rotateY(0deg); }
  50%, 68% { transform: perspective(80px) rotateY(180deg); }
  100% { transform: perspective(80px) rotateY(360deg); }
}
@keyframes sk-mark-breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .sky-loader.sky-loader--thinking { animation: sk-mark-breathe 2.4s ease-in-out infinite !important; transform: none !important; }
}
