:root {
  --bg: #0e1116;
  --fg: #e8eaed;
  --muted: #98a2b3;
  --accent: #d14b4b;
  --accent-2: #1f6f4a;
  --card: #161b22;
  --border: #2a313c;
  --radius: 10px;
  --gap: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body { min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2 { font-weight: 600; margin: 0 0 0.4em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }

.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: #ff6b6b; }
.flash { color: #7ee2a8; }

main { padding: 24px; max-width: 1100px; margin: 0 auto; }

/* Login */
.login-page { display: grid; place-items: center; min-height: 100vh; }
.login { background: var(--card); padding: 32px; border-radius: var(--radius); border: 1px solid var(--border); width: min(360px, 90vw); text-align: center; }
.login input {
  width: 100%;
  font-size: 1.8rem;
  text-align: center;
  letter-spacing: 0.5em;
  padding: 12px;
  margin: 16px 0;
  background: #0b0e12;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login button {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Calendar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.topbar .tagline { margin: 4px 0 0; color: var(--muted); }
.topbar .link, button.link {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--gap);
}

.slot {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 180px;
}
.slot { position: relative; }
.slot .motif {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 3rem;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}
.slot.opened {
  cursor: pointer;
  border: none;
  padding: 0;
  background: linear-gradient(160deg,
    hsl(var(--hue, 0) 45% 22%) 0%,
    hsl(var(--hue, 0) 55% 14%) 100%);
  color: var(--fg);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
}
.slot.opened::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 38%;
  height: 38%;
  background: linear-gradient(315deg,
    rgba(0,0,0,0.55) 0%,
    rgba(0,0,0,0.25) 45%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0.10) 100%);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  pointer-events: none;
  z-index: 3;
}
.slot.openable { aspect-ratio: 1 / 1; }
.slot.locked { aspect-ratio: 1 / 1; }
.slot .num {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(0,0,0,0.35);
  padding: 2px 8px;
  border-radius: 999px;
  z-index: 2;
}
.slot.openable button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent) 0%, #8a1f1f 100%);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 2rem;
  font-weight: 700;
  transition: filter 0.15s ease;
}
.slot.openable button:hover {
  filter: brightness(1.12);
}
.slot.openable button .num { color: white; background: transparent; font-size: 1rem; }
.slot.locked {
  display: grid;
  place-items: center;
  opacity: 0.35;
  font-size: 2rem;
  font-weight: 700;
}
.slot.opened summary {
  list-style: none;
  cursor: default;
  padding: 10px;
}
.slot.opened summary::-webkit-details-marker { display: none; }
.slot.opened .content {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}
dialog#slot-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  background: var(--card);
  color: var(--fg);
  max-width: min(720px, 92vw);
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
}
dialog#slot-dialog::backdrop { background: rgba(0,0,0,0.7); }
.dialog-inner { position: relative; padding: 20px; max-height: 88vh; overflow-y: auto; }
.dialog-close { position: absolute; top: 8px; right: 8px; }
.dialog-close button {
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 10px;
}
#slot-dialog-content h2 { margin: 0 0 12px; }
.popup-img, .popup-video {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin-bottom: 12px;
}
.popup-text { margin-bottom: 12px; }
.popup-text summary { cursor: pointer; color: var(--muted); margin-bottom: 6px; }
.popup-text pre {
  background: #0b0e12;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 40vh;
  overflow: auto;
  font-size: 0.9rem;
}
.popup-other { padding: 10px; background: #0b0e12; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 8px; }
.popup-audio { width: 100%; margin-bottom: 12px; }

/* Admin */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}
.form-row input {
  padding: 8px 10px;
  background: #0b0e12;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 180px;
}
.form-row button {
  padding: 8px 16px;
  background: var(--accent-2);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  height: 38px;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th { color: var(--muted); font-weight: 500; }
.inline { display: inline; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  background: #3a2a00;
  color: #ffd166;
  border: 1px solid #6b4d00;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

input[type="file"] {
  padding: 8px;
  background: #0b0e12;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
button.danger {
  background: transparent;
  color: #ff6b6b;
  border: 1px solid #5c2323;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
code { background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 4px; font-size: 0.85rem; }

@media (max-width: 600px) {
  main { padding: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .slot { min-height: 140px; }
}
