:root {
  color-scheme: light;
  --bg: #f7f9fa;
  --surface: #ffffff;
  --surface-2: #f1f4f6;
  --surface-3: #e8edf0;
  --text: #151a1f;
  --muted: #66727d;
  --line: #e2e7eb;
  --line-strong: #b9c3cb;
  --accent: #147ea3;
  --hot: #2f9e63;
  --warning: #b7791f;
  --danger: #c04352;
  --code-bg: #101418;
  --code-text: #e6f2ea;
  --shadow: 0 12px 32px rgba(18, 30, 42, 0.08);
  --ui-shadow: 0 18px 44px rgba(18, 30, 42, 0.1);
  --radius: 14px;
  --ui-bottom-nav-height: 64px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e11;
  --surface: #111519;
  --surface-2: #181d22;
  --surface-3: #20262c;
  --text: #edf2f5;
  --muted: #96a2ad;
  --line: #29313a;
  --line-strong: #4a5661;
  --accent: #67cff5;
  --hot: #8fdd75;
  --warning: #f0c15c;
  --danger: #ff7a86;
  --code-bg: #080b0e;
  --code-text: #e6f2ea;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.36);
  --ui-shadow: 0 20px 50px rgba(0, 0, 0, 0.44);
}

html {
  scroll-padding-top: 84px;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow-x: clip;
}

.site-shell {
  width: min(1440px, calc(100% - 40px));
  max-width: 1440px;
}

main,
.view {
  max-width: 100%;
}

.view {
  padding-block: 64px 88px;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:active,
a:active {
  transform: scale(0.985);
}

button,
.primary-link,
.ghost-link,
.section-action-link,
.contact-mail,
.back-button {
  min-height: 44px;
  border-radius: 12px;
}

.primary-link,
.ghost-link {
  padding: 10px 18px;
}

.primary-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 650;
}

.ghost-link,
.back-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.primary-link:hover,
.ghost-link:hover,
.back-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--ui-shadow);
}

.icon-button,
.music-toggle,
.theme-toggle,
.menu-toggle,
.to-top {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;
  background: var(--surface);
  border-color: var(--line);
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 120px;
}

select {
  min-height: 46px;
  padding-inline: 12px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-head,
.home-section-head {
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.section-head h2,
.home-section-head h2 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: 0;
}

.post-grid,
.book-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.tool-grid,
.directory-grid,
.gallery-grid,
.learning-path-grid,
.prompt-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.post-card,
.share-card,
.book-card,
.prompt-card,
.tool-card,
.directory-card,
.gallery-card,
.learning-path-card,
.managed-content-card,
.profile-shortcuts a {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.post-card,
.share-card,
.book-card,
.prompt-card,
.tool-card {
  min-height: 0;
  padding: 20px;
}

.post-card:hover,
.share-card:hover,
.book-card:hover,
.prompt-card:hover,
.tool-card:hover,
.directory-card:hover,
.gallery-card:hover,
.learning-path-card:hover,
.managed-content-card:hover,
.profile-shortcuts a:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--ui-shadow);
}

.post-card h3,
.share-card h3,
.book-card h3,
.prompt-card h3 {
  font-size: 18px;
}

.post-card-main > .meta,
.post-card-main > h3 {
  padding-right: 36px;
}

.post-card-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
  color: inherit;
  cursor: pointer;
}

.post-card-main:hover h3 {
  color: var(--accent);
}

.tool-card {
  min-height: 168px;
}

.tool-card header {
  margin-bottom: 16px;
}

.tool-mark,
.tag,
.share-category,
.book-category,
.prompt-chip {
  border-radius: 999px;
}

/* Header and desktop navigation */
.topbar {
  min-height: 72px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  min-width: 0;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.brand strong {
  font-size: 16px;
}

.brand small {
  font-size: 12px;
}

.nav {
  justify-content: center;
  gap: 2px;
}

.nav > a,
.nav-group > summary {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.nav-group > summary::after {
  content: "⌄";
  margin-left: 6px;
  font-size: 12px;
}

.nav-menu {
  width: 320px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--ui-shadow);
  backdrop-filter: blur(18px);
}

.nav-menu a {
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 10px;
}

.nav-menu small {
  font-size: 12px;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(8, 12, 16, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(3px);
}

.history-controls {
  display: none !important;
  pointer-events: none;
}

html.nav-open .nav-overlay,
body.nav-open .nav-overlay {
  opacity: 1;
  pointer-events: auto;
}

html.nav-open,
body.nav-open {
  overflow: hidden;
}

/* Home */
.hero-view.active {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 56px;
  min-height: auto;
  padding-block: 72px 88px;
}

.hero-copy {
  width: min(100%, 980px);
  margin: 0;
  text-align: left;
}

.hero-copy h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(40px, 6vw, 76px);
  line-height: 1.04;
  letter-spacing: 0;
}

.hero-copy .lead {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions {
  display: flex;
  width: auto;
  gap: 12px;
  margin: 28px 0 0;
}

.hero-actions > a {
  min-width: 148px;
  min-height: 48px;
  padding: 12px 22px;
}

.home-core,
.home-latest,
.home-resources {
  display: grid;
  gap: 18px;
}

.home-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.home-workbench {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.workbench-item {
  display: grid;
  min-height: 148px;
  align-content: space-between;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.workbench-item:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--ui-shadow);
}

.workbench-item strong {
  font-size: 17px;
}

.workbench-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

#latest-posts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

#latest-posts .mini-post {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

#latest-posts .mini-post:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--ui-shadow);
}

#latest-posts .mini-post strong {
  font-size: 16px;
}

.home-resource-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.home-resource-card {
  position: relative;
  display: grid;
  min-height: 132px;
  align-content: space-between;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.home-resource-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--ui-shadow);
}

.home-resource-card span {
  font-size: 16px;
  font-weight: 700;
}

.home-resource-card small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.home-resource-card b {
  position: absolute;
  right: 18px;
  bottom: 18px;
  color: var(--muted);
  font-size: 18px;
}

.section-action-link {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

/* AI generator */
.generator-workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.88fr) minmax(0, 1.12fr);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: none;
}

.generator-form {
  padding: 24px;
  border-right: 1px solid var(--line);
}

.generator-prompt textarea,
.generator-seed input,
.generator-dimensions input {
  border-radius: 10px;
  background: var(--surface-2);
}

.generator-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.generator-controls fieldset {
  min-width: 0;
}

.generator-submit {
  min-height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
}

.generator-preview {
  min-height: 560px;
  background: var(--surface-2);
}

.generator-empty {
  min-height: 520px;
}

.generator-preview > img {
  max-height: 640px;
}

.generator-history {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 20px;
}

/* AI assistant */
#assistant.active {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 72px);
  overflow: hidden;
  padding: 16px 0 0;
}

#assistant .section-head {
  flex: 0 0 auto;
  margin-bottom: 0;
}

#assistant .lead.small {
  flex: 0 0 auto;
  margin: 8px 0 0;
  font-size: 14px;
}

.assistant-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
  padding-bottom: 16px;
}

.assistant-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 16px;
}

.assistant-side {
  border-radius: 14px;
  padding: 16px;
  overflow: auto;
}

.assistant-side .quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.assistant-side button {
  min-height: 44px;
  border-radius: 10px;
  padding: 8px 12px;
  text-align: left;
}

.assistant-messages {
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  padding: 16px;
}

.assistant-form {
  position: static;
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* Prompt studio */
.prompt-studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 20px;
  align-items: start;
}

.prompt-studio-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.prompt-studio-form label {
  display: grid;
  min-width: 0;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.prompt-studio-form .prompt-studio-wide {
  grid-column: 1 / -1;
}

.prompt-studio-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-studio-actions button,
.prompt-studio-output button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.prompt-studio-output {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.prompt-studio-output textarea {
  min-height: 260px;
}

/* Mobile bottom navigation */
.mobile-bottom-nav {
  display: none;
}

/* Dialogs become bottom sheets on phones */
@media (max-width: 767px) {
  .site-shell {
    width: min(100% - 24px, 1440px);
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 64px;
    padding-block: 10px;
    backdrop-filter: none;
    z-index: 60;
  }

  .brand small {
    display: none;
  }

  .brand strong {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .music-toggle,
  .theme-toggle {
    display: none;
  }

  .site-shell > .topbar .xt-auth-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .menu-toggle {
    display: inline-grid;
    grid-column: 1;
    grid-row: 1;
  }

  .brand {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: min(82vw, 320px);
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    overflow-y: auto;
    padding: 24px 16px calc(28px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--ui-shadow);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .nav.open {
    display: flex;
    transform: translateX(0);
  }

  .nav > a,
  .nav-group {
    width: 100%;
  }

  .nav > a {
    width: 100%;
    min-height: 46px;
    text-align: left;
  }

  .nav-group > summary {
    width: 100%;
    min-height: 46px;
    justify-content: space-between;
  }

  .nav-menu {
    position: static;
    width: 100%;
    margin: 4px 0 8px;
    padding: 6px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .nav-menu a {
    grid-template-columns: minmax(0, 1fr);
  }

  .view {
    padding-block: 42px calc(64px + env(safe-area-inset-bottom) + 24px);
  }

  .hero-view.active {
    gap: 40px;
    padding-block: 48px calc(64px + env(safe-area-inset-bottom) + 24px);
  }

  .hero-copy h1 {
    font-size: clamp(34px, 10vw, 46px);
  }

  .hero-copy .lead {
    font-size: 16px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-actions > a {
    width: 100%;
    min-width: 0;
    min-height: 48px;
  }

  .home-workbench,
  .home-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #latest-posts,
  .post-grid,
  .book-shelf,
  .prompt-grid,
  .tool-grid,
  .directory-grid,
  .gallery-grid,
  .learning-path-grid {
    grid-template-columns: 1fr;
  }

  .post-grid,
  .book-shelf {
    grid-template-columns: 1fr;
  }

  .generator-workspace {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
  }

  .generator-preview {
    order: -1;
    min-height: 320px;
    border-bottom: 1px solid var(--line);
  }

  .generator-empty {
    min-height: 300px;
  }

  .generator-form {
    border-right: 0;
    padding: 16px;
  }

  .generator-controls {
    grid-template-columns: 1fr;
  }

  .generator-ratios {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .assistant-layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }

  .assistant-side {
    order: -1;
    display: block;
    width: 100%;
    min-width: 0;
    padding: 0 0 12px;
    border: 0;
    background: transparent;
  }

  .assistant-side h3 {
    margin: 0 0 8px;
  }

  .assistant-side .quick-prompts {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
  }

  .assistant-side .quick-prompts button {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    white-space: nowrap;
  }

  .assistant-panel {
    height: calc(100dvh - 300px);
    min-height: 420px;
  }

  .assistant-messages {
    min-height: 0;
    max-height: none;
    padding: 14px 14px 90px;
  }

  .assistant-form {
    position: sticky;
    bottom: calc(64px + env(safe-area-inset-bottom) + 8px);
    z-index: 20;
    padding: 10px;
    background: var(--surface);
  }

  .assistant-compose {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .assistant-compose .attach-button,
  .assistant-compose input,
  .assistant-compose button {
    min-height: 48px;
  }

  .prompt-studio-layout {
    grid-template-columns: 1fr;
  }

  .prompt-studio-form {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .prompt-studio-form .prompt-studio-wide,
  .prompt-studio-actions {
    grid-column: 1;
  }

  .prompt-studio-actions button {
    flex: 1 1 100%;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    min-height: calc(60px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(18px);
  }

  .mobile-bottom-nav a {
    display: grid;
    min-height: 52px;
    place-items: center;
    align-content: center;
    gap: 1px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .mobile-bottom-nav a span:first-child {
    font-size: 19px;
    line-height: 1;
  }

  .mobile-bottom-nav a.active {
    color: var(--accent);
  }

  .mobile-bottom-nav a.active span:first-child {
    text-shadow: 0 0 16px color-mix(in srgb, var(--accent) 55%, transparent);
  }

  .history-controls {
    display: none;
  }

  .to-top {
    display: none;
  }

  dialog[open],
  .site-search-dialog[open],
  .xt-auth-dialog[open] {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 60;
    margin: 0;
    width: 100%;
    max-width: 100%;
    max-height: min(82dvh, 760px);
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }

  .xt-auth-dialog[open] {
    max-height: min(86dvh, 760px);
  }

  .xt-auth-guest {
    display: flex;
    flex-direction: column;
  }

  .xt-auth-guest .xt-auth-continue {
    order: 1;
    margin-bottom: 14px;
  }

  .xt-auth-guest .xt-auth-tabs {
    order: 2;
  }

  .xt-auth-guest .xt-auth-form {
    order: 3;
  }

  .xt-auth-guest .xt-auth-divider {
    order: 4;
  }

  .xt-auth-guest .xt-auth-note {
    order: 5;
  }

  .xt-auth-dialog section {
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }

  .xt-auth-dialog h2 {
    margin: 4px 0 10px;
    font-size: 24px;
  }

  .xt-auth-intro {
    margin-bottom: 14px;
    font-size: 12px;
  }

  .xt-auth-tabs {
    margin-bottom: 12px;
  }

  .xt-auth-divider {
    margin: 12px 0;
  }

  .xt-auth-note {
    margin-top: 10px;
    font-size: 12px;
  }

  .xt-auth-dialog .xt-auth-close {
    position: absolute;
    left: auto;
    top: 12px;
    right: 14px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
  }

  dialog::backdrop {
    background: rgba(8, 12, 16, 0.52);
    backdrop-filter: blur(4px);
  }

  .site-search-dialog {
    width: 100%;
    height: min(82dvh, 760px);
    overflow: hidden;
  }

  .site-search-shell {
    box-sizing: border-box;
    height: 100%;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px;
  }

  .site-search-results {
    min-height: 0;
    max-height: none;
  }
}

@media (max-width: 430px) {
  .brand strong {
    display: none;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    backdrop-filter: none;
    z-index: 60;
  }

  .brand small {
    display: none;
  }

  .menu-toggle {
    display: inline-grid;
    grid-column: 1;
    grid-row: 1;
  }

  .brand {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 3;
    grid-row: 1;
  }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: min(82vw, 320px);
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    overflow-y: auto;
    padding: 24px 16px calc(28px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--ui-shadow);
    transform: translateX(-102%);
    transition: transform 0.22s ease;
  }

  .nav.open {
    display: flex;
    transform: translateX(0);
  }

  .nav > a,
  .nav-group {
    width: 100%;
  }

  .nav > a {
    width: 100%;
    min-height: 46px;
    text-align: left;
  }

  .nav-group > summary {
    width: 100%;
    min-height: 46px;
    justify-content: space-between;
  }

  .nav-menu {
    position: static;
    width: 100%;
    margin: 4px 0 8px;
    padding: 6px;
    box-shadow: none;
    backdrop-filter: none;
  }

  .nav-menu a {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-grid,
  .book-shelf,
  .prompt-grid,
  .tool-grid,
  .directory-grid,
  .gallery-grid,
  .learning-path-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-workbench,
  .home-resource-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #latest-posts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .generator-workspace {
    grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.1fr);
  }

  .generator-controls {
    grid-template-columns: 1fr;
  }

  .assistant-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
  }

  .prompt-studio-layout {
    grid-template-columns: 1fr;
  }
}

/* Short landscape auth dialog: keep the main guest CTA visible on first paint. */
@media (max-height: 500px) and (orientation: landscape) {
  .xt-auth-dialog {
    width: min(560px, calc(100vw - 20px));
    max-height: 100dvh;
  }

  .xt-auth-dialog section {
    padding: 12px 16px;
  }

  .xt-auth-guest {
    display: flex;
    flex-direction: column;
  }

  .xt-auth-dialog h2 {
    margin: 2px 0 8px;
    font-size: 20px;
  }

  .xt-auth-intro {
    margin-bottom: 10px;
    font-size: 12px;
  }

  .xt-auth-continue {
    order: 1;
  }

  .xt-auth-tabs {
    order: 2;
    margin-bottom: 8px;
  }

  .xt-auth-form {
    order: 3;
  }

  .xt-auth-divider {
    order: 4;
    margin: 8px 0;
  }

  .xt-auth-note {
    order: 5;
    margin-top: 6px;
    font-size: 11px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #assistant.active {
    padding-top: 8px;
  }

  #assistant .section-head {
    margin-bottom: 0;
  }

  #assistant .section-head .eyebrow {
    margin-bottom: 2px;
  }

  #assistant .section-head h2 {
    font-size: 18px;
  }

  #assistant .lead.small {
    display: none;
  }

  #assistant .assistant-layout {
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 10px;
    padding-bottom: 8px;
  }

  #assistant .assistant-side {
    display: flex;
    flex-direction: column;
    padding: 8px;
  }

  #assistant .assistant-side h3 {
    margin: 0 0 6px;
  }

  #assistant .assistant-side .quick-prompts {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  #assistant .assistant-side .quick-prompts button {
    flex: 0 0 auto;
    height: 36px;
    min-height: 36px;
    padding: 6px 10px;
    white-space: nowrap;
  }

  #assistant .assistant-messages {
    padding: 10px;
  }

  #assistant .assistant-form {
    padding: 6px 8px;
  }
}

@media (max-width: 767px) {
  .site-search-filters button,
  .filter-row button,
  .prompt-side-list button,
  .prompt-models button,
  .prompt-types button,
  .prompt-tag-filter button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none;
  }

  .menu-toggle {
    display: none;
  }

  .nav-overlay {
    display: none;
  }
}

/* PR5 design-system unification */
:root {
  --accent-rgb: 20, 126, 163;
  --ui-accent: var(--accent);
}

html[data-theme="dark"] {
  --accent-rgb: 103, 207, 245;
}

.ui-alive-control,
.ui-alive-frame,
.ui-alive-text {
  --ui-accent: var(--accent) !important;
  --ui-accent-rgb: var(--accent-rgb) !important;
}

.ui-alive-control {
  border-color: var(--line) !important;
  color: var(--text) !important;
  background: var(--surface) !important;
  box-shadow: none !important;
}

.ui-alive-control:hover,
.ui-alive-control:focus-visible {
  border-color: var(--accent) !important;
  background: var(--surface-2) !important;
  box-shadow: none !important;
  translate: 0 -1px;
  scale: 1;
  rotate: 0deg;
}

.ui-alive-control.is-strong {
  border-color: var(--accent) !important;
  color: #06121a !important;
  background: var(--accent) !important;
}

.ui-alive-control.active,
.ui-alive-control[aria-selected="true"],
.ui-alive-control[aria-pressed="true"],
.nav .ui-alive-control.active {
  border-color: var(--accent) !important;
  color: var(--text) !important;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)) !important;
  box-shadow: none !important;
}

.ui-alive-frame {
  border-color: var(--line) !important;
  box-shadow: none !important;
}

.ui-alive-frame:hover {
  border-color: var(--line-strong) !important;
  box-shadow: var(--ui-shadow) !important;
  translate: 0 -2px;
}

.ui-alive-text {
  color: var(--text) !important;
  text-decoration-color: var(--line-strong) !important;
}

.ui-alive-text:hover {
  color: var(--accent) !important;
  text-shadow: none !important;
}

.eyebrow,
.eyebrow.ui-alive-text {
  color: var(--accent) !important;
}

.section-head h2,
.home-section-head h2,
.section-head h3,
.home-section-head h3 {
  color: var(--text) !important;
}

.hero-copy h1 {
  color: var(--text) !important;
  background: none !important;
  -webkit-text-fill-color: var(--text);
}

.filter-row button,
.category-menu button,
.site-search-filters button,
.prompt-side-list button,
.prompt-models button,
.prompt-types button,
.prompt-tag-filter button,
.tag,
.prompt-chip,
.share-category,
.book-category {
  border-color: var(--line) !important;
  background: var(--surface-2) !important;
  color: var(--muted) !important;
  box-shadow: none !important;
}

.filter-row button.active,
.filter-row button[aria-selected="true"],
.category-menu button.active,
.site-search-filters button.active,
.prompt-side-list button.active,
.prompt-models button.active,
.prompt-types button.active,
.prompt-tag-filter button.active {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important;
  color: var(--text) !important;
}

.primary-link,
.generator-submit,
.xt-auth-submit,
.community-submit,
button[type="submit"] {
  border-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #06121a !important;
  box-shadow: none !important;
}

.ghost-link,
.back-button,
.section-action-link,
.xt-auth-continue,
.tool-open,
.contact-mail {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

.icon-button,
.music-toggle,
.theme-toggle,
.menu-toggle,
.to-top,
.site-search-trigger,
.notification-toggle,
.generator-task-indicator,
.xt-auth-button {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  box-shadow: none !important;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
textarea,
select {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted) !important;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent) !important;
}

.post-card,
.share-card,
.book-card,
.prompt-card,
.tool-card,
.directory-card,
.gallery-card,
.learning-path-card,
.managed-content-card,
.profile-shortcuts a {
  border-color: var(--line) !important;
}

.tool-card,
.tool-card:nth-child(n) {
  --tool-accent: var(--accent);
}

.nav-menu {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  box-shadow: var(--ui-shadow) !important;
}

.nav-menu a {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--text) !important;
}

.nav-menu a:hover {
  background: var(--surface-2) !important;
  border-color: transparent !important;
  color: var(--text) !important;
}

button,
a,
input,
textarea,
select,
[role="button"],
[role="link"] {
  border-radius: 12px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-row button,
.category-menu button,
.site-search-filters button,
.prompt-side-list button,
.prompt-models button,
.prompt-types button,
.prompt-tag-filter button {
  border-radius: 999px !important;
}

.xt-native-select {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  min-height: 1px !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.xt-auth-dialog {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

@media (max-height: 520px) {
  .xt-auth-dialog section {
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
}

.xt-select-trigger {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}

.xt-select-trigger::after {
  content: "⌄";
  color: var(--muted);
}

.xt-select-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.xt-select-sheet[hidden] {
  display: none;
}

.xt-select-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(8, 12, 16, 0.52);
  backdrop-filter: blur(4px);
}

.xt-select-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  max-height: min(72dvh, 600px);
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
}

.xt-select-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px max(16px, env(safe-area-inset-right)) 14px 16px;
  border-bottom: 1px solid var(--line);
}

.xt-select-title {
  color: var(--text);
  font-weight: 700;
}

.xt-select-close {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
}

.xt-select-options {
  display: flex;
  max-height: calc(72dvh - 82px);
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding: 8px;
}

.xt-select-option {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.xt-select-option:hover,
.xt-select-option:focus-visible {
  background: var(--surface-2);
}

.xt-select-option.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.xt-select-option.is-selected::before {
  content: "●";
  margin-right: 8px;
  color: var(--accent);
}

body.xt-select-open {
  overflow: hidden;
}

/* PR6 page hierarchy */
.community-rules {
  display: none;
}

.community-access {
  display: none;
}

.community-layout {
  scroll-margin-top: 84px;
}

.community-compose-toggle {
  display: none;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent);
  color: #06121a;
  font-weight: 700;
}

.filter-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.prompt-tags-more {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.empty-state,
.platform-empty,
.gallery-empty,
.profile-empty,
.generator-history-empty,
.community-empty,
.directory-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.empty-state::before,
.platform-empty::before,
.gallery-empty::before,
.profile-empty::before,
.generator-history-empty::before,
.community-empty::before,
.directory-empty::before {
  content: "◇";
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-size: 16px;
}

.workbench-item {
  position: relative;
}

.generator-empty {
  gap: 6px;
}

.generator-empty-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 16px;
}

.generator-empty strong {
  font-size: 24px;
  color: var(--text);
}

.generator-empty span:last-child {
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
}

.toc button {
  border-radius: 8px;
  padding: 7px 8px;
}

.toc button:hover {
  background: var(--surface-2);
}

.toc button:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
}

@media (min-width: 1024px) {
  #community {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    column-gap: 20px;
  }

  #community .section-head,
  #community .community-compose-toggle {
    grid-column: 1 / -1;
  }

  #community .community-layout {
    grid-column: 2;
    grid-row: 2 / span 2;
    grid-template-columns: 1fr;
  }

  #community .community-feed-head {
    grid-column: 1;
    grid-row: 2;
  }

  #community .community-feed {
    grid-column: 1;
    grid-row: 3;
  }

  #community .community-empty {
    grid-column: 1;
  }

}

@media (min-width: 768px) {
  .workbench-item {
    min-height: 104px;
    padding: 16px;
  }

  .workbench-item::before {
    content: "⌁";
    display: block;
    width: 22px;
    height: 22px;
    color: var(--accent);
    font-size: 18px;
    line-height: 1;
  }
}

@media (min-width: 1024px) and (max-width: 1180px) {
  .community-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1023px) {
  #community {
    display: flex;
    flex-direction: column;
  }

  .community-compose-toggle {
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: 16px;
  }

  #community .community-layout {
    order: 3;
    display: none;
  }

  #community .community-layout.compose-open {
    display: grid;
  }

  #community .community-feed-head {
    order: 1;
  }

  #community .community-feed {
    order: 2;
  }

  #community .community-empty {
    order: 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
