:root {
  --bg: #0f1c2e;
  --bar: #1a2c43;
  --card: #172940;
  --line: #2f455f;
  --text: #f1f4f8;
  --muted: #b4c0ce;
  --accent: #d4b27a;
  --accent-soft: #d4b27a;
  --gold: #d4b27a;
  --danger: #ff9d9d;
  --pill: #172940;
  --pill-text: #f1f4f8;
  --brand-gradient: linear-gradient(100deg, #8a6a3a 0%, #e7cf9f 50%, #8a6a3a 100%);
  --on-accent: #15263d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 'Be Vietnam Pro', system-ui, sans-serif;
  font-synthesis: none;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
a { color: var(--accent-soft); }
h2 { margin: 0; font-size: 16px; font-weight: 600; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 8px 240px;
  background: var(--card);
  color: var(--text);
}
.topbar::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--brand-gradient);
}
.brand { position: absolute; left: 16px; display: flex; }
.brand img { display: block; width: auto; height: 34px; }
.back + .brand { left: 48px; }
.brand { text-decoration: none; }
.brand-mark { display: flex; flex-direction: column; color: var(--text); font-family: 'Oswald', 'Be Vietnam Pro', sans-serif; line-height: 1.15; white-space: nowrap; }
.brand-mark > span, .brand-name { color: inherit; font-size: 21px; font-weight: 700; letter-spacing: .01em; text-decoration: none; }
.brand-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand-phone { margin-top: 3px; color: var(--accent); font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 11px; font-weight: 600; text-decoration: none; }
.brand-mark small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .42em; }
.auth-button {
  position: absolute;
  right: 16px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.auth-button:hover { background: #e7cf9f; }
.login-dialog {
  width: min(380px, calc(100vw - 32px));
  color: var(--text);
}
.login-dialog:not([open]) { display: none; }
.login-dialog::backdrop { background: rgba(5, 4, 30, .7); }
#admin-panel { margin-bottom: 8px; }
.admin-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-link { font-size: 14px; }
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.back { position: absolute; left: 16px; color: var(--accent); font-size: 22px; text-decoration: none; }

.page { max-width: 1120px; margin: 0 auto; padding: 16px 16px 64px; }

.tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 28px;
  padding: 4px;
  border-radius: 999px;
  background: var(--pill);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .35);
}
.tabs button {
  padding: 9px 18px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--pill-text);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }

.drop-zone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 120px;
  padding: 12px;
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  cursor: pointer;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--accent-soft); background: var(--card); }
.drop-zone:focus-within { border-color: var(--accent-soft); }
.drop-zone.busy { opacity: .7; pointer-events: none; }
.drop-zone img { width: 84px; height: 96px; object-fit: cover; border-radius: 10px; flex: none; }
.drop-text { display: flex; flex: 1; flex-direction: column; gap: 4px; text-align: center; }
.drop-text span { color: var(--muted); font-size: 13px; }

.status { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.status.error, .error { color: var(--danger); }
.error { margin: 0; font-size: 13px; }
ul.error { padding-left: 18px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 24px 0 14px;
}
.count { font-weight: 600; font-size: 14px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-left: auto; }

.level { display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; }
.level button {
  padding: 4px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.level button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.link-btn {
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}
.link-btn:hover { color: var(--text); }
.link-btn.strong { color: var(--accent-soft); font-weight: 600; }
.link-btn.danger { color: var(--danger); }

.empty {
  margin: 40px auto;
  max-width: 460px;
  color: var(--muted);
  text-align: center;
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.grid::after { content: ''; flex: 99999 1 0; }
.tile {
  position: relative;
  flex: calc(var(--ratio, 1) * 100) 1 calc(var(--ratio, 1) * 230px);
  aspect-ratio: var(--ratio, 1);
  overflow: hidden;
  border-radius: 14px;
  background: var(--bar);
}
/* Ô theo đúng tỷ lệ ảnh nên không cắt mất logo ở góc trái phía dưới. */
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile img.fade { opacity: 0; transform: scale(1.02); transition: opacity .5s ease, transform .7s ease; }
.tile img.fade.loaded { opacity: 1; transform: none; }
.tile-open:hover img { transform: scale(1.03); }
.tile-open img { transition: transform .5s ease; }
@media (hover: hover) {
  .tile-pick:not([aria-pressed="true"]), .tile-delete, .tile-cover { opacity: 0; transition: opacity .2s ease; }
  .tile:hover .tile-pick, .tile:hover .tile-delete, .tile:hover .tile-cover, .tile :focus-visible { opacity: 1; }
}
.tile-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; }
.tile-pick, .tile-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(10, 8, 50, .35);
  color: #fff;
  line-height: 1;
}
.tile-delete { right: auto; left: 8px; font-size: 16px; }
.tile-delete[data-armed] {
  width: auto;
  padding: 0 8px;
  border-color: var(--danger);
  border-radius: 999px;
  background: #7a1f2b;
  font-size: 12px;
}
#delete-event[data-armed] { font-weight: 600; }
.tile-pick[aria-pressed="true"] {
  background: var(--accent);
  box-shadow: inset 0 0 0 4px var(--accent), inset 0 0 0 12px #fff;
}
.tile.selected { outline: 3px solid var(--accent-soft); outline-offset: -3px; }

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(5, 4, 30, .96);
  color: #fff;
  --accent-soft: #fff;
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: transparent; }
.lightbox > img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-bar {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}
.nav { position: absolute; top: 50%; transform: translateY(-50%); }
.nav.prev { left: 12px; }
.nav.next { right: 12px; }

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.narrow { max-width: 380px; margin: 48px auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.row a { overflow-wrap: anywhere; }

input:not(.sr-only), select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
}
.primary {
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  white-space: nowrap;
}
progress { width: 100%; accent-color: var(--accent-soft); }

.drop-zone.center { justify-content: center; }

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.event-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  text-decoration: none;
}
.event-card:hover { border-color: var(--accent-soft); }
.event-cover { position: relative; aspect-ratio: 16 / 10; background: var(--bar); }
.event-cover { overflow: hidden; }
.event-cover img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 20%; transition: transform .7s ease; }
.event-card { transition: transform .3s ease, box-shadow .3s ease, border-color .3s ease; }
.event-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0, 0, 0, .4); }
.event-card:hover .event-cover img { transform: scale(1.05); }
.event-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(10, 8, 50, .8);
  font-size: 12px;
}
.event-body { display: flex; flex: 1; flex-direction: column; gap: 6px; padding: 14px 16px 16px; }
.event-body strong { font-size: 17px; font-weight: 600; line-height: 1.35; }
.event-body p {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.event-count { margin-top: auto; padding-top: 4px; color: var(--muted); font-size: 13px; }

.event-description { max-width: 620px; margin: 0; white-space: pre-line; }

/* Ảnh bìa và trang trí */
.ornament { display: block; width: min(240px, 60vw); height: auto; margin: 2px auto; color: var(--gold); }
.hero-eyebrow { margin: 0; color: var(--gold); font-family: 'Playfair Display', Georgia, serif; font-size: 18px; font-style: italic; }
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  min-height: min(68vh, 560px);
  padding: 90px 16px 44px;
  background: linear-gradient(135deg, #1e3a5f 0%, #15263d 100%);
  color: #fff;
  text-align: center;
}
.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  animation: hero-drift 24s ease-in-out infinite alternate;
}
.hero.has-image::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(to top, rgba(15, 28, 46, .9) 0%, rgba(15, 28, 46, .45) 48%, rgba(15, 28, 46, .15) 100%);
}
.hero-content { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: rise-in .9s ease both; }
.hero-content h1 { margin: 0; font-size: clamp(28px, 5vw, 48px); font-weight: 700; line-height: 1.3; }
.hero-content .hero-eyebrow, .hero-content .ornament { color: #e7cf9f; }
.hero-content .event-description { color: rgba(255, 255, 255, .88); }
.hero-button {
  margin-top: 8px;
  padding: 13px 30px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #e7cf9f 0%, #c9a266 100%);
  color: #15263d;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
  transition: transform .2s ease, box-shadow .2s ease;
}
.hero-button:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0, 0, 0, .36); }
.hero-count { margin: 0; color: rgba(255, 255, 255, .78); font-size: 13px; letter-spacing: .04em; }
.home-intro { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 44px 16px 8px; text-align: center; animation: rise-in .9s ease both; }
.home-intro h1 { margin: 0; color: var(--text); font-size: clamp(26px, 4.5vw, 40px); font-weight: 700; line-height: 1.3; }
.home-intro > p:last-child { max-width: 520px; margin: 0; color: var(--muted); }
#event-tabs { scroll-margin-top: 76px; margin-top: 8px; }

.petals { position: absolute; z-index: 2; inset: 0; overflow: hidden; pointer-events: none; }
.petal {
  position: absolute;
  top: -24px;
  width: 11px;
  height: 15px;
  border-radius: 80% 10% 80% 10%;
  background: rgba(244, 222, 180, .72);
  animation: petal-fall 15s linear infinite;
}
.petal-1 { left: 7%; animation-delay: 0s; }
.petal-2 { left: 21%; animation-delay: 5s; animation-duration: 18s; transform: scale(.7); }
.petal-3 { left: 36%; animation-delay: 9s; }
.petal-4 { left: 52%; animation-delay: 2s; animation-duration: 19s; }
.petal-5 { left: 67%; animation-delay: 7s; animation-duration: 16s; }
.petal-6 { left: 81%; animation-delay: 12s; }
.petal-7 { left: 93%; animation-delay: 4s; animation-duration: 20s; }
@keyframes petal-fall {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(0deg); }
  10% { opacity: 1; }
  85% { opacity: .8; }
  100% { opacity: 0; transform: translate3d(70px, 620px, 0) rotate(380deg); }
}
@keyframes hero-drift { from { transform: scale(1.02); } to { transform: scale(1.1); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .petals { display: none; }
  .hero-image, .hero-content, .home-intro { animation: none; }
  .tile img.fade, .tile-open img, .event-card, .event-cover img { transition: none; }
}
.tile-cover {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 8, 50, .75);
  color: #fff;
  font-size: 12px;
}
.history-title { margin: 4px 0 8px; font-size: 14px; font-weight: 600; }
.drive-history { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.drive-history li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.drive-history li > div { display: flex; flex-direction: column; min-width: 0; }
.drive-history a { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.drive-history span { color: var(--muted); font-size: 12px; }
.drive-history button { flex: none; }
.stack-label { margin-bottom: -6px; color: var(--muted); font-size: 13px; }
.check-row { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 14px; }
.check-row input { flex: none; width: auto; margin-top: 3px; }
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 18px max(16px, calc((100% - 1088px) / 2));
  border-top: 1px solid var(--line);
  background: var(--card);
}
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.contact a.primary { color: var(--on-accent); text-decoration: none; }
.contact-link { color: var(--accent); font-weight: 600; }

@media (max-width: 640px) {
  .topbar { padding: 8px 100px 8px 112px; }
  .topbar:has(.back) { padding-left: 150px; }
  .topbar h1 { font-size: 14px; }
  .brand-mark > span, .brand-name { font-size: 14px; }
  .brand-line { gap: 4px; }
  .brand-phone { margin-top: 2px; font-size: 9.5px; }
  .brand-mark small { margin-top: 2px; font-size: 7px; letter-spacing: .4em; }
  .back + .brand { left: 40px; }
  .auth-button { right: 10px; padding: 6px 10px; font-size: 12px; }
  .back { left: 12px; }
  .admin-tools { grid-template-columns: 1fr; }
  .row:has(> #drive-url) { flex-wrap: wrap; }
  #drive-url { flex-basis: 100%; }
  .grid { gap: 5px; }
  .tile { flex-basis: calc(var(--ratio, 1) * 130px); border-radius: 8px; }
  .tabs button { padding: 8px 12px; font-size: 13px; }
  .drop-zone img { width: 64px; height: 76px; }
  .toolbar-actions { margin-left: 0; width: 100%; justify-content: space-between; }
}
