.app-header {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.language-switcher {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.language-switcher a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 30px;
  padding: 0 8px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 950;
}

.primary-nav .nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary-nav .mobile-lang-link {
  display: none;
}

.language-switcher a.is-active,
.language-switcher a:hover,
.language-switcher a:focus-visible {
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

.mobile-filter-open,
.mobile-bottom-nav,
.mobile-sheet-close,
.mobile-chat-back {
  display: none;
}

.quota-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 920px;
  margin: 0 0 16px;
  padding: 14px;
  background: #eef4ff;
  border: 1px solid #cadcff;
  border-radius: var(--radius);
}

.quota-panel strong,
.quota-panel span {
  display: block;
}

.quota-panel strong {
  color: var(--ink);
  font-size: 17px;
}

.quota-panel span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.quota-panel.is-locked {
  background: #fff7ed;
  border-color: #fed7aa;
}

.quota-panel.is-active {
  background: #e8f7f1;
  border-color: #c7ebdc;
}

.my-posts-section {
  display: grid;
  gap: 14px;
  max-width: 920px;
  margin: 0 0 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.my-posts-section .view-heading {
  margin-bottom: 0;
}

.my-posts-section h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.12;
}

.my-listing-card.is-removed {
  opacity: 0.78;
}

.my-listing-card .removed-pill,
.my-listing-card .distance-pill {
  position: absolute;
  top: 10px;
  right: 10px;
}

.removed-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  color: #8f1234;
  background: #fff1f4;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 900;
}

.my-post-actions {
  justify-content: flex-end;
  min-width: 0;
}

.my-post-actions .button {
  flex: 0 1 auto;
  min-height: 34px;
  padding: 0 10px;
}

.app-shell {
  grid-template-columns: 270px minmax(0, 1fr) 310px;
  gap: 14px;
}

.filter-panel,
.workspace,
.detail-panel {
  box-shadow: 0 10px 28px rgba(19, 30, 52, 0.07);
}

.detail-panel {
  padding: 14px;
}

.workspace .listing-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

.workspace .listing-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 374px;
}

.workspace .listing-card-image {
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.listing-card-image img,
.detail-panel img.detail-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
}

.workspace .listing-card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workspace .listing-card h2 {
  -webkit-line-clamp: 1;
}

.workspace .listing-card .meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace .listing-card .profile-facts {
  max-height: 58px;
  overflow: hidden;
}

.workspace .listing-card .price {
  font-size: 17px;
  line-height: 1.15;
}

.workspace .listing-card-footer {
  margin-top: auto;
}

.detail-panel img.detail-image {
  aspect-ratio: 4 / 3;
  max-height: none;
}

.detail-copy {
  display: grid;
  gap: 10px;
}

.detail-title {
  display: -webkit-box;
  margin-bottom: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 22px;
}

.detail-copy .price {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.detail-description,
.seller-box .seller-line {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.detail-description {
  -webkit-line-clamp: 3;
}

.seller-box .seller-line {
  -webkit-line-clamp: 2;
}

.detail-copy.is-expanded .detail-description,
.detail-copy.is-expanded .seller-box .seller-line {
  display: block;
  overflow: visible;
}

.detail-read-more {
  justify-self: start;
  min-height: 28px;
  padding: 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-size: 13px;
  font-weight: 950;
}

.seller-box {
  align-items: start;
}

.listing-actions .button {
  min-height: 36px;
}

.quota-panel [data-unlock-posts] {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 10px 18px rgba(8, 102, 255, 0.18);
}

.image-guidance {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 750;
}

.editor-form.is-editing {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.field-note {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 750;
}

.location-choice select {
  background-color: #fff;
}

.location-warning {
  padding: 7px 9px;
  color: #8f5d0b;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 850;
}

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

.profile-facts span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 25px;
  padding: 0 8px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
}

.profile-facts strong {
  margin-inline-end: 4px;
  color: var(--muted);
  font-weight: 950;
}

.workspace .listing-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 12px;
}

.workspace .listing-card {
  grid-template-rows: 132px auto;
}

.workspace .listing-card-body {
  gap: 7px;
  padding: 10px;
}

.workspace .listing-card h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 16px;
  line-height: 1.15;
}

.workspace .listing-card .meta,
.workspace .listing-card .seller-line {
  font-size: 12.5px;
  line-height: 1.25;
}

.workspace .listing-card-footer {
  gap: 8px;
}

.seller-mini {
  display: inline-grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  max-width: 100%;
  gap: 7px;
}

.seller-mini > span {
  min-width: 0;
}

.seller-mini strong,
.seller-mini span span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seller-mini strong {
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.1;
}

.mini-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--blue-ink);
  background: #eaf2ff;
  border-radius: 8px;
  object-fit: cover;
  font-size: 12px;
  font-weight: 950;
}

.workspace .listing-card-footer .button,
.workspace .my-post-actions .button {
  min-height: 31px;
  padding: 0 9px;
  font-size: 13px;
}

.workspace .category-pill,
.workspace .distance-pill,
.workspace .saved-pill,
.workspace .removed-pill {
  min-height: 22px;
  padding: 0 7px;
  font-size: 11px;
}

/* Marketplace visual refinement: fixed 4:3 media, stable cards, short summaries. */
.workspace .listing-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

.workspace .listing-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 374px;
}

.workspace .listing-card-image {
  aspect-ratio: 4 / 3;
  min-height: 0;
}

.workspace .listing-card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.workspace .listing-card h2 {
  -webkit-line-clamp: 1;
}

.workspace .listing-card .meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace .listing-card-footer {
  margin-top: auto;
}

[dir="rtl"] body {
  font-family: Tahoma, Arial, ui-sans-serif, system-ui, sans-serif;
}

[dir="rtl"] .thread-row {
  text-align: right;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .app-header {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }

  .detail-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .language-switcher {
    order: 4;
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .language-switcher a {
    flex: 1;
  }

  .quota-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .my-post-actions {
    justify-content: stretch;
  }

  .my-post-actions .button {
    flex: 1 1 120px;
  }

  .workspace .listing-grid {
    grid-template-columns: 1fr;
  }

  .workspace .listing-card {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }

  .workspace .listing-card-image {
    aspect-ratio: 4 / 3;
  }

  .workspace .listing-card-body {
    gap: 9px;
    padding: 12px;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  body.filter-sheet-open,
  body.detail-sheet-open {
    overflow: hidden;
  }

  body.filter-sheet-open::before,
  body.detail-sheet-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(17, 19, 24, 0.44);
  }

  .app-header {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    min-height: 62px;
    padding: 8px 10px;
    gap: 6px;
  }

  .brand {
    gap: 7px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand span {
    max-width: 90px;
    font-size: 14px;
  }

  .menu-button {
    width: 38px;
    height: 38px;
    padding: 8px;
  }

  .language-switcher {
    display: none;
  }

  .auth-bar {
    display: none;
  }

  .primary-nav {
    inset: 62px 8px auto;
    z-index: 65;
  }

  .primary-nav .mobile-lang-link {
    display: inline-flex;
  }

  .app-shell {
    display: block;
    width: 100%;
    min-height: auto;
    margin: 0;
  }

  .workspace {
    padding: 10px 10px 14px;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .view-heading {
    gap: 10px;
    margin-bottom: 10px;
  }

  .view-heading h1 {
    font-size: 22px;
    line-height: 1.1;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    width: 100%;
    gap: 7px;
  }

  .toolbar .mobile-filter-open {
    display: inline-flex;
  }

  .toolbar select,
  .toolbar .button {
    width: 100%;
    min-width: 0;
    min-height: 36px;
    padding: 0 8px;
    font-size: 13px;
  }

  .toolbar [data-refresh-feed],
  .toolbar [data-action="start-post"] {
    display: none;
  }

  .filter-panel {
    position: fixed;
    inset: auto 0 0;
    z-index: 70;
    max-height: min(86svh, 680px);
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
    overflow: auto;
    visibility: hidden;
    background: var(--panel);
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 42px rgba(17, 19, 24, 0.22);
    transform: translateY(calc(100% + 24px));
    transition: transform 180ms ease, visibility 180ms ease;
  }

  .filter-panel.is-open {
    visibility: visible;
    transform: translateY(0);
  }

  .mobile-sheet-close {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    z-index: 2;
    display: grid;
    width: 38px;
    height: 38px;
  }

  .filter-panel .panel-heading {
    padding-inline-end: 46px;
  }

  .filter-form {
    gap: 12px;
  }

  .filter-form .button-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .filter-form .button-row .button {
    min-width: 0;
    padding: 0 6px;
    font-size: 12.5px;
  }

  .workspace .listing-grid {
    gap: 9px;
  }

  .workspace .listing-card {
    grid-template-columns: 116px minmax(0, 1fr);
    grid-template-rows: minmax(126px, auto);
    min-height: 126px;
  }

  .workspace .listing-card-image {
    aspect-ratio: auto;
    min-height: 126px;
  }

  .listing-card-image img {
    object-position: center 35%;
  }

  .workspace .listing-card-body {
    min-width: 0;
    gap: 6px;
    padding: 9px;
  }

  .workspace .listing-card h2 {
    font-size: 15px;
  }

  .workspace .listing-card .meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace .listing-card .profile-facts span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace .listing-card-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 7px;
  }

  .workspace .listing-card-footer .button {
    min-width: 50px;
    min-height: 30px;
    padding: 0 8px;
    font-size: 12.5px;
  }

  .seller-mini {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 6px;
  }

  .mini-avatar {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 11px;
  }

  .detail-panel {
    position: fixed;
    inset: auto 0 0;
    z-index: 75;
    max-height: min(90svh, 760px);
    padding: 44px 12px calc(16px + env(safe-area-inset-bottom));
    overflow: auto;
    visibility: hidden;
    background: var(--panel);
    border: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -18px 42px rgba(17, 19, 24, 0.24);
    transform: translateY(calc(100% + 24px));
    transition: transform 180ms ease, visibility 180ms ease;
  }

  .detail-panel.is-open {
    visibility: visible;
    transform: translateY(0);
  }

  .detail-panel:not(.is-open) {
    pointer-events: none;
  }

  .detail-panel .empty-state {
    display: none;
  }

  .detail-panel .detail-stack {
    grid-template-columns: 1fr;
  }

  .detail-panel img.detail-image {
    max-height: 260px;
    aspect-ratio: 4 / 3;
  }

  .detail-title {
    font-size: 22px;
  }

  .detail-sheet-close {
    top: 8px;
  }

  .mobile-bottom-nav {
    position: fixed;
    right: auto;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: flex;
    width: 100vw;
    gap: 0;
    min-height: calc(62px + env(safe-area-inset-bottom));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(19, 30, 52, 0.08);
    backdrop-filter: blur(16px);
    transition: transform 160ms ease;
  }

  body.filter-sheet-open .mobile-bottom-nav,
  body.detail-sheet-open .mobile-bottom-nav {
    transform: translateY(100%);
  }

  .mobile-bottom-nav button {
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    padding: 0 4px;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    font-size: 11.5px;
    font-weight: 950;
  }

  .mobile-bottom-nav button.is-active {
    color: var(--ink);
    background: #eef4ff;
  }

  .chat-layout {
    min-height: calc(100svh - 210px);
  }

  .thread-list.is-hidden-mobile {
    display: none;
  }

  .chat-room.is-active-mobile {
    min-height: calc(100svh - 190px);
  }

  .chat-room.is-active-mobile .chat-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 6px 9px;
  }

  .chat-room.is-active-mobile .chat-header .meta {
    grid-column: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-chat-back {
    display: inline-flex;
    min-height: 32px;
    padding: 0 9px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .brand span {
    max-width: 72px;
  }

  .workspace .listing-card {
    grid-template-columns: 104px minmax(0, 1fr);
  }
}
