:root {
  color-scheme: light;
  --shell-max: 1120px;
  --bg-top: #f6fbff;
  --bg-bottom: #fef4ff;
  --ink-main: #21304f;
  --ink-soft: #5e6b86;
  --mint: #b8f3df;
  --sky: #b9e8ff;
  --peach: #ffd8bc;
  --lavender: #e7d0ff;
  --rose: #ffc7df;
  --lemon: #ffeaa2;
  --focus: #3b78ff;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --shadow-lg: 0 18px 50px rgba(32, 51, 91, 0.18);
  --shadow-md: 0 10px 28px rgba(32, 51, 91, 0.12);
  --radius-xl: 1.4rem;
  --radius-lg: 1rem;
  --radius-md: 0.8rem;
  --radius-sm: 0.55rem;
  --space-1: 0.45rem;
  --space-2: 0.8rem;
  --space-3: 1.1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: "Avenir Next", "SF Pro Rounded", "Nunito", "Trebuchet MS", sans-serif;
  color: var(--ink-main);
  background: linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

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

img,
svg {
  max-width: 100%;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 50%, white 50%);
  outline-offset: 1px;
}

.bg-orb {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(0.2rem);
  opacity: 0.55;
  pointer-events: none;
}

.bg-orb-one {
  width: 20rem;
  height: 20rem;
  top: -4rem;
  left: -5rem;
  background: radial-gradient(circle, #c3f0ff, transparent 65%);
}

.bg-orb-two {
  width: 18rem;
  height: 18rem;
  top: 25vh;
  right: -6rem;
  background: radial-gradient(circle, #ffe0f0, transparent 60%);
}

.bg-orb-three {
  width: 22rem;
  height: 22rem;
  bottom: -8rem;
  left: 20%;
  background: radial-gradient(circle, #f9efb7, transparent 65%);
}

.app-shell {
  width: min(var(--shell-max), 100%);
  margin: 0 auto;
  padding: max(0.9rem, env(safe-area-inset-top))
    max(var(--space-3), env(safe-area-inset-right))
    calc(7.5rem + env(safe-area-inset-bottom))
    max(var(--space-3), env(safe-area-inset-left));
}

body.tab-chat-active {
  overflow: hidden;
}

body.tab-chat-active .app-shell {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.glass-card {
  backdrop-filter: blur(18px);
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.top-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.72rem;
  align-items: center;
  padding: 0.58rem 0.78rem;
  margin-bottom: 0.72rem;
  animation: slide-up 0.6s ease both;
  position: relative;
  z-index: 60;
}

.top-title {
  display: grid;
  gap: 0.08rem;
}

.top-header h1 {
  margin-top: 0;
  font-size: clamp(1.16rem, 2.8vw, 1.56rem);
  line-height: 1.12;
}

.subtitle {
  margin-top: 0.04rem;
  color: var(--ink-soft);
  line-height: 1.3;
  font-size: 0.84rem;
  max-width: 58ch;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-self: end;
}

.network-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  border-radius: 999px;
  padding: 0.3rem 0.52rem;
  border: 1px solid rgba(148, 171, 220, 0.4);
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.76rem;
  font-weight: 700;
}

.status-dot {
  width: 0.56rem;
  height: 0.56rem;
  border-radius: 999px;
  background: #13a85b;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.network-indicator.is-offline .status-dot {
  background: #da3e33;
}

.user-menu-wrap {
  position: relative;
  z-index: 70;
}

.kebab-btn {
  border: 1px solid rgba(150, 170, 216, 0.42);
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.82rem;
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  color: #2f456f;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.34rem);
  width: min(270px, 84vw);
  border-radius: 0.9rem;
  border: 1px solid rgba(145, 164, 206, 0.42);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(42, 66, 118, 0.16);
  padding: 0.5rem;
  display: none;
  gap: 0.4rem;
  z-index: 120;
}

.user-menu:not([hidden]) {
  display: grid;
}

.user-menu[hidden] {
  display: none;
}

.user-menu-label {
  margin: 0;
  padding: 0.5rem 0.56rem;
  border-radius: 0.66rem;
  background: #eff4ff;
  color: #32466f;
  font-size: 0.78rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.menu-btn {
  border: 1px solid rgba(145, 164, 206, 0.45);
  border-radius: 0.66rem;
  background: #fff;
  color: #2a3f67;
  min-height: 2.2rem;
  padding: 0.42rem 0.58rem;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: 0.85rem;
}

.hero-fragment {
  display: contents;
}

.hero-card {
  grid-column: span 12;
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  min-height: 8.2rem;
  box-shadow: var(--shadow-md);
  color: #20304e;
  display: grid;
  align-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.55);
  animation: slide-up 0.66s ease both;
}

.hero-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.hero-card p {
  color: #3c4e73;
}

.hero-card strong {
  font-size: 1.7rem;
  line-height: 1;
}

.hero-card.mint {
  background: linear-gradient(150deg, #c9f7e8, #acefd8);
}

.hero-card.sky {
  background: linear-gradient(150deg, #caebff, #acd8ff);
}

.hero-card.peach {
  background: linear-gradient(150deg, #ffe3d3, #ffcbb7);
}

.hero-card.rose {
  background: linear-gradient(150deg, #ffd9ea, #ffc2dc);
}

.top-spotlight-card {
  grid-column: span 12;
  border-radius: 1.25rem;
  padding: 1rem 1.1rem;
  color: #153155;
  border: 1px solid rgba(255, 255, 255, 0.68);
  box-shadow: var(--shadow-md);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
}

.top-spotlight-card > * {
  min-width: 0;
}

.top-spotlight-card h3 {
  font-size: 1.02rem;
  line-height: 1.3;
  margin: 0.15rem 0;
}

.top-spotlight-card p {
  color: #2f466a;
  font-size: 0.88rem;
}

.top-spotlight-card .ghost-btn {
  background: rgba(255, 255, 255, 0.75);
}

.top-spotlight-card.amber {
  background: linear-gradient(135deg, #ffddb5, #ffd0b0 55%, #ffdfe9);
}

.top-spotlight-card.blue {
  background: linear-gradient(135deg, #cde7ff, #b8f1ea 55%, #e3d6ff);
}

.spotlight-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  font-weight: 800;
  color: #3e5376;
}

.home-feed {
  display: grid;
  gap: 0.85rem;
}

.home-section {
  border-radius: 1.1rem;
  padding: 0.88rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-md);
  min-width: 0;
}


.home-section.compact {
  padding: 0.8rem;
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: 0.58rem;
}

.home-section-head h2 {
  font-size: 1.18rem;
  line-height: 1.24;
}

.home-section-head p {
  margin-top: 0.15rem;
  color: #5b6a86;
  font-size: 0.9rem;
}

.space-chip-row {
  display: flex;
  gap: 0.45rem;
  overflow: auto;
  padding-bottom: 0.2rem;
  margin-bottom: 0.6rem;
  scrollbar-width: thin;
}

.space-chip {
  border: 1px solid rgba(130, 155, 209, 0.42);
  background: #eef5ff;
  color: #2c416a;
  border-radius: 999px;
  padding: 0.4rem 0.76rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  min-height: 2.4rem;
}

.space-chip.is-active {
  background: linear-gradient(135deg, #b7e8ff, #baf4df);
  border-color: rgba(84, 170, 203, 0.7);
  border-width: 2px;
}

.metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.metric-pill {
  border-radius: 999px;
  padding: 0.33rem 0.62rem;
  background: #edf4ff;
  color: #2f456f;
  font-size: 0.79rem;
  font-weight: 700;
}

.metric-pill.warn {
  background: #ffe7ca;
  color: #7c4a14;
}

.metric-pill.good {
  background: #daf5e8;
  color: #1f5f51;
}

.ranked-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(250px, 29vw, 338px);
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  min-width: 0;
  background: transparent;
}

.ranked-grid::-webkit-scrollbar {
  display: none;
}

.ranked-card {
  border-radius: 1.05rem;
  padding: 0.7rem 5.05rem 0.64rem 0.72rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
  min-height: 8.85rem;
  display: grid;
  align-content: start;
  gap: 0.32rem;
  box-shadow: none;
  position: relative;
  min-width: 0;
  scroll-snap-align: start;
  overflow: hidden;
  background: var(--ranked-card-bg, linear-gradient(165deg, #8ad8ff, #93befa 60%, #afd5ff));
}

.ranked-thumb {
  position: absolute;
  top: 0.58rem;
  right: 0.68rem;
  margin-top: 0;
}

.ranked-thumb img,
.home-thumb-fallback {
  width: 64px;
  height: 64px;
  border-radius: 0.95rem;
  border: 2px solid rgba(255, 255, 255, 0.7);
  object-fit: cover;
}

.home-thumb-fallback {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.44);
  font-size: 1.65rem;
}

.ranked-thumb img,
.ranked-thumb .home-thumb-fallback {
  width: 50px;
  height: 50px;
  border-radius: 0.78rem;
  font-size: 1.2rem;
}

.ranked-card h3 {
  font-size: 1.08rem;
  color: rgba(255, 255, 255, 0.92);
  margin-top: 0.08rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
  padding-right: 0.1rem;
}

.ranked-card p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.76rem;
  line-height: 1.28;
  overflow-wrap: anywhere;
  max-height: 2.2em;
  overflow: hidden;
}

.ranked-card .badge {
  background: rgba(255, 255, 255, 0.35);
  color: #fff;
  justify-self: start;
  max-width: calc(100% - 0.1rem);
}

.ranked-view-btn {
  position: absolute;
  right: 0.62rem;
  bottom: 0.58rem;
  min-width: 4.05rem;
}

.ranked-actions {
  position: absolute;
  right: 0.62rem;
  bottom: 0.58rem;
  display: flex;
  gap: 0.35rem;
}

.ranked-actions .ranked-view-btn,
.ranked-actions .ranked-edit-btn {
  position: static;
  min-width: 3.6rem;
}

.home-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(260px, 30vw, 360px);
  gap: 0.65rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}

.media-tile {
  border-radius: 1rem;
  padding: 0.72rem;
  border: 1px solid rgba(144, 166, 216, 0.35);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.97), rgba(243, 247, 255, 0.9));
  display: grid;
  gap: 0.5rem;
  align-content: start;
  scroll-snap-align: start;
  min-width: 0;
  min-height: 16.8rem;
}

.expiry-tile {
  border-radius: 1rem;
  padding: 0.72rem;
  border: 1px solid rgba(144, 166, 216, 0.35);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.97), rgba(243, 247, 255, 0.9));
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-content: start;
  scroll-snap-align: start;
  min-width: 0;
  min-height: 12.2rem;
}

.expiry-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.expiry-emoji {
  font-size: 1.25rem;
}

.expiry-tile h3 {
  font-size: 0.95rem;
  color: #20304e;
  line-height: 1.2;
  margin: 0;
}

.expiry-tile p {
  color: #5b6a86;
  font-size: 0.78rem;
  line-height: 1.28;
  margin: 0;
}

.expiry-tile .media-actions {
  margin-top: auto;
  align-self: flex-end;
  justify-content: flex-end;
  gap: 0.4rem;
}

.media-visual {
  border-radius: 0.9rem;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(219, 236, 255, 0.4), rgba(240, 250, 245, 0.42));
  border: 1px solid rgba(190, 209, 246, 0.34);
}

.media-visual img,
.media-visual .home-thumb-fallback {
  width: 100%;
  height: 108px;
  border-radius: 0.9rem;
}

.media-visual .home-thumb-fallback {
  font-size: 1.45rem;
}

.media-copy h3 {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.media-copy p {
  color: #607092;
  font-size: 0.85rem;
  margin-top: 0.16rem;
  line-height: 1.38;
}

.media-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bundle-grid,
.space-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  min-width: 0;
}

.bundle-tile,
.space-highlight {
  border-radius: 0.95rem;
  border: 1px solid rgba(145, 167, 218, 0.35);
  background: rgba(255, 255, 255, 0.87);
  padding: 0.72rem;
  display: grid;
  gap: 0.42rem;
  min-width: 0;
}

.bundle-tile h3,
.space-highlight h3 {
  font-size: 0.98rem;
  overflow-wrap: anywhere;
}

.bundle-tile p,
.space-highlight p {
  font-size: 0.84rem;
  color: #607092;
}

.view-root {
  display: grid;
  gap: var(--space-3);
}

body.tab-chat-active .view-root {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body.tab-chat-active .view-root > .chat-shell {
  height: 100%;
}

.panel {
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  background: var(--glass-strong);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.85);
  animation: fade-in 0.35s ease both;
  min-width: 0;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

.panel-head h2 {
  font-size: 1.2rem;
  line-height: 1.25;
}

.panel-head p {
  color: var(--ink-soft);
  margin-top: 0.2rem;
  font-size: 0.95rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.stack {
  display: grid;
  gap: var(--space-2);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.chip-btn,
.mini-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.58rem 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
  min-height: 2.2rem;
}

.primary-btn {
  background: linear-gradient(125deg, #7fc8ff, #83f0d2);
  color: #123054;
  box-shadow: 0 8px 20px rgba(57, 149, 241, 0.22);
}

.secondary-btn {
  background: linear-gradient(135deg, #f7dbff, #d3d8ff);
  color: #2f3e66;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-main);
  border: 1px solid rgba(150, 165, 201, 0.4);
}

.chip-btn {
  background: #eff4ff;
  color: #2e3d61;
  border: 1px solid rgba(127, 157, 220, 0.34);
  font-weight: 600;
  padding: 0.42rem 0.8rem;
}

.mini-btn {
  border-radius: var(--radius-sm);
  padding: 0.28rem 0.55rem;
  background: #f4f8ff;
  color: #334467;
  border: 1px solid rgba(130, 145, 178, 0.36);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.chip-btn:hover,
.mini-btn:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none !important;
}

.field-grid {
  display: grid;
  gap: var(--space-2);
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 0.34rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.select-field {
  display: grid;
  gap: 0.42rem;
}

.select-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.select-field-title {
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.field-subtitle {
  color: #6a7997;
  font-size: 0.72rem;
  line-height: 1.25;
  min-height: 1em;
}

.pill-option-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.42rem;
  overflow-x: auto;
  padding-bottom: 0.16rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.pill-option-btn {
  border: 1px solid rgba(136, 163, 217, 0.5);
  border-radius: 999px;
  padding: 0.52rem 0.82rem;
  min-height: 2.45rem;
  background: rgba(255, 255, 255, 0.97);
  color: #2f446b;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: transform 0.12s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.pill-option-btn:hover {
  background: rgba(236, 245, 255, 0.96);
}

.pill-option-btn.is-selected {
  border-color: rgba(69, 145, 197, 0.62);
  background: linear-gradient(135deg, #d7efff, #c8f4e4);
}

.pill-option-btn.is-selected::after {
  content: " \2713";
  font-size: 0.76em;
  font-weight: 800;
}

select.select-native-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  pointer-events: none !important;
}

.add-option-btn {
  min-height: 1.9rem;
  padding: 0.28rem 0.62rem;
  font-size: 0.79rem;
  font-weight: 700;
}

.taxonomy-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.38rem;
  align-items: center;
}

.taxonomy-composer[hidden] {
  display: none !important;
}

.taxonomy-save-btn {
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.2rem 0.4rem;
  font-size: 1rem;
  line-height: 1;
}

.tips-popover {
  position: relative;
}

.tips-popover > summary {
  list-style: none;
  user-select: none;
}

.tips-popover > summary::-webkit-details-marker {
  display: none;
}

.tips-popover-card {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  z-index: 40;
  width: min(360px, 86vw);
  border-radius: 0.78rem;
  border: 1px solid rgba(145, 165, 210, 0.45);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 24px rgba(40, 64, 113, 0.16);
  padding: 0.62rem 0.7rem;
  display: grid;
  gap: 0.42rem;
}

.tips-popover-card p {
  margin: 0;
  color: #4f6081;
  font-size: 0.83rem;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(123, 143, 191, 0.36);
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.74rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-main);
  min-height: 2.55rem;
}

textarea {
  min-height: 5.2rem;
  resize: vertical;
}

.helper-text {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.asset-grid {
  display: grid;
  gap: var(--space-2);
}

.asset-card {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(165, 180, 218, 0.34);
  padding: var(--space-2);
  background: linear-gradient(170deg, rgba(255, 255, 255, 0.95), rgba(246, 249, 255, 0.82));
  display: grid;
  gap: 0.55rem;
  min-width: 0;
}

.asset-title {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  align-items: center;
}

.asset-title h3 {
  font-size: 1.04rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.asset-meta,
.asset-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  background: #eef3ff;
  color: #304068;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.badge.warn {
  background: #ffe7c9;
  color: #7e4b14;
}

.badge.good {
  background: #d8f6ea;
  color: #1d6052;
}

.badge.info {
  background: #dff0ff;
  color: #215285;
}

.badge.soft {
  background: #f6ebff;
  color: #5a3f83;
}

.asset-thumb-strip {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.asset-thumb {
  width: 52px;
  height: 52px;
  border-radius: 0.65rem;
  object-fit: cover;
  border: 1px solid rgba(130, 144, 176, 0.35);
  cursor: pointer;
}

.empty {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(115, 139, 196, 0.45);
  color: var(--ink-soft);
  text-align: center;
  background: rgba(255, 255, 255, 0.68);
}

.editor-layout {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}

.editor-layout > * {
  align-self: start;
}

.editor-layout > aside.stack {
  align-content: start;
  grid-auto-rows: max-content;
}

.editor-layout .field-grid.two,
.editor-layout .field-grid.three {
  grid-template-columns: 1fr;
}

.form-section {
  border: 1px solid rgba(143, 161, 214, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: #f8fbff;
}

.form-section h3 {
  margin-bottom: 0.55rem;
  font-size: 1rem;
}

.image-preview-grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
}

.image-preview {
  border-radius: 0.8rem;
  overflow: hidden;
  border: 1px solid rgba(141, 161, 205, 0.4);
  background: white;
}

.image-preview img {
  width: 100%;
  height: 86px;
  object-fit: cover;
  display: block;
}

.image-preview footer {
  padding: 0.3rem;
  display: flex;
  justify-content: flex-end;
}

.chat-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 0.62rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.93), rgba(243, 249, 255, 0.9));
  min-height: 0;
  height: 100%;
}

.chat-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: space-between;
  align-items: flex-start;
}

.chat-top h2 {
  font-size: 1.12rem;
}

.chat-top p {
  color: #5c6b87;
  margin-top: 0.08rem;
  font-size: 0.84rem;
}

.chat-top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  align-items: center;
}

.chat-action-row {
  display: flex;
  gap: 0.42rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.12rem;
  scrollbar-width: thin;
}

.chat-thread {
  border-radius: 1.1rem;
  border: 1px solid rgba(151, 174, 228, 0.33);
  padding: 0.42rem;
  min-height: 0;
  max-height: none;
  overflow: auto;
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
  scrollbar-gutter: stable;
}

.chat-thread-inner {
  width: 100%;
  margin: 0;
  display: grid;
  gap: 0.62rem;
}

.chat-thread::-webkit-scrollbar,
.home-scroller::-webkit-scrollbar,
.ranked-grid::-webkit-scrollbar,
.space-chip-row::-webkit-scrollbar,
.chat-action-row::-webkit-scrollbar,
.chat-prompt-row.compact::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

.chat-thread::-webkit-scrollbar-thumb,
.home-scroller::-webkit-scrollbar-thumb,
.ranked-grid::-webkit-scrollbar-thumb,
.space-chip-row::-webkit-scrollbar-thumb,
.chat-action-row::-webkit-scrollbar-thumb,
.chat-prompt-row.compact::-webkit-scrollbar-thumb {
  background: rgba(136, 159, 209, 0.5);
  border-radius: 999px;
}

.pill-option-row::-webkit-scrollbar {
  display: none;
}

.chat-welcome {
  border: 1px dashed rgba(130, 155, 209, 0.42);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 1rem;
  display: grid;
  gap: 0.65rem;
}

.chat-welcome h3 {
  font-size: 1.02rem;
}

.chat-welcome p {
  color: #5d6c88;
  line-height: 1.45;
}

.chat-prompt-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.46rem;
}

.chat-prompt-row.suggestion-strip {
  margin-top: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.16rem;
  scrollbar-width: thin;
}

.chat-prompt-row.suggestion-strip .chip-btn {
  white-space: nowrap;
  flex: 0 0 auto;
}

.chat-prompt-row.compact {
  margin-top: 0;
}

.chat-message-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem;
  align-items: start;
  min-width: 0;
}

.chat-message-row.user {
  grid-template-columns: 1fr auto;
}

.chat-message-row.user .chat-avatar {
  order: 3;
  background: linear-gradient(145deg, #d7ecff, #bde6ff);
}

.chat-message-row.user .chat-card {
  order: 2;
  justify-self: stretch;
  background: linear-gradient(145deg, rgba(221, 242, 255, 0.95), rgba(209, 242, 235, 0.95));
  border: 1px solid rgba(118, 183, 209, 0.36);
}

.chat-avatar {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.96rem;
  border: 1px solid rgba(141, 161, 203, 0.34);
  background: linear-gradient(145deg, #f2f5ff, #ffffff);
}

.chat-card {
  border-radius: 1rem;
  border: 1px solid rgba(148, 173, 230, 0.34);
  background: rgba(255, 255, 255, 0.97);
  padding: 0.58rem 0.68rem;
  display: grid;
  gap: 0.34rem;
  min-width: 0;
  width: 100%;
  max-width: none;
  box-shadow: 0 6px 18px rgba(60, 87, 144, 0.08);
}

.chat-message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.chat-message-meta strong {
  font-size: 0.8rem;
}

.chat-message-meta span {
  color: #657594;
  margin-left: 0.34rem;
  font-size: 0.72rem;
}

.chat-message-actions {
  display: flex;
  gap: 0.35rem;
}

.chat-message-actions .mini-btn {
  padding: 0.2rem 0.42rem;
  min-height: 1.8rem;
}

.chat-copy-icon-btn {
  min-width: 1.95rem;
  font-size: 0.9rem;
  line-height: 1;
}

.chat-message-content {
  color: #27385a;
  line-height: 1.42;
  overflow-wrap: anywhere;
  font-size: 0.97rem;
}

.chat-message-content p {
  margin: 0;
}

.chat-message-content p + p {
  margin-top: 0.55rem;
}

.chat-message-content ul,
.chat-message-content ol {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.3rem;
}

.chat-message-content li {
  margin: 0;
}

.chat-message-content code {
  font-family: "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.84em;
  background: #edf3ff;
  border-radius: 0.4rem;
  padding: 0.06rem 0.3rem;
}

.chat-message-content pre {
  margin: 0.1rem 0;
  background: #0f1f3d;
  color: #dbe8ff;
  border-radius: 0.72rem;
  padding: 0.58rem 0.65rem;
  overflow: auto;
}

.chat-message-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.thinking-card {
  border-style: dashed;
}

.typing-indicator {
  display: inline-flex;
  gap: 0.22rem;
  align-items: center;
}

.typing-indicator span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #7e92bd;
  animation: chat-dot 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-compose {
  position: static;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(156, 177, 224, 0.4);
  border-radius: 1rem;
  padding: 0.52rem;
  display: grid;
  gap: 0.34rem;
  box-shadow: 0 10px 24px rgba(44, 69, 124, 0.11);
}

.chat-compose-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: end;
}

.chat-textarea {
  min-height: 2.95rem;
  max-height: 10.5rem;
  resize: none;
  border-radius: 0.86rem;
  padding: 0.58rem 0.72rem;
  line-height: 1.36;
  background: rgba(255, 255, 255, 0.96);
}

.chat-compose-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.chat-send-btn {
  min-width: 5.4rem;
}

.chat-inline-note {
  color: #68779a;
  font-size: 0.74rem;
}

.settings-grid {
  display: grid;
  gap: var(--space-2);
}

.settings-root {
  display: grid;
  gap: var(--space-3);
}

.settings-card {
  border-radius: var(--radius-md);
  border: 1px solid rgba(143, 161, 214, 0.3);
  padding: var(--space-2);
  background: #f9fbff;
  min-width: 0;
}

.collection {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.collection .badge {
  padding-right: 0.35rem;
}

.collection .badge button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font-weight: 700;
  padding: 0;
}

.category-style-list {
  display: grid;
  gap: 0.65rem;
}

.category-style-row {
  border: 1px solid rgba(143, 161, 214, 0.34);
  border-radius: 0.9rem;
  padding: 0.62rem;
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  gap: 0.55rem;
}

.category-style-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.category-style-copy {
  min-width: 0;
}

.category-style-copy strong {
  font-size: 0.9rem;
  color: #253c67;
}

.category-style-preview-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.84rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  min-width: 7.6rem;
  padding: 0.34rem 0.62rem;
}

.category-style-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.52rem;
}

.category-style-controls label {
  margin: 0;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0.85rem + env(safe-area-inset-bottom));
  width: min(980px, calc(100% - 1.1rem - env(safe-area-inset-left) - env(safe-area-inset-right)));
  padding: 0.38rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.3rem;
  align-items: end;
  overflow: visible;
}

.nav-btn {
  border: 0;
  border-radius: 0.95rem;
  padding: 0.52rem 0.3rem;
  background: transparent;
  color: #30416a;
  cursor: pointer;
  display: grid;
  gap: 0.15rem;
  text-align: center;
  font-size: 1rem;
  min-width: 0;
  min-height: 2.75rem;
}

.nav-btn span {
  font-size: 0.74rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.nav-btn.is-active {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(234, 247, 255, 0.96));
  box-shadow: inset 0 0 0 1px rgba(176, 198, 236, 0.48);
}

.nav-btn.nav-add {
  background: transparent;
  padding: 0.14rem 0.3rem 0.2rem;
  min-height: 3.4rem;
  gap: 0.24rem;
}

.nav-add-icon {
  width: 2.65rem;
  height: 2.65rem;
  display: grid;
  place-items: center;
  margin-inline: auto;
  border-radius: 999px;
  background: linear-gradient(135deg, #91daff, #95f4ce);
  color: #1f3a5d;
  box-shadow: var(--shadow-lg);
  font-style: normal;
  font-size: 1.46rem;
  font-weight: 800;
  line-height: 1;
}

.nav-btn.nav-add.is-active {
  background: transparent;
  box-shadow: none;
}

.nav-btn.nav-add.is-active .nav-add-icon {
  background: linear-gradient(135deg, #74cbff, #7eeec0);
  box-shadow: 0 18px 38px rgba(33, 76, 129, 0.28);
  transform: translateY(-1px);
}

.asset-dialog {
  width: min(95vw, 720px);
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-height: min(88vh, 860px);
  overflow: hidden;
}

.asset-dialog::backdrop {
  background: rgba(8, 13, 31, 0.4);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid rgba(129, 154, 206, 0.26);
}

#asset-dialog-content {
  padding: var(--space-3);
  overflow: auto;
  max-height: calc(min(88vh, 860px) - 4.5rem);
}

.toast-stack {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top));
  right: max(0.9rem, calc(env(safe-area-inset-right) + 0.6rem));
  display: grid;
  gap: 0.45rem;
  z-index: 999;
}

.toast {
  background: rgba(28, 43, 78, 0.92);
  color: #fff;
  border-radius: 0.7rem;
  padding: 0.58rem 0.78rem;
  font-size: 0.84rem;
  box-shadow: var(--shadow-md);
  animation: fade-in 0.18s ease both;
  max-width: min(92vw, 360px);
}

code.inline {
  font-family: "Menlo", "Monaco", "Consolas", monospace;
  background: #edf2ff;
  border-radius: 0.42rem;
  padding: 0.1rem 0.35rem;
}

@media (min-width: 760px) {
  .hero-card {
    grid-column: span 6;
  }

  .top-spotlight-card {
    grid-column: span 6;
  }

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

@media (min-width: 1180px) {
  .bundle-grid,
  .space-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .hero-card {
    grid-column: span 3;
  }

  .top-header {
    align-items: center;
  }
}

@media (max-width: 1024px) {
  .field-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .home-scroller {
    grid-auto-columns: minmax(230px, 68vw);
  }
}

@media (max-width: 759px) {
  .field-grid.two {
    grid-template-columns: 1fr;
  }

  .field-grid.three {
    grid-template-columns: 1fr;
  }

  .top-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .header-meta {
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .network-indicator {
    padding-inline: 0.48rem;
  }

  .kebab-btn {
    min-width: 2.05rem;
    height: 2.05rem;
  }

  .top-spotlight-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .home-section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .bundle-grid,
  .space-grid {
    grid-template-columns: 1fr;
  }

  .home-scroller {
    grid-auto-columns: 85%;
  }

  .ranked-grid {
    grid-auto-columns: 82%;
  }

  .chat-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-compose-shell {
    grid-template-columns: 1fr;
  }

  .chat-compose-actions {
    justify-content: space-between;
  }

  .toast-stack {
    left: 0.85rem;
    right: 0.85rem;
  }

  .toast {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding: max(0.66rem, env(safe-area-inset-top))
      max(0.72rem, env(safe-area-inset-right))
      calc(7.3rem + env(safe-area-inset-bottom))
      max(0.72rem, env(safe-area-inset-left));
  }

  .top-header {
    padding: 0.55rem 0.62rem;
  }

  .top-header h1 {
    font-size: clamp(1.06rem, 6.2vw, 1.34rem);
  }

  .subtitle {
    margin-top: 0.08rem;
    font-size: 0.78rem;
    line-height: 1.28;
  }

  .bottom-nav {
    width: calc(100% - 0.7rem - env(safe-area-inset-left) - env(safe-area-inset-right));
    gap: 0.22rem;
    padding: 0.3rem;
  }

  .nav-btn {
    padding: 0.46rem 0.2rem;
  }

  .nav-btn span {
    font-size: 0.66rem;
  }

  .home-scroller {
    grid-auto-columns: 92%;
  }

  .ranked-grid {
    grid-auto-columns: 90%;
  }

  .chat-thread {
    min-height: 0;
    max-height: none;
    padding: 0.62rem;
  }

  .chat-message-row,
  .chat-message-row.user {
    grid-template-columns: auto 1fr;
  }

  .chat-message-row.user .chat-avatar,
  .chat-message-row.user .chat-card {
    order: 0;
  }

  .chat-avatar {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 0.95rem;
  }

  .chat-card {
    padding: 0.58rem 0.62rem;
  }

  .chat-top-meta {
    width: 100%;
  }

  .chat-send-btn {
    min-width: 5.3rem;
  }
}

@media (max-width: 640px) {
  .category-style-controls {
    grid-template-columns: 1fr;
  }

  .category-style-preview-pill {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 390px) {
  .nav-btn span {
    display: none;
  }

  .nav-btn {
    min-height: 2.55rem;
    padding-block: 0.45rem;
    font-size: 1.05rem;
  }

  .nav-btn.nav-add {
    min-height: 2.95rem;
    padding-block: 0.2rem;
  }

  .nav-add-icon {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.24rem;
  }

  .network-indicator {
    padding-inline: 0.36rem;
  }

  .network-indicator .status-label {
    display: none;
  }

  .kebab-btn {
    min-width: 1.95rem;
    height: 1.95rem;
    font-size: 1.1rem;
  }
}

@media (hover: hover) and (pointer: fine) {
  .home-section:hover,
  .asset-card:hover,
  .settings-card:hover,
  .top-spotlight-card:hover,
  .media-tile:hover,
  .space-highlight:hover,
  .bundle-tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(37, 63, 112, 0.16);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
  }
}

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

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chat-dot {
  0%,
  80%,
  100% {
    transform: scale(0.78);
    opacity: 0.6;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}
