/* Version: 2.6.0 */
/* Changelog: Added YouTube channel header button with hover animation and glowing badge */

:root {
  color-scheme: light;
  --bg: #0b0f19;
  --surface: #151d2f;
  --surface-hover: #1c263d;
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.15);
  --accent: #6366f1;
  --success: #10b981;
  --amber: #f59e0b;
  --line: rgba(255, 255, 255, 0.08);
  --border-radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Compact Modern Header */
.site-header {
  background: linear-gradient(135deg, #070a12 0%, #0f172a 60%, #172033 100%);
  border-bottom: 1px solid var(--line);
  padding: 18px 24px 16px;
  position: relative;
  overflow: hidden;
}

.site-header::after {
  content: "";
  position: absolute;
  top: -80px;
  right: 8%;
  width: 280px;
  height: 160px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
}

.header-actions {
  display: flex;
  align-items: center;
}

.youtube-channel-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(220, 38, 38, 0.22) 100%);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #ffffff;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  transition: all 0.25s ease;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.15);
  backdrop-filter: blur(8px);
}

.youtube-channel-btn:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #f87171;
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
  color: #ffffff;
}

.yt-play-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #ff0000;
  color: #ffffff;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 900;
  padding-left: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.youtube-channel-btn:hover .yt-play-icon {
  background: #ffffff;
  color: #ff0000;
}

.yt-info {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  text-align: left;
}

.yt-title {
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.yt-handle {
  font-size: 0.72rem;
  color: #fca5a5;
  font-weight: 500;
}

.youtube-channel-btn:hover .yt-handle {
  color: #fee2e2;
}

.yt-external-arrow {
  font-size: 0.85rem;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.youtube-channel-btn:hover .yt-external-arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
  }
  .youtube-channel-btn {
    width: 100%;
    justify-content: center;
  }
}

.header-branding {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-badge-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.portal-badge {
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.version-tag {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.2;
  background: linear-gradient(135deg, #ffffff 40%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro {
  margin: 0;
  color: #94a3b8;
  font-size: 0.86rem;
  line-height: 1.4;
}

main {
  padding: 18px 0 50px;
}

/* Category filter tabs */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.cat-btn {
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
}

.cat-btn:hover {
  background: var(--surface-hover);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}

.cat-btn.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: 210px 180px 1fr;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 4px;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 700;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  background: #0b0f19;
  font: inherit;
  font-size: 0.88rem;
  transition: border-color 0.2s;
}

select:focus,
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  padding: 10px 16px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.stat-card strong {
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
}

.stat-card span {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
}

.stat-online strong {
  color: var(--primary);
}

.stat-success strong {
  color: var(--success);
}

/* Section heading */
.section-heading {
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0 0 4px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.section-heading p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* Project grid */
.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--border-radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: #475569;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.project-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.project-card h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.35;
  color: #fff;
}

.project-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.badge-category {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.75rem;
}

.badge-status {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge-status.success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-status.partial {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-status.experiment {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.project-summary {
  margin: 0;
  font-size: 0.92rem;
  color: #cbd5e1;
  line-height: 1.55;
  flex-grow: 1;
}

.project-tools {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.project-tools span {
  display: inline-block;
  background: #0f172a;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 4px;
  margin-top: 4px;
  border: 1px solid #1e293b;
}

.project-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-launch {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-launch:hover {
  background: linear-gradient(135deg, #0369a1, #1d4ed8);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

.btn-doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  background: #0f172a;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-doc:hover {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
  background: #1e293b;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

.empty {
  text-align: center;
  padding: 48px;
  color: var(--text-dim);
  font-size: 1.05rem;
}

.site-footer {
  text-align: center;
  padding: 32px 24px;
  color: #64748b;
  font-size: 0.88rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 768px) {
  .toolbar {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .project-list {
    grid-template-columns: 1fr;
  }
}

/* Modal Reader */
.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(800px, 100%);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #fff;
  font-weight: 800;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 6px;
  border-radius: 6px;
  transition: all 0.15s;
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  color: #e2e8f0;
  line-height: 1.7;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  color: #fff;
  margin-top: 20px;
  margin-bottom: 10px;
}

.markdown-body h1 {
  font-size: 1.6rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.markdown-body h2 {
  font-size: 1.3rem;
}

.markdown-body ul {
  padding-left: 20px;
}

.markdown-body li {
  margin-bottom: 6px;
}

.markdown-body code {
  background: #0f172a;
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--primary);
}

.markdown-body pre {
  background: #0f172a;
  border: 1px solid var(--line);
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
}

/* Markdown Link & Content Enhancements */
.markdown-body a {
  color: #38bdf8;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
  transition: color 0.15s ease;
}

.markdown-body a:hover {
  color: #7dd3fc;
}

.markdown-body blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.6);
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  color: #cbd5e1;
}

/* Modal Quick Bar & Attachments */
.modal-quick-bar {
  background: #0b0f19;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-quick-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-quick-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.modal-quick-date {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
}

.modal-quick-tools {
  font-size: 0.82rem;
  color: #94a3b8;
}

.modal-launch-btn {
  padding: 8px 18px;
  font-size: 0.88rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  display: inline-flex;
  align-items: center;
}

.modal-attachments-card {
  margin-top: 20px;
  padding: 16px 20px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 10px;
}

.modal-attachments-card h4 {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 800;
}

.modal-attachments-card ul {
  margin: 0;
  padding-left: 20px;
}

.modal-attachments-card li {
  margin-bottom: 6px;
  font-size: 0.92rem;
  color: #cbd5e1;
}

/* Portal Gate Lock */
.gate-lock-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gate-lock-backdrop.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-lock-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 36px 30px;
  width: min(400px, 100%);
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 40px rgba(56, 189, 248, 0.15);
  animation: modalFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.gate-lock-icon {
  font-size: 3.2rem;
  margin-bottom: 12px;
}

.gate-lock-card h2 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
}

.gate-lock-subtitle {
  margin: 0 0 24px;
  font-size: 0.92rem;
  color: var(--text-dim);
}

#gateLockForm {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#gatePasswordInput {
  width: 100%;
  padding: 14px 16px;
  background: #0f172a;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  color: #fff;
  font-size: 1.25rem;
  text-align: center;
  letter-spacing: 6px;
  font-weight: 700;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#gatePasswordInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

#gateUnlockBtn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #0284c7, #2563eb);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

#gateUnlockBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.55);
}

.gate-lock-error {
  margin: 14px 0 0;
  color: #f87171;
  font-size: 0.9rem;
  font-weight: 600;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
