:root {
  --font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  --hour-row-height: 56px;
  --bg: #f5f1e8;
  --season-bg-start: #f8fafc;
  --season-bg-end: #f8fafc;
  --current-day-accent: #9aa8b3;
  --panel: #fffdf9;
  --text: #1f2430;
  --muted: #6d6b62;
  --grid: #dfd6c4;
  --accent: #125b50;
  --danger: #8a1c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background: linear-gradient(135deg, var(--season-bg-start), var(--season-bg-end));
  color: var(--text);
}

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 40px;
  gap: 12px;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0.4px;
}

.subtle {
  margin: 4px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn {
  border: 1px solid var(--grid);
  background: #f4efe4;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.nav-arrow {
  min-width: 38px;
  font-size: 16px;
  line-height: 1;
  padding: 8px 10px;
}

.btn-accent {
  background: var(--accent);
  color: #f7fffb;
  border-color: var(--accent);
}

.btn-danger {
  background: #fff2f2;
  border-color: #f0c1c1;
  color: var(--danger);
}

.auth-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #fff3da;
  padding: 10px 14px;
}

.hidden {
  display: none;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: .625em;
  text-align: right;
}

.refresh-ring {
  --ring-progress: 1;
  width: 1.15em;
  height: 1.15em;
  border-radius: 50%;
  flex: 0 0 auto;
  background: conic-gradient(var(--accent) calc(var(--ring-progress) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0);
  opacity: 1;
  transition: opacity 0.2s ease;
}

.refresh-ring.is-empty {
  opacity: 0;
}

.refresh-ring.spinning {
  opacity: 1;
  background: conic-gradient(var(--accent) 0deg 290deg, transparent 290deg 360deg);
  animation: refresh-ring-spin 0.8s linear infinite;
}

@keyframes refresh-ring-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.calendar-ids {
  border: 1px solid var(--grid);
  border-radius: 12px;
  background: #f8f4eb;
  padding: 10px 12px;
}

.calendar-ids-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.calendar-ids-actions {
  display: flex;
  gap: 8px;
}

.calendar-ids-output {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
  background: #fffdf9;
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 8px;
}

.snippet-wrap {
  margin-top: 10px;
}

.snippet-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.calendar-snippet {
  margin: 0;
  white-space: pre-wrap;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
  background: #fffdf9;
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 8px;
}

.calendar-wrap {
  flex: 1;
  min-height: 0;
  background: transparent;
  overflow: auto;
}

.calendar {
  min-width: 980px;
  height: 100%;
}

.calendar-head,
.calendar-body {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
}

.calendar-head {
  align-items: stretch;
}

.calendar-body {
  border-top: solid 1px var(--grid);
}

.time-head,
.day-head {
  border-bottom: 0px solid var(--grid);
  border-right: 0px solid var(--grid);
  padding: 11px 8px 8px 8px;
  background: transparent;
}

.day-head {
  min-height: 58px;
  text-align: center;

  .day-name {
    font-weight: 300;
    text-transform: uppercase;
    font-size: .75em;
  }

  .day-date {
    font-weight: 400;
    font-size: 1.5em;
    color: var(--muted);
  }

  &.current-day {
    border-top: solid 5px;
    border-top-color: var(--current-day-accent);
    padding-top: 6px;

    .day-name {
      font-weight: 500;
    }
    .day-date {
      font-weight: 700;
    }
  }
}

.day-weather {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 0.7em;
  color: var(--muted);
  line-height: 1;
}

.day-weather-icon {
  font-size: 2em;
  line-height: 1;
}

.day-weather-high {
  color: var(--text);
  font-weight: 500;
}

.day-weather-low {
  font-weight: 400;
}

.all-day-span {
  z-index: 2;
  align-self: center;
  margin: 0 1px;
  height: 18px;
  line-height: 18px;
  padding: 0 6px;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.all-day-time-bg,
.all-day-lane-bg {
  z-index: 1;
  background: transparent;
  border-right: 1px solid var(--grid);
}

.all-day-lane-bg.weekend {
  background: transparent;
}

.time-label {
  position: relative;
  border-right: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  padding: 0;
  height: 56px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;

  &:last-child {
    border-bottom-width: 0;
  }
}

.time-label span {
  position: relative;
  display: block;
  top: -0.6667em;
  width: 44px;
  background: var(--bg);
  text-align: right;
  padding-right: .5em;
  z-index: 1;
}

.day-col {
  position: relative;
  border-right: 1px solid var(--grid);
  height: 895px;
  background: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--hour-row-height) - 1px),
    rgba(122, 118, 104, 0.25) calc(var(--hour-row-height) - 1px),
    rgba(122, 118, 104, 0.25) var(--hour-row-height)
  );

  &.weekend {
    background-color: rgba(100,100,100,.1);
  }
}

.event {
  position: absolute;
  left: 0;
  right: 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  padding: 6px;
  overflow: hidden;
  color: #fff;
  box-shadow: 0 2px 10px rgba(31, 36, 48, 0.2);
}

.event-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.event-meta {
  font-size: 11px;
  line-height: 1.2;
  opacity: 0.95;
}

.event-image {
  position: absolute;
  pointer-events: none;
  height: auto;
  border-radius: 6px;

  &.logo {
    width: 80%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: .2;
    object-fit: contain;
    max-height: 80%;
  }

  &.icon {
    max-width: 50%;
    min-width: 1em;
    max-height: 70%;
    right: 4px;
    bottom: 4px;
    opacity: .2;
    object-fit: contain;
  }
}
.now-indicator {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--current-day-accent);
  border-radius: 1px;
  z-index: 10;
  pointer-events: none;

  &::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--current-day-accent);
  }
}
/* ── Year progress bar ───────────────────────────────────── */
.year-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100vh;
  display: flex;
  align-items: flex-end;
  padding: 0 16px 12px;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.year-bar__track {
  position: relative;
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  transition: height 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              background 1.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.year-bar__highlight {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  border-radius: 4px;
  background: var(--current-day-accent);
  opacity: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  transition: left 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              width 0.45s cubic-bezier(0.4, 0, 0.2, 1),
              top 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              height 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              border-radius 1.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.year-bar__week-text {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.year-bar__today {
  position: absolute;
  top: 50%;
  transform: translateX(-50%) translateY(-50%);
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.3s ease, left 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.year-bar__today.visible {
  opacity: 1;
}

.year-bar.pulse .year-bar__today {
  opacity: 0;
}

.year-bar__months {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.year-bar__month {
  position: absolute;
  top: 97%;
  transform: translateX(-50%);
  opacity: 0;
  transition: top 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.75s ease;
}

.year-bar__month:nth-child(1) {
  transition-delay: 0ms;
}
.year-bar__month:nth-child(2) {
  transition-delay: 70ms;
}
.year-bar__month:nth-child(3) {
  transition-delay: 140ms;
}
.year-bar__month:nth-child(4) {
  transition-delay: 210ms;
}
.year-bar__month:nth-child(5) {
  transition-delay: 280ms;
}
.year-bar__month:nth-child(6) {
  transition-delay: 350ms;
}
.year-bar__month:nth-child(7) {
  transition-delay: 420ms;
}
.year-bar__month:nth-child(8) {
  transition-delay: 490ms;
}
.year-bar__month:nth-child(9) {
  transition-delay: 560ms;
}
.year-bar__month:nth-child(10) {
  transition-delay: 630ms;
}
.year-bar__month:nth-child(11) {
  transition-delay: 700ms;
}
.year-bar__month:nth-child(12) {
  transition-delay: 770ms;
}

.year-bar__month-tick {
  width: 1px;
  height: 0;
  margin: 0 auto;
  background: rgba(0, 0, 0, 0.25);
  transition: height 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              background 1.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.year-bar__month-label {
  margin-top: 8px;
  position: absolute;
  top: 50%;
  left: -1.5em;
  width: 3em;
  text-align: center;
  font-size: 1.1em;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.5);
  letter-spacing: 0.5px;
  border-radius: 9px;
  background-color: transparent;
  transition: font-size 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 1.55s cubic-bezier(0.4, 0, 0.2, 1),
              color 1.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.year-bar.pulse .year-bar__track,
.year-bar.pulse .year-bar__highlight,
.year-bar.pulse .year-bar__month-tick,
.year-bar.pulse .year-bar__month-label {
  transition-delay: 0ms;
}

.year-bar:not(.pulse) .year-bar__track,
.year-bar:not(.pulse) .year-bar__highlight,
.year-bar:not(.pulse) .year-bar__month-tick,
.year-bar:not(.pulse) .year-bar__month-label {
  transition-delay: 900ms;
}

.year-bar.pulse {
  .year-bar__track {
    height: calc(100vh - 24px);
  }

  .year-bar__track {
    border-radius: 30px;
    background: rgba(0, 0, 0, 0.9);
  }

  .year-bar__highlight {
    height: 20vh;
    top: 9.5vh;
    border-radius: 12px;

    .year-bar__week-text {
      opacity: 1;
      transform: translateY(0);
      white-space: normal;
      font-size: 1em;
      text-align: center;
    }
  }

  .year-bar__month {
    opacity: 1;
    top: 1.5%;

    &:first-child {
      .year-bar__month-label {
        left: 0;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        width: 2.25em;
      }
    }

    &:last-child {
      .year-bar__month-label {  
        right: 0;
        left: auto;
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        width: 2.25em;
      }
    }

    .year-bar__month-tick {
      height: calc(100vh - 66px);
      background: white;
    }

    .year-bar__month-label {
      font-size: 2em;
      background-color: white;
      color: rgba(0, 0, 0, 0.7);
    }
  }
}

@media (max-width: 900px) {
  .year-bar.pulse .year-bar__highlight {
    height: 58px;
  }

  .year-bar__week-text {
    font-size: 10px;
  }

  .year-bar__month-label {
    font-size: 10px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}
