:root {
  --bg: #14110e;
  --bg-2: #1c1814;
  --ink: #f3ece2;
  --muted: #9c9184;
  --line: #2c261f;
  --paper: #221d18;
  --shooting: #c9a227;
  --submission: #d36b3a;
  --publish: #e8e2d6;
  --class: #c9a227;
  --awareness: #8aa8c2;
  --authority: #b59ad4;
  --urgency: #c45c4a;
  --proof: #7ea37a;
  --ip: #d4a574;
  --studio: #7ea37a;
  --brand: #8aa8c2;
  --hyrox: #c45c4a;
  --mixed: #b59ad4;
  --high: #c45c4a;
  --medium: #c9893a;
  --low: #6f7a72;
  --today: #f2c14e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", sans-serif;
}

body {
  background-image:
    radial-gradient(ellipse at top, #221c16 0%, transparent 55%),
    linear-gradient(#14110e, #0f0d0b);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 28px 72px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
  gap: 32px;
  align-items: end;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 8px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "Newsreader", serif;
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.lede {
  max-width: 420px;
  margin: 14px 0 0;
  color: #d8cfc3;
  line-height: 1.5;
}

.muted {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  padding: 16px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  font-family: "Newsreader", serif;
  font-size: 28px;
  font-weight: 600;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin: 28px 0 16px;
  flex-wrap: wrap;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.view-btn {
  height: 36px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.view-btn.active {
  background: #322a22;
  color: var(--ink);
}

.filters-bar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-group {
  display: grid;
  gap: 8px;
}

.filter-label {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.date-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.date-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.date-toggle.active {
  color: var(--ink);
  border-color: #5a4e40;
  background: #2a241e;
}

.date-toggle[data-phase="shooting"].active {
  border-color: var(--shooting);
}

.date-toggle[data-phase="submission"].active {
  border-color: var(--submission);
}

.date-toggle[data-phase="publish"].active {
  border-color: var(--publish);
}

.date-toggle[data-campaign="01"].active {
  border-color: var(--awareness);
}

.date-toggle[data-campaign="02"].active {
  border-color: var(--authority);
}

.date-toggle[data-campaign="03"].active {
  border-color: var(--ip);
}

.legend-note {
  color: #6f675c;
  font-size: 12px;
}

.table-wrap {
  margin-top: 4px;
}

.table-panel {
  padding-bottom: 18px;
}

.table-scroll {
  overflow: auto;
}

.posts-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.posts-table th,
.posts-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.posts-table th {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

.posts-table .title-cell {
  font-weight: 500;
  min-width: 180px;
}

.posts-table .date-shooting {
  color: var(--shooting);
}

.posts-table .date-submission {
  color: var(--submission);
}

.posts-table .date-publish {
  color: var(--publish);
}

.posts-table .hook-cell {
  color: #d8cfc3;
  max-width: 280px;
}

.posts-table .muted-cell {
  color: #6f675c;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #2a241e;
}

.agenda .sub strong {
  color: #b9aea0;
  font-weight: 500;
  margin-right: 4px;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-nav h2 {
  margin: 0;
  min-width: 220px;
  text-align: center;
  font-family: "Newsreader", serif;
  font-size: 28px;
  font-weight: 500;
}

.nav-btn,
.today-btn,
.drawer-close,
select {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
}

.nav-btn,
.today-btn {
  height: 36px;
  cursor: pointer;
}

.nav-btn {
  width: 36px;
  font-size: 22px;
  line-height: 1;
}

.today-btn {
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
}

.today-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.empty {
  padding: 12px 0;
  color: var(--muted);
}

.nav-btn:hover,
.drawer-close:hover {
  border-color: #5a4e40;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter {
  display: grid;
  gap: 4px;
}

.filter span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

select {
  min-width: 150px;
  max-width: 240px;
  padding: 8px 10px;
  font: inherit;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dot,
.swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
}

.dot {
  border-radius: 50%;
}

.dot.shooting {
  background: var(--shooting);
}

.dot.submission {
  background: var(--submission);
}

.dot.publish {
  background: var(--publish);
}

.dot.class {
  background: var(--class);
}

.swatch.ssf,
.mark.ssf {
  background: var(--awareness);
}

.swatch.nsca,
.mark.nsca {
  background: var(--authority);
}

.swatch.jason,
.mark.jason {
  background: var(--ip);
}

.swatch.awareness,
.mark.awareness {
  background: var(--awareness);
}

.swatch.authority,
.mark.authority {
  background: var(--authority);
}

.swatch.urgency,
.mark.urgency {
  background: var(--urgency);
}

.swatch.proof,
.mark.proof {
  background: var(--proof);
}

.swatch.class,
.mark.class {
  background: var(--class);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}

.layout[hidden],
.table-wrap[hidden],
.month-nav[hidden],
.drawer[hidden],
.drawer-backdrop[hidden] {
  display: none !important;
}

.calendar-wrap,
.panel,
.drawer {
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.weekday-row,
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  border-bottom: 1px solid var(--line);
}

.weekday-row span,
.date-num {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.weekday-row span {
  padding: 10px 8px;
  color: var(--muted);
  text-transform: uppercase;
}

.day {
  min-height: 132px;
  padding: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day:nth-child(7n) {
  border-right: 0;
}

.day.outside {
  color: #5d554c;
  background: #171410;
}

.day.today {
  outline: 1px solid var(--today);
  outline-offset: -1px;
}

.date-num {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.events {
  display: grid;
  gap: 4px;
}

.chip {
  display: grid;
  grid-template-columns: 6px 1fr;
  gap: 6px;
  width: 100%;
  padding: 4px 5px;
  border: 0;
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  line-height: 1.25;
  background: #2a241e;
}

.chip .mark {
  width: 6px;
}

.chip.shooting {
  border-left-color: var(--shooting);
}

.chip.submission {
  border-left-color: var(--submission);
}

.chip.publish {
  border-left-color: var(--publish);
}

.chip.class {
  border-left-color: var(--class);
}

.chip .label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chip:hover {
  background: #352d25;
}

.chip .meta {
  color: var(--muted);
  font-size: 10px;
}

.more {
  width: 100%;
  padding: 3px 0 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  text-align: left;
}

.panel {
  padding: 18px 16px 8px;
}

.panel h3,
.drawer h3 {
  margin: 0 0 14px;
  font-family: "Newsreader", serif;
  font-size: 22px;
  font-weight: 500;
}

.agenda {
  list-style: none;
  margin: 0;
  padding: 0;
}

.agenda li + li {
  border-top: 1px solid var(--line);
}

.agenda button {
  width: 100%;
  padding: 12px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.agenda time {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.agenda time .dot {
  flex: 0 0 10px;
}

.agenda .name {
  margin: 4px 0 2px;
}

.agenda .sub {
  color: var(--muted);
  font-size: 12px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.62);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100%);
  height: 100%;
  padding: 28px;
  overflow: auto;
}

.drawer-close {
  margin-bottom: 20px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}

.drawer h2 {
  margin: 0 0 8px;
  font-family: "Newsreader", serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.pill {
  padding: 4px 8px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.pill.ssf {
  color: var(--awareness);
  border-color: #3d4d5c;
}

.pill.nsca {
  color: var(--authority);
  border-color: #4a3d5c;
}

.pill.jason {
  color: var(--ip);
  border-color: #5c4a36;
}

.pill.high {
  color: var(--high);
}

.pill.medium {
  color: var(--medium);
}

.pill.low {
  color: var(--low);
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline div {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.remarks a {
  display: inline-block;
  margin-top: 8px;
  color: var(--publish);
}

.post-list {
  max-height: 360px;
  overflow: auto;
  margin-bottom: 8px;
}

.rail {
  display: grid;
  gap: 16px;
  align-content: start;
}

.timeline span {
  color: var(--muted);
}

.remarks {
  margin-top: 20px;
  padding: 14px;
  background: var(--paper);
  color: #e6ddd1;
  line-height: 1.5;
}

.label-short,
.filter-short {
  display: none;
}

@media (max-width: 1100px) {
  .masthead,
  .layout {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 42px;
  }

  .day {
    min-height: 108px;
  }
}

@media (max-width: 720px) {
  html,
  body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  .app {
    padding: 16px 12px calc(36px + env(safe-area-inset-bottom));
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .masthead {
    gap: 16px;
    padding-bottom: 18px;
  }

  h1 {
    font-size: 32px;
    line-height: 1.05;
  }

  .lede {
    max-width: none;
    font-size: 14px;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px 8px;
  }

  .stat b {
    font-size: 20px;
  }

  .toolbar,
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-top: 18px;
  }

  .month-nav {
    justify-content: space-between;
    gap: 8px;
  }

  .month-nav h2 {
    min-width: 0;
    flex: 1;
    font-size: 20px;
  }

  .nav-btn,
  .today-btn,
  .view-btn,
  .date-toggle {
    min-height: 44px;
  }

  .view-toggle {
    width: 100%;
  }

  .view-btn {
    flex: 1;
  }

  .date-toggles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-group:last-child .date-toggles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .date-toggle {
    justify-content: center;
    padding: 0 8px;
    font-size: 12px;
  }

  .legend {
    gap: 10px 12px;
    font-size: 12px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .rail {
    order: 2;
  }

  .calendar-wrap {
    order: 1;
    overflow: hidden;
  }

  .weekday-row span {
    padding: 8px 2px;
    text-align: center;
    font-size: 10px;
  }

  .day {
    min-height: 74px;
    padding: 5px 3px;
  }

  .day.has-events {
    cursor: pointer;
  }

  .date-num {
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
  }

  .today-tag {
    display: none;
  }

  .day-count {
    margin-left: auto;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: #322a22;
    color: var(--ink);
    font-size: 9px;
    text-align: center;
  }

  .chip {
    grid-template-columns: 4px 1fr;
    gap: 3px;
    padding: 2px 3px;
    font-size: 9px;
    border-left-width: 2px;
  }

  .chip .mark {
    width: 4px;
  }

  .label-full,
  .chip .meta {
    display: none;
  }

  .label-short {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .more {
    font-size: 10px;
  }

  .panel {
    padding: 14px 12px 6px;
  }

  .post-list {
    max-height: none;
  }

  .posts-table {
    min-width: 0;
  }

  .posts-table thead {
    display: none;
  }

  .posts-table,
  .posts-table tbody,
  .posts-table tr,
  .posts-table td {
    display: block;
    width: 100%;
  }

  .posts-table tr {
    margin-bottom: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    background: var(--paper);
  }

  .posts-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 0;
  }

  .posts-table td::before {
    content: attr(data-label);
    flex: 0 0 72px;
    color: var(--muted);
    font-family: "IBM Plex Mono", monospace;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .posts-table .title-cell {
    min-width: 0;
    font-weight: 600;
  }

  .drawer {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    max-height: min(88vh, 760px);
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
  }

  .drawer-close {
    min-height: 44px;
  }

  .table-scroll {
    overflow: visible;
  }

  .filter-long {
    display: none;
  }

  .filter-short {
    display: inline;
  }

  .drawer h2 {
    font-size: 24px;
  }

  .timeline div {
    grid-template-columns: 88px 1fr;
    gap: 8px;
  }
}
