/* The signed-in shell and the app pages. */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: 0 var(--s-6);
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.topbar__switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-1);
  transition: background-color var(--dur-1) var(--ease-out);
}
button.topbar__switch:hover { background: var(--surface-hover); }
.topbar__home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-1);
  color: var(--text-tertiary);
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.topbar__home:hover { background: var(--surface-hover); color: var(--text); }
.topbar__nav-toggle { display: none; }
.topbar__links {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.shell__body { flex: 1; display: flex; align-items: stretch; min-height: 0; }

.nav {
  width: var(--nav-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  padding: var(--s-6) var(--s-5);
  position: sticky;
  top: var(--topbar-h);
  align-self: flex-start;
  height: calc(100vh - var(--topbar-h));
  overflow: auto;
}
.nav__group + .nav__group { margin-top: var(--s-8); }
.nav__title {
  font: var(--t-micro);
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 var(--s-5) var(--s-4);
}
.nav__item {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 var(--s-5);
  border-radius: var(--r-1);
  color: var(--text-muted);
  font: var(--t-label);
  position: relative;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.nav__item:hover { background: var(--surface-hover); color: var(--text); }
.nav__item .icon {
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
  line-height: 0;
  transition: color var(--dur-1) var(--ease-out);
}
.nav__item .icon svg {
  display: block;
  width: 16px;
  height: 16px;
}
.nav__item:hover .icon { color: var(--text-muted); }
.nav__item.is-active { color: var(--text); }
.nav__item.is-active .icon { color: var(--accent); }
.nav__item.is-active::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--s-5));
  top: var(--s-3);
  bottom: var(--s-3);
  width: 2px;
  background: var(--accent);
  border-radius: var(--r-pill);
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--s-8) var(--s-8) var(--s-10);
  overflow-x: auto;
}
.main__inner { max-width: var(--w-app); margin: 0 auto; min-width: 0; }

/* Page header */

.pagehead {
  display: flex;
  align-items: flex-end;
  gap: var(--s-6);
  padding-bottom: var(--s-6);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--s-7);
  flex-wrap: wrap;
}
.pagehead__text { flex: 1; min-width: 220px; }
.pagehead h1 { font: var(--t-title); }
.pagehead__meta { font: var(--t-micro); color: var(--text-tertiary); margin-top: var(--s-3); }
.pagehead__actions { display: flex; align-items: center; gap: var(--s-4); }

/* Panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--s-7);
}
.panel__head { display: flex; align-items: baseline; gap: var(--s-5); margin-bottom: var(--s-6); }
.panel__head h2 { font: var(--t-subtitle); }
.panel__head p { font: var(--t-micro); color: var(--text-tertiary); }
.panel + .panel { margin-top: var(--s-7); }

.filterbar {
  display: flex;
  align-items: flex-end;
  gap: var(--s-5);
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  padding: var(--s-5);
  margin-bottom: var(--s-6);
}
.filterbar .field { min-width: 148px; }
.filterbar .field--grow { flex: 1; min-width: 200px; }

/* Blotter */

.blotter__shortcuts { display: flex; gap: var(--s-4); }
.unread-line {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-6);
  border: 1px solid var(--hairline);
  border-left: 2px solid var(--accent-line);
  border-radius: var(--r-1);
  background: var(--surface);
  font: var(--t-body-s);
  color: var(--text-muted);
  margin-bottom: var(--s-7);
}

/* Compose */

.compose {
  display: grid;
  grid-template-columns: 480px minmax(0, 1fr);
  gap: var(--s-8);
  align-items: start;
}
.compose__form { display: flex; flex-direction: column; gap: var(--s-6); }
.compose__group { display: flex; flex-direction: column; gap: var(--s-6); }
.compose__send {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding-top: var(--s-6);
  border-top: 1px solid var(--hairline);
}
.compose__preview { position: sticky; top: calc(var(--topbar-h) + var(--s-8)); min-width: 0; }

.factory {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(520px, 1.15fr);
  gap: var(--s-7);
  align-items: start;
}
.factory__preview {
  position: sticky;
  top: calc(var(--topbar-h) + var(--s-8));
  min-width: 0;
}
.factory__preview .preview { min-height: 640px; }
.factory__actions { display: flex; gap: var(--s-4); margin-top: var(--s-5); }
.settings { max-width: 640px; min-width: 0; }
.formgrid { min-width: 0; }

@media (max-width: 1100px) {
  .factory { grid-template-columns: minmax(0, 1fr); }
  .factory__preview { position: static; }
}

/* Template tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-6);
}
.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  padding: var(--s-7);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  text-align: left;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.tile:hover { border-color: var(--hairline-strong); background: var(--surface-hover); }
.tile__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); }
.tile__star {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  border-radius: var(--r-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tile__star .icon,
.tile__star .icon svg {
  width: 22px;
  height: 22px;
}
.tile__star:hover { color: var(--text); background: var(--surface-hover); }
.tile__star.is-on { color: #e8c547; }
.tile--fav { outline: 1px solid var(--hairline-strong); }
.tiles__label {
  grid-column: 1 / -1;
  font: var(--t-micro);
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: var(--s-4) 0 0;
}
.tile__kinds { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.tile__note { font: var(--t-micro); color: var(--text-tertiary); }

.kindlist { display: flex; flex-direction: column; gap: var(--s-5); }
.kindcard {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-6);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface);
}
.kindcard__top { display: flex; align-items: center; gap: var(--s-5); }
.kindcard__top h3 { font: var(--t-subtitle); flex: 1; }
.kindcard p { font: var(--t-body-s); color: var(--text-muted); max-width: var(--w-prose); }
.kindcard__fields { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* Settings */

.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s-6); }
.formgrid--one { grid-template-columns: minmax(0, 420px); }

/* Company links in Defaults */

.linklist { display: flex; flex-direction: column; }
.linkrow {
  display: grid;
  grid-template-columns: minmax(0, 190px) minmax(0, 1fr);
  align-items: start;
  gap: var(--s-5) var(--s-6);
  padding: var(--s-6) 0;
  border-top: 1px solid var(--hairline);
}
.linkrow:first-child { border-top: 0; padding-top: 0; }
.linkrow__who { display: flex; align-items: center; gap: var(--s-3); padding-top: 2px; }
.linkrow__send {
  font: var(--t-micro);
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  border: 1px solid var(--hairline);
  border-radius: var(--r-1);
  padding: 1px var(--s-2);
}
.linkrow .field { min-width: 0; }
@media (max-width: 620px) {
  .linkrow { grid-template-columns: minmax(0, 1fr); }
}

/* Module switchboard */

.modulelist { display: flex; flex-direction: column; gap: var(--s-5); }
.modulerow {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-6) var(--s-7);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface);
  text-align: left;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.modulerow:hover { border-color: var(--hairline-strong); background: var(--surface-hover); }
.modulerow h2 { font: var(--t-subtitle); }
.modulerow p { font: var(--t-micro); color: var(--text-tertiary); margin-top: var(--s-2); }

/* News */

.newslist { display: flex; flex-direction: column; }
.newsitem {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: var(--s-5);
  padding: var(--s-7) 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  width: 100%;
}
.newsitem:last-child { border-bottom: 0; }
.newsitem__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 9px; }
.newsitem__dot.is-read { background: transparent; }
.newsitem__meta { display: flex; align-items: center; gap: var(--s-5); margin-bottom: var(--s-3); }
.newsitem__kind { font: var(--t-micro); color: var(--text-tertiary); letter-spacing: 0.06em; text-transform: uppercase; }
.newsitem__scope { font: var(--t-micro); color: var(--text-faint); padding: 1px var(--s-3); border: 1px solid var(--hairline); border-radius: var(--r-pill); }
.newsitem__date { font: var(--t-micro); color: var(--text-faint); }
.newsitem h2 { font: var(--t-subtitle); margin-bottom: var(--s-4); }
.newsitem p { font: var(--t-body); color: var(--text-muted); max-width: var(--w-prose); }

/* Tickets */

.thread__head { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.thread { display: flex; flex-direction: column; gap: var(--s-5); max-height: 46vh; overflow-y: auto; padding-right: var(--s-2); }
.post {
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--canvas-sunk);
  padding: var(--s-5) var(--s-6);
  max-width: 84%;
}
.post--mine { align-self: flex-end; background: var(--accent-sunk); border-color: var(--accent-line); }
.post__meta { display: flex; align-items: center; gap: var(--s-4); margin-bottom: var(--s-3); }
.post__who { font: var(--t-micro); color: var(--text-tertiary); }
.post__when { font: var(--t-micro); color: var(--text-faint); }
.post__body { font: var(--t-body-s); color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.thread__box { display: flex; align-items: flex-end; gap: var(--s-4); }
.thread__box .textarea { flex: 1; }

/* 403 / 404 inside the shell */

.pagemsg { padding: var(--s-13) 0; }

@media (max-width: 1320px) {
  .compose { grid-template-columns: 420px minmax(0, 1fr); }
}

/* Below this the preview cannot hold a 600px letter beside the form, so it stacks. */
@media (max-width: 1100px) {
  .compose { grid-template-columns: minmax(0, 1fr); }
  .compose__preview { position: static; }
}

@media (max-width: 900px) {
  .topbar__nav-toggle { display: inline-flex; }
  .topbar__links { display: none; }
  .topbar { gap: var(--s-3); }
  .nav {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    height: auto;
    z-index: var(--z-drawer);
    box-shadow: var(--shadow-pop);
    transform: translateX(-100%);
    transition: transform var(--dur-3) var(--ease-out);
  }
  .nav.is-open { transform: none; }
  .main { padding: var(--s-7) var(--s-6) var(--s-12); }
  .compose { grid-template-columns: minmax(0, 1fr); }
  .compose__preview { position: static; }
}

/* Marketplace */

.chiprow { margin: var(--s-5) 0 var(--s-6); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.chip {
  padding: 5px var(--s-5);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--surface);
  font: var(--t-micro);
  color: var(--text-secondary);
  transition: border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.chip:hover { border-color: var(--hairline-strong); color: var(--text); }
.chip--on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-sunk); }

.listinggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: var(--s-6); }
.listinggrid__empty { grid-column: 1 / -1; }
.listing {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  background: var(--surface);
  overflow: hidden;
}
.listing--off { opacity: 0.55; }
.listing__open { display: flex; flex-direction: column; text-align: left; flex: 1; position: relative; }
.listing__cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface-hover);
}
.listing__cover--blank {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font: var(--t-micro);
}
.listing__hero { width: 100%; border-radius: var(--r-2); max-height: 280px; object-fit: cover; }
.listing__preview .listing__cover { border-radius: var(--r-2); }
.listing__body { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-5) var(--s-6) var(--s-4); flex: 1; }
.listing__tags { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.listing__body h2 { font: var(--t-subtitle); overflow-wrap: anywhere; }
.listing__seller { font: var(--t-micro); color: var(--text-tertiary); }
.listing__desc {
  font: var(--t-micro);
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.listing__full { white-space: pre-wrap; font: var(--t-body-s); }
.listing__buy {
  font: var(--t-body-s);
  color: var(--text-secondary);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  background: var(--surface-raised);
}
.listing__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding: var(--s-4) var(--s-6) var(--s-5);
  border-top: 1px solid var(--hairline);
}
.listing__price { font: var(--t-subtitle); color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.listing__stock { font: var(--t-micro); color: var(--text-tertiary); margin-left: auto; }
.listing__owner { position: absolute; top: var(--s-3); right: var(--s-3); }
.order {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
}
.order--done { opacity: 0.6; }
.order__head { font: var(--t-subtitle); }
.order__meta { font: var(--t-micro); color: var(--text-tertiary); }
.order__note { white-space: pre-wrap; font: var(--t-body-s); }
.coverfield { display: block; }
.swatches { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-bottom: var(--s-4); }
.swatch {
  width: 34px;
  height: 26px;
  border-radius: var(--r-2);
  border: 1px solid var(--hairline);
  background-size: cover;
  background-position: center;
}
.swatch--on { outline: 2px solid var(--accent); outline-offset: 2px; }


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

.swatch--purple { background-image: url('/assets/listings/purple.png'); }
.swatch--blue { background-image: url('/assets/listings/blue.png'); }
.swatch--teal { background-image: url('/assets/listings/teal.png'); }
.swatch--green { background-image: url('/assets/listings/green.png'); }
.swatch--amber { background-image: url('/assets/listings/amber.png'); }
.swatch--orange { background-image: url('/assets/listings/orange.png'); }
.swatch--red { background-image: url('/assets/listings/red.png'); }
.swatch--pink { background-image: url('/assets/listings/pink.png'); }
.swatch--slate { background-image: url('/assets/listings/slate.png'); }
