:root {
  --bg: #f6f5ef;
  --surface: #ffffff;
  --surface-soft: #f0eee4;
  --ink: #1d2733;
  --muted: #69727c;
  --line: #dfddd2;
  --teal: #0f766e;
  --teal-dark: #0a5f59;
  --coral: #e65f45;
  --gold: #d9a21b;
  --blue: #375a8c;
  --green: #2f855a;
  --shadow: 0 18px 45px rgba(40, 44, 52, 0.12);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(223, 221, 210, 0.85);
  background: rgba(246, 245, 239, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand-text strong {
  font-size: 18px;
}

.brand-text small {
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
}

.auth-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.auth-user div {
  display: grid;
  gap: 1px;
}

.auth-user strong {
  font-size: 13px;
}

.auth-user small {
  color: var(--muted);
  font-size: 11px;
}

.auth-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #f5c451;
  color: #3c2b08;
  font-size: 13px;
  font-weight: 850;
}

.auth-area .ghost-button {
  min-height: 42px;
  padding: 0 12px;
}

.primary-action,
.ghost-button,
.icon-button,
.category-button,
.small-action {
  border: 0;
  border-radius: 8px;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  background: var(--teal);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.primary-action:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.ghost-button:hover,
.icon-button:hover,
.small-action:hover {
  background: var(--surface-soft);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 330px;
  gap: 20px;
  padding: 22px 24px 32px;
}

.left-panel,
.message-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.profile-panel,
.seller-panel,
.category-panel,
.campus-rules,
.message-panel,
.summary-grid > div,
.listing-card,
.modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.profile-panel {
  padding: 16px;
}

.seller-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.seller-section {
  display: grid;
  gap: 9px;
}

.seller-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 850;
}

.seller-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.seller-empty {
  padding: 12px;
  border-radius: 8px;
  background: #f7f6f0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.seller-notice,
.seller-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.seller-notice.unread {
  border-color: rgba(15, 118, 110, 0.4);
  background: #edf8f5;
}

.seller-notice strong,
.seller-item strong {
  font-size: 13px;
  line-height: 1.35;
}

.seller-notice p,
.seller-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.seller-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seller-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: #eceae0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.seller-action.primary {
  background: var(--teal);
  color: #fff;
}

.seller-action.danger {
  background: #f9ded8;
  color: #9f2d1c;
}

.seller-action:disabled {
  cursor: not-allowed;
  background: #d8d6cc;
  color: #6b7280;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e6f4f2;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 850;
}

.status-pill.sold {
  background: #ede7d4;
  color: #8a6110;
}

.status-pill.delisted {
  background: #eceff3;
  color: #64707d;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background: #f5c451;
  color: #3c2b08;
  font-weight: 800;
}

.profile-head div:last-child {
  display: grid;
  gap: 4px;
}

.profile-head span,
.level-row,
.profile-stats,
.market-toolbar p,
.message-header span,
.modal-head span,
.meta-line,
.listing-description,
.seller-line,
.tag-row,
.chat-title {
  color: var(--muted);
}

.level-row,
.profile-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  font-size: 13px;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  margin-top: 10px;
  border-radius: 999px;
  background: #ece8da;
}

.progress-track span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

.profile-stats strong {
  color: var(--ink);
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.avatar.has-image,
.auth-avatar.has-image,
.profile-avatar-preview.has-image {
  background-position: center;
  background-size: cover;
  color: transparent;
}

.profile-editor {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.profile-editor label {
  display: grid;
  gap: 6px;
  color: #4c5661;
  font-size: 13px;
  font-weight: 700;
}

.profile-avatar-preview {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border-radius: 8px;
  background: #f5c451;
  color: #3c2b08;
  font-size: 28px;
  font-weight: 900;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.task-card.done {
  background: #eef6f2;
}

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

.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.task-reward {
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.deploy-note {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(217, 162, 27, 0.42);
  border-radius: 8px;
  background: #fff7df;
}

.deploy-note p {
  margin: 0;
  color: #6f5420;
  font-size: 13px;
  line-height: 1.5;
}

.data-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.data-actions .seller-action {
  min-height: 42px;
}

.category-panel {
  padding: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 800;
}

.panel-title button {
  border: 0;
  background: transparent;
  color: var(--teal);
  font-weight: 700;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
}

.category-button span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.category-button small {
  color: var(--muted);
}

.category-button.active,
.category-button:hover {
  background: #e7f2ef;
  color: var(--teal-dark);
}

.campus-rules {
  display: flex;
  gap: 12px;
  padding: 14px;
}

.campus-rules p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.rule-icon {
  display: grid;
  flex: 0 0 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: #e9f5ee;
  color: var(--green);
}

.market-area {
  min-width: 0;
}

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

.market-toolbar h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 0;
}

.market-toolbar p {
  margin: 0;
}

.filter-row {
  display: flex;
  gap: 10px;
  align-items: end;
}

.filter-row label,
.form-grid label,
.modal-card > label {
  display: grid;
  gap: 6px;
  color: #4c5661;
  font-size: 13px;
  font-weight: 700;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

select,
input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid > div {
  padding: 14px;
}

.summary-grid span {
  display: block;
  font-size: 24px;
  font-weight: 850;
}

.summary-grid small {
  color: var(--muted);
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 16px;
}

.listing-card {
  overflow: hidden;
  min-width: 0;
  box-shadow: 0 10px 24px rgba(40, 44, 52, 0.06);
}

.listing-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-soft);
}

.listing-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(29, 39, 51, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.favorite-button {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

.favorite-button.active {
  color: var(--coral);
}

.listing-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.listing-title-row {
  display: flex;
  gap: 12px;
  align-items: start;
  justify-content: space-between;
}

.listing-title-row h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.price {
  white-space: nowrap;
  color: var(--coral);
  font-size: 20px;
  font-weight: 900;
}

.listing-description {
  margin: 0;
  min-height: 42px;
  line-height: 1.5;
  font-size: 14px;
}

.seller-line,
.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.seller-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font-weight: 800;
}

.reputation {
  color: var(--green);
  font-weight: 800;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 8px;
  border-radius: 999px;
  background: #f1f0e9;
  color: #4f5965;
  font-size: 12px;
  font-weight: 700;
}

.tag.online {
  background: #e6f4f2;
  color: var(--teal-dark);
}

.tag.offline {
  background: #fff1df;
  color: #9a5b12;
}

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

.small-action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #f3f2eb;
  color: var(--ink);
  font-weight: 800;
}

.small-action.buy {
  background: #233044;
  color: #fff;
}

.small-action.buy:hover {
  background: #111827;
}

.small-action:disabled,
.small-action.buy:disabled,
.small-action.buy:disabled:hover {
  cursor: not-allowed;
  background: #d8d6cc;
  color: #6b7280;
  transform: none;
}

.message-panel {
  position: sticky;
  top: 84px;
  max-height: calc(100vh - 106px);
  min-height: 620px;
  overflow: hidden;
}

.message-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.message-header div {
  display: grid;
  gap: 2px;
}

.conversation-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.conversation {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.conversation strong {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.conversation span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation.active,
.conversation:hover {
  background: #e7f2ef;
}

.conversation-placeholder {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.chat-window {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  height: 100%;
}

.chat-title {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 9px;
  overflow: auto;
  padding: 14px;
}

.message {
  max-width: 86%;
  padding: 10px 11px;
  border-radius: 8px;
  background: #f0eee4;
  font-size: 13px;
  line-height: 1.45;
}

.message.mine {
  align-self: flex-end;
  background: var(--teal);
  color: #fff;
}

.message time {
  display: block;
  margin-top: 5px;
  color: inherit;
  font-size: 11px;
  opacity: 0.72;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.message-form button,
.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: #f3f2eb;
  color: var(--ink);
}

.message-form input {
  min-width: 0;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(17, 24, 39, 0.42);
  backdrop-filter: blur(4px);
}

.modal-card {
  display: grid;
  gap: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal-card.compact {
  max-width: 560px;
  margin: auto;
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head div {
  display: grid;
  gap: 3px;
}

.modal-head strong {
  font-size: 20px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.image-preview {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

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

.image-preview img {
  width: 112px;
  height: 84px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-soft);
}

.image-preview div {
  display: grid;
  gap: 6px;
}

.image-preview strong {
  font-size: 14px;
}

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

.choice-block {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf6;
}

.choice-block > span {
  flex: 0 0 100%;
  color: #4c5661;
  font-size: 13px;
  font-weight: 800;
}

.choice-block label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.choice-block input[type="checkbox"],
.choice-block input[type="radio"] {
  min-height: auto;
}

.choice-block.stacked,
.choice-block.stacked > div {
  display: grid;
  gap: 9px;
}

.auth-card > label {
  display: grid;
  gap: 6px;
  color: #4c5661;
  font-size: 13px;
  font-weight: 700;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 8px;
  background: #f1f0e9;
}

.auth-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(40, 44, 52, 0.08);
}

.auth-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.order-preview {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #f7f6f0;
}

.order-preview img {
  width: 94px;
  height: 76px;
  border-radius: 8px;
  object-fit: cover;
}

.order-preview h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.order-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  gap: 8px;
  padding: 30px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1d2733;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

[data-lucide] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .message-panel {
    grid-column: 1 / -1;
    position: static;
    min-height: 460px;
    max-height: none;
  }

  .listing-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .search-box {
    grid-column: 1 / -1;
    order: 3;
  }

  .top-actions {
    align-items: stretch;
    grid-column: 1 / -1;
    order: 4;
    justify-content: stretch;
  }

  .top-actions > .primary-action,
  .auth-area,
  .auth-area > * {
    flex: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 16px;
  }

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

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

  .filter-row,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .filter-row {
    display: grid;
  }

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

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
  }

  .brand-text small {
    display: none;
  }

  .primary-action {
    padding: 0 12px;
  }

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

  .auth-user {
    justify-content: space-between;
    width: 100%;
  }

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

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

  .form-grid,
  .order-preview,
  .image-preview,
  .profile-editor {
    grid-template-columns: 1fr;
  }

  .order-preview img,
  .image-preview img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }

  .modal-head,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions button,
  .modal-actions .primary-action {
    width: 100%;
  }
}
