/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Brand colors from logo */
  --navy: #1B2A4A;
  --navy-light: #2C3E6B;
  --teal: #2A9D8F;
  --teal-light: #3AB8A8;
  --yellow: #F2B705;
  --yellow-light: #FFD44D;
  --orange: #E76F51;
  --orange-light: #F4845F;
  --kraft: #D2B48C;
  --kraft-light: #E8D5B7;
  --kraft-bg: #F5EDE0;
  --kraft-dark: #C4A882;
  --card-bg: #FFFDF8;
  --text: #1B2A4A;
  --text-light: #5C6B8A;
  --white: #FFFFFF;
  --shadow: 0 3px 12px rgba(27,42,74,.1);
  --shadow-hover: 0 8px 28px rgba(27,42,74,.16);
  --radius: 14px;
  --transition: .3s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: "Noto Sans TC", "PingFang TC", -apple-system, sans-serif;
  background: var(--kraft-bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  /* subtle kraft paper texture */
  background-image: url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }

/* ===== Navigation ===== */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy);
  padding: 0 2rem;
  box-shadow: 0 2px 16px rgba(27,42,74,.2);
}
.navbar .container {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 68px;
}
.navbar .logo {
  display: flex; align-items: center; gap: .75rem;
  font-size: 1.3rem; font-weight: 800; color: var(--white);
  letter-spacing: .5px;
}
.navbar .logo .brand-i { color: var(--yellow); }
.navbar .logo img {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover;
  border: 2px solid var(--yellow);
}
.nav-links { display: flex; gap: .5rem; list-style: none; }
.nav-links a {
  padding: .5rem 1.1rem; border-radius: 24px;
  font-weight: 600; font-size: .95rem;
  color: rgba(255,255,255,.7);
  transition: var(--transition);
  border: 2px solid transparent;
}
.nav-links a:hover {
  color: var(--white);
  background: rgba(255,255,255,.1);
}
.nav-links a.active {
  background: var(--yellow);
  color: var(--navy);
  border-color: var(--yellow);
}

/* hamburger */
.hamburger { display: none; background: none; border: none; font-size: 1.5rem; color: var(--white); }

@media (max-width: 768px) {
  .hamburger { display: block; }
  .nav-links {
    display: none; flex-direction: column;
    position: absolute; top: 68px; left: 0; right: 0;
    background: var(--navy); padding: 1rem; gap: .25rem;
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 4.5rem 2rem 3.5rem;
  background: var(--kraft);
  background-image:
    url("data:image/svg+xml,%3Csvg width='200' height='200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(27,42,74,.08) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 1; }
.hero h1 {
  font-size: 3.2rem; font-weight: 900;
  color: var(--navy);
  margin-bottom: .15rem;
  letter-spacing: 2px;
}
.hero h1 .brand-i { color: var(--yellow); display: inline; }
.hero .slogan {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  opacity: .6;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: .6rem;
}
.hero .subtitle {
  font-size: 1.15rem;
  color: var(--navy);
  opacity: .75;
  max-width: 500px; margin: 0 auto;
}

/* Decorative sticker-style badges */
.hero .badge-row {
  display: flex; justify-content: center; gap: 1rem;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.sticker {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem 1rem;
  border-radius: 24px;
  font-weight: 700; font-size: .85rem;
  transform: rotate(-2deg);
  box-shadow: 2px 3px 8px rgba(0,0,0,.12);
}
.sticker:nth-child(2) { transform: rotate(1.5deg); }
.sticker:nth-child(3) { transform: rotate(-1deg); }
.sticker-navy { background: var(--navy); color: var(--white); }
.sticker-teal { background: var(--teal); color: var(--white); }
.sticker-yellow { background: var(--yellow); color: var(--navy); }
.sticker-orange { background: var(--orange); color: var(--white); }

/* ===== Sections ===== */
.section {
  max-width: 1200px; margin: 0 auto;
  padding: 3rem 2rem;
}
.section-title {
  font-size: 1.5rem; font-weight: 800; margin-bottom: 1.5rem;
  color: var(--navy);
  display: flex; align-items: center; gap: .6rem;
}
.section-title::before {
  content: '';
  width: 5px; height: 1.4em;
  background: var(--yellow);
  border-radius: 3px;
}

/* ===== Cards Grid ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* ===== Album Card ===== */
.album-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
  border: 2px solid transparent;
}
.album-card:hover {
  transform: translateY(-5px) rotate(-.5deg);
  box-shadow: var(--shadow-hover);
  border-color: var(--yellow);
}
.album-card .cover {
  width: 100%; height: 220px; object-fit: cover;
}
.album-card .info { padding: 1rem 1.25rem; }
.album-card .info h3 {
  font-size: 1.05rem; margin-bottom: .3rem;
  color: var(--navy); font-weight: 700;
}
.album-card .info .meta {
  font-size: .82rem; color: var(--text-light);
  display: flex; align-items: center; gap: .4rem;
}
.album-card .info .photo-count {
  background: var(--teal);
  color: var(--white);
  padding: .1rem .5rem;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
}

/* ===== Article Card ===== */
.article-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
  padding: 1.5rem;
  border-left: 4px solid var(--yellow);
}
.article-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.article-card h3 {
  font-size: 1.1rem; margin-bottom: .5rem;
  color: var(--navy); font-weight: 700;
}
.article-card .date { font-size: .8rem; color: var(--text-light); margin-bottom: .75rem; }
.article-card .excerpt {
  font-size: .93rem; color: var(--text-light);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card .tags { margin-top: .75rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.article-card .tag {
  font-size: .75rem; padding: .2rem .65rem;
  background: var(--kraft-bg); border-radius: 20px;
  color: var(--navy); font-weight: 600;
  border: 1px solid var(--kraft-dark);
}

/* ===== Photo Grid ===== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}
.photo-grid img {
  width: 100%; height: 200px; object-fit: cover;
  border-radius: 10px; cursor: pointer;
  transition: var(--transition);
  border: 3px solid transparent;
}
.photo-grid img:hover {
  transform: scale(1.03);
  box-shadow: var(--shadow-hover);
  border-color: var(--yellow);
}

/* ===== Lightbox ===== */
.lightbox {
  display: none; position: fixed; inset: 0;
  background: rgba(27,42,74,.95); z-index: 1000;
  align-items: center; justify-content: center;
  flex-direction: column;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw; max-height: 85vh; border-radius: 10px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
}
.lightbox .close-btn {
  position: absolute; top: 1rem; right: 1.5rem;
  background: none; border: none; color: var(--yellow);
  font-size: 2.2rem; cursor: pointer;
  transition: var(--transition);
}
.lightbox .close-btn:hover { transform: scale(1.2); }
.lightbox .nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,.1); border: 2px solid rgba(255,255,255,.2);
  color: #fff;
  font-size: 2rem; padding: .5rem 1rem; border-radius: 10px;
  cursor: pointer; transition: var(--transition);
}
.lightbox .nav-btn:hover { background: var(--yellow); color: var(--navy); border-color: var(--yellow); }
.lightbox .nav-btn.prev { left: 1rem; }
.lightbox .nav-btn.next { right: 1rem; }
.lightbox .counter {
  color: rgba(255,255,255,.6); margin-top: .75rem; font-size: .9rem;
  font-weight: 600;
}

/* ===== Back Button ===== */
.back-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; border-radius: 24px;
  background: var(--card-bg); border: 2px solid var(--kraft-dark);
  font-size: .9rem; color: var(--navy);
  margin-bottom: 1.5rem; transition: var(--transition);
  font-weight: 600;
}
.back-btn:hover { background: var(--yellow); border-color: var(--yellow); }

/* ===== Modal ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(27,42,74,.5); z-index: 500;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 2rem; width: 90%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 16px 48px rgba(27,42,74,.25);
  border: 2px solid var(--kraft-dark);
}
.modal h2 { margin-bottom: 1.5rem; color: var(--navy); }
.modal label { display: block; font-weight: 700; margin-bottom: .3rem; font-size: .9rem; color: var(--navy); }
.modal input, .modal textarea, .modal select {
  width: 100%; padding: .65rem .9rem; border: 2px solid var(--kraft-dark);
  border-radius: 10px; font-size: .95rem; margin-bottom: 1rem;
  font-family: inherit; transition: var(--transition);
  background: var(--kraft-bg);
}
.modal input:focus, .modal textarea:focus {
  outline: none; border-color: var(--teal);
  background: var(--white);
}
.modal textarea { min-height: 150px; resize: vertical; }
.modal .btn-row { display: flex; gap: .75rem; justify-content: flex-end; margin-top: .5rem; }

/* ===== Buttons ===== */
.btn {
  padding: .6rem 1.4rem; border-radius: 24px;
  font-weight: 700; font-size: .9rem;
  border: 2px solid transparent; transition: var(--transition);
  letter-spacing: .3px;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-teal { background: var(--teal); color: var(--white); }
.btn-teal:hover { background: var(--teal-light); }
.btn-yellow { background: var(--yellow); color: var(--navy); }
.btn-yellow:hover { background: var(--yellow-light); }
.btn-outline {
  background: transparent; border: 2px solid var(--kraft-dark);
  color: var(--text-light);
}
.btn-outline:hover { background: var(--kraft-bg); border-color: var(--navy); color: var(--navy); }
.btn-danger { background: var(--orange); color: var(--white); }
.btn-danger:hover { background: var(--orange-light); }

.add-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  margin-bottom: 1.5rem;
}

/* ===== Article Detail ===== */
.article-detail {
  max-width: 800px; margin: 0 auto;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 2.5rem; box-shadow: var(--shadow);
  border: 2px solid var(--kraft-dark);
}
.article-detail h1 {
  font-size: 1.8rem; margin-bottom: .5rem; color: var(--navy);
}
.article-detail .meta { color: var(--text-light); font-size: .85rem; margin-bottom: 1.5rem; }
.article-detail .content { line-height: 1.9; white-space: pre-wrap; }
.article-detail .actions { margin-top: 2rem; display: flex; gap: .75rem; }

/* ===== Footer ===== */
.footer {
  text-align: center; padding: 2rem;
  background: var(--navy);
  color: rgba(255,255,255,.5);
  font-size: .85rem;
  margin-top: 3rem;
}
.footer strong { color: var(--yellow); font-weight: 700; }
.footer .footer-slogan {
  font-size: .75rem; letter-spacing: 2px; text-transform: uppercase;
  margin-top: .4rem; opacity: .6;
}

/* ===== Section Header ===== */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .75rem;
}
.section-header .section-title { margin-bottom: 0; }
.btn-sm { padding: .4rem 1rem; font-size: .82rem; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center; padding: 4rem 2rem; color: var(--text-light);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 1.05rem; }

/* ===== Nav Auth ===== */
.nav-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--yellow); color: var(--navy);
  font-size: .75rem; font-weight: 800;
  margin-right: .2rem;
}
.nav-register-btn {
  background: var(--yellow) !important;
  color: var(--navy) !important;
  border-radius: 24px !important;
}
.nav-link-logout {
  opacity: .6;
}
.nav-link-logout:hover { opacity: 1 !important; }
.nav-link-admin { color: var(--yellow) !important; }

#auth-nav { display: contents; }

/* ===== Form Card ===== */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 2px solid var(--kraft-dark);
}
.form-title {
  font-size: 1.5rem; font-weight: 800;
  color: var(--navy); margin-bottom: .25rem;
}
.form-subtitle {
  color: var(--text-light); font-size: .9rem;
  margin-bottom: 1.5rem;
}
.form-card label {
  display: block; font-weight: 700;
  margin-bottom: .3rem; font-size: .9rem; color: var(--navy);
}
.form-card input, .form-card textarea, .form-card select {
  width: 100%; padding: .65rem .9rem;
  border: 2px solid var(--kraft-dark);
  border-radius: 10px; font-size: .95rem;
  margin-bottom: 1rem; font-family: inherit;
  transition: var(--transition);
  background: var(--kraft-bg);
}
.form-card input:focus, .form-card textarea:focus {
  outline: none; border-color: var(--teal);
  background: var(--white);
}
.form-card input:disabled {
  opacity: .6; cursor: not-allowed;
}
.form-card textarea { resize: vertical; }
.form-error {
  color: var(--orange); font-size: .85rem;
  font-weight: 600; margin-bottom: .5rem;
  padding: .5rem .75rem; border-radius: 8px;
  background: rgba(231,111,81,.08);
}
.form-success {
  color: var(--teal); font-size: .85rem;
  font-weight: 600; margin-bottom: .5rem;
  padding: .5rem .75rem; border-radius: 8px;
  background: rgba(42,157,143,.08);
}
.form-footer {
  text-align: center; margin-top: 1.5rem;
  font-size: .9rem; color: var(--text-light);
}
.form-footer a {
  color: var(--navy); font-weight: 700;
  border-bottom: 2px solid var(--yellow);
}

/* ===== Profile ===== */
.profile-avatar-section {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 1.5rem;
}
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--yellow);
  display: flex; align-items: center; justify-content: center;
  background: var(--kraft);
}
.profile-avatar-placeholder {
  font-size: 2.5rem; font-weight: 800;
  color: var(--navy);
}
.profile-avatar-img {
  width: 100%; height: 100%; object-fit: cover;
}
.role-badge {
  display: inline-block;
  padding: .15rem .6rem; border-radius: 12px;
  font-size: .75rem; font-weight: 700;
}
.role-admin {
  background: var(--yellow); color: var(--navy);
}
.role-member {
  background: var(--teal); color: var(--white);
}

/* ===== Admin Panel ===== */
.admin-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 2px solid var(--kraft-dark);
}
.admin-card h3 {
  color: var(--navy); font-size: 1.1rem;
  margin-bottom: 1rem;
}
.admin-add-form {
  display: flex; gap: .75rem; flex-wrap: wrap;
  align-items: flex-end;
}
.admin-add-form input {
  flex: 1; min-width: 120px;
  padding: .5rem .75rem; border: 2px solid var(--kraft-dark);
  border-radius: 10px; font-size: .9rem;
  background: var(--kraft-bg); font-family: inherit;
  transition: var(--transition);
}
.admin-add-form input:focus {
  outline: none; border-color: var(--teal); background: var(--white);
}
.member-table { margin-top: .5rem; }
.member-row {
  display: grid;
  grid-template-columns: 1fr 1fr .7fr 1.2fr;
  gap: .5rem; align-items: center;
  padding: .65rem .5rem;
  border-bottom: 1px solid rgba(0,0,0,.06);
  font-size: .9rem;
}
.member-header {
  font-weight: 700; color: var(--text-light);
  font-size: .8rem; text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 2px solid var(--kraft-dark);
}
.member-username {
  font-family: monospace; font-size: .85rem;
  color: var(--text-light);
}
.member-actions { display: flex; gap: .5rem; }
.btn-icon {
  background: var(--kraft-bg); border: 1px solid var(--kraft-dark);
  border-radius: 8px; padding: .3rem .5rem;
  font-size: .9rem; cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--yellow); border-color: var(--yellow); }
.btn-icon-danger:hover { background: var(--orange); border-color: var(--orange); color: #fff; }

/* ===== Upload Zone ===== */
.upload-zone {
  border: 3px dashed var(--kraft-dark);
  border-radius: var(--radius);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--kraft-bg);
  margin-bottom: 1rem;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--teal);
  background: rgba(42,157,143,.05);
}
.upload-zone p { color: var(--text-light); margin-top: .5rem; }
.upload-zone small { color: var(--text-light); opacity: .6; }

/* Photo Preview */
.photo-preview {
  display: flex; flex-wrap: wrap; gap: .5rem;
  margin-bottom: 1rem;
}
.preview-item {
  position: relative; width: 100px; height: 100px;
  border-radius: 8px; overflow: hidden;
}
.preview-item img {
  width: 100%; height: 100%; object-fit: cover;
}
.preview-remove {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.6); color: #fff;
  border: none; border-radius: 50%;
  width: 22px; height: 22px; font-size: .7rem;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}
.preview-count {
  width: 100%; font-size: .85rem;
  color: var(--teal); font-weight: 600;
}

/* Upload Status */
.upload-status {
  text-align: center; padding: 1rem;
  color: var(--teal); font-weight: 600;
  font-size: .9rem;
}

/* Author Badge on Album Card */
.author-badge {
  font-size: .7rem; padding: .1rem .5rem;
  background: var(--navy); color: var(--white);
  border-radius: 10px; margin-left: .3rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .member-row {
    grid-template-columns: 1fr 1fr;
    gap: .3rem;
  }
  .member-header { display: none; }
  .admin-add-form { flex-direction: column; }
  .admin-add-form input { min-width: 100%; }
}

/* ===== Mobile FAB (Floating Action Button) ===== */
.fab-new-album {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--yellow);
  color: var(--navy);
  border: none;
  border-radius: 2rem;
  padding: .75rem 1.25rem;
  font-size: .9rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 900;
  text-decoration: none;
  align-items: center;
  gap: .4rem;
  transition: transform .2s, box-shadow .2s;
}
.fab-new-album:hover, .fab-new-album:active {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
.fab-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.fab-new-album.visible {
  display: flex;
}

@media (min-width: 769px) {
  .fab-new-album { display: none !important; }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .hero .subtitle { font-size: .95rem; }
  .section { padding: 2rem 1rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .photo-grid img { height: 140px; }
  .article-detail { padding: 1.5rem; }
  .sticker { font-size: .75rem; padding: .35rem .75rem; }
  .form-card { padding: 1.25rem; }
  .profile-avatar { width: 80px; height: 80px; }
  .upload-zone { padding: 2rem .75rem; }
  .preview-item { width: 80px; height: 80px; }
  .preview-remove { width: 26px; height: 26px; font-size: .85rem; }
  .section-header { gap: .5rem; }
  .section-header .btn-sm { font-size: .78rem; padding: .35rem .85rem; }
}
