:root{
  --bg: #0c0f14;
  --panel: #12161d;
  --text: #dfe7f1;
  --muted: #9fb0c4;
  --accent: #8fd3ff;
  --radius: 10px;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
}

body{
  margin: 0;
  padding-bottom: 4rem;
  background: radial-gradient(1200px 800px at 20% 10%, #111623, #0a0c10 60%, #07090c);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

.site-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  backdrop-filter: blur(8px);
  background: rgba(7,9,12,0.55);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  z-index: 20;
}

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

.brand-mark{
  filter: drop-shadow(0 0 6px rgba(143,211,255,.8));
}

.brand-name{
  font-weight: 600;
}

.actions .button{
  margin-left: 8px;
}

.intro{
  max-width: 800px;
  margin: 22px auto 10px;
  padding: 0 18px;
  color: var(--muted);
}

.intro p {
  padding: 12px;
  border: 1px solid gray;
  border-radius: 10px;
  background-color: #1a2136;
  color: white;
  text-align: center;
  font-weight: bold;
}

.grid{
  --size: 35px;      /* base tile size */
  --gap: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--size), 1fr));
  gap: var(--gap);
  padding: 14px 18px 40px;
}

.tile{
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 6px;
  background: hsl(var(--h) var(--s) var(--l) / calc(var(--alpha, 1)));
  box-shadow:
    0 0 16px hsl(var(--h) var(--s) calc(var(--l) + 8%) / calc(max(var(--alpha,1) * .8, .35))),
    inset 0 0 12px hsl(var(--h) var(--s) calc(var(--l) + 12%) / calc(max(var(--alpha,1) * .25, .2)));
  cursor: pointer;
  transition: transform .08s ease, box-shadow .2s ease;
  animation: pulse 5.5s ease-in-out infinite alternate;
  will-change: transform, box-shadow;
}

.tile:hover{
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 0 22px hsl(var(--h) var(--s) calc(var(--l) + 12%) / .9),
    inset 0 0 16px hsl(var(--h) var(--s) calc(var(--l) + 16%) / .35);
}

@keyframes pulse{
  0%{ filter: brightness(0.96); }
  100%{ filter: brightness(1.07); }
}

.button{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.button:hover{
  border-color: rgba(255,255,255,0.28);
}
.button--ghost{
  background: transparent;
}

.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal[aria-hidden="false"]{
  display: flex;
}

.modal-card{
  width: min(680px, 92vw);
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 20px 90px rgba(0,0,0,.45);
}

textarea{
  width: 100%;
  min-height: 120px;
  background: #0b0f14;
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  resize: vertical;
}

.form-row{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.spacer{ flex: 1; }

.note-wrap{
  padding: 4px;
}



#noteText {
  /* Properties from the second, more specific block */
  font-size: 1.1rem;
  font-weight: bold;
  padding: 12px;
  border-radius: 10px;
  background-color: #1a2136;
  color: white;
  margin: 0 0 10px 0; /* This is more specific than just margin-bottom */
  
  /* Useful properties from the first block */
  text-align: center;
  line-height: 1.4;
}

#noteMeta {
  /* All properties combined and deduplicated */
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

.sr-only{
  position: absolute !important;
  height: 1px; width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* motion sensitivity */
@media (prefers-reduced-motion: reduce){
  .tile{ animation: none; }
  .tile:hover{ transform: none; }
}
.kofi-btn {
  display: inline-block;
  background: #1a2136;
  color: #fff;
  font-weight: 600;
  padding: 0.7em 1em;
  border-radius: 8px;
  margin-left: 0.8em;
  text-decoration: none;
  transition: background 0.2s ease, transform 0.2s ease;
  font-size: 0.8em;
}

.kofi-btn:hover {
    background: #ff7676;
    transform: translateY(-2px);
}

.add-btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #ffd75e, #ffcc00);
  color: #222;
  font-weight: 700;
  padding: 0.8em 1.6em;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.add-btn:hover {
  transform: translateY(-2px);
}

/* The sparkle effect */
.add-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
}

/* shimmer animation */
@keyframes shimmer {
  0% {
    left: -75%;
  }
  100% {
    left: 125%;
  }
}

/* run the shimmer occasionally */
.add-btn.shimmer::before {
  animation: shimmer 1.8s ease-in-out;
}

/* run it on a passive timer */
@keyframes shimmer-timer {
  0%, 97% { opacity: 1; }
  98%, 100% { opacity: 1; } /* maintain active appearance */
}

/* optional subtle glow during the shimmer */
.add-btn.shimmer {
  box-shadow: 0 0 8px rgba(255, 215, 94, 0.5);
}

.discover-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(20, 22, 30, 0.95); /* matches dark theme */
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
  padding: 0.7em 0.5em;
  z-index: 10;
}

.discover-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  padding: 0.4em 1em;
  font-size: 0.95em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.discover-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.discover-btn.active {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* --- Base styles for header buttons --- */
.actions {
  display: flex;
  gap: 0.6em;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}


/* ************************* */
/* Mobile layout adjustments */
/* ************************* */
@media (max-width: 600px) {
  .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.4em;
    margin-top: 0.5em;
  }

  .actions .add-btn,
  .actions .kofi-btn {
    width: 100%;
    font-size: 1rem;
    padding: 0.6em 0.8em;
    border-radius: 8px;
  }

  .discover-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0.6em;
    gap: 0.6em;
    -webkit-overflow-scrolling: touch;
  }

  .discover-btn {
    flex: 0 0 auto; /* prevent shrinking */
    font-size: 0.9rem;
    padding: 0.5em 0.9em;
  }

  /* optional: small scroll hint fade */
  .discover-bar::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    width: 30px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(20,22,30,0.95));
    pointer-events: none;
  }
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(to right, #ffd369, #8fd3ff);
  width: 0%;
  z-index: 100;
  transition: width 0.15s linear;
}

#load-more{ display:block; height:1px; margin:120px 0; }
/* Add this to the bottom of styles.css */
.category-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.category-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.category-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Style for the user-selected or AI-suggested category */
.category-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(143,211,255,.5);
}

/* A slightly different style for the AI's first suggestion */
.category-btn.suggested {
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 10px rgba(143,211,255,.2);
}

.amplify-btn {
  background: transparent;
  border-color: #ffd75e;
  color: #ffd75e;
  transition: all 0.2s ease;
}
.amplify-btn:hover:not(:disabled) {
  background: #ffd75e;
  color: #222;
  box-shadow: 0 0 10px #ffd75e;
}
.amplify-btn:disabled {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.amplify-count {
  color: var(--muted);
  min-width: 20px;
}

/* Add a subtle glow to the modal card using the tile's color */
#readModalCard {
  /* HSL color variables will be applied here by JavaScript */
  box-shadow: 0 0 50px hsl(var(--h, 200) var(--s, 70%) calc(var(--l, 60%) - 15%) / 0.3);
  border: 1px solid hsl(var(--h, 200) var(--s, 70%) var(--l, 60%) / 0.2);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* A clean horizontal line to separate content from actions */
.modal-separator {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.1), transparent);
  margin: 1rem 0;
}

/* Use flexbox for the action bar */
.modal-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Group the amplify button and its counter */
.amplify-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Style the counter to be more distinct */
.amplify-count {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  min-width: 30px;
  text-align: center;
}

/* Make the close button less prominent */
#closeRead.button--ghost {
    color: var(--muted);
}
#closeRead.button--ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

/* --- Amplify Pulse Effect --- */

@keyframes amplify-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 16px hsl(var(--h) var(--s) calc(var(--l) + 8%) / calc(max(var(--alpha,1) * .8, .35)));
  }
  50% {
    transform: scale(1.3);
    box-shadow: 0 0 28px hsl(var(--h) var(--s) calc(var(--l) + 15%) / .95);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 16px hsl(var(--h) var(--s) calc(var(--l) + 8%) / calc(max(var(--alpha,1) * .8, .35)));
  }
}

/* This class will be temporarily added by JavaScript to trigger the animation */
.tile--amplified {
  animation: amplify-pulse 1.2s ease-out;
}

.share-btn {
  background: transparent;
  color: var(--muted);
}
.share-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}