/* ============================================================
   BASE
============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:    #2563eb;
  --blue-d:  #1d4ed8;
  --blue-l:  #eff6ff;
  --gray-50: #f8fafc;
  --gray-100:#f1f5f9;
  --gray-200:#e2e8f0;
  --gray-400:#94a3b8;
  --gray-600:#475569;
  --gray-800:#1e293b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.1);
  --radius:    14px;
  --radius-sm: 8px;
}

body {
  font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   TOPBAR
============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  height: 54px; padding: 0 16px; gap: 12px;
}

.topbar-logo {
  background: linear-gradient(135deg, var(--blue) 0%, #4f46e5 100%);
  color: white;
  font-size: .68rem; font-weight: 800;
  padding: 4px 8px; border-radius: 6px;
  letter-spacing: .06em; flex-shrink: 0;
}

.topbar-title {
  font-size: .95rem; font-weight: 700; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   CONTAINER
============================================================ */
.container { max-width: 1100px; margin: 0 auto; padding: 20px 16px 80px; }

/* ============================================================
   HERO
============================================================ */
.page-hero {
  background: linear-gradient(135deg, var(--blue) 0%, #4f46e5 100%);
  border-radius: var(--radius);
  padding: 24px 22px;
  color: white;
  margin-bottom: 20px;
}

.page-hero h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 4px; }
.page-hero p  { font-size: .82rem; opacity: .85; }

/* ============================================================
   GRID
============================================================ */
.subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 600px) {
  .subject-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .subject-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   SUBJECT CARD
============================================================ */
.subject-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: box-shadow .18s, transform .18s;
}

.subject-card:not(.unavailable):hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.subject-card.unavailable { opacity: .6; }

.card-top {
  padding: 18px 18px 14px;
  flex: 1;
}

.card-name-row {
  display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px;
}

.card-name {
  font-size: 1rem; font-weight: 700; line-height: 1.3; flex: 1;
}

.card-desc {
  font-size: .82rem; color: var(--gray-600); line-height: 1.6;
}

/* ============================================================
   BADGE
============================================================ */
.badge {
  font-size: .65rem; font-weight: 700;
  padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
  margin-top: 2px;
}

.badge-coming {
  background: var(--gray-100); color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

/* ============================================================
   STATS
============================================================ */
.card-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
}

.stat-item {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 4px; text-align: center;
}

.stat-item + .stat-item { border-left: 1px solid var(--gray-100); }

.stat-val {
  font-size: 1.4rem; font-weight: 800; color: var(--blue); line-height: 1;
  margin-bottom: 3px;
}

.unavailable .stat-val { color: var(--gray-400); }

.stat-lbl { font-size: .68rem; color: var(--gray-600); }

/* ============================================================
   CARD FOOTER
============================================================ */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
}

.card-updated { font-size: .75rem; color: var(--gray-400); }

.btn-open {
  display: inline-flex; align-items: center;
  background: var(--blue);
  color: white; font-size: .82rem; font-weight: 700;
  padding: 8px 16px; border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .15s;
}

.btn-open:hover { background: var(--blue-d); }

.btn-disabled {
  display: inline-flex; align-items: center;
  background: var(--gray-200); color: var(--gray-400);
  font-size: .82rem; font-weight: 700;
  padding: 8px 16px; border-radius: var(--radius-sm);
  cursor: not-allowed;
}

/* ============================================================
   ERROR
============================================================ */
.error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius);
  padding: 20px 22px;
  line-height: 1.75;
  margin-top: 16px;
  white-space: pre-wrap;
}
