:root {
  color-scheme: light;
  --text: #161616;
  --muted: #8a8a8a;
  --line: #f0f0f0;
  --soft: #f6f6f6;
  --coral: #f25c3d;
  --green: #0d8a43;
  --gold: #9a6b00;
  --rose: #c4375a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body.chat-app {
  background: #efefef;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, textarea, select { font-family: inherit; font-size: 15px; }
button { cursor: pointer; }
a { color: inherit; }

.chat-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 480px);
  min-height: 100%;
  margin: 0 auto;
  background: #fff;
}

.chat-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.chat-live-notice {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.chat-live-notice strong,
.chat-live-notice p {
  display: block;
  margin: 0 0 6px;
}

.chat-live-notice p {
  color: var(--muted);
  font-size: 13px;
}

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

.chat-live-notice a,
.chat-live-notice button {
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  line-height: 32px;
  text-decoration: none;
}

.chat-live-notice a {
  background: var(--coral);
  color: #fff;
}

.chat-live-notice button {
  background: var(--soft);
  color: var(--text);
}

.chat-top > div {
  flex: 1;
  min-width: 0;
}

.chat-top h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.chat-top p,
.chat-note,
.chat-error {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.chat-error { color: var(--rose); padding: 8px 14px 0; }

.chat-back, .chat-linkish {
  border: 0;
  background: transparent;
  color: var(--coral);
  font-weight: 600;
  text-decoration: none;
  padding: 0;
  cursor: pointer;
}

.chat-top form {
  margin: 0;
}

.chat-main {
  flex: 1;
  padding: 14px;
}

.chat-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-card label { font-size: 13px; font-weight: 600; }

.chat-card input,
.chat-card textarea,
.chat-card select,
.chat-compose textarea,
.order-box input,
.order-box textarea,
.order-box select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.chat-submit, .chat-compose button, .order-box button {
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--coral);
  color: #fff;
  font-weight: 600;
}

.chat-link-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-link-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.chat-link-row button, .text-action {
  flex: none;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: #161616;
  color: #fff;
  font-weight: 600;
}

.thread-list { display: flex; flex-direction: column; }
.thread-list a {
  display: block;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.thread-list strong { display: block; }
.thread-list span { color: var(--muted); font-size: 13px; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fafafa;
}

.bubble {
  max-width: 78%;
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background: #f1f1f1;
}

.bubble.is-mine {
  margin-left: auto;
  background: var(--coral);
  color: #fff;
}

.bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.bubble time { display: block; margin-top: 4px; opacity: 0.7; font-size: 11px; }

.chat-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  padding: 10px;
  border-top: 1px solid var(--line);
}

.chat-picked {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px;
  border-radius: 12px;
  background: #e8f6ee;
}

.chat-picked[hidden] {
  display: none;
}

.chat-picked img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: #fff;
}

.chat-picked span {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
}

.chat-picked button {
  margin-left: auto;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.chat-file {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
}

.chat-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.chat-compose textarea {
  flex: 1;
  width: auto;
  min-width: 0;
}

.chat-compose button {
  flex: none;
  padding: 0 14px;
}

.chat-compose .chat-picked button {
  height: 28px;
  margin-left: auto;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.chat-from {
  margin: 4px auto 12px;
  max-width: 92%;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.chat-zoom {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.bubble img {
  display: block;
  max-width: 180px;
  max-height: 240px;
  border-radius: 10px;
}

.chat-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}

.chat-lightbox[hidden] {
  display: none;
}

.chat-lightbox img {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 8px;
}

.chat-lightbox .lb-close,
.chat-lightbox .lb-prev,
.chat-lightbox .lb-next {
  position: absolute;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 600;
}

.chat-lightbox .lb-close {
  top: 16px;
  right: 16px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
}

.chat-lightbox .lb-prev,
.chat-lightbox .lb-next {
  top: 50%;
  width: 42px;
  height: 42px;
  margin-top: -21px;
  border-radius: 50%;
}

.chat-lightbox .lb-prev { left: 12px; }
.chat-lightbox .lb-next { right: 12px; }

.chat-lightbox .lb-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 13px;
}

.chat-compose textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
}

.chat-compose button { flex: none; padding: 0 16px; }

.order-box, .order-list { padding: 0 14px 16px; }
.order-list article, .order-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.order-list p { margin: 4px 0; }
.status-pending { color: var(--gold); }
.status-approved { color: var(--green); }
.status-rejected { color: var(--rose); }

.chat-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 32px 24px;
  text-align: center;
}

.chat-empty { color: var(--muted); }
