/* One layout contract for App Store, Projects, and AI. Loaded after legacy page styles. */
:root {
  --shell-ink: #1d1d1f;
  --shell-muted: #65666d;
  --shell-line: #dce0e6;
  --shell-line-soft: #e9ecf0;
  --shell-active: #0b57d0;
  --shell-active-bg: #e8eefb;
  --shell-hover: #f2f4f7;
  --shell-page: #f5f6f8;
  --shell-radius: 16px;
}

body.section-page {
  height: auto;
  min-height: 100dvh;
  padding-top: 64px;
  background: var(--shell-page);
  color: var(--shell-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.section-page .section-container {
  width: calc(100% - 48px);
  max-width: 1280px;
  min-height: 0;
  margin: 0 auto;
  padding: 32px 0 64px;
  background: transparent;
}

body.section-page .section-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  grid-template-rows: none;
  align-items: start;
  gap: 32px;
  width: 100%;
  max-width: none;
  min-height: 0;
  margin: 0;
  padding: 0;
}

body.section-page .section-sidebar {
  display: block;
  position: sticky;
  top: 96px;
  order: initial;
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.section-page .section-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  margin: 0;
  padding: 20px;
  border-bottom: 1px solid var(--shell-line-soft);
  color: var(--shell-ink);
  font-size: 22px !important;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

body.section-page .section-brand > img {
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px;
  object-fit: contain;
  filter: none;
}

body.section-page .as-sidebar-brand-title {
  color: inherit;
  font: inherit;
}

body.section-page .section-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 4px;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 8px;
  background: transparent;
}

body.section-page .section-tabs > button {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  justify-content: start;
  gap: 12px;
  width: 100%;
  min-width: 0;
  height: auto;
  min-height: 48px;
  margin: 0;
  padding: 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--shell-ink);
  font: 600 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  transform: none;
}

body.section-page .section-tabs > button:hover { background: var(--shell-hover); }
body.section-page .section-tabs > button.is-active {
  background: var(--shell-active-bg);
  color: var(--shell-active);
}
body.section-page .section-tabs > button > :first-child { width: 20px; height: 20px; }
body.section-page .section-tabs > button > span { min-width: 0; }
body.section-page .section-tabs :is(.ai-tab-name, .projects-tab-name) { color: inherit; font: inherit; }
body.section-page :is(.ai-tab-note, .projects-tab-note) { display: none; }
body.section-page .as-nav-icon { filter: brightness(0); opacity: 0.85; }
body.section-page .as-nav-btn.is-active .as-nav-icon {
  filter: brightness(0) saturate(100%) invert(26%) sepia(85%) saturate(1979%) hue-rotate(207deg);
}
body.section-page .section-tabs .ai-tab .ai-tab-icon { color: inherit; }

body.section-page :is(button, a):focus-visible {
  outline: 3px solid var(--shell-active);
  outline-offset: 3px;
}

body.section-page .section-content {
  display: block;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0;
}

body.section-page .section-header {
  display: block;
  margin: 0 0 24px;
  padding: 0;
}
body.section-page :is(.as-title, .projects-title, .ai-section-title) {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  color: var(--shell-ink);
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 700;
}
body.section-page :is(.as-subtitle, .projects-header .tagline, .ai-section-copy) {
  max-width: 65ch;
  margin: 0;
  color: var(--shell-muted);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}
body.section-page .projects-header .divider { display: none; }
body.section-page [hidden] { display: none !important; }

body.section-page :is(.projects-grid, .spotlight-grid, .ai-panel .ai-release-list) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
}
body.section-page .section-content :is(.projects-grid, .spotlight-grid) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
body.section-page :is(.project-card, .ai-feature, .as-card.as-material-card) {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: #fff;
  box-shadow: 0 2px 6px rgb(20 30 50 / 3%);
  overflow: hidden;
  transform: none;
}
body.section-page :is(.project-card, .ai-feature, .as-card.as-material-card):hover {
  border-color: #bdc7d5;
  box-shadow: 0 4px 14px rgb(20 30 50 / 6%);
  transform: none;
}
body.section-page :is(.project-body, .ai-panel .ai-feature-body) {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 20px;
  background: #fff;
}
body.section-page :is(.project-title, .ai-panel .ai-release-title) {
  margin: 0 0 8px;
  color: var(--shell-ink);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
body.section-page :is(.project-desc, .ai-panel .ai-release-copy) {
  margin: 0 0 16px;
  color: var(--shell-muted);
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
}
body.section-page .project-thumb { height: 180px; border-bottom: 1px solid var(--shell-line); }
body.section-page .project-thumb > img { border-width: 1px; }
body.section-page .ai-feature { display: flex; flex-direction: column; }
body.section-page .ai-panel .ai-feature-art {
  padding: 8px;
  border-bottom: 1px solid var(--shell-line-soft);
  background: var(--shell-hover);
}
body.section-page .ai-panel .ai-feature-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 5;
  object-fit: cover;
  object-position: center;
  border: 1px solid var(--shell-line);
  border-radius: 8px;
}
body.section-page .ai-panel .ai-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: auto 0 0;
  padding-top: 4px;
}
body.section-page .ai-panel .ai-button { min-height: 44px; font-size: 14px; }
body.section-page .as-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 0; }
body.section-page .as-card.as-material-card { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 20px; }
body.section-page .as-card.as-material-card .as-card-desc { font-size: 16px; line-height: 1.5; -webkit-line-clamp: unset; display: block; }
body.section-page .as-card.as-material-card .as-card-name { font-size: 20px; line-height: 1.3; margin-bottom: 6px; }
body.section-page .as-card.as-material-card .as-card-tag { font-size: 13px; }
body.section-page .as-card .as-card-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 60px;
  height: 32px;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
}
/* Preserve a comfortable touch area around the compact visual capsule. */
body.section-page .as-card .as-card-cta::after {
  content: "";
  position: absolute;
  inset: -6px -2px;
}
body.section-page .ai-empty { border: 1px solid var(--shell-line); border-radius: var(--shell-radius); padding: 28px; background: #fff; }

/* Clover's output stays square, with prompts visible before opening an image. */
.clover-collection { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--shell-line); }
.clover-collection h3 { margin: 0 0 6px; font-size: 20px; line-height: 1.3; }
.clover-collection p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--shell-muted); }
.clover-collection a { color: var(--shell-active); font-size: 14px; line-height: 1.5; text-decoration: none; }
.clover-collection a:hover { text-decoration: underline; }
.clover-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.clover-card { display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden; text-align: left; color: var(--shell-ink); background: #fff; border: 1px solid var(--shell-line); border-radius: var(--shell-radius); cursor: zoom-in; font: inherit; transition: border-color 160ms ease, box-shadow 160ms ease; }
.clover-card:hover { border-color: #a4b6ce; box-shadow: 0 4px 14px rgb(20 30 50 / 8%); }
.clover-card > img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.clover-caption { display: grid; gap: 6px; padding: 16px; }
.clover-caption strong { font-size: 16px; line-height: 1.3; font-weight: 600; }
.clover-caption > span { color: var(--shell-muted); font-size: 14px; line-height: 1.5; }
.clover-viewer { width: min(720px, calc(100% - 32px)); max-width: none; max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--shell-line); border-radius: 20px; background: #fff; color: var(--shell-ink); overflow: auto; overscroll-behavior: contain; }
.clover-viewer::backdrop { background: rgb(12 16 24 / 72%); backdrop-filter: blur(6px); }
body:has(.clover-viewer[open]) { overflow: hidden; }
.clover-viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; font-size: 14px; }
.clover-viewer-bar form { margin: 0; }
.clover-viewer button { min-width: 44px; min-height: 44px; padding: 8px 12px; background: var(--shell-hover); border: 0; border-radius: 8px; color: inherit; font: inherit; cursor: pointer; }
.clover-viewer button:hover { background: var(--shell-active-bg); }
.clover-viewer-image { display: block; width: 100%; height: min(58dvh, 512px); object-fit: contain; background: #f0f1f3; }
.clover-viewer-details { display: grid; gap: 16px; padding: 20px; }
.clover-viewer-details h2 { font-size: 20px; line-height: 1.3; margin: 0 0 6px; }
.clover-viewer-details p { color: var(--shell-muted); font-size: 16px; line-height: 1.5; margin: 0; }
.clover-viewer-controls { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.clover-viewer-caption { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.clover-viewer-caption h2 { margin: 0; }
.clover-prompt-bar { display: grid; gap: 8px; padding: 14px 16px; border: 1px solid var(--shell-line); border-radius: 14px; background: #f7f8fa; }
.clover-prompt-bar label { font-size: 13px; font-weight: 600; color: var(--shell-muted); }
.clover-prompt-bar textarea { display: block; resize: none; width: 100%; min-height: 3em; padding: 0; border: 0; background: transparent; color: var(--shell-ink); font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
.clover-collection-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; }
.clover-explore { min-height: 44px; padding: 10px 18px; border: 0; border-radius: 999px; background: var(--shell-active); color: #fff; font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.clover-explore:hover { background: #0948ad; }
body.section-page .ai-panel[data-ai-panel="gallery"] .ai-actions { justify-content: center; }
body.section-page .ai-panel[data-ai-panel="gallery"] .clover-explore { display: inline-flex; align-items: center; justify-content: center; width: min(100%, 320px); min-height: 48px; border: 2px solid #202124; border-radius: 10px; background: #fff; color: #202124; box-shadow: 2px 2px 0 rgb(0 0 0 / 8%); font-size: 16px; font-weight: 700; text-decoration: none; }
body.section-page .ai-panel[data-ai-panel="gallery"] .clover-explore:hover { background: #f7f7f7; }
body.section-page .ai-panel[data-ai-panel="gallery"] .clover-explore:focus-visible { outline: 3px solid var(--shell-active); outline-offset: 3px; }
body.section-page .ai-panel[data-ai-panel="gallery"] .ai-feature.is-text-only .ai-feature-body { justify-content: center; padding: 30px; }
body.section-page .ai-panel[data-ai-panel="gallery"] .ai-feature.is-text-only .ai-release-title { font-size: clamp(24px, 2.4vw, 32px); letter-spacing: -0.035em; }
body.section-page .ai-panel[data-ai-panel="gallery"] .ai-library-count { margin: 0 0 26px; color: #405780; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
body.section-page .ai-panel[data-ai-panel="gallery"] .ai-library-count span { padding: 0 6px; color: #a8b0bb; }

@media (max-width: 1100px) {
  body.section-page .section-content :is(.projects-grid, .spotlight-grid) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) and (min-width: 901px) {
  body.section-page .section-layout { grid-template-columns: 220px minmax(0, 1fr); gap: 24px; }
  .clover-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  body.section-page .section-container { width: calc(100% - 32px); padding: 24px 0 48px; }
  body.section-page .section-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  body.section-page .section-sidebar { position: static; }
  body.section-page .section-brand { min-height: 60px; padding: 16px; font-size: 20px !important; }
  body.section-page .section-brand > img { width: 24px !important; height: 24px !important; flex-basis: 24px; }
  body.section-page .section-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.section-page .section-tabs > button { min-height: 44px; padding: 10px; gap: 10px; font-size: 14px; }
  body.section-page :is(.as-title, .projects-title, .ai-section-title) { font-size: 28px; }
  body.section-page .section-header { margin-bottom: 20px; }
  body.section-page :is(.projects-grid, .spotlight-grid, .ai-panel .ai-release-list) { gap: 16px; }
  .clover-gallery { gap: 16px; }
}

@media (max-width: 600px) {
  body.section-page :is(.projects-grid, .spotlight-grid, .ai-panel .ai-release-list) { grid-template-columns: minmax(0, 1fr); }
  body.section-page .as-card.as-material-card { grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; padding: 16px; gap: 12px; }
  body.section-page .as-card.as-material-card .as-card-icon { width: 56px; height: 56px; align-self: start; }
  body.section-page .as-card-cta { grid-column: 3; align-self: start; justify-self: end; }
  body.section-page :is(.project-body, .ai-panel .ai-feature-body) { padding: 18px; }
  .clover-collection { flex-direction: column; align-items: start; gap: 10px; }
  .clover-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .clover-caption { padding: 12px; }
  .clover-caption strong { font-size: 15px; }
  .clover-viewer-details { flex-direction: column; align-items: stretch; gap: 16px; padding: 16px; }
  .clover-viewer-controls { justify-content: space-between; }
  .clover-viewer-caption { flex-direction: column; align-items: stretch; gap: 12px; }
  .clover-viewer-bar { padding: 8px 12px; }
  .clover-viewer-image { height: min(48dvh, 512px); }
}

@media (max-width: 360px) {
  .clover-gallery { grid-template-columns: minmax(0, 1fr); }
  body.section-page .section-tabs > button { grid-template-columns: 18px minmax(0, 1fr); gap: 6px; padding-inline: 8px; }
  body.section-page .as-card.as-material-card { grid-template-columns: 56px minmax(0, 1fr); align-items: start; }
  body.section-page .as-card-cta { grid-column: 2; justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  body.section-page *, body.section-page *::before, body.section-page *::after { scroll-behavior: auto; transition: none; animation: none; }
}

/* Compact dataset rows keep the catalog easy to scan without large image panels. */
.dataset-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.dataset-card { display: flex; min-width: 0; overflow: hidden; border: 1px solid var(--shell-line); border-radius: 14px; background: #fff; box-shadow: 0 2px 6px rgb(20 30 50 / 3%); }
.dataset-preview { position: relative; display: block; flex: 0 0 168px; min-height: 178px; overflow: hidden; border-right: 1px solid var(--shell-line-soft); background: var(--shell-hover); }
.dataset-preview img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
.dataset-body { display: flex; flex-direction: column; align-items: start; flex: 1; min-width: 0; padding: 16px 18px; }
.dataset-kind { margin: 0 0 4px; color: var(--shell-muted); font-size: 12px; line-height: 1.3; font-weight: 600; }
.dataset-body h2 { margin: 0 0 6px; color: var(--shell-ink); font-size: 18px; line-height: 1.25; letter-spacing: -0.02em; }
.dataset-description { margin: 0 0 10px; color: var(--shell-muted); font-size: 14px; line-height: 1.4; }
.dataset-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.dataset-facts span { padding: 3px 7px; border-radius: 6px; background: var(--shell-hover); color: #4b5565; font-size: 12px; line-height: 1.3; }
.dataset-link { display: inline-flex; gap: 10px; align-items: center; min-height: 44px; margin-top: auto; color: var(--shell-active); font-size: 13px; font-weight: 600; text-decoration: none; }
.dataset-link.ai-button:hover { text-decoration: none; }
.ai-panel[data-ai-panel="other"] .dataset-grid { max-width: 620px; }
@media (max-width: 600px) {
  .dataset-grid { gap: 10px; }
  .dataset-preview { flex-basis: 104px; min-height: 150px; }
  .dataset-body { padding: 12px; }
  .dataset-body h2 { font-size: 16px; }
  .dataset-description { font-size: 13px; }
  .dataset-facts { margin-bottom: 10px; }
}

@media (max-width: 360px) {
  .clover-prompt-bar textarea { min-height: 4.5em; }
}

/* Image-led dataset collection; full specifications live on Hugging Face. */
#ai-panel-datasets .dataset-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
#ai-panel-datasets .dataset-card {
  flex-direction: column;
}
#ai-panel-datasets .dataset-preview {
  flex: none;
  width: 100%;
  min-height: 0;
  aspect-ratio: 16 / 10;
  border-right: 0;
  border-bottom: 1px solid var(--shell-line-soft);
}
#ai-panel-datasets .dataset-body {
  padding: 20px;
}
#ai-panel-datasets .dataset-body h2 {
  font-size: 19px;
  line-height: 1.3;
}
#ai-panel-datasets .dataset-description {
  margin-bottom: 20px;
  line-height: 1.5;
}
#ai-panel-datasets .dataset-link {
  font-size: 13px;
}
@media (max-width: 1200px) {
  #ai-panel-datasets .dataset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #ai-panel-datasets .dataset-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

/* Outline the App Store selection using a darker shade of its blue fill. */
body.appstore-page .section-tabs > button { border: 2px solid transparent; }
body.appstore-page .section-tabs > button.is-active { border-color: #7897cd; }
