/* =========================================
   1. カラー＆基本設定
   ========================================= */
:root {
    --bg-white: #f8fafc;
    --brand-pink: #f10ae6;
    --brand-gradient: linear-gradient(135deg, #f09433 0%, #dc2743 50%, #bc1888 100%);
    --text-main: #334155;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #cbd5e1;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-white);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================
   2. インスタ風ヘッダー
   ========================================= */
.insta-profile-header {
    background: var(--brand-gradient);
    padding: 10px 0;
    box-shadow: 0 4px 12px rgba(220, 39, 67, 0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    width: 100%;
}

.back-arrow {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #ffffff !important;
    font-size: 2.2rem;
    font-weight: 200;
    text-decoration: none;
    z-index: 10;
    padding: 10px;
}

.title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0 50px;
}

.site-title {
    color: #ffffff !important;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.05em;
}

.site-tagline {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
    margin-top: 2px;
}

/* =========================================
   3. カテゴリグリッド（2列）
   ========================================= */
.category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 20px;
}

.card.text-only {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    min-height: 85px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.card.text-only:active {
    transform: scale(0.97);
}

.card.text-only .card-content {
    color: var(--brand-pink);
    font-weight: 800;
    font-size: 0.95rem;
    text-align: center;
    white-space: normal; 
    width: 100%;
    overflow-wrap: anywhere; 
    word-break: break-word;
    line-height: 1.3;
}

/* =========================================
   4. 検索エリア
   ========================================= */
.search-container {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#subject-search-input {
    width: 90%;
    max-width: 500px;
    height: 48px;
    padding: 0 20px;
    font-size: 16px;
    color: var(--text-main);
    font-weight: 600;
    border: 2px solid var(--brand-pink);
    border-radius: 24px;
    box-sizing: border-box;
    outline: none;
    background-color: #ffffff;
    appearance: none;
}

#result-count {
    text-align: center;
    margin: 12px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* =========================================
   5. 検索結果：問題カード
   ========================================= */
#search-results {
    width: 100%;
    padding-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.q-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 24px 16px; 
    margin: 16px auto 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    width: 92%;
    max-width: 500px;
    box-sizing: border-box;
}

.q-text { 
    font-weight: 700; 
    font-size: 1.05rem; 
    margin-bottom: 16px; 
    line-height: 1.6;
    color: var(--text-main);
}

.q-options {
    margin: 15px 0 25px 0;
    padding: 0 4px;
    line-height: 1.8;
    color: #444;
    font-size: 0.95rem; 
}

.q-answer-box {
    margin-top: 15px; 
    padding: 16px;
    background-color: #fffdf2;
    border-left: 4px solid #ffcc00;
    border-radius: 8px;
}

.ans-number {
    font-weight: bold; 
    color: #e60000;
    margin-bottom: 8px; 
    display: block;
    font-size: 1.1rem;
}

.ans-explanation {
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
}

/* =========================================
   6. 上付き・下付き文字（数式・核種）
   ========================================= */
sup, sub {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

sup {
    top: -0.45em;
    margin-left: 0.1em;
}

sub {
    bottom: -0.2em;
    margin-left: 0.1em;
}

/* 強調表示用 */
.q-text sup, .q-options sup {
    font-weight: bold;
}



/* =========================================
   全ページ共通：フッター統一デザイン
   ========================================= */
.mago-footer-nav {
    margin-top: 50px;
    padding: 60px 15px 40px; /* 上部余白を多めにとり、コンテンツと分離 */
    background-color: #fff;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

/* 📢 広告エリア：ad-gen.js が中身を流し込む場所 */
.footer-ad-space {
    width: 100%;
    max-width: 728px;
    margin: 0 auto 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 内部の広告ユニットデザイン */
.ad-container {
    width: 100%;
    text-align: center;
}

.ad-label {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-bottom: 5px;
    display: block;
    letter-spacing: 0.1em;
}

.ad-unit {
    width: 100%;
    min-height: 100px;
    background: #f8fafc; /* 背景を少しだけグレーにして「枠」を意識 */
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

/* 🔗 法的リンク集（免責事項など） */
.footer-links {
    margin: 25px 0 15px;
    font-size: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.footer-links a {
    color: #64748b; /* 視認性の良いグレー */
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #f10ae6; /* ホバー時はブランドカラーのピンク */
}

.footer-separator {
    color: #e2e8f0;
    margin: 0; /* flexのgapを使うためセパレーター自体は非表示または幅0を推奨 */
}

/* © コピーライト */
.copyright {
    color: #cbd5e1;
    font-size: 0.7rem;
    margin-top: 15px;
    display: block;
    letter-spacing: 0.05em;
}