:root {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: #1f2937;
  background: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f8fafc;
  padding-bottom: 100px;
}

.page-header {
  padding: 32px 20px 16px;
  text-align: center;
}

.page-header h1 {
  margin: 0;
  font-size: 1.9rem;
}

.page-header p {
  margin: 8px 0 0;
  color: #475569;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

.controls {
  margin: 18px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.controls-search {
  flex: 1 1 220px;
  display: grid;
  gap: 8px;
}

.controls label {
  font-size: 0.95rem;
  font-weight: 600;
}
.controls input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-size: 0.95rem;
}

.table-toggle-button {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  font-size: 0.9rem;
  color: #1f2937;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-toggle-button:hover,
.table-toggle-button:focus {
  background: #f1f5f9;
}

.map-wrap {
  margin: 18px 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  position: relative;
}

.map-wrap h2 {
  margin: 0;
  font-size: 1.05rem;
}

.map-status {
  margin: 8px 0 10px;
  color: #475569;
  font-size: 0.88rem;
}

#fishMap {
  width: 100%;
  height: 460px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* ==============================
   Leaflet UI (cute + minimal)
   ============================== */

#fishMap .leaflet-control-zoom.leaflet-bar {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

#fishMap .leaflet-control-zoom.leaflet-bar a {
  width: 34px;
  height: 34px;
  line-height: 34px;
  color: #1f2937;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

#fishMap .leaflet-control-zoom.leaflet-bar a:last-child {
  border-bottom: 0;
}

#fishMap .leaflet-control-zoom.leaflet-bar a:hover,
#fishMap .leaflet-control-zoom.leaflet-bar a:focus {
  background: #f1f5f9;
}

#fishMap .leaflet-bar a,
#fishMap .leaflet-bar a:hover {
  border-radius: 0;
}

#fishMap .leaflet-control-attribution {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px 8px;
  color: #475569;
}

#fishMap .leaflet-popup-content-wrapper {
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

#fishMap .leaflet-popup-tip {
  border: 1px solid #e2e8f0;
}

#fishMap .leaflet-popup-content {
  margin: 10px 12px;
  color: #1f2937;
  font-size: 0.92rem;
  line-height: 1.4;
}

#fishMap .leaflet-popup-content a {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  text-decoration: none;
  color: #1f2937;
  background: #f8fafc;
}

#fishMap .leaflet-popup-content a:hover,
#fishMap .leaflet-popup-content a:focus {
  background: #f1f5f9;
}

.table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: auto;
  position: absolute;
  top: 60px;
  right: 12px;
  bottom: 12px;
  width: 38%;
  max-width: 420px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.18);
  z-index: 1200;
  backdrop-filter: blur(4px);
}

.table-wrap.is-hidden {
  display: none;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

thead th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  text-align: left;
  font-weight: 700;
  font-size: 0.88rem;
  border-bottom: 1px solid #cbd5e1;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: top;
  white-space: pre-line;
  font-size: 0.9rem;
}

tbody tr:hover {
  background: #f8fafc;
}

.table-wrap tbody tr {
  cursor: pointer;
}

@media (max-width: 768px) {
  .table-toggle-button {
    margin-left: auto;
  }

  .table-wrap {
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: auto;
    max-width: none;
    height: 55vh;
    margin-top: 0;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -10px 25px rgba(15, 23, 42, 0.25);
  }
}

.result-count {
  margin: 10px 2px 0;
  color: #475569;
  font-size: 0.9rem;
}

.ads-wrap {
  margin: 18px 2px 0;
}

/* iChannels Dynamic Ads */
.ichan-popup-ad {
  min-height: 20px;
}
.ichan-ad-divider {
  margin: 10px 0;
  border-top: 1px dashed #cbd5e1;
}
.ichan-ad-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.ichan-ad-content {
  font-size: 0.88rem;
  line-height: 1.5;
  color: #334155;
}
.ichan-ad-content strong {
  color: #0f172a;
}
.ichan-ad-content a {
  display: inline !important;
  margin-top: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  text-decoration: underline !important;
  color: #2563eb !important;
  background: transparent !important;
}

/* --- Auth & Modal Styles --- */
.is-hidden { display: none !important; }

.page-header .header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.auth-status {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.btn-primary, .btn-full {
  background: #2563eb;
  color: white;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-full { width: 100%; margin-top: 1rem; }
.btn-primary:hover, .btn-full:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.modal {
  position: fixed;
  z-index: 5000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.media-content { max-width: 800px; background: #000; border: none; }
.media-content .close { color: #fff; }

.close {
  position: absolute;
  right: 1rem;
  top: 0.5rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: #666;
  z-index: 10;
}

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #eee;
}

.tab-btn {
  flex: 1;
  padding: 0.8rem;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 600;
  color: #888;
}

.tab-btn.active {
  color: #2563eb;
  border-bottom: 2px solid #2563eb;
}

.divider {
  margin: 1.5rem 0;
  text-align: center;
  position: relative;
}

.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: #eee;
}

.divider span {
  background: white;
  padding: 0 10px;
  position: relative;
  color: #aaa;
  font-size: 0.8rem;
}

#loginFormSection form input, 
#registerFormSection form input {
  width: 100%;
  padding: 0.8rem;
  margin-bottom: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
}

/* --- Comment Section Styles --- */
.comment-section-header {
  font-weight: bold;
  margin: 15px 0 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
  font-size: 1rem;
}

.comment-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 15px;
}

.comment-card {
  background: #f1f5f9;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 5px;
}

.comment-user { font-weight: 700; display: flex; align-items: center; gap: 5px; }
.comment-date { color: #64748b; margin-left: auto; margin-right: 10px; }
.delete-comment-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  font-size: 1rem;
  opacity: 0.5;
  transition: opacity 0.2s;
  color: #ef4444;
  line-height: 1;
}
.delete-comment-btn:hover { opacity: 1; }
.comment-content { font-size: 0.88rem; line-height: 1.4; white-space: pre-wrap; }

.comment-media-list {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.comment-media-thumbnail {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #e2e8f0;
}

.comment-form {
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}

.comment-form textarea {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  min-height: 60px;
  margin-bottom: 8px;
  box-sizing: border-box;
  font-family: inherit;
}

.file-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.file-input-label {
  padding: 4px 10px;
  background: #e2e8f0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

#mediaPreviewBody img, #mediaPreviewBody video {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.logout-btn {
  background: none;
  border: 1px solid #cbd5e1;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.logout-btn:hover { background: #f1f5f9; }

@media (max-width: 600px) {
  .page-header .header-top { justify-content: center; text-align: center; }
}
/* Forum & Popup Buttons */
.btn-sm-primary {
  padding: 6px 10px;
  background: #3b82f6;
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}
.btn-sm-outline {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  color: #475569;
  text-decoration: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}
.btn-sm-primary:hover { background: #2563eb; }
.btn-sm-outline:hover { background: #f1f5f9; }

.comment-list-mini {
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid #f1f5f9;
  border-radius: 8px;
}

/* Forum Page Layout */
.forum-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 850px) {
  .forum-layout { grid-template-columns: 1fr; }
}

.comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.comment-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-prompt-box {
  padding: 1.5rem;
  background: #f8fafc;
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comment-form-wrap {
  position: sticky;
  top: 20px;
}

.forum-card {
  padding: 1.5rem !important;
  border-bottom: 1px solid #f1f5f9;
}
.forum-card:last-child { border-bottom: none; }

/* --- Profile Modal Specific Styles --- */
.profile-content {
  max-width: 350px;
}

.profile-avatar-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: #f8fafc;
  border-radius: 12px;
}

.avatar-preview-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  background: white;
}

.profile-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit-icon {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.5);
  color: white;
  font-size: 0.8rem;
  padding: 4px 0;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.avatar-preview-wrapper:hover .avatar-edit-icon {
  opacity: 1;
}

.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.4rem;
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-sizing: border-box;
}

.btn-secondary {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.edit-profile-btn {
  background: none;
  border: 1px solid #3b82f6;
  color: #3b82f6;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  cursor: pointer;
  margin-right: 5px;
  font-weight: 500;
}

.edit-profile-btn:hover {
  background: #eff6ff;
}

/* --- Discovery & Hot Sections --- */
.homepage-discovery {
  margin-bottom: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.discovery-section {
  background: white;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  border: 1px solid #f1f5f9;
}

.discovery-section h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.discovery-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.discovery-card {
  border: 1px solid #f1f5f9;
  padding: 1rem;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  background: #ffffff;
}

.discovery-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 20px -8px rgba(0,0,0,0.1);
  border-color: #3b82f644;
  background: #f8faff;
}

.discovery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.discovery-port {
  font-weight: 700;
  color: #2563eb;
  font-size: 0.85rem;
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 6px;
}

.discovery-user {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
}

.discovery-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #334155;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

/* --- Media List & Video Previews --- */
.comment-media-list {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.media-preview-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  border: 1px solid #f1f5f9;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Specific heights for different contexts */
.comment-media-list.discovery-mode .media-preview-container {
  height: 200px;
}

.comment-media-list.full-width-mode .media-preview-container {
  min-height: 300px;
  max-height: 500px;
}

.comment-media-thumbnail, .video-preview-wrapper video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-preview-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.video-preview-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.video-preview-wrapper:hover video {
  opacity: 1;
}

.play-icon-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 10px;
  pointer-events: none;
  transition: opacity 0.2s;
}

.video-preview-wrapper.is-playing .play-icon-overlay {
  opacity: 0;
}


/* --- Like Button Styles --- */
.like-button {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 2px 10px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
  color: #64748b;
}

.like-button:hover {
  background: #f8fafc;
  color: #ef4444;
  border-color: #fca5a5;
}

.like-button.is-liked {
  background: #fff1f2;
  border-color: #fecaca;
  color: #e11d48;
}

.like-button.is-liked .like-icon {
  transform: scale(1.1);
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #94a3b8;
  font-style: italic;
}
