:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --border: #e6e8ee;
  --text: #11131a;
  --muted: #626b7a;
  --brand: #1db954; /* Spotify green hint */
  --brand-dark: #169443;
  --accent: #1b6efe;
  --danger: #e53935;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 16px;
}

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

.brand-logo { position: relative; display: inline-block; overflow: visible; }
.brand-logo .logo { 
  width: 100px;
  height: 100px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
  overflow: visible;
}

/* Only animate flames - body stays still */
.logo .flame-main { 
  animation: flameFlicker 0.6s ease-in-out infinite;
  transform-origin: 65px 95px;
}
.logo .flame-inner { 
  animation: flameFlicker 0.4s ease-in-out infinite;
  transform-origin: 60px 97px;
}
.logo .flame-spark { 
  animation: flameFlicker 0.5s ease-in-out infinite;
  transform-origin: 58px 99px;
}

@keyframes flameFlicker {
  0%, 100% { transform: scale(1) translateX(0); opacity: 0.9; }
  50% { transform: scale(1.15) translateX(-2px); opacity: 1; }
}

.brand h1 {
  font-size: 24px;
  margin: 0;
  letter-spacing: 0.2px;
}

.brand .dotcom { color: var(--muted); font-weight: 500; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.share { display: flex; gap: 8px; align-items: center; }
.auth { display: flex; gap: 8px; align-items: center; }
.hidden { display: none !important; }

.main { display: grid; gap: 20px; padding: 20px 0 40px; }

/* Extra safety: hide composer unless admin */
body:not(.is-admin) #composer { display: none !important; }
body:not(.is-admin) #clear-wall { display: none !important; }

.composer {
  display: grid;
  gap: 12px;
}

.add-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.form-extra { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-extra textarea { grid-column: 1 / -1; }
.checkbox-row { grid-column: 1 / -1; display: inline-flex; gap: 8px; align-items: center; color: var(--text); }

.content { display: grid; grid-template-columns: 1fr; gap: 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.wall-header, .favorites-header { display: flex; align-items: center; justify-content: space-between; }

.weekly-container { margin-top: 10px; }
.weekly-container .frame { width: 100%; height: 352px; border: 0; border-radius: 12px; overflow: hidden; }

.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.tile { position: relative; }
.tile .frame { width: 100%; height: 352px; border: 0; border-radius: 12px; overflow: hidden; }
.tile .meta { margin: 6px 4px 0; }
.tile .meta .title { font-weight: 700; }
.tile .meta .desc { color: var(--muted); margin-top: 2px; }
.tile .meta .tags { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: #f8fafc; color: #334155; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.tile .tile-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn:hover { background: #f6f8fb; }
.btn:active { transform: translateY(1px); }

.btn.primary { background: var(--brand); border-color: var(--brand); color: #001f0f; font-weight: 700; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #00160b; }
.btn.subtle { background: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #300; }

.input {
  width: 100%;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.input[readonly] {
  opacity: 0.9;
}

.hint { color: var(--muted); margin: 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
}
.footer-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }

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

/* Collapsible Wall Section */
.wall-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  cursor: pointer;
  user-select: none;
  background: white;
  position: relative;
  z-index: 1;
  border-radius: 8px 8px 0 0;
  transition: background-color 0.2s ease;
}

.wall-header:hover {
  background-color: #f8f9fa;
}

.toggle-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.5rem;
  margin: -0.5rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.toggle-button h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.toggle-icon {
  transition: transform 0.2s ease-in-out;
  margin-left: auto;
  color: var(--muted);
}

[aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

.wall-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  transition: opacity 0.3s ease-in-out, height 0.3s ease-in-out;
  overflow: hidden;
  position: relative;
  background: white;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Smooth transition for the grid when collapsing/expanding */
.wall-grid[style*="display: none"] {
  display: grid !important;
  opacity: 0;
  height: 0 !important;
  padding-top: 0;
  padding-bottom: 0;
  margin-top: 0;
  margin-bottom: 0;
  border: none;
  overflow: hidden;
  transition: opacity 0.3s ease-in-out, height 0.3s ease-in-out, padding 0.3s ease-in-out, margin 0.3s ease-in-out;
}

/* Empty state */
.wall-grid p {
  grid-column: 1 / -1;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
}

/* View All button */
#view-all {
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
}

#view-all:hover {
  background: var(--border);
}

/* Ensure the wall grid has proper spacing */
.wall {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .wall-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .wall-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .toggle-button {
    width: 100%;
  }
}

/* Playlist Comments */
.playlist-comments-container {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.playlist-comments-section {
  margin-top: 0.5rem;
}

.playlist-comments-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding-right: 0.25rem;
}

.playlist-comment {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9em;
}

.playlist-comment:last-child {
  margin-bottom: 0;
}

.playlist-comment .comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  font-size: 0.85em;
  color: var(--muted);
}

.playlist-comment .comment-author {
  font-weight: 600;
  color: var(--text);
}

.playlist-comment .comment-time {
  font-size: 0.8em;
  opacity: 0.8;
}

.playlist-comment .comment-content {
  margin: 0;
  line-height: 1.4;
  word-break: break-word;
}

.playlist-comment-form {
  margin-top: 0.75rem;
}

.comment-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.comment-input-wrapper {
  display: flex;
  gap: 0.5rem;
}

.comment-input-wrapper .input {
  flex: 1;
  padding: 0.5rem;
  font-size: 0.9em;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.comment-input-wrapper .btn {
  padding: 0.5rem 1rem;
  font-size: 0.9em;
  white-space: nowrap;
}

.view-all-comments {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.85em;
  padding: 0.25rem;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-align: center;
}

.view-all-comments:hover {
  text-decoration: underline;
}

/* Comments Modal */
.comments-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.comments-modal-content {
  background: var(--bg);
  border-radius: 8px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

.comments-modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem;
  line-height: 1;
}

.comments-modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.comments-modal .playlist-comment {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
}

.comments-modal .playlist-comments-list {
  max-height: none;
  margin-top: 1rem;
}

/* Make sure the comment form is sticky at the bottom in the modal */
.comments-modal .playlist-comment-form {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 1rem;
  border-top: 1px solid var(--border);
  margin: 0 -1rem -1rem;
}

/* Comments Section */
.comments-section {
    margin-top: 2rem;
    padding: 1.5rem;
}

.comments-section h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text);
}

.comments-list {
    margin-bottom: 1.5rem;
}

.comment {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--muted);
}

.comment-author {
    font-weight: 600;
    color: var(--text);
}

.comment-time {
    color: var(--muted);
    font-size: 0.8em;
}

.comment-content {
    line-height: 1.5;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.comment-form {
    margin-top: 1.5rem;
}

.comment-form .input {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.comment-form .input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.2);
}

.comment-form textarea.input {
    min-height: 100px;
    resize: vertical;
}

.comment-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.comment-actions .input {
    flex: 1;
}

.comment-actions .btn {
    white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .comment-actions {
        flex-direction: column;
    }
    
    .comment-actions .input,
    .comment-actions .btn {
        width: 100%;
    }
}

@media (max-width: 860px) {
  .content { grid-template-columns: 1fr; }
}

/* Auth dialog */
.auth-dialog::backdrop { background: rgba(0,0,0,0.25); }
.auth-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; }
.auth-form { display: grid; gap: 10px; padding: 16px; min-width: 320px; }
.actions-row { display: flex; gap: 8px; justify-content: flex-end; }


