:root {
  color-scheme: light dark;
  --bg: #0f0f12;
  --card-bg: #1a1a1f;
  --border: #2c2c33;
  --text: #e8e8ec;
  --muted: #9a9aa5;
  --accent: #7dd3fc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 2rem 1.5rem 4rem;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

header {
  position: relative;
  max-width: 960px;
  margin: 0 auto 1.5rem;
  overflow: hidden;
  border-radius: 8px;
}

.header-visual {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
}

.header-text {
  position: relative;
  padding: 1.5rem 1.25rem;
}

.header-text h1 {
  font-size: 1.6rem;
  margin: 0 0 0.4rem;
}

.header-text p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

/* --- 統計セクション --- */

.stats {
  max-width: 960px;
  margin: 0 auto 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.stat-cards {
  display: flex;
  flex-wrap: nowrap;
  gap: 1.25rem;
  align-items: stretch;
}

.heatmap-card {
  flex: 1 1 0;
  min-width: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}

.tagchart-body {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.tagchart-pie {
  flex: 0 0 auto;
  width: 110px;
  height: 110px;
  border-radius: 50%;
}

.tagchart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.tagchart-legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tagchart-swatch {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.tagchart-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tagchart-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.7rem;
}

.heatmap-title {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.heatmap-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
}

.heatmap-weekdays {
  display: grid;
  grid-template-rows: repeat(7, 10px);
  gap: 3px;
  font-size: 0.6rem;
  color: var(--muted);
  line-height: 10px;
  flex: 0 0 auto;
  padding-top: 18px;
}

.heatmap-gridwrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.heatmap-months {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(10px, 1fr);
  font-size: 0.6rem;
  color: var(--muted);
  height: 14px;
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  gap: 3px;
}

.heatmap-col {
  display: grid;
  grid-template-rows: repeat(7, 10px);
  gap: 3px;
}

.heatmap-cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--border);
}

.heatmap-cell-future {
  background: transparent;
}

.heatmap-level-0 { background: var(--border); }
.heatmap-level-1 { background: #184f95; }
.heatmap-level-2 { background: #2a78d6; }
.heatmap-level-3 { background: #6da7ec; }
.heatmap-level-4 { background: #b7d3f6; }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 0.75rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.heatmap-legend .heatmap-cell {
  width: 10px;
  height: 10px;
}

/* --- カード一覧 --- */

#grid {
  max-width: 960px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border-color: var(--accent);
}

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

.card-preview {
  position: relative;
  height: 240px;
  border-bottom: 1px solid var(--border);
  background: #000;
}

.card-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}

.card-preview-overlay {
  position: absolute;
  inset: 0;
}

.card-body {
  padding: 1rem;
}

.card-body h2 {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

.meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.note {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notes-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
}

.notes-link:hover {
  text-decoration: underline;
}
