:root {
  --bg: #f1f5f9;
  --bar: #e5e7eb;
  --card: #ffffff;
  --line: #cbd5e1;
  --text: #111827;
  --muted: #4b5563;
  --accent: #3000d9;
  --accent-soft: #3000d9;
  --danger: #c81e1e;
  --pill: #ffffff;
  --pill-text: #111827;
  --brand-gradient: radial-gradient(circle at 50% 190%, rgba(220, 54, 111, .6) 0%, rgba(0, 0, 0, 0) 60%), linear-gradient(100deg, #6f1fa1 0%, #3000d9 58%, #5900dc 100%);
  color-scheme: light;
}

* { 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;
}

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 170px;
  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; }
.auth-button {
  position: absolute;
  right: 16px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.auth-button:hover { background: #2700ad; }
.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 4px rgba(17, 24, 39, .12);
}
.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: #fff; }

.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: #fff; }

.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: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 14px;
  background: var(--card);
}
.tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.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: #fff;
  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 img { display: block; width: 100%; height: 100%; object-fit: cover; }
.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: 16px; font-weight: 600; }
.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: 720px; margin: 0 auto 18px; color: var(--muted); text-align: center; white-space: pre-line; }
.tile-cover {
  position: absolute;
  bottom: 8px;
  left: 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;
}

@media (max-width: 640px) {
  .topbar { padding: 8px 100px 8px 112px; }
  .topbar h1 { font-size: 14px; }
  .brand img { height: 24px; }
  .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 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .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; }
}
