:root{
  --brand:#0ea5e9;
  --ink:#0f172a;
  --text:#334155;
  --muted:#64748b;
  --bg:#f8fafc;
  --card:#ffffff;
  --border:#e2e8f0;
  --shadow:0 1px 3px rgba(0,0,0,.1);
  --radius:12px;
}

*{margin:0;padding:0;box-sizing:border-box}

body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans JP',sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
  min-height:100vh;
}

.container{
  max-width:800px;
  margin:0 auto;
  padding:20px;
}

header{
  position:relative;
  background:#040b1c;
  border-radius:var(--radius);
  padding:20px;
  margin-bottom:30px;
  box-shadow:var(--shadow);
  text-align:center;
}
header h1{
  font-size:2.2em;
  font-weight:700;
  color:#e5e7eb;
  letter-spacing:.02em;
}
header p{
  margin-top:8px;
  color:#94a3b8;
  font-size:1em;
}

.section{
  background:transparent;
  border-radius:0;
  padding:0 0 28px 0;
  margin-bottom:28px;
  box-shadow:none;
  border:none;
  border-bottom:1px solid var(--border);
}
h2{
  font-size:1.4em;
  color:var(--ink);
  margin-bottom:14px;
}

.cards{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
}
.card{
  flex:1 1 320px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:10px;
  padding:16px;
  box-shadow:var(--shadow);
  transition:background .15s ease, transform .15s ease;
}
.card:hover{background:#f8fafc; transform:translateY(-1px)}
.card h3{font-size:1.05em;color:var(--ink);margin-bottom:6px}

.badge{
  display:inline-block;
  padding:2px 6px;
  border-radius:6px;
  font-size:.82em;
  font-weight:500;
  background:#e0f2fe;
  color:#0369a1;
}

.highlight{
  background:linear-gradient(transparent 90%, #7db7d6 20%);
  font-weight:600;
}

.viz{
  background:#f8fafc;
  border:1px solid var(--border);
  border-radius:8px;
  padding:10px;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:6px;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
}
.token{
  background:#0ea5e9;
  color:#fff;
  border-radius:6px;
  padding:3px 6px;
  font-size:.86em;
}
.token.-char{background:#ef4444}
.token.-sub{background:#10b981}

.note{
  background:#f0f9ff;
  border:1px solid #bae6fd;
  border-radius:8px;
  padding:12px 14px;
  color:#0369a1;
  font-size:.92em;
  margin-top:14px;
}

.grid-2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
.grid-2 .card ul{padding-left:18px;color:#475569}

.inline{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  color:#475569;
}
.inline .heavy, .emphasis{font-weight:700;color:#dc2626}

footer{
  text-align:center;
  padding:20px 0;
  margin-top: 20px;
  border-top: 1px solid var(--border);
}
.footer-nav-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  text-decoration: none;
}
.footer-nav-link:hover {
  text-decoration: underline;
}
.copyright{
  color:#94a3b8;
  font-size:.86em;
}
.copyright a {
  color: inherit;
  text-decoration: none;
}
.copyright a:hover {
  text-decoration: underline;
}

/* ainote ナビ用 共通パーツ */
.nav-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.button{
  display:inline-block;
  padding:10px 14px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#ffffff;
  color:#0f172a;
  text-decoration:none;
  font-weight:600;
  transition:background .15s ease, transform .15s ease, box-shadow .15s ease;
  box-shadow:var(--shadow);
}
.button.-brand{
  background:var(--brand);
  color:#fff;
  border-color:#0891b2;
}
.button:hover{background:#f8fafc; transform:translateY(-1px)}
.button.-brand:hover{background:#0284c7}

/* カテゴリグリッド（ナビページ） */
.category{
  background:transparent;
  border:none;
  padding:0 0 10px 0;
  margin-bottom:22px;
  border-bottom:1px solid var(--border);
}
.category h2{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:1.2em;
  margin-bottom:12px;
}
.category .cards .card a{
  color:inherit;
  text-decoration:none;
}
.category .meta{
  color:#64748b;
  font-size:.88em;
  margin-top:6px;
}
.date {
  font-size: .82em;
  color: var(--muted);
  margin-top: 8px;
}

/* サイドバー */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  transform: translateX(0);
  transition: transform 0.3s ease;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}

.sidebar.closed {
  transform: translateX(-100%);
}

.sidebar-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  z-index: 1001;
  transition: background 0.2s ease;
}

.sidebar-toggle:hover {
  background: #0284c7;
}

.sidebar-toggle.closed {
  left: 20px;
}

.sidebar-nav h3 {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  margin-top: 60px;
}

.sidebar-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin-bottom: 8px;
}

.sidebar-nav a {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
  font-weight: 500;
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--brand);
}

.sidebar-nav a.active {
  background: var(--brand);
  color: white;
}

/* オーバーレイ */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  z-index: 999;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* メインコンテンツの調整 */
.container {
  margin-left: 300px;
  transition: margin-left 0.3s ease;
}

/* モバイル最適化 */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    left: 20px;
  }

  .sidebar-toggle.closed {
    left: 20px;
  }

  .container {
    margin-left: 0;
  }

  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .cards { gap: 10px; }
  .card { flex: 1 1 100%; width: 100%; padding: 14px; }
  .section { padding: 0 0 14px 0; margin-bottom: 40px; border-radius: 0; }
  .container { padding: 14px; }
  header { padding: 16px; }
  h2 { font-size: 1.2em; }
}

/* 表示モード切り替えボタン */
.view-mode-toggle {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

.view-mode-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-mode-btn:hover {
  background: var(--bg);
  transform: translateY(-1px);
}

.view-mode-btn.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.view-mode-btn.active:hover {
  background: #0284c7;
}

/* 時系列表示用スタイル */
.timeline-section {
   background: transparent;
   border: none;
   padding: 0 0 10px 0;
   margin-bottom: 22px;
   border-bottom: 1px solid var(--border);
}

.timeline-section h2 {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 1.2em;
   margin-bottom: 12px;
}

.timeline-cards {
   display: flex;
   flex-direction: column;
   gap: 12px;
}

.timeline-cards .card {
   padding: 16px;
   padding-bottom: 24px;
   min-height: 140px;
   max-height: 160px;
   overflow: hidden;
   flex-shrink: 0;
}

.timeline-cards .card a {
   color: inherit;
   text-decoration: none;
}

.timeline-cards .card-header {
   margin-bottom: 8px;
}

.timeline-cards .thumbnail {
   width: 40px;
   height: 40px;
   font-size: 1.5rem;
}

.timeline-cards .preview {
   -webkit-line-clamp: 2;
   font-size: .85em;
   line-height: 1.3;
}

.timeline-cards .meta {
   color: #64748b;
   font-size: .82em;
   margin-top: 4px;
}

.timeline-cards .category-badge {
   display: inline-block;
   padding: 1px 4px;
   border-radius: 4px;
   font-size: .65em;
   font-weight: 500;
   background: #f1f5f9;
   color: #475569;
   margin-top: 4px;
}

.timeline-cards .card-footer {
   padding-top: 8px;
   margin-top: 8px;
   border-top: 1px solid var(--border);
   position: relative;
   z-index: 1;
}

/* 新しいカード構造のスタイル */
.card-header {
   display: flex;
   gap: 12px;
   align-items: flex-start;
   margin-bottom: 12px;
}

.thumbnail {
   font-size: 2rem;
   line-height: 1;
   flex-shrink: 0;
   display: flex;
   align-items: center;
   justify-content: center;
   width: 48px;
   height: 48px;
   background: var(--bg);
   border-radius: 8px;
}

.card-content {
   flex: 1;
   min-width: 0;
}

.preview {
   color: #64748b;
   font-size: .88em;
   line-height: 1.4;
   margin-top: 6px;
   margin-bottom: 8px;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   -webkit-box-orient: vertical;
   overflow: hidden;
}

.card-footer {
   border-top: 1px solid var(--border);
   padding-top: 6px;
   margin-top: 10px;
   display: flex;
   justify-content: space-between;
   align-items: flex-start;
   flex-wrap: wrap;
   gap: 6px;
   min-height: auto;
}

.card-footer .date {
   font-size: .8em;
   margin-top: 0;
   order: 2;
}

.card-footer .category-badge {
   font-size: .7em;
   padding: 1px 4px;
   margin-top: 0;
   order: 1;
}