/* =====================================================================
   Stream calendar
   ===================================================================== */
.streams-page { overflow-x: hidden; }
.streams-main { padding-bottom: calc(160 * var(--u)); }

.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-button:hover { color: var(--brown); }

.streams-panel {
  width: min(94vw, 1700px);
  margin: 0 auto;
}

.streams-toolbar {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.2vw, 16px);
  flex-wrap: wrap;
  margin-bottom: clamp(24px, 4vh, 48px);
}
.month-label {
  flex: 1;
  margin: 0;
  text-align: center;
  font-family: var(--body);
  font-weight: 800;
  font-size: clamp(22px, 2.6vw, 40px);
  line-height: 1.1;
  color: var(--cream);
  text-shadow: 0 0.08em 0.25em rgba(0, 0, 0, 0.35);
}
.month-btn,
.tool-btn {
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 0 12px 2px rgba(0, 0, 0, 0.18), 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.month-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0 0 4px;
  font-size: 30px;
  line-height: 1;
}
.tool-btn {
  min-height: 44px;
  padding: 0.45em 1.1em;
  font-size: clamp(12px, 1.1vw, 16px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.month-btn:hover,
.tool-btn:hover { background: #fff3b8; transform: translateY(-1px); }
.tool-btn.is-on { background: var(--brown); color: var(--cream); }
.streams-tools { display: flex; gap: 8px; margin-left: auto; }

/* ---------------------------------------------------------------- calendar */
.calendar {
  --hex: clamp(30px, 8.6vw, 168px);
  --cal-gap: clamp(3px, 0.8vw, 14px);
  --pad-x: calc((var(--hex) + var(--cal-gap)) / 2);
}
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, var(--hex));
  gap: var(--cal-gap);
  justify-content: center;
  padding-inline: var(--pad-x);
  margin-bottom: calc(var(--cal-gap) * 1.4);
  color: var(--cream);
  font-weight: 800;
  font-size: clamp(10px, 1vw, 15px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
}
.calendar-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-inline: var(--pad-x);
}
.cal-week {
  display: flex;
  gap: var(--cal-gap);
}
/* Pointy-top hexes interlock when consecutive rows overlap by a quarter of
   their height. Without this the days read as separate rows, not a honeycomb. */
.cal-week + .cal-week { margin-top: calc(var(--hex) * -0.2887 + var(--cal-gap)); }
.cal-week.is-offset { transform: translateX(var(--pad-x)); }

.cal-hex {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--hex);
  height: calc(var(--hex) * 1.1547);
  padding: 0;
  border: 0;
  background: none;
  color: #7a5317;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.2s ease, transform 0.2s ease;
}
.cal-hex::before,
.cal-hex::after {
  content: "";
  position: absolute;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  pointer-events: none;
}
.cal-hex::before {
  inset: 0;
  background: linear-gradient(180deg, #d99a17, #ffc23e);
}
.cal-hex::after {
  inset: 6%;
  background: linear-gradient(180deg, #ffedb0, #ffd35e);
}
.cal-hex:hover { filter: brightness(1.06) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25)); transform: translateY(-1px); }
.cal-hex:focus-visible { outline: none; filter: drop-shadow(0 0 0.45rem #fff3b8); }
.cal-hex.is-today::before { background: linear-gradient(180deg, #ffe17e, #fff3b8); }
.cal-hex.is-today::after { background: linear-gradient(180deg, #fff7d1, #ffe17e); }
.cal-hex.is-blank { visibility: hidden; pointer-events: none; }
/* Days that belong to the next month: faded so the current month reads clearly. */
.cal-hex.is-outmonth {
  filter: saturate(0.32) brightness(0.88);
  opacity: 0.62;
}
.cal-hex.is-outmonth:hover { filter: saturate(0.4) brightness(0.95); opacity: 0.75; }

.cal-daynum {
  position: absolute;
  top: 9%;
  z-index: 1;
  min-width: 1.6em;
  padding: 0 0.25em;
  border-radius: 999px;
  font-size: clamp(9px, 1.15vw, 16px);
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}
.cal-hex.is-today .cal-daynum { background: var(--brown); color: var(--cream); }
.cal-icon {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 72%;
  height: 72%;
  margin-top: 10%;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.22));
}
.cal-icon svg,
.cal-icon img { width: 100%; height: 100%; object-fit: contain; overflow: visible; }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6em 1.6em;
  margin: clamp(20px, 3vh, 34px) 0 0;
  color: rgba(255, 225, 126, 0.82);
  font-size: clamp(12px, 1vw, 16px);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.calendar-legend > span { display: inline-flex; align-items: center; gap: 0.5em; }
.legend-icon { display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; }
.legend-icon svg,
.legend-icon img { width: 100%; height: 100%; object-fit: contain; }
.legend-hex {
  width: 1.2em;
  height: 1.4em;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background: linear-gradient(180deg, #ffe9a8, #f7d03c);
  border: 2px solid #ce741a;
}
.legend-hex-muted {
  background: linear-gradient(180deg, #bdb184, #9a8a5e);
  border-color: #7d6a3e;
  filter: saturate(0.32) brightness(0.9);
}
.calendar-status {
  min-height: 1.5em;
  margin: 0.8em 0 0;
  text-align: center;
  color: rgba(255, 225, 126, 0.72);
  font-size: clamp(12px, 1vw, 15px);
}

/* ---------------------------------------------------------------- day modal */
.day-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 48px);
  background: rgba(20, 12, 0, 0.82);
  -webkit-backdrop-filter: blur(4px);
          backdrop-filter: blur(4px);
}
.day-modal[hidden] { display: none; }
.day-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(86dvh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(22px, 3.4vw, 46px);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow:
    inset calc(-31 * var(--u)) calc(-60 * var(--u)) calc(129.4 * var(--u)) rgba(255, 198, 105, 0.17),
    inset calc(65 * var(--u)) calc(31 * var(--u)) calc(115.7 * var(--u)) rgba(0, 0, 0, 0.25),
    0 30px 80px rgba(0, 0, 0, 0.55);
  color: var(--cream);
}
.day-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.day-modal-close:hover { filter: brightness(1.08); }
.day-modal-title {
  margin: 0 0 0.1em;
  padding-right: 48px;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(26px, 4vw, 48px);
  line-height: 1.1;
}
.day-modal-sub {
  margin: 0 0 1.2em;
  color: rgba(255, 225, 126, 0.78);
  font-weight: 700;
}
.day-empty {
  margin: 0;
  padding: 1.2em;
  border-radius: calc(var(--radius) * 0.5);
  background: rgba(255, 225, 126, 0.08);
  text-align: center;
  font-weight: 700;
}
.stream-entry {
  padding: 1em 0;
  border-top: 1px solid rgba(255, 225, 126, 0.2);
}
.stream-entry:first-of-type { border-top: 0; }
.stream-entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  flex-wrap: wrap;
}
.stream-entry-title {
  margin: 0;
  font-weight: 800;
  font-size: clamp(18px, 1.8vw, 26px);
  line-height: 1.15;
}
.stream-entry-time {
  font-weight: 800;
  color: #ffd75e;
  white-space: nowrap;
}
.stream-entry-desc { margin: 0.45em 0 0; }
.stream-entry-link { display: inline-block; margin-top: 0.5em; color: #ffd75e; font-weight: 800; }
.stream-entry-off { color: #cfd8de; font-weight: 800; }
.stream-entry-actions { display: flex; gap: 8px; margin-top: 0.7em; }
.stream-entry-category {
  display: flex;
  align-items: center;
  gap: 0.55em;
  margin-top: 0.6em;
  font-weight: 700;
  color: rgba(255, 225, 126, 0.9);
}
.stream-entry-catimg {
  width: 2.6em;
  height: 3.5em;
  border-radius: 6px;
  object-fit: cover;
  background: #4a2b00;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ---------------------------------------------------------------- edit form */
.edit-box {
  margin-top: 1.2em;
  padding-top: 1.2em;
  border-top: 1px solid rgba(255, 225, 126, 0.2);
}
.edit-box h3 { margin: 0 0 0.8em; font-size: 1.1em; }
.edit-form { display: grid; gap: 0.8em; }
.edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8em; }
.edit-field { display: grid; gap: 0.3em; font-size: 0.9em; font-weight: 700; }
.edit-field input,
.edit-field select,
.edit-field textarea {
  width: 100%;
  padding: 0.55em 0.7em;
  border: 2px solid transparent;
  border-radius: 10px;
  background: #fff3c9;
  color: var(--brown);
  font: inherit;
  font-size: 1rem;
}
.edit-field textarea { min-height: 5.5em; resize: vertical; }
.edit-category { position: relative; }
.edit-category-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border-radius: 10px;
  background: #2a1c00;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}
.edit-category-opt {
  display: flex;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  padding: 5px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--cream);
  font: inherit;
  font-size: 0.92em;
  text-align: left;
  cursor: pointer;
}
.edit-category-opt:hover,
.edit-category-opt:focus-visible { background: rgba(255, 225, 126, 0.16); outline: none; }
.edit-category-opt img { width: 1.7em; height: 2.3em; border-radius: 4px; object-fit: cover; }
.edit-category-none { padding: 6px 8px; color: rgba(255, 225, 126, 0.6); font-size: 0.9em; }
.edit-field input:focus,
.edit-field select:focus,
.edit-field textarea:focus { outline: none; border-color: #ffd75e; box-shadow: 0 0 0 3px rgba(255, 215, 94, 0.3); }
.edit-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  min-height: 44px;
  padding: 0.5em 1.1em;
  border: 0;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn-ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 2px rgba(255, 225, 126, 0.55); }
.btn-danger { background: #ffb4a0; color: #5a1200; }
.edit-error { margin: 0; color: #ffb4a0; font-weight: 700; }
.edit-hint { margin: 0; color: rgba(255, 225, 126, 0.68); font-size: 0.85em; }

@media (max-width: 360px) {
  .calendar { --hex: clamp(30px, 9vw, 40px); --cal-gap: 3px; }
}

@media (max-width: 700px) {
  .streams-toolbar { justify-content: center; }
  .month-label { flex-basis: 100%; order: -1; }
  .streams-tools { margin-left: 0; }
  .edit-row { grid-template-columns: 1fr; }
  .day-modal { padding: 0; place-items: end stretch; }
  .day-card { width: 100%; max-height: 92dvh; border-radius: var(--radius) var(--radius) 0 0; }
}
