body {
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f4f7f6;
  margin: 0;
  padding: 0;
  text-align: center;
  padding-bottom: 100px;
}

.dark-mode {
  background-color: black;
  color: white;
}

.dark-mode .topnav, 
.dark-mode .mobile-content {
  background-color: #1e1e1e;
}

.dark-mode table {
  border: 1px solid #ffffff;
}

.dark-mode th, .dark-mode td {
  background-color: #333;
  color: #ffffff;
}

.dark-mode .topnav {
  background-color: #222222;
}

.dark-mode .topnav a {
  color: #F0F0F0;
}

.dark-mode .topnav a:hover {
  background-color: #555555;
  color: #ffffff;
}

.dark-mode .topnav a.active {
  background-color: #5A67D8;
  color: white;
}

.dark-mode button {
  background-color: #5A67D8;
  color: #FFFFFF;
}

.dark-mode button:hover {
  opacity: 0.8;
}

.topnav {
  background-color: #333;
  overflow: hidden;
}

.topnav a {
  float: left;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.topnav a:hover {
  background-color: #ddd;
  color: black;
}

.topnav a.active {
  background-color: #04AA6D;
  color: white;
}

.topnav .icon {
  display: none;
}

@media screen and (max-width: 600px) {
  .topnav a:not(:first-child) {display: none;}
  .topnav a.icon {
      float: right;
      display: block;
  }
}

@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive .icon {
      position: absolute;
      right: 0;
      top: 0;
  }
  .topnav.responsive a {
      float: none;
      display: block;
      text-align: left;
  }
}

button {
  background-color: #04AA6D;
  color: white;
  padding: 14px 20px;
  margin: 8px 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 50%;
  font-size: 16px;
}

button:hover {
  opacity: 0.8;
}

footer {
  background-color: #222;
  font-size: 14px;
  color: white;
  text-align: center;
  padding: 5px;
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
}

#date4 {
  position: fixed;
  top: 50px;
  right: 5px;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
  #date4 {
      top: 50px;
      font-size: 0.8rem;
  }
}

#clock4 {
  position: fixed;
  top: 85px;
  right: 5px;
  font-size: 1.2rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

@media (max-width: 600px) {
  #clock4 {
      top: 75px;
      font-size: 0.8rem;
  }
}

h2 {
  text-align: center;
  color: #333;
}

.dark-mode h2 {
  color: #FFFFFF;
}

.mobile-content {
  display: none;
}

@media (max-width: 600px) {
  .desktop-content {
      display: none;
  }
  .mobile-content {
      display: block;
  }
}

.toggle-container {
  position: fixed;
  top: 120px;
  right: 15px;
  display: inline-block;
  width: 60px;
  height: 34px;
  cursor: pointer;
}

@media (max-width: 600px) {
  .toggle-container {
      top: 100px;
  }
}

.toggle-container input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: background-color 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: #fff;
  transition: transform 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #4d4d4d;
}

input:checked + .slider:before {
  transform: translateX(26px);
}

.slider .icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: #f39c12;
  transition: opacity 0.4s;
}

.slider .icon.sun {
  left: 6px;
  opacity: 1;
}

input:checked + .slider .icon.sun {
  opacity: 0;
}

.slider .icon.moon {
  right: 6px;
  opacity: 0;
  fill: #f1c40f;
}

input:checked + .slider .icon.moon {
  opacity: 1;
}

.message-board {
  max-width: 600px;
  margin: 20px auto;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.dark-mode .message-board {
  background-color: #2c2c2c;
  box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  scroll-behavior: smooth;
}

.message {
  max-width: 70%;
  margin: 10px 0;
  padding: 10px 15px;
  border-radius: 15px;
  position: relative;
  word-wrap: break-word;
}

.message.sent {
  background-color: #00c73c;
  color: white;
  margin-left: auto;
}

.message.received {
  background-color: #e9ecef;
  margin-right: auto;
}

.dark-mode .message.received {
  background-color: #3a3a3a;
}

.message .user {
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 5px;
  color: #333;
}

.dark-mode .message .user {
  color: #FFFFFF;
}

.message .content {
  color: #333;
}

.dark-mode .message .content {
  color: #FFFFFF;
}

.message .time {
  font-size: 10px;
  color: #333;
  position: absolute;
  bottom: 5px;
  right: 10px;
}

.dark-mode .message .time {
  color: #FFFFFF;
}

.reply-button {
  margin-top: 5px;
  padding: 5px 10px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}

.reply-button:hover {
  background-color: #0056b3;
}

.reply-form {
  margin-left: 20px;
  margin-top: 10px;
  display: none;
  flex-direction: row;
  gap: 10px;
}

.reply-form textarea {
  flex: 1;
  resize: none;
  padding: 5px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 14px;
}

.dark-mode .reply-form textarea {
  border-color: #555;
  background-color: #333;
  color: #e0e0e0;
}

.reply-form button {
  padding: 5px 10px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.reply-form button:hover {
  background-color: #0056b3;
}

.reply {
  margin-left: 20px;
  margin-top: 10px;
  background-color: #e9ecef;
  padding: 10px;
  border-radius: 15px;
  max-width: 60%;
}

.reply.sent {
  background-color: #00c73c;
  color: white;
  margin-left: auto;
}

.reply.received {
  background-color: #e9ecef;
  margin-right: auto;
}

.dark-mode .reply.received {
  background-color: #3a3a3a;
}

.reply .reply-content {
  margin-bottom: 5px;
}

.reply .user {
  font-size: 12px;
  font-weight: bold;
  color: #333;
}

.dark-mode .reply .user {
  color: #FFFFFF;
}

.reply .content {
  color: #333;
}

.dark-mode .reply .content {
  color: #FFFFFF;
}

.reply .time {
  font-size: 10px;
  color: #333;
  text-align: right;
  display: block;
  position: static;
}

.dark-mode .reply .time {
  color: #FFFFFF;
}

.message-form {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.message-form textarea {
  flex: 1;
  resize: none;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 16px;
}

.dark-mode .message-form textarea {
  border-color: #555;
  background-color: #333;
  color: #e0e0e0;
}

.message-form button {
  padding: 10px;
  background-color: #00c73c;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.message-form button:hover {
  background-color: #00a633;
}

.caution {
  color: #dc3545;
  font-size: 14px;
  margin-bottom: 15px;
  text-align: center;
}

#welcome-message h3 {
  color: #333;
}

.dark-mode #welcome-message h3 {
  color: #FFFFFF;
}

#refresh-btn {
  background-color: #007bff;
  color: white;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin-bottom: 10px;
}

#refresh-btn:hover {
  background-color: #0056b3;
}


/* 載入動畫容器 */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* 載入動畫內容 */
.loading-content {
  background: white;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

/* 旋轉動畫 */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 10px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 暗黑模式支援 */
body.dark-mode .loading-content {
  background: #2c2c2c; /* 與 .message-board 一致 */
  color: #fff;
}