:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #1f2937;
  --primary-soft: #f3f4f6;
  --container: 1200px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --app-height: 100vh;
  --header-offset: 72px;
  --viewport-bottom-offset: 0px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: var(--app-height);
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

.page-inner {
  width: min(100% - 32px, var(--container));
  margin: 0 auto;
}

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 1000;
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.header-inner {
  width: min(100% - 32px, var(--container));
  margin: 0 auto;
  min-height: 72px;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.site-logo strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.site-logo {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--text);
  text-align: left;
}

.site-logo span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 24px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.main-nav a,
.nav-button {
  font-size: 14px;
  color: var(--muted);
}

.nav-button {
  border: none;
  background: transparent;
  min-height: 36px;
  padding: 0 4px;
}

.nav-button.is-active {
  color: var(--text);
  font-weight: 700;
}

.header-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-menu-trigger {
  min-height: 48px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.user-menu-trigger.is-open {
  border-color: var(--primary);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-soft);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.user-meta strong {
  display: block;
  font-size: 14px;
}

.user-meta span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.header-user .text-button {
  white-space: nowrap;
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1300;
  width: 184px;
  padding: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 40px rgba(17, 24, 39, 0.12);
}

.user-menu button {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.user-menu button:hover {
  background: var(--primary-soft);
}

.is-hidden {
  display: none !important;
}

.toast-region {
  position: fixed;
  top: calc(var(--safe-top) + 84px);
  right: calc(var(--safe-right) + 18px);
  z-index: 2200;
  width: min(380px, calc(100vw - var(--safe-left) - var(--safe-right) - 32px));
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 14px 14px 14px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 18px 44px rgba(17, 24, 39, 0.16);
}

.toast-item--error {
  border-left: 4px solid #dc2626;
}

.toast-item--success {
  border-left: 4px solid #16a34a;
}

.toast-item--info {
  border-left: 4px solid var(--primary);
}

.toast-content strong {
  display: block;
  font-size: 14px;
  line-height: 1.4;
}

.toast-content p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.toast-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

.toast-close:hover {
  color: var(--text);
  border-color: var(--primary);
}

.notice-bar {
  background: #fafafa;
  border-bottom: 1px solid var(--line);
}

.notice-bar .page-inner {
  min-height: 42px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.page-main {
  padding: calc(var(--header-offset) + 24px) 0
    calc(40px + var(--safe-bottom));
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.app-view {
  display: none;
}

.app-view.is-active {
  display: block;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.toolbar-title h1 {
  margin: 0;
  font-size: 28px;
}

.toolbar-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-actions input,
.toolbar-actions select,
.chat-input-row input,
.chat-offer-row input {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 12px;
  color: var(--text);
}

.toolbar-actions input {
  width: 320px;
}

.toolbar-actions button,
.primary-button {
  height: 40px;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
}

.page-content {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 420px;
  gap: 20px;
  align-items: start;
  position: relative;
}

.page-content:has(.detail-panel.is-empty) {
  grid-template-columns: minmax(0, 1fr);
}

.list-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.panel-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header strong {
  font-size: 16px;
}

.panel-header span {
  font-size: 13px;
  color: var(--muted);
}

.detail-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-close-button {
  display: none;
  min-height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
}

.detail-mask {
  display: none;
}

.list-head {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr 0.9fr 0.8fr;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  background: #fafafa;
}

.listing-list {
  display: block;
}

.listing-empty-state {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 16px;
  border-bottom: 1px solid var(--line);
}

.listing-empty-state strong {
  display: block;
  font-size: 18px;
}

.listing-empty-state p {
  max-width: 520px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

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

.listing-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 0.8fr 0.9fr 0.8fr;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.listing-row.is-active,
.listing-row:hover {
  background: #f9fafb;
}

.listing-main {
  cursor: pointer;
}

.listing-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.listing-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.listing-tags,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.listing-tags span,
.tag-row span {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--muted);
  font-size: 12px;
}

.listing-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.listing-col span {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.listing-price {
  font-size: 20px;
  font-weight: 700;
}

.listing-action {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.contact-button,
.secondary-button,
.text-button {
  height: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.buy-button {
  height: 36px;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0 12px;
}

.detail-panel {
  padding-bottom: 16px;
}

.detail-block {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-block h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.detail-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-channel {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.detail-top h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.35;
}

.detail-price {
  font-size: 28px;
  font-weight: 700;
  white-space: nowrap;
}

.detail-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.detail-description {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

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

.meta-item {
  padding: 12px;
  background: #fafafa;
  border: 1px solid var(--line);
}

.meta-item span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.meta-item strong {
  font-size: 15px;
}

.seller-simple {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.seller-simple p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.flow-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 16px;
}

.seller-center-section,
.account-section,
.orders-section {
  margin-top: 20px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-header strong {
  display: block;
  font-size: 20px;
}

.section-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-header span {
  color: var(--muted);
  font-size: 13px;
}

.seller-center-layout,
.account-layout,
.orders-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: 20px;
  align-items: start;
}

.seller-form,
.my-listings-panel,
.account-panel,
.wallet-panel,
.orders-panel,
.order-detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.account-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.account-card strong {
  font-size: 15px;
}

.account-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.account-card-actions .secondary-button,
.account-card-actions .primary-button {
  width: 100%;
}

.wallet-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.wallet-metric {
  padding: 12px;
  border: 1px solid var(--line);
  background: #fafafa;
}

.wallet-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.wallet-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.withdraw-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.ledger-list {
  display: grid;
}

.ledger-item {
  display: grid;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.ledger-item:last-child {
  border-bottom: none;
}

.ledger-item-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.ledger-item-top strong {
  font-size: 14px;
}

.ledger-item-top span,
.ledger-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.ledger-item p {
  margin: 0;
}

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

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field span,
.seller-checkbox span {
  color: var(--muted);
  font-size: 13px;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.form-field input,
.form-field select {
  height: 42px;
}

.form-field textarea {
  min-height: 108px;
  padding-top: 10px;
  padding-bottom: 10px;
  resize: vertical;
  line-height: 1.6;
}

.seller-field-wide {
  grid-column: 1 / -1;
}

.upload-preview-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upload-status,
.upload-error {
  grid-column: 1 / -1;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--primary-soft);
  color: var(--text);
  font-size: 13px;
}

.upload-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.upload-preview-item {
  position: relative;
  min-height: 128px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.upload-preview-item img {
  width: 100%;
  height: 128px;
  display: block;
  object-fit: cover;
}

.upload-preview-item .text-button {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(255, 255, 255, 0.92);
}

.upload-empty {
  padding: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 13px;
}

.seller-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.seller-checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.seller-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 16px 16px;
}

.seller-form-feedback {
  margin: 0 16px 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  line-height: 1.7;
}

.seller-form-feedback[hidden] {
  display: none;
}

.seller-form-feedback--success {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success-text);
}

.seller-form-feedback--error {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.seller-form-actions .secondary-button,
.seller-form-actions .primary-button {
  min-width: 112px;
}

.my-listings-list {
  display: block;
}

.my-listing-item {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.my-listing-item:last-child {
  border-bottom: none;
}

.my-listing-head,
.my-listing-meta {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.my-listing-head strong {
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.my-listing-meta span,
.my-listing-note,
.order-tip {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.my-listing-note {
  margin: 0;
}

.my-listing-empty {
  padding: 18px 16px;
}

.my-listing-empty strong {
  display: block;
  font-size: 15px;
}

.my-listing-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.order-tabs {
  display: flex;
  gap: 8px;
}

.order-tab {
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
}

.order-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.orders-list {
  display: block;
}

.order-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fff;
  text-align: left;
  padding: 14px 16px;
}

.order-item.is-active,
.order-item:hover {
  background: #f9fafb;
}

.order-item-top,
.order-card-head,
.progress-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.order-item-top strong,
.order-card-head strong {
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.order-item-meta,
.order-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.order-item-meta span,
.order-item-bottom span,
.order-card-head p {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.order-detail-content {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.order-card {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
}

.order-card-title {
  display: block;
  margin-bottom: 12px;
  font-size: 15px;
}

.order-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.order-meta-item {
  padding: 12px;
  background: #fafafa;
  border: 1px solid var(--line);
}

.order-meta-item span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.order-meta-item strong {
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.order-progress {
  display: grid;
  gap: 10px;
}

.progress-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d1d5db;
  margin-top: 5px;
}

.progress-item.is-done .progress-dot,
.progress-item.is-current .progress-dot {
  background: var(--primary);
}

.progress-body {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.progress-item:last-child .progress-body {
  border-bottom: none;
  padding-bottom: 0;
}

.progress-top span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.progress-body p,
.order-note,
.order-delivery,
.order-tip,
.order-empty p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.order-empty {
  padding: 24px 16px;
}

.order-empty strong {
  display: block;
  font-size: 15px;
}

.payment-modal,
.login-modal,
.upload-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
}

.payment-modal.is-hidden,
.login-modal.is-hidden,
.upload-modal.is-hidden {
  display: none;
}

.payment-mask,
.login-mask,
.upload-mask {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.28);
}

.payment-dialog,
.login-dialog {
  position: relative;
  width: min(100% - 32px, 440px);
  margin: 110px auto 0;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
}

.upload-dialog {
  position: relative;
  width: min(100% - 32px, 360px);
  margin: 160px auto 0;
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.upload-dialog strong {
  font-size: 18px;
}

.upload-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.upload-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: upload-spin 0.8s linear infinite;
}

@keyframes upload-spin {
  to {
    transform: rotate(360deg);
  }
}

.payment-header,
.login-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.payment-body,
.login-body {
  padding: 16px;
  display: grid;
  gap: 16px;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  background: #fafafa;
}

.auth-mode-tab {
  min-height: 38px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.auth-mode-tab.is-active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}

.form-field {
  display: grid;
  gap: 8px;
}

.form-field span {
  color: var(--muted);
  font-size: 13px;
}

.form-field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
}

.payment-summary {
  border: 1px solid var(--line);
  background: #fafafa;
}

.payment-row {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.payment-row:last-child {
  border-bottom: none;
}

.payment-row span {
  color: var(--muted);
  font-size: 13px;
}

.payment-row strong {
  font-size: 14px;
}

.payment-row-amount strong {
  font-size: 24px;
}

.payment-methods {
  display: grid;
  gap: 10px;
}

.payment-method {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #fff;
}

.payment-method input {
  margin: 0;
}

.payment-note,
.login-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.payment-actions,
.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 16px 16px;
}

.payment-actions .secondary-button,
.payment-actions .primary-button,
.login-actions .secondary-button,
.login-actions .primary-button {
  height: 40px;
}

body.is-chat-open,
body.is-payment-open,
body.is-login-open,
body.is-upload-open {
  overflow: hidden;
}

.chat-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--safe-bottom) + var(--viewport-bottom-offset));
  height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: none;
  background: var(--primary);
  color: #fff;
  z-index: 1100;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.14);
}

body.is-chat-open .chat-launcher {
  opacity: 0;
  pointer-events: none;
}

.chat-launcher span {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.chat-dock {
  position: fixed;
  right: 20px;
  bottom: calc(80px + var(--safe-bottom) + var(--viewport-bottom-offset));
  width: min(760px, calc(100vw - 40px));
  height: 520px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
  z-index: 1100;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.chat-dock.is-collapsed {
  display: none;
}

.chat-dock-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fafafa;
}

.chat-dock-header strong,
.session-panel-header strong,
.conversation-header strong {
  display: block;
  font-size: 15px;
}

.chat-dock-header p,
.conversation-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-dock-actions {
  display: flex;
  gap: 8px;
}

.chat-dock-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 0;
}

.session-panel {
  border-right: 1px solid var(--line);
  background: #fafafa;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

.session-panel-header,
.conversation-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.session-panel-header span {
  color: var(--muted);
  font-size: 12px;
}

.session-list {
  overflow-y: auto;
}

.session-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 12px 14px;
}

.session-item.is-active,
.session-item:hover {
  background: #f0f2f5;
}

.session-title {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.session-subtitle,
.session-preview {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.conversation-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  min-height: 0;
}

.chat-window {
  padding: 12px;
  background: #fff;
  overflow-y: auto;
  min-height: 0;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-item {
  display: flex;
  gap: 10px;
}

.message-item.is-buyer {
  justify-content: flex-end;
}

.message-item.is-system {
  justify-content: center;
}

.message-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 auto;
}

.message-content {
  max-width: 78%;
}

.message-item.is-buyer .message-content {
  text-align: right;
}

.message-meta {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-bubble {
  display: inline-block;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  text-align: left;
  overflow-wrap: anywhere;
}

.message-item.is-buyer .message-bubble {
  background: #eceff3;
}

.message-item.is-system .message-bubble {
  background: #f3f4f6;
  color: var(--muted);
  font-size: 12px;
}

.offer-message {
  border-left: 3px solid var(--primary);
  background: #f7f7f8;
}

.offer-state,
.offer-actions {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  text-align: left;
}

.offer-state span,
.offer-actions span {
  color: var(--muted);
  font-size: 12px;
}

.offer-state strong {
  font-size: 14px;
}

.offer-actions .secondary-button,
.offer-actions .primary-button {
  height: 32px;
  padding: 0 10px;
}

.offer-counter {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) auto;
  gap: 8px;
  width: 100%;
}

.offer-counter input {
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  padding: 0 10px;
}

.chat-input-row,
.chat-offer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.chat-note {
  margin: 0;
  padding: 0 12px calc(12px + var(--safe-bottom) + var(--viewport-bottom-offset));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .page-content {
    grid-template-columns: 1fr;
  }

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

  .account-layout,
  .seller-center-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 860px) {
  .toast-region {
    top: calc(var(--safe-top) + var(--header-offset) + 10px);
    left: calc(var(--safe-left) + 12px);
    right: calc(var(--safe-right) + 12px);
    width: auto;
  }

  .header-inner {
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 12px;
    min-height: auto;
    padding: 12px 0;
  }

  .header-user {
    justify-self: stretch;
    width: 100%;
    justify-content: space-between;
  }

  .user-avatar {
    width: 34px;
    height: 34px;
  }

  .user-menu-trigger {
    flex: 1;
    justify-content: flex-start;
    min-width: 0;
  }

  .user-menu {
    left: 0;
    right: auto;
    width: min(100%, 260px);
  }

  .main-nav {
    position: static;
    display: flex;
    gap: 12px;
    padding: 0;
    background: transparent;
    border-top: none;
  }

  .main-nav a,
  .nav-button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
  }

  .page-main {
    padding-bottom: calc(40px + var(--safe-bottom));
  }

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

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar-actions input,
  .toolbar-actions select,
  .toolbar-actions button {
    width: 100%;
    min-height: 44px;
  }

  .toolbar-title p {
    line-height: 1.6;
  }

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

  .seller-form-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .seller-form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .seller-form-actions .secondary-button,
  .seller-form-actions .primary-button {
    width: 100%;
    min-height: 44px;
  }

  .upload-preview-list {
    grid-template-columns: 1fr;
  }

  .list-head {
    display: none;
  }

  .listing-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

  .listing-action {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .listing-action .contact-button,
  .listing-action .buy-button {
    width: 100%;
    height: 44px;
  }

  .listing-empty-state {
    flex-direction: column;
    align-items: stretch;
  }

  .listing-empty-state .primary-button {
    width: 100%;
    min-height: 44px;
  }

  .detail-top,
  .seller-simple {
    flex-direction: column;
    align-items: start;
  }

  .detail-mask {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1190;
  }

  .detail-mask.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .detail-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    max-height: calc(var(--app-height) - var(--header-offset) - 12px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.12);
    transform: translateY(calc(100% + 16px));
    opacity: 0;
    pointer-events: none;
    transition:
      transform 0.22s ease,
      opacity 0.22s ease;
    padding-bottom: calc(
      16px + var(--safe-bottom) + var(--viewport-bottom-offset)
    );
  }

  .detail-panel.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .detail-panel .panel-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fff;
  }

  .detail-close-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .order-item-meta,
  .order-item-bottom,
  .order-card-head,
  .progress-top,
  .my-listing-head,
  .my-listing-meta {
    flex-direction: column;
    align-items: start;
  }

  input,
  select {
    font-size: 16px;
  }

  .chat-launcher {
    right: calc(12px + var(--safe-right));
    left: auto;
    bottom: calc(12px + var(--safe-bottom) + var(--viewport-bottom-offset));
    min-height: 48px;
  }

  .chat-dock {
    right: 0;
    left: 0;
    top: var(--header-offset);
    bottom: auto;
    width: auto;
    height: calc(var(--app-height) - var(--header-offset));
    max-height: none;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.08);
  }

  .chat-dock-body {
    grid-template-columns: 1fr;
    grid-template-rows: 152px minmax(0, 1fr);
  }

  .session-panel {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .session-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .session-item {
    min-width: 220px;
    border-right: 1px solid var(--line);
    border-bottom: none;
  }

  .message-content {
    max-width: 86%;
  }

  .payment-dialog {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    margin: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    box-shadow: 0 -14px 30px rgba(0, 0, 0, 0.12);
  }

  .payment-body {
    max-height: calc(var(--app-height) - 180px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .payment-actions {
    padding-bottom: calc(16px + var(--safe-bottom) + var(--viewport-bottom-offset));
  }
}

@media (max-width: 520px) {
  .page-inner,
  .header-inner {
    width: min(100% - 16px, var(--container));
  }

  .page-main {
    padding-top: calc(var(--header-offset) + 16px);
  }

  .toolbar-title h1 {
    font-size: 24px;
  }

  .meta-grid,
  .order-meta-grid {
    grid-template-columns: 1fr;
  }

  .chat-input-row,
  .chat-offer-row,
  .offer-counter {
    grid-template-columns: 1fr;
  }

  .payment-actions {
    flex-direction: column;
  }

  .seller-form-actions {
    grid-template-columns: 1fr;
  }

  .payment-actions .secondary-button,
  .payment-actions .primary-button {
    width: 100%;
  }

  .chat-launcher {
    right: calc(12px + var(--safe-right));
    bottom: calc(12px + var(--safe-bottom) + var(--viewport-bottom-offset));
    padding: 0 12px;
  }

  .chat-dock-header,
  .session-panel-header,
  .conversation-header,
  .chat-window,
  .chat-input-row,
  .chat-offer-row {
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-window {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .payment-header,
  .payment-body,
  .payment-actions {
    padding-left: 12px;
    padding-right: 12px;
  }
}

body.is-detail-open {
  overflow: hidden;
}
