html:not(.widget) body,
html:not(.widget) .shell {
  background-color: #fff;
  color: #202733;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
}

html:not(.widget) .shell .app-header { min-height: 102px; }
.shell .app-header .brand { color: #303946; font-size: 17px; font-weight: 600; letter-spacing: .02em; }
.shell .app-header nav[aria-label] { gap: clamp(4px, 1.1vw, 16px); }
.shell .app-header nav button {
  gap: 7px; padding-inline: 10px; font-size: 14px; font-weight: 500; color: #657080;
}
.shell .app-header nav button:hover { background: transparent; color: #303946; transform: none; }
.shell .app-header nav button[data-page].active { background: transparent; color: #4c65df; box-shadow: none; }
.shell .app-header nav .ui-icon, .shell .profile-area .ui-icon { width: 17px; height: 17px; }
.shell .app-header .profile-area { display: flex; align-items: center; gap: clamp(12px, 2vw, 28px); }
.shell .profile-area .account-pill,
.shell .profile-area .mobile-account {
  padding: 5px 4px; min-height: 36px; background: transparent; box-shadow: none; border: 0; color: #202733;
}
.shell .profile-area button:hover { transform: none; color: #4057ba; }
.shell .app-header .account-avatar { width: 20px; height: 20px; background: transparent; color: #546071; }
.shell .app-header .account-pill strong { max-width: min(13vw, 120px); }

.library-heading, .preview-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 21px 14px 0 4px; margin-bottom: 65px; min-width: 0;
}
.library-heading h1 { color: #202733; font-size: 22px; font-weight: 600; }
#page-cats .action-create, #page-home #desktop-open {
  display: inline-flex; gap: 9px; align-items: center; justify-content: center; flex: none;
  min-height: 46px; padding: 10px 27px; border: 0; border-radius: 99px;
  background: #6279f5; color: white; font-size: 14px; font-weight: 600;
  box-shadow: 0 7px 16px -5px rgb(67 89 176 / .32);
}
#page-cats .action-create { min-width: 186px; }
#page-home #desktop-open { min-width: 178px; }
#page-cats .action-create:hover, #page-home #desktop-open:hover { background: #526bea; }
.library-heading .ui-icon, .preview-summary .ui-icon { width: 17px; height: 17px; }
.pet-library-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 306px), 328px));
  gap: 16px; padding: 0 2px 12px;
}
.library-pet {
  display: grid; grid-template-columns: 115px minmax(0, 1fr); align-items: stretch; gap: 12px;
  box-sizing: border-box; min-width: 0; min-height: 162px; padding: 12px;
  background: #fff; border: 1px solid #dce2ea; border-radius: 15px; color: #202733;
}
.library-pet .pet-portrait {
  display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center;
  align-self: center; width: 100%; height: 134px; min-width: 0;
  margin: 0; padding: 0; border: 0; border-radius: 9px; background: transparent; box-shadow: none;
}
/* On a 512px portrait canvas the cat occupies at most 448px of width and 440px of height.
   The transparent margins may extend beyond the column while the entire cat fits inside. */
.library-pet .pet-portrait img { display: block; width: min(128px, 114%); height: auto; aspect-ratio: 1; object-fit: contain; }
/* George's 369px original has 360px of artwork and its paw line at y=361.
   Place it at the same scale and y=476 baseline as the canonical 512px canvas. */
.tight-demo-portrait { transform: translateY(.84%) scale(.881); }
.library-pet .pet-portrait .ui-icon { width: 20px; height: 20px; color: #a6afbc; }
.library-pet .pet-portrait img:not([hidden]) + .ui-icon { display: none; }
.pet-detail { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; padding: 9px 0 8px; }
.pet-detail h2 { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 18px; font-weight: 600; }
.demo-badge, #page-home #demo-tag {
  display: inline-flex; align-items: center; align-self: flex-start; width: fit-content;
  min-height: 22px; padding: 2px 8px; border-radius: 5px;
  background: #e8efff; color: #304d9f; font-size: 13px; font-weight: 600;
}
.pet-progress { color: #5e697a; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.library-pet .pet-place {
  gap: 7px; margin-top: auto; min-height: 34px; min-width: 116px; padding: 7px 13px;
  border-radius: 10px; background: #202733; color: white; font-size: 13px; font-weight: 550; box-shadow: none;
}
.library-pet .pet-place:hover { background: #121923; }
.library-pet .pet-place .ui-icon { width: 15px; height: 15px; }
.library-pet .pet-job, #page-home .playback-retry {
  min-height: 32px; padding: 4px 0; background: transparent; color: #425cda; font-size: 13px; box-shadow: none;
}
.library-pet .pet-job { margin-top: auto; }

.preview-summary { min-height: 94px; padding-top: 12px; margin-bottom: 40px; }
.preview-identity { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; }
#page-home #cat-name { margin: 0; color: #202733; font-size: 19px; font-weight: 600; }
#desktop-state { color: #596678; font-size: 12px; }
html:not(.widget) #page-home .habitat { display: block; height: clamp(265px, calc(100dvh - 268px), 580px); }
html:not(.widget) #page-home .stage-card {
  width: 100%; height: 100%; padding: 0; border-radius: 18px; background: #e8edf2; color: #273345;
}
.desktop-menubar {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center; gap: 9px; height: 21px;
  padding: 0 18px; background: #f7f8fa; color: #b5bfcc;
}
.desktop-menubar i { width: 10px; height: 3px; border-radius: 2px; background: currentColor; }
.desktop-menubar i:nth-child(2) { width: 20px; }
.desktop-menubar i:nth-child(3) { width: 15px; }
.desktop-menubar b { width: 15px; height: 6px; margin-left: auto; border-radius: 2px; background: currentColor; }
.desktop-folder { position: absolute; top: 10%; right: 3.5%; color: #98aec3; }
.desktop-folder .ui-icon { display: block; width: 23px; height: 23px; }
html:not(.widget) #page-home .cat-stage {
  position: absolute; inset: 21px 0 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  justify-items: center; align-items: end; padding-bottom: clamp(14px, 6dvh, 55px);
}
html:not(.widget) #page-home .cat-stage::before { content: none; }
html:not(.widget) #page-home .cat-stage canvas, #preview-poster {
  grid-area: 1 / 1; width: auto; min-height: 0; max-width: 80%; object-fit: contain;
}
html:not(.widget) #page-home .cat-stage canvas {
  height: min(72%, 315px); transform: scale(calc(.48 + var(--cat-scale, .9) * .46)); transform-origin: bottom center;
}
#preview-poster { height: min(51%, 209px); aspect-ratio: 1; }
html:not(.widget) .cat-stage:not([data-playing]) canvas { visibility: hidden; }
.cat-stage[data-playing] #preview-poster { display: none; }
html:not(.widget) #page-home .stage-feedback { position: static; display: flex; margin-top: 8px; }
html:not(.widget) #page-home .stage-feedback:not(:has(> :not([hidden]))) { display: none; }
.widget .preview-summary, .widget .desktop-menubar, .widget .desktop-folder, .widget #preview-poster { display: none; }

@media (max-width: 940px) {
  html:not(.widget) .shell .app-header { min-height: 77px; }
  .shell .app-header nav[aria-label] { gap: 2px; }
  .shell .app-header nav button { gap: 5px; padding-inline: 7px; font-size: 13px; }
  .shell .app-header .profile-area { gap: 8px; }
  .library-heading { margin-bottom: 46px; }
  .preview-summary { min-height: 80px; margin-bottom: 26px; }
  html:not(.widget) #page-home .habitat { height: clamp(245px, calc(100dvh - 214px), 580px); }
}
@media (max-width: 679px) {
  html:not(.widget) .shell .app-header { gap: 4px; padding-block: 9px; }
  .shell .app-header .profile-area { grid-area: 1 / 2; }
  .shell .app-header nav button {
    min-width: 0; padding-inline: 2px; font-size: 12px; white-space: normal;
    overflow-wrap: anywhere; line-height: 1.2;
  }
  html:is(:lang(en), :lang(ja), :lang(ko)) .shell .app-header nav button .ui-icon { display: none; }
  .shell .app-header nav .ui-icon { width: 15px; height: 15px; }
  .library-heading, .preview-summary { gap: 9px; margin: 0 0 26px; padding: 16px 0 0; }
  .library-heading h1 { font-size: 20px; }
  #page-cats .action-create, #page-home #desktop-open { min-width: 0; min-height: 42px; padding: 9px 16px; }
  .pet-library-grid { padding-inline: 0; }
}
@media (max-width: 350px) {
  .shell .app-header nav button { font-size: 11px; gap: 4px; }
  .library-pet { grid-template-columns: 92px minmax(0, 1fr); gap: 8px; }
}

/* The macOS window controls occupy their own row above the navigation. */
html.macos-library .shell {
  --library-leading-edge: 17px;
  padding-inline-start: var(--library-leading-edge);
}
html.macos-library .shell .app-header {
  min-height: 102px;
  padding: 36px 0 13px;
}
html.macos-library .app-header .brand { min-height: 38px; align-items: center; }
html.macos-library .app-header .brand img.wordmark { height: 23px; }
html.macos-library .shell .profile-area {
  margin-inline-end: max(0px, calc(min(8.5vw, 100px) - var(--gutter) - 4px));
}
html.macos-library main:has(#page-cats[hidden]) {
  padding-inline-start: max(0px, calc(var(--gutter) - var(--library-leading-edge)));
}
html.macos-library #page-cats .library-heading {
  padding: 20px 0 0;
  margin-bottom: 67px;
}
html.macos-library #library-title { align-self: start; margin-top: 5px; }
@media (min-width: 680px) {
  #page-cats {
    --content-gutter: clamp(28px, 4.24vw, 50px);
    padding-inline-start: calc(var(--content-gutter) - var(--library-leading-edge, var(--gutter)));
    padding-inline-end: calc(var(--content-gutter) - var(--gutter));
  }
  #page-cats .library-heading, #page-cats .pet-library-grid { padding-inline: 0; }
}
