body {
  background-color: #121212;
  font-family: 'Segoe UI', 'Noto Sans', 'Microsoft JhengHei', Arial, sans-serif;
  letter-spacing: 0.01em;
  font-size: 16px;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: 18px;
  box-sizing: border-box;
}
h2 {
  margin-bottom: 20px;
  color: #00ffd0;
  margin-top: 0;
}
#log {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-width: 100vw;
  width: 100%;
  padding-right: 8px;
  border-radius: 8px;
  border: 1px solid #23272a;
  background: #18191c;
  box-shadow: 0 2px 16px 0 rgba(0,0,0,0.25);
  padding-bottom: 90px;
  margin-top: 92px;
}
.msg-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  background-color: #1f1f1f;
  border-left: 4px solid #5865f2;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  margin-bottom: 2px;
  transition: background 0.2s, box-shadow 0.2s;
  border-bottom: 1px solid #23272a;
  padding: 12px 16px 12px 12px;
  gap: 14px;
  position: relative;
}
.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5865f2 60%, #23272a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: #fff;
  font-weight: bold;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 1px 4px #0006;
  user-select: none;
}
.msg-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.nickname {
  font-weight: 600;
  color: #e3e5e8;
  font-size: 1.08em;
  margin-right: 4px;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px #0008;
  line-height: 1.2;
}
.timestamp {
  font-size: 0.85em;
  color: #949ba4;
  margin-left: 0;
  line-height: 1.2;
}
.meta {
  font-size: 0.8em;
  color: #b5bac1;
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.meta span {
  color: #5865f2;
  margin-left: 0;
}
.msg-text {
  margin-top: 2px;
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 1em;
  color: #e0e0e0;
  word-break: break-word;
}
.tag-button {
  display: inline-block;
  background-color: transparent;
  color: #5865f2;
  text-shadow: none;
  padding: 6px 18px;
  font-size: 1em;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: background 0.2s, color 0.2s;
  font-weight: 700;
  box-shadow: none;
  margin-left: 8px;
}
.tag-button:hover {
  background-color: #5865f2;
  color: #fff;
  text-shadow: 0 1px 2px #23272a99;
}
.msg-card:not(:last-child) {
  margin-bottom: 8px;
}
#log::-webkit-scrollbar {
  width: 8px;
  background: #18191c;
}
#log::-webkit-scrollbar-thumb {
  background: #23272a;
  border-radius: 8px;
}
#log::-webkit-scrollbar-thumb:hover {
  background: #5865f2;
}
#msgInput {
  flex: 1;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #222;
  color: #eee;
}
#sendBtn {
  padding: 8px 18px;
  border-radius: 4px;
  background: #00ffd0;
  color: #222;
  border: none;
  font-weight: bold;
  cursor: pointer;
}
.input-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 10px 12px 12px 12px;
  background: #121212;
  box-shadow: 0 -2px 16px 0 rgba(0,0,0,0.25);
  z-index: 10;
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.input-user-row {
}
.input-msg-row {
  flex: 1;
}
@media (max-width: 600px) {
  .input-container {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 6px 12px 6px;
  }
  .input-user-row {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .input-user-row input#nicknameInput {
    width: 100%;
    flex: 1 1 0%;
  }
  .input-user-row span,
  .input-user-row input#profileCodeInput {
    flex-shrink: 0;
  }
  .input-msg-row {
    width: 100%;
  }
}
@media (max-width: 600px) {
  .msg-card {
    flex-direction: row;
    align-items: flex-start;
  }
  .msg-content {
    width: 100%;
  }
  .msg-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
  }
  .msg-header .meta {
    width: 100%;
    justify-content: flex-end;
    align-items: center;
    display: flex;
    gap: 10px;
    margin-top: 2px;
    font-size: 0.85em;
  }
  .msg-header .meta span {
    color: #5865f2;
  }
}
.main-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: #121212;
  box-shadow: 0 2px 16px 0 rgba(0,0,0,0.25);
  padding: 18px 20px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.header-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0;
  min-height: 24px;
}
.main-header h2 {
  margin-bottom: 0;
  margin-right: 0;
  line-height: 1.2;
  display: flex;
  align-items: center;
}
#userCount {
  color: #00ffd0;
  font-size: 1.05em;
  font-weight: 600;
  background: rgba(18,18,18,0.85);
  padding: 2px 14px 2px 10px;
  border-radius: 16px 0 0 16px;
  box-shadow: 0 1px 6px #0004;
  pointer-events: none;
  margin-left: 16px;
  margin-bottom: 0;
  min-width: unset;
  text-align: center !important;
  justify-content: center !important;
  align-items: center !important;
  display: flex !important;
  height: 24px;
}
.search-bar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-bar input {
  width: 100%;
  max-width: 100vw;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid #333;
  background: #222;
  color: #eee;
  font-size: 1em;
}
@media (max-width: 600px) {
  .main-header {
    padding: 12px 6px 6px 6px;
  }
  #log {
    margin-top: 80px;
  }
  #userCount {
    font-size: 0.98em;
    padding: 2px 10px 2px 8px;
  }
}
#aboutModal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  justify-content: center;
  align-items: center;
}
#aboutModal > div {
  background: #18191c;
  color: #e0e0e0;
  border-radius: 12px;
  box-shadow: 0 4px 32px #000a;
  padding: 32px 24px 20px 24px;
  max-width: 90vw;
  min-width: 260px;
  text-align: center;
  position: relative;
}
#closeAboutModal {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #888;
  font-size: 1.5em;
  cursor: pointer;
}
#aboutModal a {
  color: #00ffd0;
  text-decoration: underline;
}
body.light-theme {
  background-color: #f6f7fa;
  color: #23272a;
}
.light-theme .main-header {
  background: #fff;
  box-shadow: 0 2px 16px 0 rgba(180,180,180,0.15);
}
.light-theme #log {
  background: #fff;
  border: 1px solid #e3e5e8;
  box-shadow: 0 2px 16px 0 rgba(180,180,180,0.15);
}
.light-theme .msg-card {
  background-color: #f3f6fa;
  border-left: 4px solid #5865f2;
  border-bottom: 1px solid #e3e5e8;
  color: #23272a;
}
.light-theme .msg-avatar {
  background: linear-gradient(135deg, #5865f2 60%, #e3e5e8 100%);
  color: #23272a;
}
.light-theme .nickname {
  color: #23272a;
  text-shadow: none;
}
.light-theme .timestamp {
  color: #888;
}
.light-theme .meta {
  color: #5865f2;
}
.light-theme .msg-text {
  color: #23272a;
}
.light-theme .tag-button {
  color: #5865f2;
  background: #e3e5e8;
}
.light-theme .tag-button:hover {
  background: #5865f2;
  color: #fff;
}
.light-theme #msgInput,
.light-theme #nicknameInput,
.light-theme #profileCodeInput {
  background: #f6f7fa !important;
  color: #23272a !important;
  border: 1px solid #e3e5e8 !important;
}
.light-theme #sendBtn {
  background: linear-gradient(90deg, #4fbcff 0%, #5865f2 100%) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 2px 8px #4fbcff33;
  font-weight: bold;
  letter-spacing: 0.04em;
  transition: background 0.2s, color 0.2s;
}
.light-theme #sendBtn:hover {
  background: linear-gradient(90deg, #5865f2 0%, #4fbcff 100%) !important;
  color: #fff !important;
}
.light-theme .input-container {
  background: #fff !important;
  box-shadow: 0 -2px 16px 0 rgba(180,180,180,0.10);
}
.light-theme #aboutModal > div {
  background: #fff;
  color: #23272a;
}
.light-theme #aboutModal div[style*="font-size:1.18em"] {
  color: #5865f2 !important;
}
.light-theme #aboutModal div[style*="font-size:1.05em"] {
  color: #23272a !important;
}
.light-theme #aboutModal div[style*="font-size:1.08em"] {
  color: #5865f2 !important;
}
.light-theme #aboutModal span[style*="color:#e3e5e8"] {
  color: #23272a !important;
}
.light-theme #aboutModal a {
  color: #5865f2 !important;
}
.light-theme #aboutModal div[style*="font-size:0.98em"] {
  color: #888 !important;
}
.light-theme #aboutModal div[style*="font-size:0.95em"] {
  color: #aaa !important;
}
.light-theme h2 {
  color: #5865f2;
}
.light-theme #userCount {
  color: #5865f2;
  background: rgba(255,255,255,0.85);
  box-shadow: 0 1px 6px #bbb4;
}
.light-theme #aboutBtn {
  background: #fff !important;
  color: #5865f2 !important;
  border: 1px solid #5865f2 !important;
}
.light-theme #themeToggleBtn {
  background: #fff !important;
  color: #ffb300 !important;
  border: 1px solid #ffb300 !important;
}
.light-theme #searchModeBtn {
  background: #fff !important;
  color: #5865f2 !important;
  border: 1px solid #5865f2 !important;
}
.light-theme .search-bar input {
  background: #f6f7fa !important;
  color: #23272a !important;
  border: 1px solid #e3e5e8 !important;
}
.light-theme .sidebar {
  background: #fff;
  box-shadow: 2px 0 16px 0 rgba(180,180,180,0.10);
}
.light-theme .sidebar-content {
  /* 保持與暗色一致 */
}
.light-theme .sidebar-btn {
  background: #fff;
  color: #ffb300;
  border: 1px solid #ffb300;
  font-size: 1em;
  padding: 7px 18px;
}
.light-theme .sidebar-btn:hover {
  background: #ffecb3;
  color: #23272a;
}
.light-theme .sidebar-close {
  color: #888;
  background: none;
}
.light-theme .sidebar-open {
  background: transparent;
  color: #5865f2;
  border: 1.5px solid #5865f2;
}
.light-theme .sidebar-open:hover {
  background: #5865f2;
  color: #fff;
  border-color: #5865f2;
}
/* 側邊選單樣式 */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: #18191c;
  box-shadow: 2px 0 16px 0 rgba(0,0,0,0.18);
  z-index: 2000;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  padding: 24px 0 0 0;
}
.sidebar.open {
  transform: translateX(0);
}
.sidebar-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #888;
  font-size: 2em;
  cursor: pointer;
}
.sidebar-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 40px;
  align-items: flex-start;
  padding-left: 32px;
}
.sidebar-btn {
  background: #23272a;
  color: #ffd700;
  border: 1px solid #ffd700;
  border-radius: 6px;
  padding: 7px 18px;
  font-size: 1em;
  cursor: pointer;
  margin-bottom: 8px;
  width: 140px;
  text-align: left;
}
.sidebar-btn:last-child {
  margin-bottom: 0;
}
.sidebar-open {
  position: static;
  background: transparent;
  color: #00ffd0;
  border: 1.5px solid #00ffd0;
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 1.3em;
  cursor: pointer;
  box-shadow: none;
  margin-right: 2px;
  margin-left: 0;
  height: 36px;
  display: inline-flex;
  align-items: center;
  transition: background 0.18s, color 0.18s, border 0.18s;
}
.sidebar-open:hover {
  background: #00ffd0;
  color: #18191c;
  border-color: #00ffd0;
}
.sidebar.open ~ .sidebar-open {
  display: none !important;
}
@media (max-width: 600px) {
  .sidebar {
    width: 80vw;
    min-width: 160px;
    max-width: 320px;
    padding-top: 16px;
  }
  .sidebar-content {
    padding-left: 0;
    width: 100%;
    align-items: center;
  }
  .sidebar-btn {
    width: 80%;
    min-width: 120px;
    max-width: 240px;
    margin-left: 0;
    margin-right: 0;
    text-align: center;
    display: block;
  }
  .sidebar-open {
    top: 12px;
    left: 8px;
    font-size: 1.2em;
    padding: 4px 10px;
  }
}
/* 商品表格美化，支援亮/暗主題 */
.item-list-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #181a1b;
  color: #e3e5e8;
  border-radius: 10px;
  overflow: hidden;
  font-size: 1em;
  box-shadow: 0 2px 8px #0002;
  min-width: 900px;
}
.item-list-table th, .item-list-table td {
  padding: 12px 8px;
  text-align: center;
  border-bottom: 1px solid #23272a;
}
.item-list-table thead th {
  background: #23272a;
  color: #00ffd0;
  font-weight: 600;
  font-size: 1.05em;
  border-bottom: 2px solid #00ffd0;
}
.item-list-table tbody tr:nth-child(even) {
  background: #202225;
}
.item-list-table tbody tr:hover {
  background: #23272a;
  transition: background 0.18s;
}
/* 買賣種類顏色區分 */
.item-type-sell {
  background: linear-gradient(90deg, #ffb3d1 0%, #ffecb3 100%);
  color: #e44d8c;
  border-radius: 8px;
  padding: 4px 14px;
  font-weight: bold;
  display: inline-block;
  font-size: 1em;
  letter-spacing: 0.04em;
}
.item-type-buy {
  background: linear-gradient(90deg, #b3ffd1 0%, #e6fff7 100%);
  color: #1db16a;
  border-radius: 8px;
  padding: 4px 14px;
  font-weight: bold;
  display: inline-block;
  font-size: 1em;
  letter-spacing: 0.04em;
}
.item-type-other {
  background: #eee;
  color: #888;
  border-radius: 8px;
  padding: 4px 14px;
  font-weight: bold;
  display: inline-block;
  font-size: 1em;
  letter-spacing: 0.04em;
}
body.light-theme .item-type-sell {
  background: linear-gradient(90deg, #ffe6ef 0%, #fff7e6 100%);
  color: #e44d8c;
}
body.light-theme .item-type-buy {
  background: linear-gradient(90deg, #e6fff7 0%, #f6fff6 100%);
  color: #1db16a;
}
body.light-theme .item-type-other {
  background: #f6f7fa;
  color: #888;
}
.item-contact-btn {
  background: #5865f2;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s;
}
.item-contact-btn:hover {
  background: #00ffd0;
  color: #23272a;
}
.item-list-table td {
  font-size: 1em;
  word-break: break-all;
}
body.light-theme .item-list-table {
  background: #fff;
  color: #23272a;
  box-shadow: 0 2px 8px #bbb2;
}
body.light-theme .item-list-table th, 
body.light-theme .item-list-table td {
  border-bottom: 1px solid #e3e5e8;
}
body.light-theme .item-list-table thead th {
  background: #f6f7fa;
  color: #5865f2;
  border-bottom: 2px solid #5865f2;
}
body.light-theme .item-list-table tbody tr:nth-child(even) {
  background: #f6f7fa;
}
body.light-theme .item-list-table tbody tr:hover {
  background: #e3e5e8;
}
body.light-theme .item-type-sell {
  background: linear-gradient(90deg, #ffe6ef 0%, #fff7e6 100%);
  color: #e44d8c;
}
body.light-theme .item-type-buy {
  background: linear-gradient(90deg, #e6fff7 0%, #f6fff6 100%);
  color: #1db16a;
}
body.light-theme .item-contact-btn {
  background: #5865f2;
  color: #fff;
}
body.light-theme .item-contact-btn:hover {
  background: #00ffd0;
  color: #23272a;
}
