/* サイトマップ全体 */
.sm-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    padding: 20px;
    background: var(--bg-page);
}

/* カード本体 */
.sm-card {
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    border: 2px solid var(--border-soft);
    display: flex;
    flex-direction: column;
}

/* 教科ヘッダー（リンク） */
.sm-header-link {
    text-decoration: none;
}

.sm-header {
    background-color: var(--this-subject-color);
    padding: 20px;
    color: var(--text-main);
    /* 背景が色の時は白文字固定 */
    text-align: center;
    font-weight: bold;
    font-size: 1.6rem;
    transition: filter 0.2s;
}

body[data-theme="dark"] .sm-header {
    background: var(--menu-bg-dark);
}

.sm-header:hover {
    filter: brightness(1.1);
}

/* ダークモード時のヘッダー色調整 */
body[data-theme="dark"] .sm-header {
    filter: saturate(0.8) brightness(0.9);
}

/* 中身 */
.sm-body {
    padding: 10px 0;
}

/* 学年セクション */
.sm-grade-section {
    padding: 15px 20px;
    border-bottom: 1px dashed var(--border-light);
}

.sm-grade-section:last-child {
    border-bottom: none;
}

.sm-grade-title {
    display: inline-block;
    color: var(--text-main);
    font-weight: bold;
    font-size: 1.5rem;
    margin-bottom: 12px;
    text-decoration: none;
    transition: color 0.2s;
}

.sm-grade-title:hover {
    color: var(--this-subject-color);
    text-decoration: underline;
}

/* リンクアイテム */
.sm-link-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sm-item-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-history-item);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-main);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.sm-item-box:hover {
    background: var(--bg-card);
    border-color: var(--this-subject-color);
    transform: translateX(5px);
}

.sm-item-name {
    font-size: 1.4rem;
    font-weight: 500;
}

/* タグとバッジ */
.sm-tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}

.sm-badge {
    font-size: 1.4rem;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: bold;
    white-space: nowrap;
}

/* 動的タグ（リンク） */
.badge-tag {
    background: var(--bg-card);
    color: var(--this-subject-color);
    border: 1px solid var(--this-subject-color);
    cursor: pointer;
    transition: all 0.2s;
}

.badge-tag:hover {
    background: var(--this-subject-color);
    color: #fff;
}

/* その他のバッジ */
.badge-none {
    background: var(--border-soft);
    color: var(--text-muted);
}

.badge-game {
    background: var(--accent-main);
    color: #fff;
}

/* --- ダークモード時の微調整 --- */
body[data-theme="dark"] .sm-item-box {
    background: var(--bg-history-item);
    /* ダークモード用変数 #23384d */
    color: var(--text-main);
}

body[data-theme="dark"] .badge-tag {
    background: rgba(255, 255, 255, 0.05);
}