:root {
  color-scheme: light;
  --ink: #121617;
  --muted: #65706b;
  --panel: #ffffff;
  --surface: #f7faf8;
  --line: #e3e9e5;
  --sidebar: #121716;
  --sidebar-text: #dce6e1;
  --green: #2ecc71;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "system-ui", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

body.modal-open {
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 22px;
  background: var(--sidebar);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 52px;
}

.brand img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand p {
  margin: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  font-weight: 850;
}

.shop-nav {
  display: grid;
  gap: 28px;
  margin-top: 18px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  align-items: center;
  gap: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}

.nav-item span,
.nav-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.nav-item strong {
  font-weight: 700;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  border-color: var(--green);
  background: var(--green);
  color: var(--ink);
  box-shadow: 0 0 0 1px #101010, 0 0 0 2px #fff;
}

.credit-link {
  display: grid;
  place-items: center;
  min-height: 58px;
  margin-top: auto;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 850;
}

.credit-link:hover {
  border-color: rgba(46, 204, 113, 0.75);
}

.main-content {
  min-height: 100svh;
  padding: 34px 64px;
}

.back-link {
  display: inline-block;
  padding: 10px 0;
  margin: 0 0 24px;
  color: var(--muted);
  text-decoration: none;
  font-size: 16px;
  font-weight: 800;
}

.back-link:hover {
  color: var(--ink);
}

.shop-panel {
  max-width: 1080px;
  min-height: calc(100svh - 130px);
  display: grid;
  align-content: center;
}

.shop-copy {
  width: 100%;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 5vw, 58px);
  line-height: 1;
  font-weight: 700;
}

.shop-copy > p {
  margin: 16px 0 0;
  color: #48534e;
  font-size: 18px;
  line-height: 1.5;
}

.marketplace {
  width: min(780px, 100%);
  margin: 32px auto 0;
  text-align: center;
}

.marketplace-heading {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0;
  color: #159652;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 850;
}

.marketplace h2 {
  margin: 14px 0 10px;
  color: #6b756f;
  font-size: clamp(34px, 4vw, 44px);
  line-height: 1;
  font-weight: 700;
}

.product-grid {
  display: grid;
  gap: 20px;
}

.product-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(230px, 0.6fr);
  gap: 26px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(18, 22, 23, 0.08);
  text-align: left;
}

.product-media {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.image-tile {
  min-width: 0;
}

.image-view-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: zoom-in;
}

.image-view-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-view-button::after {
  content: "View";
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(18, 22, 23, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.image-view-button:hover::after,
.image-view-button:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.image-view-button:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}

.image-tile span {
  display: block;
  margin-top: 8px;
  color: #6b756f;
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}

.image-viewer[hidden] {
  display: none;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 34px;
  background: rgba(8, 12, 11, 0.82);
}

.viewer-frame {
  width: min(920px, 100%);
  max-height: calc(100svh - 68px);
  display: grid;
  gap: 14px;
  margin: 0;
}

.viewer-frame img {
  display: block;
  width: 100%;
  max-height: calc(100svh - 138px);
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
}

.viewer-frame figcaption {
  color: #fff;
  text-align: center;
  font-size: 16px;
  font-weight: 850;
}

.viewer-close {
  position: fixed;
  top: 20px;
  right: 20px;
  min-width: 76px;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 850;
}

.viewer-close:hover,
.viewer-close:focus-visible {
  background: var(--green);
  color: var(--ink);
  outline: none;
}

.ai-panel[hidden] {
  display: none;
}

.ai-panel {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  place-items: end;
  padding: 28px;
  background: rgba(8, 12, 11, 0.38);
}

.ai-window {
  width: min(430px, calc(100vw - 56px));
  max-height: min(680px, calc(100svh - 56px));
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
  overflow: hidden;
  border: 1px solid rgba(46, 204, 113, 0.36);
  border-radius: 8px;
  background: #111716;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.36);
}

.ai-header {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-header img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: #fff;
}

.ai-header p,
.ai-header h2 {
  margin: 0;
}

.ai-header p {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.ai-header h2 {
  color: #fff;
  font-size: 22px;
  line-height: 1.1;
}

.ai-close {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.ai-close:hover,
.ai-close:focus-visible {
  background: var(--green);
  color: var(--ink);
  outline: none;
}

.ai-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
}

.ai-message {
  width: fit-content;
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ecf4f0;
  font-size: 14px;
  line-height: 1.42;
}

.ai-message.agent {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.ai-message.user {
  justify-self: end;
  background: var(--green);
  color: var(--ink);
  font-weight: 750;
}

.ai-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 14px;
}

.ai-actions button {
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
}

.ai-actions button:hover,
.ai-actions button:focus-visible {
  border-color: var(--green);
  background: rgba(46, 204, 113, 0.2);
  outline: none;
}

.ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-form input {
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
}

.ai-form input:focus {
  border-color: var(--green);
  outline: none;
}

.ai-form button {
  min-height: 42px;
  padding: 10px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: var(--ink);
  cursor: pointer;
  font-weight: 850;
}

.product-info {
  display: grid;
  align-content: center;
  gap: 12px;
}

.product-info h3 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.05;
  font-weight: 800;
}

.price {
  margin: 0;
  color: #159652;
  font-size: 34px;
  line-height: 1;
  font-weight: 850;
}

.product-info p:last-child,
.empty-state p {
  margin: 0;
  color: #3f4945;
  font-size: 16px;
  line-height: 1.5;
}

.empty-state {
  padding: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 50px rgba(18, 22, 23, 0.08);
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 10px;
  color: #6b756f;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1;
}

.ai-button {
  position: fixed;
  right: 22px;
  bottom: 20px;
  width: 94px;
  height: 94px;
  padding: 0;
  border: 2px solid var(--green);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(46, 204, 113, 0.2);
  cursor: pointer;
}

.ai-button img {
  width: 100%;
  height: 100%;
  padding: 5px;
  object-fit: contain;
}

.ai-button span {
  position: absolute;
  right: -7px;
  bottom: -7px;
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 28px;
  padding: 0 9px;
  border: 2px solid var(--green);
  border-radius: 999px;
  background: var(--green);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
    padding: 22px;
  }

  .shop-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 8px;
  }

  .nav-item {
    min-height: 58px;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 4px;
    text-align: center;
  }

  .credit-link {
    margin-top: 0;
  }

  .main-content {
    min-height: auto;
    padding: 30px 22px 118px;
  }

  .shop-panel {
    min-height: auto;
    align-content: start;
    padding: 44px 0 0;
  }

  .marketplace {
    width: 100%;
  }

  .product-card {
    grid-template-columns: 1fr;
  }

  .store-card,
  .empty-state {
    padding: 34px 22px;
  }

  .ai-button {
    width: 80px;
    height: 80px;
    right: 16px;
    bottom: 16px;
  }

  .ai-panel {
    align-items: end;
    padding: 14px;
  }

  .ai-window {
    width: 100%;
    max-height: calc(100svh - 28px);
  }
}

@media (max-width: 500px) {
  .brand p {
    font-size: 22px;
  }

  h1 {
    font-size: 40px;
  }

  .shop-nav {
    grid-template-columns: 1fr;
  }

  .nav-item {
    min-height: 44px;
    grid-template-columns: 31px minmax(0, 1fr);
    text-align: left;
  }

  .marketplace h2,
  .empty-state h3 {
    font-size: 32px;
  }

  .product-media {
    grid-template-columns: 1fr;
  }

  .product-media.three-up {
    grid-template-columns: 1fr;
  }

  .product-info h3 {
    font-size: 24px;
  }
}
