* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(180px, auto) 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
  font-weight: 760;
}

.brand h1 a {
  color: inherit;
  text-decoration: none;
}

.brand h1 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.brand .powered-by {
  margin-top: 3px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
}

.brand .range {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 420px) auto auto auto auto auto;
  justify-content: center;
  gap: 10px;
}

.search {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.segmented button {
  min-width: 82px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
}

.calendar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.calendar-link:hover {
  border-color: var(--accent);
}

.summary {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.metric {
  min-width: 92px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  display: block;
  font-size: 16px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.layout {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 0;
}

.sidebar {
  position: sticky;
  top: 63px;
  align-self: start;
  height: calc(100vh - 63px);
  padding: 14px 12px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel-deep);
}

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

.team-toggle {
  display: grid;
  grid-template-columns: 18px 10px 1fr auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.team-toggle:hover,
.team-toggle.active {
  border-color: var(--line);
  background: var(--panel);
}

.team-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.team-toggle:nth-child(3n + 2) .dot {
  background: var(--accent-2);
}

.team-toggle:nth-child(3n + 3) .dot {
  background: var(--accent-3, #c44a1e);
}

.team-toggle:not(.active) .dot,
.team-toggle:not(.active) .team-name,
.team-toggle:not(.active) .team-count {
  opacity: 0.48;
}

.team-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  font-weight: 650;
  line-height: 1.25;
}

.team-count {
  color: var(--muted);
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 16px;
}

.board {
  display: grid;
  gap: 18px;
}

.date-section {
  min-width: 0;
  scroll-margin-top: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-deep);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.date-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.date-section-head:hover {
  background: var(--hover-bg);
}

.date-section-head:focus-visible {
  outline: 3px solid var(--accent-outline);
  outline-offset: -3px;
}

.is-collapsed .date-section-head {
  border-bottom: 0;
}

.date-title-wrap {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.date-chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease;
  flex: 0 0 auto;
}

.is-collapsed .date-chevron {
  transform: rotate(-45deg);
}

.date-title {
  min-width: 0;
  font-size: 15px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.date-section-body {
  display: block;
}

.is-collapsed .date-section-body {
  display: none;
}

.date-summary {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--hover-bg);
}

.date-summary > p {
  margin: 0;
  line-height: 1.55;
}

.team-summaries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.team-summary {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border-inner);
  border-radius: 8px;
  background: var(--panel);
}

.team-summary-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: baseline;
}

.team-summary-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-summary-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.team-summary p {
  margin: 7px 0 0;
  color: var(--text-2);
  line-height: 1.5;
}

.team-summary ul {
  margin: 7px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.date-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 320px);
  gap: 12px;
  padding: 12px;
  align-items: start;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-gutter: stable;
}

.lane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.lane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.lane-title {
  min-width: 0;
  font-size: 15px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.3;
}

.lane-body {
  display: grid;
  gap: 10px;
  padding: 10px;
}

.lane-body .day {
  position: static;
}

.lane-empty {
  padding: 18px 10px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.timeline {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.day {
  position: sticky;
  top: 76px;
  z-index: 8;
  justify-self: center;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.message {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border-inner);
  border-radius: 8px;
  background: var(--panel);
}

.message:hover {
  border-color: var(--border-hover);
}

.message-main {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text-2);
  overflow: hidden;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-content {
  min-width: 0;
}

.message-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
}

.author {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 720;
}

.time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.team-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin-top: 7px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text-2);
  font-size: 12px;
}

.text {
  margin-top: 7px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.attachments {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.attachment {
  display: block;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--hover-bg);
  color: var(--accent);
  text-decoration: none;
}

.attachment img,
.attachment video {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--img-bg);
}

.file-link {
  padding: 9px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.empty {
  margin: 32px auto;
  max-width: 460px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
  color: var(--muted);
}

.file-loader {
  margin-top: 12px;
}

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

  .toolbar {
    grid-template-columns: minmax(120px, 1fr) auto auto auto auto auto;
    gap: 8px;
  }

  .summary {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .team-filter {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .day {
    top: 0;
  }
}

@media (max-width: 620px) {
  .topbar,
  .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .brand h1 {
    font-size: 15px;
  }

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

  .search {
    flex: 1 1 100%;
    width: 100%;
    height: 36px;
  }

  .segmented {
    flex: 1 1 100%;
    display: flex;
    width: 100%;
  }

  .segmented button {
    flex: 1;
    min-width: 0;
    height: 30px;
  }

  .calendar-link {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    padding: 0 6px;
    font-size: 12px;
  }

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

  .sidebar {
    padding: 8px 10px;
    overflow-x: auto;
  }

  .team-filter {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    grid-template-columns: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .team-filter::-webkit-scrollbar {
    display: none;
  }

  .team-toggle {
    flex: 0 0 auto;
    width: auto;
    min-width: auto;
    white-space: nowrap;
    grid-template-columns: 18px 10px auto auto;
  }

  .team-name {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .date-grid {
    grid-auto-columns: minmax(250px, 86vw);
  }
}
