:root {
  color-scheme: light;
  --orange: #ff5a12;
  --orange-dark: #e84800;
  --red: #ef2d25;
  --ink: #171717;
  --muted: #757575;
  --line: #e9e9e9;
  --paper: #f3f3f3;
  --white: #ffffff;
  --green: #1b9a61;
  --blue: #287bd1;
  --shadow: 0 3px 12px rgba(25, 25, 25, 0.08);
}

* { box-sizing: border-box; letter-spacing: 0; }
html, body { margin: 0; min-height: 100%; background: #dedede; color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
body { overscroll-behavior: none; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { display: block; }
.is-hidden { display: none !important; }

.app-shell { width: 100%; max-width: 760px; min-height: 100dvh; margin: 0 auto; overflow: hidden; background: var(--paper); box-shadow: 0 0 28px rgba(0,0,0,.12); }
.screen { position: relative; display: flex; min-height: 100dvh; flex-direction: column; background: var(--paper); }

.market-header { position: sticky; z-index: 6; top: 0; padding: calc(13px + env(safe-area-inset-top)) 12px 0; background: rgba(255,255,255,.98); border-bottom: 1px solid #ededed; }
.channel-tabs { display: flex; align-items: center; gap: 30px; height: 45px; }
.channel-tab { position: relative; padding: 0 3px 10px; border: 0; background: transparent; color: #242424; font-size: 23px; font-weight: 650; cursor: pointer; }
.channel-tab.is-active { color: var(--orange); font-weight: 800; }
.channel-tab.is-active::after { content: ""; position: absolute; right: 8px; bottom: 2px; left: 8px; height: 3px; background: var(--orange); }

.search-row { display: grid; min-height: 52px; margin-top: 5px; grid-template-columns: 1fr 78px; border: 3px solid var(--orange); border-radius: 8px; overflow: hidden; background: var(--white); }
.search-field { display: grid; min-width: 0; align-items: center; grid-template-columns: 26px 1fr 28px; gap: 8px; padding: 0 12px; }
.search-field img { width: 24px; height: 24px; opacity: .55; }
.search-field input { min-width: 0; height: 44px; padding: 0; border: 0; outline: 0; color: #404040; font-size: 17px; }
.search-row > button { border: 0; background: var(--orange); color: var(--white); font-size: 18px; font-weight: 750; cursor: pointer; }

.category-tabs { display: flex; min-height: 49px; gap: 24px; align-items: end; overflow-x: auto; scrollbar-width: none; }
.category-tabs::-webkit-scrollbar { display: none; }
.category-tabs button { position: relative; flex: 0 0 auto; padding: 12px 0 11px; border: 0; background: transparent; color: #4d4d4d; font-size: 16px; cursor: pointer; }
.category-tabs button.is-active { color: #111; font-weight: 800; }
.category-tabs button.is-active::after { content: ""; position: absolute; right: 28%; bottom: 4px; left: 28%; height: 3px; background: var(--orange); }

.market-scroll { overflow-y: auto; padding: 10px 10px calc(82px + env(safe-area-inset-bottom)); }
.supply-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.supply-panel { position: relative; display: flex; min-width: 0; min-height: 140px; overflow: hidden; padding: 13px; border-radius: 7px; background: var(--white); box-shadow: var(--shadow); }
.supply-panel > div:first-child { position: relative; z-index: 1; display: flex; min-width: 0; flex-direction: column; }
.supply-panel strong { font-size: 19px; }
.supply-panel span { margin-top: 14px; color: var(--muted); font-size: 13px; }
.supply-panel b { margin-top: 3px; font-size: 30px; line-height: 1; }
.supply-panel b small { margin-left: 4px; color: var(--muted); font-size: 13px; font-weight: 500; }
.supply-panel em { margin-top: 10px; color: #6c6c6c; font-size: 13px; font-style: normal; }
.supply-panel > img { position: absolute; right: 8px; bottom: 11px; width: 43%; aspect-ratio: 1; border-radius: 5px; object-fit: cover; }
.price-chip { position: absolute !important; right: 12px; bottom: 13px; width: 47%; padding: 8px 5px; border-radius: 6px; background: #ff884e; color: var(--white); font-size: 14px; font-weight: 800; text-align: center; }

.feature-strip { display: grid; margin-top: 8px; padding: 15px 5px 13px; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--white); border-radius: 7px; box-shadow: var(--shadow); }
.feature-strip div { display: flex; min-width: 0; align-items: center; flex-direction: column; gap: 8px; }
.feature-strip i { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 8px; color: var(--white); font-size: 19px; font-style: normal; font-weight: 900; }
.feature-strip span { width: 100%; overflow: hidden; color: #4c4c4c; font-size: 12px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.feature-red { background: #e81d2c; } .feature-coral { background: #ff4f37; } .feature-orange { background: var(--orange); } .feature-gold { background: #c89534; } .feature-yellow { background: #efaa2d; }

.catalog-empty { margin: 34px 0; color: var(--muted); text-align: center; }
.product-grid { display: grid; margin-top: 9px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.product-card { min-width: 0; overflow: hidden; border-radius: 7px; background: var(--white); box-shadow: var(--shadow); }
.product-card > img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #eee; }
.product-copy { padding: 10px 10px 11px; }
.product-copy h2 { display: -webkit-box; min-height: 43px; margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 16px; font-weight: 650; line-height: 1.36; }
.product-copy mark { margin-right: 4px; padding: 2px 4px; border-radius: 3px; background: var(--orange); color: var(--white); font-size: 11px; font-weight: 800; }
.product-copy p { display: flex; min-width: 0; align-items: end; gap: 6px; margin: 8px 0 0; }
.product-copy p b { flex: 0 0 auto; color: var(--orange); font-size: 24px; line-height: 1; }
.product-copy p b::first-letter { font-size: 15px; }
.product-copy p span { min-width: 0; overflow: hidden; color: #8a8a8a; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.product-copy footer { display: flex; min-height: 20px; align-items: center; gap: 7px; margin-top: 9px; color: #9a712d; font-size: 12px; }
.product-copy footer span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-copy footer .arrival { color: var(--green); }
.product-copy footer .discount { color: var(--red); font-weight: 700; }

.bottom-nav { position: fixed; z-index: 8; right: 0; bottom: 0; left: 0; display: grid; width: 100%; max-width: 760px; min-height: calc(68px + env(safe-area-inset-bottom)); margin: 0 auto; padding: 7px 7px env(safe-area-inset-bottom); grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid #e3e3e3; background: rgba(255,255,255,.98); }
.nav-item { position: relative; display: flex; min-width: 0; align-items: center; justify-content: center; flex-direction: column; gap: 3px; padding: 3px 0; border: 0; background: transparent; color: #333; font-size: 12px; cursor: pointer; }
.nav-item img { width: 27px; height: 27px; opacity: .83; }
.nav-item.is-active { color: var(--orange); }
.nav-item.is-active img { filter: invert(43%) sepia(97%) saturate(3300%) hue-rotate(355deg) brightness(101%); }
.nav-item b { position: absolute; top: 0; left: calc(50% + 7px); min-width: 20px; height: 20px; padding: 1px 5px; border: 2px solid var(--white); border-radius: 10px; background: var(--red); color: var(--white); font-size: 10px; line-height: 14px; }
.nav-item b[hidden] { display: none; }

.plain-header, .chat-header { display: flex; min-height: calc(67px + env(safe-area-inset-top)); align-items: center; gap: 12px; padding: env(safe-area-inset-top) 14px 0; border-bottom: 1px solid var(--line); background: var(--white); }
.plain-header > div, .chat-identity { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.plain-header strong, .chat-identity strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.plain-header span, #chat-status { color: var(--muted); font-size: 12px; }
.icon-button { display: grid; width: 42px; height: 42px; flex: 0 0 42px; padding: 0; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--white); cursor: pointer; }
.icon-button img, .header-icon { width: 21px; height: 21px; }
.danger-button { border-color: #ffd7ce; background: #fff3ef; }
.danger-button img { filter: invert(39%) sepia(98%) saturate(2600%) hue-rotate(354deg) brightness(97%); }

.login-content { width: 100%; max-width: 560px; margin: 0 auto; padding: 28px 22px calc(28px + env(safe-area-inset-bottom)); }
.service-visual { display: flex; height: 140px; align-items: center; justify-content: center; flex-direction: column; gap: 13px; border-radius: 8px; background: #fff0e8; color: var(--orange-dark); font-weight: 800; }
.service-visual img { width: 48px; height: 48px; filter: invert(43%) sepia(97%) saturate(3300%) hue-rotate(355deg) brightness(101%); }
.login-content h1 { margin: 25px 0 8px; font-size: 27px; }
.login-content > p { margin: 0 0 23px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.login-content > label:not(.consent-row), .archive-dialog label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 750; }
#invite-input, #message-input, #archive-code { width: 100%; border: 1px solid #d8d8d8; border-radius: 7px; outline: 0; background: var(--white); color: var(--ink); }
#invite-input { min-height: 112px; padding: 13px; resize: none; line-height: 1.55; }
#invite-input:focus, #message-input:focus, #archive-code:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,90,18,.12); }
.consent-row { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 21px; color: #4b4b4b; font-size: 13px; line-height: 1.5; }
.consent-row input { width: 20px; height: 20px; flex: 0 0 20px; margin: 0; accent-color: var(--orange); }
.primary-button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border: 0; border-radius: 7px; background: var(--orange); color: var(--white); font-weight: 800; cursor: pointer; }
.login-content > .primary-button { width: 100%; }
.primary-button img { width: 20px; height: 20px; filter: brightness(0) invert(1); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.form-status { min-height: 20px; margin: 11px 0 0 !important; color: #c43c22 !important; font-size: 13px !important; text-align: center; }

.chat-header { padding-right: 12px; padding-left: 12px; }
#chat-status { display: flex; align-items: center; gap: 6px; }
#chat-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
#chat-status.is-error { color: var(--red); }
#chat-status.is-error i { background: var(--red); }
.retention-note, .archive-banner { padding: 8px 14px; background: #fff1e9; color: #8e491f; font-size: 11px; line-height: 1.45; text-align: center; }
.message-list { display: flex; min-height: 0; flex: 1; overflow-y: auto; flex-direction: column; gap: 17px; padding: 19px 14px; overscroll-behavior: contain; }
.empty-state { display: flex; min-height: 240px; align-items: center; justify-content: center; flex: 1; flex-direction: column; color: var(--muted); text-align: center; }
.empty-state img { width: 42px; height: 42px; margin-bottom: 13px; opacity: .5; }
.empty-state strong { color: var(--ink); font-size: 17px; }
.empty-state span { margin-top: 7px; font-size: 13px; }
.message-item { display: flex; width: fit-content; max-width: 86%; flex-direction: column; align-self: flex-start; }
.message-item.is-own { align-self: flex-end; align-items: flex-end; }
.message-sender, .message-meta { color: var(--muted); font-size: 11px; }
.message-sender { margin-bottom: 6px; font-weight: 750; }
.message-bubble { max-width: 100%; padding: 11px 13px; overflow-wrap: anywhere; border: 1px solid #dfdfdf; border-radius: 7px; background: var(--white); font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.message-item.is-own .message-bubble { border-color: var(--orange); background: var(--orange); color: var(--white); }
.message-meta { margin-top: 6px; }
.message-media { width: min(72vw, 360px); padding: 0; overflow: hidden; }
.message-media img, .message-media video { width: 100%; max-height: 420px; object-fit: contain; background: #111; }
.media-placeholder { display: flex; min-height: 126px; align-items: center; justify-content: center; flex-direction: column; gap: 8px; padding: 18px; background: #fafafa; color: #575757; text-align: center; }
.message-item.is-own .media-placeholder { background: rgba(255,255,255,.16); color: var(--white); }
.media-placeholder img { width: 31px; height: 31px; background: transparent; opacity: .75; }
.message-item.is-own .media-placeholder img { filter: brightness(0) invert(1); }
.media-placeholder strong { max-width: 100%; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.media-placeholder span { font-size: 11px; opacity: .75; }
.media-placeholder button { min-height: 34px; padding: 0 13px; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; font-weight: 700; cursor: pointer; }

.upload-state { display: grid; align-items: center; gap: 7px 10px; padding: 9px 12px; grid-template-columns: 1fr 36px; border-top: 1px solid var(--line); background: #fff8f4; }
.upload-state > div { display: flex; min-width: 0; align-items: center; gap: 8px; }
.upload-state > div img { width: 19px; height: 19px; }
.upload-state span { min-width: 0; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.upload-state progress { width: 100%; height: 6px; grid-column: 1; accent-color: var(--orange); }
.upload-state button { grid-row: 1 / span 2; grid-column: 2; width: 34px; height: 34px; padding: 7px; border: 0; background: transparent; cursor: pointer; }
.upload-state button img { width: 100%; height: 100%; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 9px 10px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--white); }
.composer-icon, #send-button { display: grid; width: 46px; height: 46px; flex: 0 0 46px; padding: 0; place-items: center; border-radius: 50%; cursor: pointer; }
.composer-icon { border: 1px solid #d8d8d8; background: var(--white); }
.composer-icon img, #send-button img { width: 21px; height: 21px; }
#message-input { min-height: 46px; max-height: 116px; padding: 11px 13px; overflow-y: auto; resize: none; line-height: 1.45; }
#send-button { border: 0; background: var(--orange); }
#send-button img { filter: brightness(0) invert(1); }
#send-button:disabled, .composer-icon:disabled { opacity: .5; }

.archive-header .header-icon { margin-right: 10px; opacity: .65; }
.archive-list { background: #f7f3ef; }
.archive-list .message-item { opacity: .94; }
.archive-dialog { width: min(90vw, 410px); padding: 0; border: 0; border-radius: 8px; box-shadow: 0 22px 70px rgba(0,0,0,.28); }
.archive-dialog::backdrop { background: rgba(0,0,0,.48); }
.archive-dialog form { padding: 20px; }
.archive-dialog header { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.archive-dialog header img { width: 30px; height: 30px; }
.archive-dialog header div { display: flex; flex-direction: column; gap: 3px; }
.archive-dialog header strong { font-size: 19px; }
.archive-dialog header span { color: var(--muted); font-size: 12px; }
#archive-code { height: 46px; padding: 0 12px; }
.dialog-actions { display: grid; margin-top: 17px; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-actions > button { min-height: 45px; border-radius: 7px; cursor: pointer; }
#archive-cancel { border: 1px solid var(--line); background: var(--white); color: #555; }

.toast { position: fixed; z-index: 30; right: 18px; bottom: calc(22px + env(safe-area-inset-bottom)); left: 18px; max-width: 430px; min-height: 43px; margin: 0 auto; padding: 12px 15px; transform: translateY(24px); border-radius: 7px; background: #202020; color: var(--white); font-size: 13px; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 390px) {
  .channel-tabs { gap: 20px; }
  .channel-tab { font-size: 20px; }
  .category-tabs { gap: 19px; }
  .supply-panel { min-height: 132px; padding: 11px; }
  .supply-panel strong { font-size: 17px; }
  .feature-strip i { width: 34px; height: 34px; }
  .product-copy h2 { font-size: 15px; }
  .product-copy p b { font-size: 22px; }
}

@media (min-width: 900px) and (orientation: landscape) {
  .app-shell { max-width: 1060px; }
  .bottom-nav { max-width: 1060px; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
