:root {
  --bg: #0b0d10;
  --panel: #0f1318;
  --panel2: #0b0f14;
  --text: #e6edf3;
  --muted: #9aa6b2;
  --border: rgba(255, 255, 255, 0.08);
  --border2: rgba(255, 255, 255, 0.12);
  --accent: #4aa3ff;
  --danger: #ff5c5c;
  --radius: 1px;
  --grid: 4px;
  --btn-h: 32px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  /* API / billing / admin: one place to change the content column width */
  --app-page-max-width: 1440px;
  /* Dot grid: applied only on diffui-content .content (see components/diffui-content.js) */
  --canvas-dot-grid-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  --canvas-dot-grid-size: 16px 16px;
  color: var(--text);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0.2px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--border2) var(--panel2);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--panel2);
}

*::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 999px;
  border: 2px solid var(--panel2);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

*::-webkit-scrollbar-corner {
  background: var(--panel2);
}

#content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: 12px;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 14px;
}

.headerLeft {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brandLogo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
}

.brandLogo svg {
  display: block;
}

.brandTitle {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.brandTitleHeavy {
  font-weight: 900;
}

.tabs {
  display: flex;
  gap: 4px;
}

.creatorTabs {
  display: flex;
  gap: 4px;
  margin: 0 0 12px 0;
}

.tab {
  height: var(--btn-h);
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  border-color: var(--border2);
  background: var(--panel);
}

.panelTitle {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 calc(var(--grid) * 2) 0;
}

#pagesSidebar {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
  position: relative;
}

.pagesSidebarFooter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 12px;
  margin: -12px;
  display: flex;
  justify-content: flex-end;
  box-sizing: border-box;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: calc(var(--grid) * 3);
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  font-size: 11px;
  color: var(--muted);
}

textarea {
  min-height: 78px;
  resize: vertical;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  outline: none;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.contentHeader {
  gap: 6px;
  flex-wrap: nowrap;
}

.statusStack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.backBtn {
  width: 22px;
  height: 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.backBtn[data-visible="true"] {
  display: inline-flex;
}

.btn {
  height: var(--btn-h);
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}

.btn.primary {
  border-color: rgba(74,163,255,0.35);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle {
  display: flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle button {
  height: var(--btn-h);
  padding: 0 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.toggle button[data-on="true"] {
  background: var(--panel);
  color: var(--text);
}

.drop {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font-size: 11px;
}

.dropHint {
  display: block;
}

.dropHint[hidden] {
  display: none;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.thumbs .note {
  grid-column: 1 / -1;
}

.thumbs img {
  width: 100%;
  height: auto;
  aspect-ratio: var(--page-ratio, 3 / 4);
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

.note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.contextMenu {
  position: fixed;
  min-width: 180px;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 2000;
  display: none;
}

.contextMenu[data-open="true"] {
  display: block;
}

.contextMenuItem {
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.contextMenuItem:hover {
  background: rgba(255, 255, 255, 0.06);
}

.contextMenuItem[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.contextMenuDivider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}


#content[data-orientation="portrait"] {
  --option-ratio: 3 / 4;
}

#content[data-orientation="landscape"] {
  --option-ratio: 4 / 3;
}

.grid {
  display: grid;
  height: 100%;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
}

.gridWrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.card {
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  aspect-ratio: var(--option-ratio, 3 / 4);
  transition: background-color 0.2s ease-in-out;
}

.card[data-selected="true"] {
  outline: 1px solid rgba(74,163,255,0.6);
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  aspect-ratio: var(--option-ratio, 3 / 4);
  display: block;
  background: transparent;
}

.pagesCanvasShell {
  position: relative;
  flex: 1;
  min-height: 0;
}

.pagesCanvasScroller {
  position: relative;
  height: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.pagesCanvas {
  display: flex;
  gap: 24px;
  align-items: stretch;
  height: 100%;
  width: max-content;
  padding-top: 16px;
  padding-right: 24px;
  padding-bottom: 12px;
}

.pageColumn,
.optionsColumn {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}

.pageColumn,
.pageAddColumn {
  position: relative;
}

.codeColumn {
  overflow: hidden;
  width: 0;
  transition: width 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .codeColumn {
    transition: none;
  }
}


.pageFrame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
  height: 100%;
  flex: 1;
  aspect-ratio: var(--page-ratio, 3 / 4);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.pageImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.optionsGrid {
  display: grid;
  grid-template-columns: repeat(var(--option-cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--option-rows, 3), minmax(0, 1fr));
  gap: 8px;
  height: 100%;
  flex: 1;
}

.buildHeaderRow {
  justify-content: space-between;
  align-items: center;
}

.buildActions {
  margin-top: 10px;
}

.buildSectionTitle {
  margin-top: 16px;
}

.buildThumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.buildThumbCard {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.buildThumbImage {
  height: 100px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

.buildThumbLabel {
  max-width: 140px;
}

.buildPre {
  white-space: pre-wrap;
}

.buildStreamLabel {
  margin-top: 6px;
}

.buildDownload {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  margin-top: 12px;
}

.buildSidebarTitle {
  margin-top: 12px;
}

.buildSidebarFiles {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.buildSidebarItem {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 6px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.buildSidebarItem[data-selected="true"] {
  background: var(--panel);
  border-color: var(--border);
}

.buildSidebarFolder {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 8px;
  padding-left: calc(var(--build-indent, 0) * 12px);
}

.buildSidebarFile {
  font-size: 12px;
  padding-left: calc(var(--build-indent, 0) * 12px + 8px);
}

.buildFileContent {
  overflow: auto;
  min-height: 0;
}

.buildFileContentSolo {
  flex: 1;
  max-height: none;
  margin: 0;
}

.buildSidebarPage {
  font-size: 12px;
  padding: 8px 12px;
}

@keyframes diffuiBuildSpin {
  to { transform: rotate(360deg); }
}

.buildSidebarSpinner {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border2);
  border-top-color: rgba(188, 155, 48, 0.9);
  border-radius: 50%;
  animation: diffuiBuildSpin 0.7s linear infinite;
}

.buildSidebarCheck {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.buildSidebarCheck svg {
  display: block;
  width: 16px;
  height: 16px;
}

.buildSidebarPageStatus {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.buildPageSplit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: calc(100vh - 200px);
  min-height: 400px;
}

.buildPageCode {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.buildPageCode diffui-code-page {
  flex: 1;
  height: 100%;
}

.buildPagePreview {
  display: flex;
  flex: 1;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

.buildPagePreview diffui-page {
  flex: 1;
  height: 100%;
}

.buildPreviewImage {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.buildPreviewViewport {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.buildPreviewStage {
  position: relative;
  transform-origin: top left;
}

.buildPreviewFrame {
  display: block;
  border: 0;
  background: #fff;
}

.optionCard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  overflow: hidden;
  cursor: pointer;
  display: grid;
  place-items: center;
  aspect-ratio: var(--option-ratio, 3 / 4);
  transition: background-color 0.2s ease-in-out;
}

.optionCard[data-selected="true"] {
  outline: 1px solid rgba(74,163,255,0.6);
}

.optionCard img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  aspect-ratio: var(--option-ratio, 3 / 4);
  display: block;
  background: transparent;
}

.skeletonCard {
  background: #161c23;
  border: 1px solid var(--border);
  transition: background-color 0.4s ease-in-out;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.skeletonCard[data-highlight="true"] {
  background: #2a3340;
}

.cardMeta {
  padding: 8px;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.focusShell {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: calc(var(--grid) * 3);
  height: 100%;
}

.focusTop {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: calc(var(--grid) * 3);
  min-height: 0;
}

.focusImage {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-y: auto;
  background: #000;
  display: grid;
  place-items: center;
}

.focusImage img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.focusActions {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel2);
  padding: calc(var(--grid) * 3);
  display: flex;
  flex-direction: column;
  gap: calc(var(--grid) * 2);
  min-width: 0;
}

.filmstrip {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 8px 0;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 2;
}

.filmstrip img {
  width: 120px;
  height: 80px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: #000;
}

.filmstrip img[data-selected="true"] {
  outline: 1px solid rgba(74,163,255,0.6);
}

.modalTitle {
  font-size: 12px;
  color: var(--text);
}

.modalActions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.02);
  color: var(--muted);
  font-size: 11px;
}

.qa {
  display: grid;
  gap: calc(var(--grid) * 3);
  margin-top: calc(var(--grid) * 3);
}

.qCard {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  padding: calc(var(--grid) * 3);
  display: grid;
  gap: calc(var(--grid) * 2);
}

.qTitle {
  font-size: 12px;
  color: var(--text);
}

.qOpts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.optBtn {
  height: var(--btn-h);
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.optBtn[data-on="true"] {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border2);
}

/* App view containers */
#appNav {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
}

.viewContainer {
  padding: calc(var(--grid) * 4);
  max-width: 960px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}

.viewContainer--full {
  padding: 0;
  max-width: none;
  margin: 0;
}

.viewContainer--full diffui-shell {
  height: 100%;
}

.viewContainer.hidden {
  display: none !important;
}

#authView:not(.hidden) {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 48px;
}

/* API, billing, admin, generations list, generation settings: centered column (--app-page-max-width) */
.viewContainer--appPanel {
  padding: 0;
  max-width: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.appPanelCanvas {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--bg);
}

.appPanelColumn {
  position: relative;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--app-page-max-width);
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: calc(var(--grid) * 4);
}

.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sidebarColumn {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
}

.sidebarPanel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* [hidden] alone loses to .sidebarPanel { display: flex } (equal specificity, later rule). */
.sidebarPanel[hidden] {
  display: none !important;
}

.projectTitle {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: calc(var(--grid) * 2);
  line-height: 1.3;
  word-break: break-word;
}

.pagesListBody {
  flex: 1;
  min-height: 48px;
  overflow: auto;
}

.sidebarBottom {
  margin-top: auto;
  padding-top: calc(var(--grid) * 3);
  border-top: 1px solid var(--border);
}

.settingsInput,
.settingsTextarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  resize: vertical;
}

.codePanelScroll {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 11px;
  line-height: 1.45;
}

.workspacePanel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

#workspaceCode.workspacePanel {
  overflow: hidden;
}

.workspacePanel[hidden] {
  display: none !important;
}

.workspaceSettingsPanel.workspacePanel {
  overflow: hidden;
}

.codeWorkspaceInner {
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: calc(var(--grid) * 1);
  min-height: 0;
}

.panelTitleSpaced {
  margin-top: calc(var(--grid) * 3);
}

.rowSpaced {
  margin-top: calc(var(--grid) * 2);
}

.codePagesToBuild {
  min-height: 0;
}

.codeBuildDynamicArea {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebarPanelCodeFiles {
  min-height: 0;
}

.codeBuildFilesSidebar {
  flex: 1;
  min-height: 120px;
  border: none;
  padding: 0;
  background: transparent;
}

.buildWorkspace {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.buildFileSidebar {
  border-right: 1px solid var(--border);
  background: var(--panel2);
  overflow: auto;
  padding: calc(var(--grid) * 2);
  min-width: 0;
}

.buildWorkspaceMain {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.generationsLayout {
  width: 100%;
}

.generationsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: calc(var(--grid) * 4);
}

.generationsTitle {
  margin: 0;
  font-size: 18px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.generationsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: calc(var(--grid) * 4);
}

.generationCard {
  width: 500px;
  max-width: 100%;
  height: 200px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: inherit;
}

.generationCard:hover {
  border-color: var(--border2);
}

.generationCardTitle {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.generationCardThumbs {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  padding: 2px;
  min-height: 0;
  background: var(--panel2);
}

.generationCardThumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.generationCardPlaceholder {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11px;
}

.generationsEmpty {
  text-align: center;
  padding: 24px;
}
