:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #111;
  --muted: #666;
  --border: #e7e7ef;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Noto Sans JP",
    "Hiragino Kaku Gothic ProN",
    Meiryo,
    sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

header {
  position: sticky;
  top: 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
}

header h1 {
  font-size: 24px;
  font-weight: 500;
  color: #000;
  margin: 0;
  cursor: pointer;
  transition: opacity 0.2s;
  user-select: none;
}

header h1:hover {
  opacity: 0.6;
}

.info-btn {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 0.2s, color 0.2s;
}

.info-btn:hover {
  background-color: #eee;
  color: #333;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 16px 0;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background-color: #eee;
  color: #333;
}

.modal-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.9;
  color: #333;
}

.modal-body p {
  margin: 0 0 12px;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-body a {
  color: #333;
  text-decoration: underline;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

 .search-mode-selector {
   display: flex;
   width: fit-content;
   margin: 4px auto 8px; 
   background-color: #eee;
   padding: 2px;
   border-radius: 6px;
   user-select: none;
 }

.radio-label {
  display: flex;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-label span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  line-height: 1;
  transition: all 0.2s ease;
  color: var(--muted);
}

.radio-label input[type="radio"]:checked + span {
  background-color: var(--card);
  color: #333;
  font-weight: 600;
}

input[type="search"] {
  flex: 1;
  min-width: 0; 
  padding: 10px 12px;
  border: 1px solid #d7d7e2;
  border-radius: 10px;
  background: #fff;
}

#search-btn {
  padding: 8px 16px;
  border: 1px solid #d7d7e2;
  border-radius: 10px;
  background-color: #333;
  color: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
}

#search-btn:hover {
  background-color: #727272;
}

#search-btn:active {
  opacity: 0.7;
}

main {
  padding: 16px;
  max-width: 1000px;
  margin: 0 auto;
}

.meta {
  font-size: 12px;
  color: #555;
  margin: 0;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end; /* 下端（ベースライン付近）で揃える */
  height: 32px; /* 高さを統一 */
  margin-bottom: 20px;
  padding-bottom: 4px;
}

.list-header .meta {
  margin-bottom: 0;
}

#sort-btn {
  font-size: 11px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.content-wrapper {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 32px;
}

.today-section {
  flex: 0 0 280px;
  position: sticky;
  /* JSのgetHeaderOffset(約160px)と合わせる */
  top: 170px; 
}

.list-section {
  flex: 1;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.gaiji {
  height: 0.85em;
  vertical-align: -0.08em;
}

.title .gaiji {
  width: 0.95em;
  height: 0.95em;
  vertical-align: -0.05em;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  cursor: default;
  user-select: none;
}

.poem-body {
  user-select: text;
  white-space: pre-line;
}

.card:focus-within,
.card:hover {
  border-color: #d3d3ea;
}

.cardHeader {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.3;
}

.sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.chev {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: #fff;
  color: #333;
  margin-top: 2px;
}

.chev span {
  display: inline-block;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.card.is-open .chev span {
  transform: rotate(180deg);
}

.body {
  font-size: 14px;
  line-height: 1.9;
  color: #222;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

.card:not(.is-open) .body {
  display: none;
}

/* 詩集一覧表示用のスタイル */
.author-group {
  margin-bottom: 40px;
}

.author-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 0 0 16px 0;
  letter-spacing: 0.05em;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.book-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.book-card:hover {
  border-color: #bbb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.book-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.4;
}

.book-meta {
  font-size: 11px;
  color: var(--muted);
}

.body br {
  line-height: 2;
}

.error {
  background: #fff0f0;
  border: 1px solid #ffd2d2;
  color: #7a1f1f;
  padding: 12px;
  border-radius: 12px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  margin: 8px 0;
}

@media (max-width: 768px) {
  header {
    padding: 6px 10px;
  }
  .row {
    gap: 6px;
  }
  input[type="search"] {
    font-size: 12px; 
  }
  .content-wrapper {
    flex-direction: column;
    align-items: stretch;
  }
  .today-section,
  .list-section {
    flex: none;
    width: 100%;
  }
  .today-section {
    position: static;
  }
}
