/* CoreMate 协作看板 —— 暖纸底 + 深墨绿顶栏 + 单一深绿强调色；卡片靠 1px 线分层 */

:root {
  --ink: oklch(0.24 0.008 60);
  --muted: oklch(0.48 0.012 60);
  --bg: oklch(0.955 0.007 90);
  --panel: oklch(0.992 0.003 90);
  --accent: oklch(0.48 0.095 160);
  --accent-soft: oklch(0.93 0.03 160);
  --line: oklch(0.875 0.009 80);
  --warn: oklch(0.945 0.05 85);
  --warn-ink: oklch(0.47 0.1 65);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --space-3xl: 3rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 2rem;
  --radius: 8px;
  --z-sticky: 3;
  --z-modal: 4;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: oklch(0.93 0.006 90);
    --muted: oklch(0.69 0.012 60);
    --bg: oklch(0.175 0.006 60);
    --panel: oklch(0.22 0.007 60);
    --accent: oklch(0.78 0.11 160);
    --accent-soft: oklch(0.29 0.035 160);
    --line: oklch(0.31 0.009 60);
    --warn: oklch(0.32 0.05 85);
    --warn-ink: oklch(0.86 0.1 85);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: var(--text-base);
  line-height: 1.55;
}

body.sheet-open {
  overflow: hidden;
}

.skip {
  position: absolute;
  left: var(--space-lg);
  top: -3rem;
  padding: var(--space-sm) var(--space-md);
  background: var(--panel);
  color: var(--ink);
  z-index: 6;
}

.skip:focus {
  top: var(--space-md);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

p {
  margin: 0;
}

/* ---------- 顶栏 ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  padding: var(--space-lg) clamp(1rem, 3vw, 2rem) var(--space-md);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.masthead-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-lg) var(--space-2xl);
  width: min(120rem, 100%);
  margin: 0 auto;
}

.brand {
  min-width: 0;
  margin-right: auto;
}

.wordmark {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.who-block {
  min-width: 0;
}

.who-kicker {
  margin: 0 0 var(--space-sm);
  color: var(--muted);
  font-size: var(--text-xs);
}

.who-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  width: fit-content;
  max-width: 100%;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--bg);
}

.who-item,
.text-btn {
  appearance: none;
  font: inherit;
  cursor: pointer;
}

.who-item {
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  padding: 0.4rem 0.75rem;
  min-height: 2.25rem;
  border-radius: 6px;
}

.who-item:hover {
  background: var(--accent-soft);
}

.who-item[aria-checked="true"] {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}

.who-item:disabled {
  opacity: 0.45;
  cursor: wait;
}

.text-btn {
  margin: 0 0 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: var(--text-sm);
  min-height: 2.25rem;
}

.text-btn:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.text-btn:disabled {
  opacity: 0.45;
  cursor: wait;
  text-decoration: none;
}

.status-line {
  margin: var(--space-md) 0 0;
  line-height: 1.5;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ---------- 次级文字 ---------- */

.muted,
.time,
.disclaimer,
.ticket-meta,
.ticket-owner,
.lane-empty,
.lane-count {
  color: var(--muted);
  font-size: var(--text-xs);
}

.muted {
  margin: 0;
}

/* ---------- 布局 ---------- */

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  width: min(120rem, calc(100% - 2rem));
  margin: var(--space-xl) auto 4rem;
}

@media (min-width: 960px) {
  .layout {
    grid-template-columns: minmax(16rem, 19rem) minmax(0, 1fr);
    gap: var(--space-2xl);
    align-items: start;
  }

  #mentions {
    position: sticky;
    top: 6.25rem;
    max-height: calc(100dvh - 7rem);
    overflow: auto;
    padding-right: var(--space-sm);
  }
}

.panel-head {
  margin: 0 0 var(--space-lg);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-head h2 {
  margin: 0 0 var(--space-xs);
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
}

.panel-head .muted {
  margin-top: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.6;
}

.subhead {
  margin: var(--space-2xl) 0 var(--space-md);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---------- 空态与错误 ---------- */

.empty {
  max-width: 42em;
  color: var(--muted);
}

.empty p {
  margin: 0;
  font-size: var(--text-base);
  line-height: 1.65;
  text-wrap: pretty;
}

.error-banner {
  max-width: 42em;
  padding: var(--space-lg) var(--space-xl);
  border: 1px solid color-mix(in srgb, var(--warn-ink) 30%, var(--line));
  border-radius: var(--radius);
  background: var(--warn);
}

.error-banner strong {
  display: block;
  margin: 0 0 var(--space-xs);
}

.error-banner p {
  margin: 0 0 var(--space-xs);
  line-height: 1.6;
}

.error-banner p:last-child {
  margin-bottom: 0;
}

.error-list {
  max-width: 42em;
  margin-top: var(--space-xl);
}

.error-list h3 {
  margin: 0 0 var(--space-xs);
  font-size: var(--text-md);
}

.error-item {
  margin: var(--space-sm) 0 0;
  color: var(--warn-ink);
  font-size: var(--text-xs);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ---------- 提及消息 ---------- */

.message {
  margin: 0 0 var(--space-lg);
  padding: var(--space-lg);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.message.severity-blocking {
  background: var(--warn);
  border-color: color-mix(in srgb, var(--warn-ink) 30%, var(--line));
}

.message-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  align-items: baseline;
  margin-bottom: var(--space-xs);
}

.who {
  font-weight: 600;
}

.ats {
  color: var(--accent);
  font-size: var(--text-sm);
}

.flags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-md);
  margin: 0;
  font-size: var(--text-xs);
  color: var(--muted);
}

.kicker {
  margin: var(--space-md) 0 var(--space-xs);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
}

.flags .kicker {
  margin: 0;
  font-weight: 400;
}

.prose,
.fyi {
  margin: 0;
  max-width: 42em;
  font-size: var(--text-base);
  line-height: 1.65;
  text-wrap: pretty;
}

.fyi {
  padding-left: 1.1rem;
}

.fyi li + li {
  margin-top: var(--space-xs);
}

.disclaimer {
  margin: var(--space-md) 0 0;
  line-height: 1.6;
}

/* 健康度/过期的小 chip：线框样式，在哪一列底色上都读得出 */

.health {
  display: inline-block;
  margin: var(--space-sm) 0;
  padding: 0.1rem 0.45rem;
  border: 1px solid color-mix(in srgb, var(--warn-ink) 45%, var(--line));
  border-radius: 6px;
  color: var(--warn-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
}

/* ---------- 日板 ---------- */

.day-board {
  container-type: inline-size;
  margin: 0 0 var(--space-3xl);
}

.day-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-sm) var(--space-lg);
  margin: 0 0 var(--space-lg);
}

.day-num .date {
  display: block;
  font-size: var(--text-2xl);
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.day-num .month {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.day-label strong {
  display: block;
  font-size: var(--text-base);
  font-weight: 600;
}

.day-label span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
}

/* 今天的标签做成实心小牌，一眼定位 */

.kind-today .day-label strong {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--panel);
  font-size: var(--text-sm);
}

.day-board.kind-past .day-num .date {
  color: var(--muted);
}

.day-board.kind-past > summary.day-head {
  cursor: pointer;
  list-style: none;
}

.day-board.kind-past > summary.day-head::-webkit-details-marker {
  display: none;
}

.day-board.kind-past > summary.day-head::after {
  content: "";
  align-self: center;
  margin-left: auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(-45deg);
}

.day-board.kind-past[open] > summary.day-head::after {
  transform: rotate(45deg);
}

.day-board.kind-past > summary.day-head:hover::after {
  border-color: var(--ink);
}

/* 更早日期：整组折叠，组内每天仍可单独展开 */

.past-group {
  margin: 0 0 var(--space-3xl);
  border-top: 1px solid var(--line);
}

.past-group-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.past-group-head::-webkit-details-marker {
  display: none;
}

.past-group-head:hover {
  color: var(--ink);
}

.past-group-head::after {
  content: "";
  margin-left: auto;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(-45deg);
}

.past-group[open] > .past-group-head::after {
  transform: rotate(45deg);
}

@media (prefers-reduced-motion: no-preference) {
  .past-group-head::after {
    transition: transform 180ms var(--ease);
  }
}

/* 今天/昨天已说明日期，不再重复 ISO 日期 */

.day-board.kind-today .day-label span,
.day-board.kind-yesterday .day-label span {
  display: none;
}

/* 日级健康提示收紧，不抢泳道视线 */

.day-board > .health {
  margin: calc(-1 * var(--space-sm)) var(--space-sm) var(--space-md) 0;
}

/* ---------- 泳道 ---------- */

.lanes {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  align-items: start;
}

@container (min-width: 36rem) {
  .lanes {
    grid-template-columns: 1fr 1fr;
  }
}

@container (min-width: 58rem) {
  .lanes {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.lane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.lane-blocked {
  background: var(--warn);
  border-color: color-mix(in srgb, var(--warn-ink) 25%, var(--line));
}

.lane-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--line);
}

.lane-blocked .lane-head {
  border-bottom-color: color-mix(in srgb, var(--warn-ink) 20%, var(--line));
}

.lane-head h3 {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

.lane-count {
  font-variant-numeric: tabular-nums;
}

.lane-empty {
  margin: var(--space-sm) 0;
}

/* ---------- 泳道票：扫一眼能点进去的卡片 ---------- */

.ticket {
  display: block;
  width: 100%;
  margin: 0;
  padding: var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px oklch(0.3 0.02 60 / 0.06);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.ticket + .ticket {
  margin-top: var(--space-sm);
}

.ticket:hover,
.ticket.is-open {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.ticket:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px oklch(0.3 0.02 60 / 0.1);
}

.ticket:active {
  transform: none;
  box-shadow: 0 1px 2px oklch(0.3 0.02 60 / 0.06);
}

.ticket-owner {
  margin: 0 0 var(--space-xs);
  font-weight: 600;
}

.ticket-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.ticket .health {
  margin: 0 0 var(--space-sm);
}

.ticket-current {
  margin: 0;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.ticket-meta {
  overflow-wrap: anywhere;
}

/* ---------- 个人抽屉 ---------- */

.sheet {
  width: min(72rem, calc(100% - 2rem));
  height: auto;
  max-height: calc(100dvh - 3rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 48px oklch(0.2 0.01 60 / 0.22);
}

.sheet::backdrop {
  background: oklch(0.2 0.01 60 / 0.45);
}

.sheet-body {
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0 var(--space-2xl) var(--space-2xl);
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-xs) var(--space-lg);
  align-items: start;
  margin-bottom: var(--space-xl);
  padding: var(--space-xl) 0 var(--space-lg);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.sheet-head .kicker {
  grid-column: 1;
  margin: 0;
}

.sheet-head h2 {
  grid-column: 1;
  margin: 0;
  font-size: 1.625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sheet-close {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  margin: 0;
  padding: 0.35rem 0.7rem;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.sheet-close:hover {
  color: var(--ink);
  background: var(--bg);
  text-decoration: none;
}

/* 宽屏：当前详情在左、历史快照在右，两栏各自滚动 */

@media (min-width: 60rem) {
  .sheet-body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    overflow: hidden;
    padding-bottom: 0;
  }

  .sheet-head {
    grid-column: 1 / -1;
  }

  .sheet-body > .sheet-section {
    overflow: auto;
    min-height: 0;
    margin: 0;
    padding-bottom: var(--space-2xl);
  }

  .sheet-body > .sheet-section:first-of-type {
    padding-right: var(--space-2xl);
  }

  .sheet-body > .sheet-section:last-of-type {
    padding-left: var(--space-2xl);
    border-left: 1px solid var(--line);
  }
}

.sheet-section {
  margin: 0 0 var(--space-2xl);
}

.sheet-section > h3 {
  position: sticky;
  top: 0;
  margin: 0 0 var(--space-md);
  padding: var(--space-xs) 0 var(--space-sm);
  background: var(--panel);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

.sheet-section > .muted {
  margin: calc(-1 * var(--space-sm)) 0 var(--space-md);
  font-size: var(--text-xs);
}

.detail-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.flag-lane {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
}

.detail .kicker {
  margin: var(--space-lg) 0 var(--space-xs);
}

.detail .prose {
  font-size: var(--text-base);
  line-height: 1.75;
}

.detail-next {
  color: var(--muted);
}

.detail-meta {
  margin: var(--space-lg) 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* 历史快照：按日分段，段内条目再细分 */

.history-day {
  margin: 0 0 var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--line);
}

.history-day:first-of-type {
  margin-top: var(--space-md);
  padding-top: 0;
  border-top: 0;
}

.history-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  align-items: baseline;
  margin: 0 0 var(--space-md);
}

.history-head strong {
  font-size: var(--text-base);
  font-weight: 600;
}

.history-day .detail + .detail {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--line);
}

.history-day .detail-title {
  font-size: var(--text-base);
}

.history-day .detail .prose {
  font-size: var(--text-md);
  line-height: 1.7;
}

/* ---------- 动效 ---------- */

@media (prefers-reduced-motion: no-preference) {
  .sheet {
    animation: sheet-in 220ms var(--ease);
  }

  .who-item,
  .ticket {
    transition:
      background-color 180ms var(--ease),
      border-color 180ms var(--ease),
      box-shadow 180ms var(--ease),
      transform 180ms var(--ease);
  }

  .day-board.kind-past > summary.day-head::after {
    transition: transform 180ms var(--ease);
  }
}

@keyframes sheet-in {
  from {
    transform: translateY(0.75rem);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet {
    animation: none;
  }
}

/* ---------- 骨架屏 ---------- */

.skeleton-lanes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
}

.skeleton-card,
.skeleton-day {
  height: 8rem;
  background: var(--accent-soft);
  border-radius: var(--radius);
}

.skeleton-card + .skeleton-card {
  margin-top: var(--space-md);
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton-card,
  .skeleton-day {
    background: linear-gradient(90deg, var(--bg), var(--accent-soft), var(--bg));
    background-size: 200% 100%;
    animation: shine 1.4s linear infinite;
  }
}

@keyframes shine {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* ---------- 窄屏 ---------- */

@media (max-width: 900px) {
  .skeleton-lanes {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .layout {
    width: calc(100% - 1.5rem);
    gap: var(--space-2xl);
  }

  .skeleton-lanes {
    grid-template-columns: 1fr;
  }

  .who-item,
  .text-btn {
    min-height: 2.75rem;
  }

  .sheet-close {
    min-height: 2.25rem;
  }

  .sheet {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .sheet-body {
    padding: 0 var(--space-lg) 4rem;
  }

  .sheet-head {
    padding-top: var(--space-xl);
  }
}
