/* AI Auto Poster - Admin CSS */
:root{--bg:#f0f0f1;--card:#fff;--bdr:#dcdcde;--bdr-l:#eaeaec;--txt:#1d2327;--txt-m:#50575e;--txt-l:#8c8f94;--blue:#2271b1;--blue-h:#135e96;--blue-bg:#f0f6fc;--green:#00a32a;--green-bg:#edfaef;--red:#d63638;--red-bg:#fcf0f1;--yellow-bg:#fff8e1;--orange:#dba617;--r:6px;--sh:0 1px 3px rgba(0,0,0,.07)}

/* .aiap-wrap は WP コアの .wrap と同じ要素に乗る (`<div class="wrap aiap-wrap">`)。
   WP コアの .wrap が独自に持っている margin と max-width を尊重し、ここでは
   max-width:none だけ宣言して、プラグイン側コンテンツが幅制限なく広がれるようにする。
   (旧版にあった margin-right:20px は WP の .wrap{margin-right:20px(desktop)/12px(mobile)}
   に上乗せされて右余白が二重になっていた上、モバイルで box-sizing:border-box +
   width:100% を強制するルールと組み合わさるとボックスが viewport を超えて切られる
   原因になっていたため削除。) */
.aiap-wrap{max-width:none}
.aiap-page-head{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin-bottom:12px}
.aiap-page-head h1{margin:0}
.aiap-tab-icon{font-size:16px;width:16px;height:16px}
.aiap-check-row{display:block;margin-bottom:6px}
.aiap-card-title-between{justify-content:space-between}

/* Card */
.aiap-card{background:var(--card);border:1px solid var(--bdr);border-radius:var(--r);padding:16px 18px;margin-bottom:14px;box-shadow:var(--sh)}
.aiap-card-accent{border-left:3px solid var(--blue)}
.aiap-card h2{font-size:14px;font-weight:700;margin:0 0 10px;padding:0 0 9px;border-bottom:1px solid var(--bdr-l);display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.aiap-card h2 .ico{flex-shrink:0}

/* Provider icon badges */
.ico{width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;font-weight:800;font-size:9px;flex-shrink:0;line-height:1}
.ico-lg{width:22px;height:22px;font-size:11px;border-radius:5px}
.ico-claude{background:#d97757;color:#fff}
.ico-openai{background:#000;color:#fff}
.ico-gemini{background:linear-gradient(135deg,#4285f4,#ea4335,#fbbc05,#34a853);color:#fff}
.ico-mistral{background:#f97316;color:#fff}
.ico-groq{background:#f55036;color:#fff}
.ico-deepseek{background:#4f6df5;color:#fff}
.ico-openrouter{background:#6366f1;color:#fff}
.ico-dalle{background:#000;color:#10a37f}
.ico-imagen{background:linear-gradient(135deg,#4285f4,#ea4335);color:#fff}
.ico-stability{background:#7c3aed;color:#fff}
.ico-flux{background:#0ea5e9;color:#fff}
.ico-unsplash{background:#111;color:#fff}
.ico-pixabay{background:#2ec66d;color:#fff}
.ico-pexels{background:#05a081;color:#fff}
.ico-openverse{background:#c52b9b;color:#fff}

/* Sub tabs (provider/image service tabs) */
.aiap-sub-tabs{display:flex;gap:0;background:var(--card);border:1px solid var(--bdr);border-radius:var(--r);overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;margin-bottom:14px}
.aiap-sub-tabs::-webkit-scrollbar{display:none}
.aiap-sub-tab{padding:9px 14px;font-size:11px;font-weight:600;color:var(--txt-m);border-right:1px solid var(--bdr-l);display:inline-flex;align-items:center;gap:5px;white-space:nowrap;text-decoration:none;transition:.15s;flex-shrink:0}
.aiap-sub-tab:last-child{border-right:none}
.aiap-sub-tab:hover{background:var(--blue-bg);color:var(--blue)}
.aiap-sub-tab.active{background:var(--blue);color:#fff}
.aiap-sub-tab.active .ico{filter:brightness(2.5) saturate(.4)}

/* Radio pill group (provider/source selection) */
.aiap-radio-group{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:8px}
.aiap-radio-pill{display:flex;align-items:center;gap:5px;padding:5px 12px;border:1px solid var(--bdr);border-radius:18px;cursor:pointer;font-size:11px;font-weight:600;transition:.15s}
.aiap-radio-pill:hover{border-color:var(--blue);background:var(--blue-bg)}
.aiap-radio-pill input[type="radio"]{display:none}
.aiap-radio-pill.checked{border-color:var(--blue);background:var(--blue);color:#fff}
.aiap-radio-pill.checked .ico{filter:brightness(2.5) saturate(.4)}

/* Badge */
.aiap-badge{display:inline-flex;align-items:center;gap:3px;padding:2px 7px;border-radius:10px;font-size:10px;font-weight:600}
.aiap-badge-on{background:var(--green-bg);color:var(--green)}
.aiap-badge-off{background:#f0f0f1;color:var(--txt-l)}
.aiap-badge-free{background:#ede9fe;color:#7c3aed}
.aiap-dot{width:7px;height:7px;border-radius:50%;display:inline-block}
.aiap-dot-green{background:var(--green)}

/* API key row */
.aiap-api-row{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.aiap-api-row input[type="password"],.aiap-api-row input[type="text"]{flex:1;min-width:160px}

/* Test result */
.aiap-test-result{display:inline-flex;align-items:center;gap:3px;padding:3px 8px;border-radius:var(--r);font-size:11px;font-weight:600;margin-left:4px}
.aiap-test-result-loading{color:var(--txt-l)}
.aiap-test-result-ok{background:var(--green-bg);color:var(--green)}
.aiap-test-result-error{background:var(--red-bg);color:var(--red);white-space:normal;display:inline-block;max-width:520px;vertical-align:middle}

/* Status dot for active provider */
.aiap-active-dot{color:var(--green);font-weight:bold;margin-left:4px}

/* Schedule row */
.aiap-sched-row{display:flex;align-items:center;gap:5px;margin-bottom:4px}
.aiap-sched-row .day-label{width:30px;font-weight:700;font-size:12px;color:var(--txt-m);flex-shrink:0}
.aiap-sched-row input{flex:1;min-width:0}

/* Schedule grid: 2 列レイアウトで縦の伸びを抑える(7曜日 → 4行に圧縮) */
.aiap-sched-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:4px 16px;margin:6px 0}
.aiap-sched-grid .aiap-sched-row{margin-bottom:0}

/* #47 ランダム投稿モード - mobile-first
   小幅: 縦積み + カード幅 100%。768px 以上で横並び + カード固定幅。WP_List_Table のカード化だけ max-width:782px を例外として扱う */
.aiap-random-fields{
    display:flex;
    flex-direction:column;
    gap:8px;
    margin:6px 0 4px;
}
.aiap-random-fields .aiap-field{margin-top:0;flex:0 0 auto}
.aiap-random-fields .aiap-field-label{margin-bottom:4px}

/* 全コントロール (input / button) の共通サイズ。
   高さ 30px / line-height 28px / font-size 13px / box-sizing border-box。
   これにより時刻入力と削除/追加ボタンが同じ高さで並ぶ。 */
.aiap-random-fields .aiap-input-text,
.aiap-allowed-actions .button{
    box-sizing:border-box;
    height:30px;
    min-height:30px;
    line-height:28px;
    padding:0 8px;
    font-size:13px;
    margin:0;
    vertical-align:middle;
}

/* 1日の投稿回数: min 〜 max を 1 行に */
.aiap-counts-row{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.aiap-counts-row .aiap-input-text{
    flex:0 0 56px;
    width:56px;
    text-align:center;
}
.aiap-counts-sep{color:var(--txt-m);font-size:13px;flex:0 0 auto}

/* 投稿してよい時間帯 (Phase 13): 各行をカード状の枠で囲み、右端に [削除] [+ 追加] を配置 */
.aiap-allowed-list{display:flex;flex-direction:column;gap:6px;margin:4px 0 4px}
.aiap-allowed-row{
    display:flex;
    align-items:center;
    gap:6px;
    flex-wrap:nowrap;
    padding:6px 8px;
    border:1px solid #c3c4c7;
    border-radius:4px;
    background:#fff;
    width:100%;
    box-sizing:border-box;
}
/* 時刻入力: flex 伸縮 (ボタン分を引いた残りを使う) */
.aiap-allowed-row .aiap-input-text{
    flex:1 1 0;
    width:auto;
    min-width:0;
}
.aiap-allowed-row .aiap-counts-sep{
    flex:0 0 auto;
    padding:0 2px;
}
.aiap-allowed-actions{
    margin-left:auto;
    display:flex;
    gap:4px;
    flex:0 0 auto;
}

/* スマホ (~767px): 1 行に詰めると時刻 input が squeeze されて
   "8:00" の数字部分まで枠で切れて表示されるため、削除/追加ボタンを
   下の行に折り返し、時刻 input には可読な最小幅を確保する。 */
@media (max-width: 767px){
    .aiap-allowed-row{
        flex-wrap:wrap;
    }
    .aiap-allowed-row .aiap-input-text{
        flex:1 1 0;
        min-width:80px;
    }
    .aiap-allowed-actions{
        flex:1 1 100%;
        margin-left:0;
        margin-top:6px;
        justify-content:flex-end;
    }
}
.aiap-allowed-actions [data-aiap-allowed-remove]{
    color:#b32d2e;
    border-color:#b32d2e;
}
.aiap-allowed-actions [data-aiap-allowed-remove]:hover,
.aiap-allowed-actions [data-aiap-allowed-remove]:focus{
    color:#fff;
    background:#b32d2e;
    border-color:#b32d2e;
}

/* 0 行のとき表示する「+ 時間帯を追加」ボタン */
.aiap-allowed-add-empty{
    align-self:flex-start;
    margin-top:4px;
}

/* ≥768px: 共通ブレークポイントに合わせて横並び + カード固定幅 */
@media (min-width: 768px){
    .aiap-random-fields{
        flex-direction:row;
        flex-wrap:wrap;
        gap:8px 28px;
    }
    .aiap-allowed-row{
        width:380px;
    }
    .aiap-allowed-row .aiap-input-text{
        flex:0 0 100px;
        width:100px;
    }
}

/* 判定基準(dedup sensitivity) チェックボックス風一覧 */
.aiap-dedup-sens-wrap{
    margin: 8px 0 10px 28px;
    padding: 10px 12px;
    background: #f6f7f7;
    border: 1px solid #eaeaec;
    border-radius: 4px;
}
.aiap-dedup-sens-label{
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #50575e;
    margin-bottom: 8px;
}
.aiap-dedup-sens-group{
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.aiap-dedup-sens-option{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    color: #50575e;
    user-select: none;
    border-radius: 3px;
    transition: background 0.15s;
}
.aiap-dedup-sens-option::before{
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    background: #fff;
    flex-shrink: 0;
    box-sizing: border-box;
}
.aiap-dedup-sens-option:hover{
    background: rgba(34, 113, 177, 0.08);
}
.aiap-dedup-sens-option.is-active{
    color: #1d2327;
    font-weight: 600;
}
.aiap-dedup-sens-option.is-active::before{
    background: #2271b1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23fff' d='M7.629 14.571L3.514 10.457l1.414-1.414 2.701 2.7 6.443-6.443 1.414 1.414z'/%3E%3C/svg%3E") no-repeat center / 14px 14px;
    border-color: #2271b1;
}
.aiap-dedup-sens-option input[type="radio"]{
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.aiap-dedup-sens-wrap .description{
    margin-top: 8px;
    margin-bottom: 0;
    font-size: 12px;
}
@media (max-width: 768px) {
    .aiap-dedup-sens-wrap{
        margin-left: 0;
    }
}
.aiap-task-options{
    display: flex;
    flex-wrap: wrap;
    gap: 14px 20px;
    margin: 6px 0 12px;
    padding: 10px 12px;
    background: #f6f7f7;
    border: 1px solid #eaeaec;
    border-radius: 4px;
}
.aiap-task-options > label{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}
.aiap-task-options select,
.aiap-task-options input[type="number"]{
    max-width: 100%;
}
.aiap-task-option-label{
    font-weight: 600;
    color: #50575e;
    white-space: nowrap;
}

/* Task table - status badges */
.aiap-status-on{color:var(--green)}
.aiap-status-off{color:var(--txt-l)}

/* Buttons */
.aiap-btn-test{font-size:12px}
.aiap-btn-delete{color:var(--red);border-color:var(--red)}
.aiap-inline-form{display:inline}
.aiap-toggle-row{margin-top:10px}
.aiap-format-preview-wrap{display:flex;justify-content:center;width:100%;max-width:400px;margin:12px 0}
.aiap-format-preview{width:180px;height:101px;background:linear-gradient(135deg,#60a5fa,#a78bfa);border-radius:8px;display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:14px}
.aiap-quality-bar{position:relative;height:12px;border-radius:6px;background:linear-gradient(to right,#22c55e,#eab308,#ef4444);margin:12px 0}
.aiap-quality-knob{position:absolute;left:20%;top:-4px;width:20px;height:20px;background:#fff;border:2px solid #ccc;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.aiap-quality-labels{display:flex;justify-content:space-between;font-size:11px;color:#646970}
.aiap-hint-spaced{margin-top:12px}
.aiap-description-spaced{margin-top:8px}
.aiap-form-table-spaced{margin-top:10px}
.aiap-log-status{display:inline-block;width:7px;height:7px;border-radius:50%;background:gray}
.aiap-log-status-success{background:var(--green)}
.aiap-log-status-error{background:var(--red)}
.aiap-log-status-info{background:var(--txt-l)}

/* Hint text */
.aiap-hint{color:var(--txt-l);font-size:11px;margin-top:2px}

/* ====================================================================
   Pro 機能ロック表示
   - .aiap-pro-badge: 「PRO」バッジ(タイトル横などに付ける)
   - .aiap-locked: コンテンツ全体をロック(半透明 + クリック不能)
   - .aiap-pro-card: アップグレード CTA 用のカード
   - .aiap-plan-card: 現在のプラン状態と利用状況を表示
   ==================================================================== */
.aiap-pro-badge{display:inline-block;padding:2px 8px;font-size:11px;font-weight:600;letter-spacing:.5px;color:#fff;background:linear-gradient(135deg,#7c3aed,#4f46e5);border-radius:3px;vertical-align:middle;margin-left:8px}
.aiap-pro-badge-trial{background:linear-gradient(135deg,#f59e0b,#dc2626)}
.aiap-locked{position:relative;opacity:.55;pointer-events:none;user-select:none}
.aiap-locked::after{content:"";position:absolute;inset:0;background:repeating-linear-gradient(135deg,transparent,transparent 8px,rgba(124,58,237,.05) 8px,rgba(124,58,237,.05) 16px);pointer-events:none}
.aiap-pro-cta{display:inline-flex;align-items:center;gap:6px;margin-left:12px;padding:4px 10px;font-size:12px;font-weight:600;color:#7c3aed;background:#f5f3ff;border:1px solid #c4b5fd;border-radius:4px;text-decoration:none}
.aiap-pro-cta:hover{background:#ede9fe;color:#6d28d9}
.aiap-pro-cta .dashicons{font-size:14px;width:14px;height:14px}

/* Plan & Usage カード */
.aiap-plan-card{margin-bottom:16px}
.aiap-plan-status{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:8px}
.aiap-plan-name{font-size:15px;font-weight:600}
.aiap-plan-name-pro{color:#7c3aed}
.aiap-plan-name-trial{color:#dc2626}
.aiap-usage-bar{position:relative;height:8px;background:var(--bdr-l);border-radius:4px;margin:8px 0;overflow:hidden}
.aiap-usage-fill{position:absolute;top:0;left:0;height:100%;background:linear-gradient(90deg,#10b981,#059669);transition:width .3s}
.aiap-usage-fill-warn{background:linear-gradient(90deg,#f59e0b,#d97706)}
.aiap-usage-fill-full{background:linear-gradient(90deg,#ef4444,#dc2626)}
.aiap-usage-text{font-size:12px;color:var(--txt-m)}
.aiap-usage-warning{margin-top:8px;padding:8px 10px;background:#fef3c7;border-left:3px solid #f59e0b;color:#92400e;font-size:12px;border-radius:0 4px 4px 0}
.aiap-usage-error{margin-top:8px;padding:8px 10px;background:#fee2e2;border-left:3px solid #ef4444;color:#991b1b;font-size:12px;border-radius:0 4px 4px 0}

/* Free 制限スキップ集計バナー */
.aiap-skip-summary{background:#fef3c7 !important;border-left:4px solid #f59e0b !important;color:#92400e}
.aiap-skip-summary .dashicons{font-size:18px;width:18px;height:18px}

/* Pro 専用カード自体のヘッダ強調 */
.aiap-card-pro{position:relative}
.aiap-card-pro h2{display:flex;align-items:center;flex-wrap:wrap;gap:0}

/* Form table override for tighter spacing */
.aiap-card .form-table th{padding:12px 10px 12px 0;font-size:13px;width:200px;word-break:normal;overflow-wrap:break-word;max-width:100%;box-sizing:border-box}
.aiap-card .form-table td{padding:8px 0}
.aiap-card .form-table td p.description,
.aiap-card .form-table td .description,
.aiap-card .form-table td label{word-break:normal;overflow-wrap:break-word;max-width:100%;display:block}

/* SEO detail panel */
.aiap-seo-detail{margin-top:14px;padding-top:14px;border-top:1px solid var(--bdr-l)}
.aiap-seo-detail label{display:block;margin:6px 0}
.aiap-seo-group-label{display:block;font-weight:600;font-size:11px;color:var(--txt-m);margin:12px 0 3px;text-transform:uppercase;letter-spacing:.3px}
.aiap-seo-group-label:first-child{margin-top:0}

/* Responsive */
@media (max-width: 768px) {
    .aiap-card .form-table th{display:block;width:100%;padding-bottom:2px}
    .aiap-card .form-table td{display:block;padding-top:0}
    .aiap-api-row{flex-direction:column}
    .aiap-api-row input{width:100%}
}


/* ======================================
   追加CSS — サブタブ方式 (BotWriter style) + 画像設定
   admin.css の末尾に追加
   ====================================== */

/* Sub-tab navigation (BotWriter style) */
.aiap-subtab-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid #c3c4c7;
    margin-bottom: 0;
    padding: 0 4px;
    background: #f6f7f7;
    border-radius: 4px 4px 0 0;
}
.aiap-subtab {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 16px;
    font-size: 12.5px;
    font-weight: 500;
    color: #50575e;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all .15s;
    white-space: nowrap;
}
.aiap-subtab:hover {
    color: #2271b1;
    background: rgba(34, 113, 177, .04);
}
.aiap-subtab-active {
    color: #2271b1;
    border-bottom-color: #2271b1;
    background: #fff;
    font-weight: 600;
}
.aiap-subtab-current .aiap-dot {
    margin-left: 2px;
}

/* Panel below sub-tabs */
.aiap-subtab-panel {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 20px;
}
.aiap-subtab-panel .aiap-card {
    border: none;
    padding: 0;
    margin-bottom: 0;
}
.aiap-subtab-panel .aiap-card-accent {
    border: none;
    border-left: 4px solid #2271b1;
    padding-left: 16px;
}

/* 2-column grid for image settings */
.aiap-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
@media (max-width: 768px) {
    .aiap-grid-2col {
        grid-template-columns: 1fr;
    }
    .aiap-subtab-wrapper {
        gap: 0;
    }
    .aiap-subtab {
        padding: 8px 10px;
        font-size: 11.5px;
    }
}

/* Full-width select inside cards */
.aiap-full-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    margin-bottom: 12px;
}

/* Provider/Quality mapping table */
.aiap-mapping-table {
    width: 100%;
    font-size: 12px;
    border-collapse: collapse;
}
.aiap-mapping-table td {
    padding: 3px 0;
}
.aiap-mapping-table td:first-child {
    color: #646970;
}
.aiap-mapping-table td:last-child {
    color: var(--wp-admin-theme-color, #2271b1);
}


/* Main tabs styled like attached reference */
.aiap-main-tab-wrapper{
    margin-top: 8px;
    margin-bottom: 0;
    border-bottom: 1px solid #2271b1;
    background: #f0f0f1;
    padding: 0 12px;
}
.aiap-main-tab-wrapper .aiap-subtab{
    padding: 14px 18px;
    font-size: 13px;
    gap: 8px;
    border-bottom-width: 3px;
}
.aiap-main-tab-wrapper .aiap-subtab-active{
    background: #fff;
    border: 1px solid #2271b1;
    border-bottom: 3px solid #fff;
    border-radius: 0;
    margin-bottom: -1px;
}
.aiap-main-tab-panel{
    border-top: none;
    border-radius: 0;
    padding: 18px 12px 22px;
}

/* BotWriter-like scroll sections for provider settings */
.aiap-provider-picker{
    background: linear-gradient(135deg,#5b7cfa 0%,#7f54b3 100%);
    border-radius: 6px;
    padding: 18px 24px 20px;
    margin: 2px 0 20px;
}
.aiap-provider-picker label{
    display: block;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px;
}
.aiap-provider-picker select{
    width: 100%;
    max-width: none;
    min-height: 34px;
    border-color: transparent;
    border-radius: 4px;
}
.aiap-scroll-stack{
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.aiap-subtab-panel .aiap-scroll-stack .aiap-card{
    border: 1px solid var(--bdr-l);
    border-left: 4px solid var(--blue);
    border-radius: var(--r);
    padding: 16px 18px;
    margin-bottom: 0;
    box-shadow: none;
}
.aiap-provider-card{
    scroll-margin-top: 52px;
}
.aiap-scroll-submit{
    margin: 0;
    padding: 0;
}
@media (max-width: 768px) {
    .aiap-main-tab-wrapper{
        padding: 0;
        overflow-x: visible;
        flex-wrap: wrap;
        gap: 2px;
        background: #f0f0f1;
        border-bottom: 1px solid #2271b1;
    }
    .aiap-main-tab-wrapper .aiap-subtab{
        padding: 8px 6px;
        font-size: 11px;
        flex: 1 1 auto;
        min-width: 0;
        justify-content: center;
        text-align: center;
        border-bottom-width: 2px;
    }
    .aiap-main-tab-wrapper .aiap-subtab .aiap-tab-icon{
        font-size: 14px;
        width: 14px;
        height: 14px;
    }
    .aiap-main-tab-wrapper .aiap-subtab span:not(.aiap-tab-icon){
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .aiap-main-tab-wrapper .aiap-subtab-active{
        margin-bottom: 0;
    }
    .aiap-wrap{
        margin-right: 10px;
        overflow-x: hidden;
    }
    .aiap-provider-picker{
        padding: 16px;
    }

    /* ──────────────────────────────────────────
       タスク一覧テーブルをカード風に縦積み表示
       (widefat のデフォルト横組では4列が画面幅を超える)
       ────────────────────────────────────────── */
    .aiap-wrap table.widefat {
        width: 100%;
        max-width: 100%;
        table-layout: fixed;
        display: block;
    }
    .aiap-wrap table.widefat thead,
    .aiap-wrap table.widefat tbody,
    .aiap-wrap table.widefat tr,
    .aiap-wrap table.widefat th,
    .aiap-wrap table.widefat td {
        display: block;
        width: auto;
        max-width: 100%;
        box-sizing: border-box;
    }
    .aiap-wrap table.widefat thead {
        display: none; /* カード表示では列見出しを隠す */
    }
    .aiap-wrap table.widefat tr {
        border: 1px solid #dcdcde;
        border-radius: 6px;
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
        overflow: hidden;
    }
    .aiap-wrap table.widefat td {
        border: none;
        padding: 6px 0;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
    .aiap-wrap table.widefat td:empty {
        display: none;
    }
    /* 操作列のボタン群は横並びで折り返し */
    .aiap-wrap table.widefat td .aiap-inline-form,
    .aiap-wrap table.widefat td .button {
        display: inline-flex;
        margin: 3px 4px 3px 0;
        vertical-align: middle;
    }

    /* ──────────────────────────────────────────
       幅固定の入力を画面幅に収める
       ────────────────────────────────────────── */
    .aiap-wrap input.regular-text,
    .aiap-wrap input[type="text"]:not(.small-text),
    .aiap-wrap input[type="number"]:not(.small-text),
    .aiap-wrap textarea.large-text,
    .aiap-wrap textarea.code {
        max-width: 100%;
        box-sizing: border-box;
    }

    /* スケジュール入力行がテーブル内でも縮むように */
    .aiap-sched-row {
        flex-wrap: wrap;
    }
    .aiap-sched-row input {
        width: 100%;
        max-width: 100%;
    }

    /* スケジュールグリッド: モバイルでは 1 列に戻す(インラインスタイルを上書き) */
    .aiap-sched-grid {
        grid-template-columns: 1fr !important;
    }

    /* form-table の th/td も縦積みに */
    .aiap-wrap table.form-table th,
    .aiap-wrap table.form-table td {
        display: block;
        width: 100%;
        padding: 8px 0;
        box-sizing: border-box;
    }

    /* サブタブのパネルパディングを削減(画面幅を有効活用) */
    .aiap-subtab-panel,
    .aiap-main-tab-panel {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* カード(aiap-card)もパディング圧縮 */
    .aiap-wrap .aiap-card {
        padding: 14px;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* タスクオプション(言語・文字数)をモバイルでは縦積み */
    .aiap-task-options {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .aiap-task-options > label {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        width: 100%;
    }
    .aiap-task-options select,
    .aiap-task-options input[type="number"] {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

.aiap-progress {
    margin-top: 16px;
    padding: 12px 14px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}
.aiap-progress-main {
    flex: 1 1 320px;
    min-width: 0;
}
.aiap-progress-media {
    flex: 0 0 auto;
    width: 200px;
    align-self: flex-start;
}
.aiap-progress-video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
    transition: opacity 0.3s ease;
}
.aiap-progress.is-idle .aiap-progress-video,
.aiap-progress.is-done .aiap-progress-video,
.aiap-progress.is-error .aiap-progress-video {
    opacity: 0.45;
}
@media (max-width: 768px) {
    .aiap-progress-media {
        width: 100%;
        max-width: 240px;
        margin: 0 auto;
    }
}
.aiap-progress-step {
    display: none;
    padding: 4px 0;
    color: #50575e;
}
.aiap-progress-step.is-running,
.aiap-progress-step.is-done,
.aiap-progress-step.is-error {
    display: block;
}
.aiap-progress-step.is-running::before {
    content: "⏳";
    display: inline-block;
    margin-right: 6px;
    /* 進捗中であることを視覚的に伝えるため、砂時計絵文字をゆるく回転させる。
       既存の @keyframes aiap-spin を流用して定義の重複を避ける。 */
    animation: aiap-spin 2s linear infinite;
    transform-origin: 50% 50%;
}
/* エラー / 完了で進捗エリアが終了状態になった時、進行中ステップの砂時計アニメーションを停止する。
   ステップ行のテキストや状態クラス(is-running)は意図的に上書きしないため、
   ここで動きだけ止めて「動き続けているのに失敗/完了している」矛盾した見た目を防ぐ。
   is-done セレクタは Free プラン上限到達の専用バナー(showResult('limit')) を含むケースで効く: 
   そのケースは progress に is-done が付与されるため、これで止まる。 */
.aiap-progress.is-error .aiap-progress-step.is-running::before,
.aiap-progress.is-done  .aiap-progress-step.is-running::before {
    animation: none;
}
.aiap-progress-step.is-done::before    { content: "✅ "; }
.aiap-progress-step.is-error::before   { content: "❌ "; }
.aiap-progress-step.is-running { color: #1d4ed8; }
.aiap-progress-step.is-done    { color: #1d8348; }
.aiap-progress-step.is-error   { color: #b32d2e; font-weight: 600; }

.aiap-progress-result {
    display: none;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #dcdcde;
    font-weight: 600;
}
.aiap-progress-result.is-done,
.aiap-progress-result.is-error,
.aiap-progress-result.is-limit {
    display: block;
}
.aiap-progress-result.is-done  { color: #1d8348; }
.aiap-progress-result.is-error { color: #b32d2e; }
/* エラー時、結果行は「進行中ステップ行の真下に追加表示されるエラー行」として、
   ステップ行の is-error スタイル(❌ + 赤 + 太字)と見た目を揃える。
   破線区切りや余分な padding を打ち消し、ステップ行と同じ流れで表示する。 */
.aiap-progress-result.is-error::before {
    content: "❌ ";
}
.aiap-progress-result.is-error {
    border-top: none;
    padding-top: 4px;
    margin-top: 0;
}
.aiap-progress-result.is-limit {
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    padding: 12px 14px;
    margin-top: 8px;
}
.aiap-progress-result a { margin-left: 4px; }
.aiap-progress-upgrade {
    margin-top: 10px;
}
.aiap-progress-upgrade .aiap-pro-cta {
    margin-left: 0;
}
.aiap-add-task-toggle-wrap {
    margin: 16px 0;
}

.aiap-model-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.aiap-model-notice {
    margin-top: 6px;
    padding: 6px 10px;
    background: #fff8e1;
    border-left: 3px solid #dba617;
    color: #6b4e00;
    font-size: 12px;
    border-radius: 3px;
}
.aiap-model-notice .dashicons {
    color: #dba617;
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}
.aiap-model-feedback {
    margin-top: 6px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 3px;
}
.aiap-model-feedback.is-ok { background: #e8f5e9; color: #1d8348; }
.aiap-model-feedback.is-warning { background: #fff8e1; color: #6b4e00; }
.aiap-model-feedback.is-error { background: #fdecea; color: #b32d2e; }

/* ===== 統一ボタンデザイン ===== */
.button.aiap-btn-primary,
.button.aiap-btn-success,
.button.aiap-btn-neutral,
.button.aiap-btn-danger,
.button.aiap-btn-danger-outline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    text-shadow: none;
    box-shadow: none;
    line-height: 1.2;
}
.button.aiap-btn-primary .dashicons,
.button.aiap-btn-success .dashicons,
.button.aiap-btn-neutral .dashicons,
.button.aiap-btn-danger .dashicons,
.button.aiap-btn-danger-outline .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
}

/* primary: 青背景/白文字 */
.button.aiap-btn-primary,
.button.aiap-btn-primary:hover,
.button.aiap-btn-primary:focus {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}
.button.aiap-btn-primary:hover { background: #135e96; border-color: #135e96; }
.button.aiap-btn-primary:disabled,
.button.aiap-btn-primary[disabled] { background: #7eb4d8; border-color: #7eb4d8; color: #fff; opacity: 0.85; }

/* success: 緑背景/白文字 */
.button.aiap-btn-success,
.button.aiap-btn-success:hover,
.button.aiap-btn-success:focus {
    background: #1d8348;
    border-color: #1d8348;
    color: #fff;
}
.button.aiap-btn-success:hover { background: #166534; border-color: #166534; }

/* neutral: グレー背景/白文字 */
.button.aiap-btn-neutral,
.button.aiap-btn-neutral:hover,
.button.aiap-btn-neutral:focus {
    background: #6b7280;
    border-color: #6b7280;
    color: #fff;
}
.button.aiap-btn-neutral:hover { background: #4b5563; border-color: #4b5563; }

/* danger: 赤背景/白文字 */
.button.aiap-btn-danger,
.button.aiap-btn-danger:hover,
.button.aiap-btn-danger:focus {
    background: #b32d2e;
    border-color: #b32d2e;
    color: #fff;
}
.button.aiap-btn-danger:hover { background: #8f1f1f; border-color: #8f1f1f; }

/* danger-outline: 白背景/赤文字 */
.button.aiap-btn-danger-outline,
.button.aiap-btn-danger-outline:hover,
.button.aiap-btn-danger-outline:focus {
    background: #fff;
    border-color: #b32d2e;
    color: #b32d2e;
}
.button.aiap-btn-danger-outline:hover { background: #fef2f2; }

/* テストボタンの状態別カラー */
.button.aiap-btn-test.aiap-btn-test-loading,
.button.aiap-btn-test.aiap-btn-test-loading:hover,
.button.aiap-btn-test.aiap-btn-test-loading:focus {
    background: #6b7280;
    border-color: #6b7280;
    color: #fff;
    opacity: 0.9;
}
.button.aiap-btn-test.aiap-btn-test-ok,
.button.aiap-btn-test.aiap-btn-test-ok:hover,
.button.aiap-btn-test.aiap-btn-test-ok:focus {
    background: #1d8348;
    border-color: #1d8348;
    color: #fff;
}
.button.aiap-btn-test.aiap-btn-test-error,
.button.aiap-btn-test.aiap-btn-test-error:hover,
.button.aiap-btn-test.aiap-btn-test-error:focus {
    background: #b32d2e;
    border-color: #b32d2e;
    color: #fff;
    max-width: 100%;
    white-space: normal;
    text-align: left;
    line-height: 1.3;
}

/* spinner アニメーション */
.aiap-spin {
    animation: aiap-spin 1s linear infinite;
}
@keyframes aiap-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.aiap-run-now-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-top: 10px;
    margin-bottom: 10px;
}
.aiap-run-now-options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.aiap-run-now-options select:disabled,
.aiap-run-now-options input:disabled {
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.aiap-toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.aiap-toggle-switch input[type="radio"],
.aiap-toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.aiap-toggle-slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    background: #c3c4c7;
    border-radius: 22px;
    transition: background 0.2s;
    flex: none;
}
.aiap-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.aiap-toggle-switch input:checked + .aiap-toggle-slider {
    background: #1d8348;
}
.aiap-toggle-switch input:checked + .aiap-toggle-slider::before {
    transform: translateX(18px);
}
.aiap-toggle-switch input:focus-visible + .aiap-toggle-slider {
    box-shadow: 0 0 0 2px #2271b1;
}
.aiap-toggle-label {
    font-size: 13px;
    color: #1d2327;
}
.aiap-toggle-status {
    margin-left: 12px;
    font-size: 12px;
    color: #1d8348;
    font-weight: 500;
}

.aiap-progress-warning {
    display: block;
    margin-top: 6px;
    padding: 6px 10px;
    background: #fff8e1;
    border-left: 3px solid #dba617;
    color: #6b4e00;
    font-weight: 500;
    border-radius: 3px;
}

/* Execution logs: keep each log entry on one line */
.aiap-log-table th,
.aiap-log-table td{white-space:nowrap}

/* ============================================
   Prompts & Tasks tab - 2-column layout
   - 左カラム: システムプロンプト (textarea + 保存)
   - 右カラム: Free プラン警告(条件付き) + タスク一覧 + Add Task フォーム
   - 1100px 以下では 1カラムに折り畳む。
   - align-items: start で各カラムの高さが揃わなくても上揃え(タスクが伸びても左カラムは詰まる)。
   - minmax(0, ...) は Grid アイテムの内部コンテンツが幅をはみ出させないための定石。
   ============================================ */
.aiap-prompts-layout {
    display: grid;
    grid-template-columns: minmax(0, 38%) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    margin-top: 16px;
}
.aiap-prompts-col {
    min-width: 0;
}
/* 左カラム内の保存ボタンは余白を最小限に(縦に間延びしない) */
.aiap-prompts-col-system .aiap-prompts-form .submit,
.aiap-prompts-col-system > .submit {
    margin-top: 12px;
    padding: 0;
}
/* WP 標準のタブレット折り畳み閾値 (max-width: 992px) に揃える。
   admin-modern.css 側でも min-width:960px で 2 カラムに切り替えており、両ファイルの
   閾値を同じに保つことでモダンテーマ ON/OFF どちらでも同じ折り返し挙動になる。 */
@media (max-width: 992px) {
    .aiap-prompts-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ============================================
   Generated posts list table (Logs tab)
   - WP_List_Table の標準スタイル(.wp-list-table)に乗せる調整のみ。
   - サムネ画像のサイズとアクションボタン列の最小幅を整える。
   ============================================ */
.aiap-logs-table-section .wp-list-table th,
.aiap-logs-table-section .wp-list-table td {
    vertical-align: middle;
}
/* ヘッダー: 「投稿ステータス」のような長めのラベルとソート矢印が改行されないように nowrap。
   sort 矢印は WP 標準で <span> として末尾に追加されるため、これも一緒に1行に保つ。 */
.aiap-logs-table-section .wp-list-table thead th,
.aiap-logs-table-section .wp-list-table tfoot th {
    white-space: nowrap;
}
.aiap-logs-table-section .wp-list-table .column-image,
.aiap-logs-table-section .wp-list-table .column-actions {
    width: 80px;
}
.aiap-logs-table-section .wp-list-table .column-published {
    width: 180px;
    white-space: nowrap;
}
.aiap-logs-table-section .wp-list-table .column-status {
    width: 130px;
}
.aiap-logs-table-section .wp-list-table .column-writer {
    width: 110px;
}
.aiap-logs-table-section .wp-list-table .column-created_at {
    width: 150px;
    white-space: nowrap;
}
.aiap-logs-table-section img.aiap-logs-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}
/* アクション列・公開列のボタンは inline-flex でアイコンとテキストを縦中央揃えにする。
   dashicons はデフォルトで vertical-align: top のため、line-height やテキストとズレやすい。
   inline-flex + align-items: center で一貫したベースライン。 */
.aiap-logs-table-section .column-actions .button-small,
.aiap-logs-table-section .column-published .button-small {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    line-height: 1.6;
    height: auto;
}
.aiap-logs-table-section .column-actions .button-small .dashicons,
.aiap-logs-table-section .column-published .button-small .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
    vertical-align: middle;
    /* flex 子要素として配置されるので margin は親 gap で吸収 */
    margin: 0;
}
.aiap-logs-table-section .column-actions .aiap-delete-btn {
    color: #b32d2e;
    border-color: #b32d2e;
    /* アイコンのみのボタンは正方形気味に */
    padding: 2px 8px;
}
.aiap-logs-table-section .column-actions .aiap-delete-btn:hover {
    background: #b32d2e;
    color: #fff;
}

/* ============================================
   Image Settings - 用途プリセットカードUI
   (システムフォントのみ。外部リソースは使わない)
   ============================================ */
.aiap-image-settings-form{max-width:780px;margin:0 auto}
.aiap-img-hero{margin:8px 0 24px;padding:0 4px}
.aiap-img-hero-eyebrow{display:inline-block;font-size:11px;font-weight:700;letter-spacing:.18em;color:var(--txt-l);text-transform:uppercase;margin-bottom:12px}
.aiap-img-hero-title{font-size:22px;line-height:1.45;letter-spacing:-.005em;color:var(--txt);margin:0;font-weight:700;border:0;padding:0}
/* セクションリード文 (img-hero-sub / imgset-lede / provider-hero-sub): 3 種類で同一スタイルなので集約 */
.aiap-img-hero-sub,
.aiap-imgset-lede,
.aiap-provider-hero-sub{margin-top:8px;font-size:13px;color:var(--txt-m);line-height:1.6}

.aiap-image-presets{display:grid;grid-template-columns:1fr;gap:12px;margin-bottom:20px}
.aiap-preset-card{position:relative;background:var(--card);border:1.5px solid var(--bdr);border-radius:12px;padding:0;cursor:pointer;transition:transform .2s ease,box-shadow .2s ease,border-color .2s ease;overflow:hidden;text-align:left;width:100%;font-family:inherit;color:inherit;display:block}
/* タイル系カード (preset / imgset / provider-tile) の hover: 3 種類で同一スタイルなので集約 */
.aiap-preset-card:hover,
.aiap-imgset-card:hover,
.aiap-provider-tile:hover{border-color:var(--txt-l);transform:translateY(-1px);box-shadow:0 4px 16px -4px rgba(15,23,42,.08)}
/* タイル系カードの選択状態: 3 種類で同一スタイルなので集約 */
.aiap-preset-card.is-selected,
.aiap-imgset-card.is-selected,
.aiap-provider-tile.is-selected{border-color:var(--txt);box-shadow:0 12px 40px -8px rgba(15,23,42,.12),0 0 0 3px rgba(29,35,39,.04)}
.aiap-preset-card:focus-visible{outline:2px solid var(--blue);outline-offset:2px}

.aiap-preset-visual{display:flex;align-items:center;justify-content:center;height:110px;width:100%}
.aiap-preset-card-blog .aiap-preset-visual{background:linear-gradient(135deg,#fef3c7 0%,#fed7aa 100%);color:#c2410c}
.aiap-preset-card-sns  .aiap-preset-visual{background:linear-gradient(135deg,#d1fae5 0%,#a7f3d0 100%);color:#047857}
.aiap-preset-card-lite .aiap-preset-visual{background:linear-gradient(135deg,#e0e7ff 0%,#c7d2fe 100%);color:#3730a3}
.aiap-preset-icon{width:56px;height:56px;display:block}

.aiap-preset-body{padding:16px 18px 18px;display:flex;flex-direction:column;gap:6px}
.aiap-preset-title{font-size:16px;font-weight:700;color:var(--txt);display:flex;align-items:center;justify-content:space-between;gap:8px}
.aiap-preset-sub{font-size:13px;color:var(--txt-m);line-height:1.55}
.aiap-preset-meta{display:flex;gap:8px;margin-top:8px;flex-wrap:wrap}
.aiap-preset-chip{font-size:11px;font-weight:600;color:var(--txt-m);background:var(--bdr-l);padding:3px 9px;border-radius:999px}
.aiap-preset-check{display:inline-flex;align-items:center;gap:5px;font-size:11px;font-weight:700;color:var(--txt);opacity:0;transform:translateY(2px);transition:opacity .2s ease,transform .2s ease}
.aiap-preset-check svg{background:var(--txt);border-radius:50%;color:#fff;padding:2px}
.aiap-preset-card.is-selected .aiap-preset-check{opacity:1;transform:translateY(0)}

.aiap-image-current{background:var(--card);border:1px solid var(--bdr);border-radius:10px;padding:14px 18px;margin-bottom:20px;display:flex;align-items:center;gap:12px}
.aiap-image-current-dot{width:8px;height:8px;border-radius:50%;background:var(--txt);flex-shrink:0}
.aiap-image-current-text{flex:1;font-size:13px;color:var(--txt-m)}
.aiap-image-current-text strong{color:var(--txt);font-weight:700;font-size:14px;margin-right:6px}

.aiap-image-advanced{margin-top:24px;border-top:1px solid var(--bdr);padding-top:20px}
.aiap-image-advanced-toggle{display:flex;align-items:center;justify-content:space-between;width:100%;padding:12px 16px;background:var(--card);border:1px solid var(--bdr);border-radius:8px;font-family:inherit;font-size:13px;font-weight:600;color:var(--txt);cursor:pointer;transition:border-color .15s}
.aiap-image-advanced-toggle:hover{border-color:var(--txt-l)}
.aiap-image-advanced-label{display:flex;flex-direction:column;text-align:left}
.aiap-image-advanced-caption{display:block;font-size:11px;font-weight:500;color:var(--txt-l);margin-top:2px;letter-spacing:.02em}
.aiap-image-advanced-chev{transition:transform .2s;color:var(--txt-l);flex-shrink:0;margin-left:8px}
.aiap-image-advanced.is-open .aiap-image-advanced-chev{transform:rotate(180deg)}
.aiap-image-advanced-panel{margin-top:12px;padding:20px;background:var(--card);border:1px solid var(--bdr);border-radius:8px}

.aiap-field{display:flex;flex-direction:column;gap:6px;margin-bottom:18px}
.aiap-field:last-child{margin-bottom:0}
.aiap-field > label{font-size:13px;font-weight:600;color:var(--txt)}
.aiap-field-hint{font-size:12px;color:var(--txt-l);line-height:1.5}
.aiap-field-row{display:flex;align-items:center;gap:8px}
.aiap-field-row .aiap-field-unit{font-size:13px;color:var(--txt-m)}
.aiap-field-note{font-size:12px;color:var(--txt-l);background:var(--blue-bg);padding:10px 12px;border-radius:6px;margin-top:14px;line-height:1.5}

@media (min-width: 768px){
    .aiap-image-presets{grid-template-columns:repeat(3,1fr);gap:14px}
    .aiap-preset-visual{height:120px}
    .aiap-img-hero-title{font-size:26px}
}

/* ============================================
   画像設定 — 用途プリセットUI (新デザイン)
   全セレクタは .aiap-imgset- プレフィックスで衝突回避
   ============================================ */
.aiap-imgset-form{margin:0}
.aiap-imgset{max-width:780px;margin:0 auto}

.aiap-imgset-hero{margin:8px 4px 22px}
.aiap-imgset-eyebrow{display:inline-block;font-size:11px;font-weight:700;letter-spacing:.18em;color:var(--txt-l);text-transform:uppercase;margin-bottom:10px}
.aiap-imgset-title{font-size:22px;font-weight:700;line-height:1.45;letter-spacing:-.005em;color:var(--txt);margin:0;border:0;padding:0}
/* .aiap-imgset-lede は img-hero-sub 群と集約済み (上記) */

.aiap-imgset-presets{display:grid;grid-template-columns:1fr;gap:12px;margin-bottom:18px;padding:0}

.aiap-imgset-card{position:relative;background:var(--card);border:1.5px solid var(--bdr);border-radius:12px;padding:0;cursor:pointer;transition:border-color .2s,box-shadow .2s,transform .2s;overflow:hidden;text-align:left;width:100%;font-family:inherit;color:inherit;display:flex;flex-direction:column;-webkit-appearance:none;-moz-appearance:none;appearance:none}
/* :hover / .is-selected は preset-card 群と集約済み (上記) */
.aiap-imgset-card:focus-visible{outline:2px solid var(--blue);outline-offset:2px}

.aiap-imgset-card__visual{display:flex;align-items:center;justify-content:center;height:110px;width:100%;box-sizing:border-box}
.aiap-imgset-card--blog .aiap-imgset-card__visual{background:linear-gradient(135deg,#fef3c7 0%,#fed7aa 100%)}
.aiap-imgset-card--sns  .aiap-imgset-card__visual{background:linear-gradient(135deg,#d1fae5 0%,#a7f3d0 100%)}
.aiap-imgset-card--lite .aiap-imgset-card__visual{background:linear-gradient(135deg,#e0e7ff 0%,#c7d2fe 100%)}
.aiap-imgset-card__visual svg{display:block}

.aiap-imgset-card__body{display:flex;flex-direction:column;gap:6px;padding:16px 18px 18px;width:100%;box-sizing:border-box}
.aiap-imgset-card__title{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:15px;font-weight:700;color:var(--txt);width:100%}
.aiap-imgset-card__name{display:inline-block}
.aiap-imgset-card__sub{display:block;font-size:12.5px;color:var(--txt-m);line-height:1.55}
.aiap-imgset-card__chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;width:100%}
.aiap-imgset-card__chip{display:inline-block;font-size:10.5px;font-weight:600;color:var(--txt-m);background:var(--bdr-l);padding:3px 9px;border-radius:999px}
.aiap-imgset-card__check{display:inline-flex;align-items:center;gap:5px;font-size:11px;font-weight:700;color:var(--txt);opacity:0;transform:translateY(2px);transition:opacity .2s,transform .2s;flex-shrink:0}
.aiap-imgset-card__check svg{background:var(--txt);border-radius:50%;color:#fff;padding:2px;width:14px;height:14px;flex-shrink:0}
.aiap-imgset-card.is-selected .aiap-imgset-card__check{opacity:1;transform:translateY(0)}

.aiap-imgset-current{display:flex;align-items:center;gap:12px;background:var(--card);border:1px solid var(--bdr);border-radius:10px;padding:13px 16px;margin-bottom:18px}
.aiap-imgset-current__dot{width:8px;height:8px;border-radius:50%;background:var(--txt);flex-shrink:0}
.aiap-imgset-current__text{flex:1;font-size:12.5px;color:var(--txt-m);line-height:1.5}
.aiap-imgset-current__text strong{color:var(--txt);font-weight:700;font-size:13px;margin-right:6px}

.aiap-imgset-advanced{margin-top:22px;border-top:1px solid var(--bdr);padding-top:18px}
.aiap-imgset-advanced__toggle{display:flex;align-items:center;justify-content:space-between;width:100%;padding:12px 16px;background:var(--card);border:1px solid var(--bdr);border-radius:8px;font-family:inherit;font-size:13px;font-weight:600;color:var(--txt);cursor:pointer;text-align:left;transition:border-color .15s}
.aiap-imgset-advanced__toggle:hover{border-color:var(--txt-l)}
.aiap-imgset-advanced__label{display:flex;flex-direction:column;text-align:left}
.aiap-imgset-advanced__label-main{display:block}
.aiap-imgset-advanced__caption{display:block;font-size:11px;font-weight:500;color:var(--txt-l);margin-top:2px;letter-spacing:.02em}
.aiap-imgset-advanced__chev{transition:transform .2s;color:var(--txt-l);flex-shrink:0;margin-left:10px}
.aiap-imgset-advanced.is-open .aiap-imgset-advanced__chev{transform:rotate(180deg)}
.aiap-imgset-advanced__panel{display:none;margin-top:10px;padding:18px;background:var(--card);border:1px solid var(--bdr);border-radius:8px}
.aiap-imgset-advanced.is-open .aiap-imgset-advanced__panel{display:block}

.aiap-imgset-field{display:flex;flex-direction:column;gap:6px;margin-bottom:16px}
.aiap-imgset-field:last-child{margin-bottom:0}
.aiap-imgset-field > label{font-size:12.5px;font-weight:600;color:var(--txt)}
.aiap-imgset-field input[type=number]{font-family:inherit;font-size:13px;padding:7px 10px;border:1px solid var(--bdr);border-radius:6px;background:#fff;color:var(--txt);width:90px;max-width:100%;box-sizing:border-box}
.aiap-imgset-field select.aiap-full-select{width:100%;max-width:100%}
.aiap-imgset-field__row{display:flex;align-items:center;gap:8px}
.aiap-imgset-field__unit{font-size:12.5px;color:var(--txt-m)}
.aiap-imgset-field__hint{font-size:11.5px;color:var(--txt-l);line-height:1.5}
.aiap-imgset-field__note{font-size:12px;color:var(--txt-l);background:var(--blue-bg);padding:10px 12px;border-radius:6px;margin:14px 0 0;line-height:1.5}

.aiap-imgset-submit{margin-top:22px}

@media (min-width: 768px){
    .aiap-imgset-title{font-size:26px}
    .aiap-imgset-presets{grid-template-columns:repeat(3,1fr);gap:14px}
    .aiap-imgset-card__visual{height:130px}
}

/* ============================================
   Provider Selection - タイル型UI
   (システムフォントのみ。外部リソースは使わない)
   ============================================ */
.aiap-provider-form{max-width:780px;margin:0 auto}

.aiap-provider-hero{margin:8px 0 20px;padding:0 4px}
.aiap-provider-hero-eyebrow{display:inline-block;font-size:11px;font-weight:700;letter-spacing:.18em;color:var(--txt-l);text-transform:uppercase;margin-bottom:10px}
.aiap-provider-hero-title{font-size:22px;line-height:1.4;font-weight:700;letter-spacing:-.005em;color:var(--txt);border:0;padding:0;margin:0}
/* .aiap-provider-hero-sub は img-hero-sub 群と集約済み (上記) */

.aiap-provider-section-label{font-size:11px;font-weight:700;letter-spacing:.14em;color:var(--txt-l);text-transform:uppercase;margin:18px 4px 10px}

/* よく使われる: 大きめタイル */
.aiap-provider-popular{display:grid;grid-template-columns:1fr;gap:10px;margin-bottom:8px}
.aiap-provider-tile{
    position:relative;background:var(--card);
    border:1.5px solid var(--bdr);border-radius:12px;
    padding:14px 16px;cursor:pointer;transition:transform .18s,box-shadow .18s,border-color .18s;
    display:flex;align-items:center;gap:12px;
    font-family:inherit;color:inherit;text-align:left;width:100%;
}
/* :hover / .is-selected は preset-card 群と集約済み (上記) */
.aiap-provider-tile:focus-visible{outline:2px solid var(--blue);outline-offset:2px}

.aiap-provider-tile-icon{flex-shrink:0}
.aiap-provider-tile-meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.aiap-provider-tile-name{font-size:14px;font-weight:700;color:var(--txt);line-height:1.3}
.aiap-provider-tile-sub{font-size:11px;color:var(--txt-m);line-height:1.4}

.aiap-provider-tile-status{
    display:inline-flex;align-items:center;gap:5px;
    font-size:11px;font-weight:600;color:var(--txt-l);flex-shrink:0;
}
.aiap-provider-tile-status::before{content:"";display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--bdr)}
.aiap-provider-tile-status.is-configured{color:var(--green)}
.aiap-provider-tile-status.is-configured::before{background:var(--green)}

.aiap-provider-tile-check{
    width:22px;height:22px;border-radius:50%;background:var(--txt);color:#fff;
    display:none;align-items:center;justify-content:center;flex-shrink:0;
}
.aiap-provider-tile.is-selected .aiap-provider-tile-check{display:inline-flex}
.aiap-provider-tile.is-selected .aiap-provider-tile-status{display:none}

/* その他: コンパクトタイル */
.aiap-provider-other{display:grid;grid-template-columns:repeat(2,1fr);gap:8px;margin-bottom:8px}
.aiap-provider-tile-compact{
    position:relative;background:var(--card);
    border:1.5px solid var(--bdr);border-radius:10px;
    padding:10px 12px;cursor:pointer;transition:border-color .15s,box-shadow .15s;
    display:flex;align-items:center;gap:9px;
    font-family:inherit;color:inherit;text-align:left;width:100%;
}
.aiap-provider-tile-compact:hover{border-color:var(--txt-l);box-shadow:var(--shadow-sm)}
.aiap-provider-tile-compact.is-selected{border-color:var(--txt);box-shadow:var(--shadow-md),0 0 0 3px rgba(29,35,39,.04)}
.aiap-provider-tile-compact:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.aiap-provider-tile-compact .aiap-provider-tile-icon{width:30px;height:30px;font-size:12px;border-radius:6px;flex-shrink:0}
.aiap-provider-tile-compact .aiap-provider-tile-name{flex:1;min-width:0;font-size:12px;font-weight:600;color:var(--txt);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.aiap-provider-tile-compact .aiap-provider-tile-status{font-size:0;width:7px;height:7px;border-radius:50%;background:var(--bdr);padding:0;margin-left:auto;flex-shrink:0}
.aiap-provider-tile-compact .aiap-provider-tile-status::before{display:none}
.aiap-provider-tile-compact .aiap-provider-tile-status.is-configured{background:var(--green)}
.aiap-provider-tile-compact.is-selected .aiap-provider-tile-status{display:none}
.aiap-provider-tile-compact .aiap-provider-tile-check{width:18px;height:18px;margin-left:auto}
.aiap-provider-tile-compact .aiap-provider-tile-check svg{width:11px;height:11px}

/* 設定パネル (選択中プロバイダのみ) */
.aiap-provider-panel{
    background:var(--card);border:1.5px solid var(--bdr);border-radius:12px;
    margin-top:18px;overflow:hidden;padding:0;
}
.aiap-provider-panel:not([hidden]){animation:aiap-slidedown .35s cubic-bezier(.2,.8,.2,1)}
@keyframes aiap-slidedown{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:translateY(0)}}

.aiap-provider-panel-header{
    display:flex;align-items:center;gap:12px;
    padding:14px 18px;border-bottom:1px solid var(--bdr-l);
    background:linear-gradient(180deg,#fafafa,transparent);
}
.aiap-provider-panel-icon{flex-shrink:0}
.aiap-provider-panel-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}
.aiap-provider-panel-title{font-size:14px;font-weight:700;color:var(--txt);line-height:1.3}
.aiap-provider-panel-sub{font-size:11px;color:var(--txt-m)}
.aiap-provider-panel-active{
    display:inline-flex;align-items:center;gap:5px;
    padding:3px 9px;border-radius:999px;background:var(--green-bg);color:var(--green);
    font-size:10px;font-weight:700;letter-spacing:.04em;flex-shrink:0;
}
.aiap-provider-panel-active::before{content:"";width:5px;height:5px;border-radius:50%;background:var(--green)}
.aiap-provider-panel-body{padding:16px 18px 18px}

.aiap-field-label{display:block;font-size:12px;font-weight:600;color:var(--txt);margin-bottom:5px}
.aiap-field-label-hint{color:var(--txt-l);font-weight:400;margin-left:6px;font-size:11px}
.aiap-input-text{
    flex:1;font-family:inherit;font-size:13px;
    padding:8px 11px;border:1px solid var(--bdr);border-radius:6px;
    background:#fff;color:var(--txt);min-width:0;width:100%;box-sizing:border-box;
}
.aiap-input-text:focus{outline:2px solid var(--blue);outline-offset:-1px;border-color:transparent}
.aiap-select{
    flex:1;font-family:inherit;font-size:13px;
    padding:8px 11px;border:1px solid var(--bdr);border-radius:6px;
    background:#fff;color:var(--txt);min-width:0;
    appearance:none;-webkit-appearance:none;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5c5c' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat:no-repeat;background-position:right 11px center;padding-right:32px;
}
.aiap-btn{
    font-family:inherit;font-size:12px;font-weight:600;
    padding:8px 12px;border:1px solid var(--bdr);border-radius:6px;
    background:#fff;color:var(--txt);cursor:pointer;transition:all .15s;
    display:inline-flex;align-items:center;gap:5px;flex-shrink:0;
}
.aiap-btn:hover{border-color:var(--txt-l);background:#fafafa}
.aiap-btn .dashicons{font-size:14px;width:14px;height:14px;line-height:1}
.aiap-provider-panel .aiap-btn-primary{background:var(--txt);color:#fff;border-color:var(--txt)}
.aiap-provider-panel .aiap-btn-primary:hover{background:#000;border-color:#000}
.aiap-btn-icon{padding:8px 10px}

.aiap-field-actions{display:flex;align-items:center;justify-content:space-between;margin-top:8px;flex-wrap:wrap;gap:8px}
.aiap-field-link{font-size:11px;color:var(--blue);text-decoration:none;display:inline-flex;align-items:center;gap:3px}
.aiap-field-link:hover{text-decoration:underline}

/* デスクトップレイアウト */
@media (min-width: 768px){
    .aiap-provider-hero-title{font-size:26px}
    .aiap-provider-popular{grid-template-columns:repeat(3,1fr);gap:12px}
    .aiap-provider-other{grid-template-columns:repeat(4,1fr)}
    .aiap-provider-tile{flex-direction:column;text-align:center;padding:18px 14px;align-items:center;min-height:140px}
    .aiap-provider-tile .aiap-provider-tile-meta{align-items:center;text-align:center}
    .aiap-provider-tile .aiap-provider-tile-status,
    .aiap-provider-tile .aiap-provider-tile-check{position:absolute;top:10px;right:10px}
    .aiap-provider-tile .aiap-provider-tile-icon{width:44px;height:44px;font-size:16px;margin-bottom:4px}
}

/* 既存のグラデセレクター .aiap-provider-picker は新UIで使わないので非表示 */
.aiap-provider-form .aiap-provider-picker{display:none}

/* ============================================
   Top Tab Navigation
   ============================================ */
.aiap-page-head{padding:14px 0 8px;border-bottom:0}
.aiap-page-head h1{font-size:18px;font-weight:700;letter-spacing:-.01em;color:var(--txt);margin:0 0 4px}

.aiap-tabs{
    display:flex;gap:0;
    border-bottom:1px solid var(--bdr);
    margin:0 0 24px;padding:0;
    overflow-x:auto;-webkit-overflow-scrolling:touch;
    scrollbar-width:none;
}
.aiap-tabs::-webkit-scrollbar{display:none}
.aiap-tab{
    display:inline-flex;align-items:center;gap:6px;
    padding:11px 14px;
    font-size:13px;font-weight:500;color:var(--txt-m);
    text-decoration:none;
    border-bottom:2px solid transparent;
    transition:color .15s,border-color .15s;
    flex-shrink:0;white-space:nowrap;
    box-shadow:none;
}
.aiap-tab:hover{color:var(--txt)}
.aiap-tab.is-active{color:var(--txt);border-bottom-color:var(--txt);font-weight:600}
.aiap-tab:focus{box-shadow:none;outline:none}
.aiap-tab:focus-visible{outline:2px solid var(--blue);outline-offset:2px;border-radius:4px}
.aiap-tab .aiap-tab-icon{font-size:15px;width:15px;height:15px;line-height:1}

.aiap-tab-panel{padding:0}

/* ============================================
   Plan Card v2
   ============================================ */
.aiap-plan-card-v2{
    background:var(--card);border:1.5px solid var(--bdr);border-radius:12px;
    padding:16px 18px;margin:0 0 18px;
}
.aiap-plan-card-v2-pro{border-color:#1d8348;background:linear-gradient(180deg,#edfaef,transparent 40%)}
.aiap-plan-card-v2-trial{border-color:#92400e;background:linear-gradient(180deg,#fef3c7,transparent 40%)}
.aiap-plan-card-v2-row{display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.aiap-plan-card-v2-name{display:flex;align-items:center;gap:8px;flex-shrink:0}
.aiap-plan-card-v2-label{font-size:14px;font-weight:700;color:var(--txt)}
.aiap-plan-card-v2-badge{
    font-size:10px;font-weight:800;letter-spacing:.06em;
    padding:2px 8px;border-radius:999px;background:var(--txt);color:#fff;
}
.aiap-plan-card-v2-badge-pro{background:#1d8348}
.aiap-plan-card-v2-badge-trial{background:#92400e}
.aiap-plan-card-v2-info{flex:1;min-width:0;display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}
.aiap-plan-card-v2-stat{font-size:13px;color:var(--txt-m)}
.aiap-plan-card-v2-stat strong{font-size:18px;font-weight:700;color:var(--txt);margin-right:2px}
.aiap-plan-card-v2-stat-sep{color:var(--txt-l);margin:0 2px}
.aiap-plan-card-v2-stat-limit{color:var(--txt-m)}
.aiap-plan-card-v2-stat-unit{margin-left:6px;color:var(--txt-l);font-size:12px}
.aiap-plan-card-v2-cta{
    display:inline-flex;align-items:center;gap:5px;
    padding:7px 14px;background:#1d2327;color:#fff;border-radius:6px;
    font-size:12px;font-weight:600;text-decoration:none;flex-shrink:0;
    transition:background .15s;
}
.aiap-plan-card-v2-cta:hover{background:#000;color:#fff}
.aiap-plan-card-v2-cta .dashicons{font-size:14px;width:14px;height:14px}
.aiap-plan-card-v2-bar{height:5px;background:var(--bdr-l);border-radius:999px;margin-top:12px;overflow:hidden}
.aiap-plan-card-v2-bar-fill{height:100%;width:var(--aiap-bar-pct,0%);background:var(--green);border-radius:999px;transition:width .3s}
.aiap-plan-card-v2-bar-fill.aiap-usage-fill-warn{background:#f59e0b}
.aiap-plan-card-v2-bar-fill.aiap-usage-fill-full{background:var(--red)}
.aiap-plan-card-v2-warning{font-size:12px;color:#92400e;margin:8px 0 0}

/* ============================================
   Section (cards used by settings/prompts/logs)
   ============================================ */
.aiap-section{
    background:var(--card);border:1.5px solid var(--bdr);border-radius:12px;
    margin:0 0 18px;overflow:hidden;
}
.aiap-section-header{padding:14px 18px 0}
.aiap-section-header:last-child{padding-bottom:14px}
.aiap-section-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.aiap-section-title{font-size:14px;font-weight:700;color:var(--txt);margin:0;border:0;padding:0;line-height:1.3}
.aiap-section-sub{font-size:12px;color:var(--txt-m);margin:4px 0 0;line-height:1.5}
.aiap-section-count{
    font-size:11px;font-weight:700;color:var(--txt-m);
    background:var(--bdr-l);padding:2px 8px;border-radius:999px;
}
.aiap-section-cta{font-size:12px;color:var(--blue);text-decoration:none;font-weight:600;margin-left:auto}
.aiap-section-cta:hover{text-decoration:underline}
.aiap-section-action{margin-left:auto}
.aiap-section-body{padding:14px 18px 18px}
.aiap-section-body-flush{padding:0}
.aiap-section-locked{opacity:.55;pointer-events:none}
.aiap-section-pro{position:relative}

/* Pro pill */
.aiap-pro-pill{
    display:inline-block;font-size:9px;font-weight:800;letter-spacing:.08em;
    padding:2px 7px;border-radius:999px;background:#1d8348;color:#fff;
    text-transform:uppercase;vertical-align:middle;
}

/* ============================================
   Form fields (settings)
   ============================================ */
.aiap-grid-2{display:grid;grid-template-columns:1fr;gap:14px}
@media (min-width: 768px){
    .aiap-grid-2{grid-template-columns:1fr 1fr;gap:14px 18px}
    .aiap-field-fullspan{grid-column:1/-1}
}
.aiap-input-narrow{max-width:120px}

.aiap-row-flex{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.aiap-row-flex-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.aiap-row-flex-title{font-size:14px;font-weight:700;color:var(--txt)}
.aiap-row-flex-sub{font-size:12px;color:var(--txt-m)}

.aiap-checkbox-row{display:flex;gap:10px;align-items:flex-start;cursor:pointer;padding:6px 0}
.aiap-checkbox-row input[type=checkbox]{margin-top:3px;flex-shrink:0}
.aiap-checkbox-row > span{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
.aiap-checkbox-row strong{font-size:13px;font-weight:600;color:var(--txt);line-height:1.4}

.aiap-radio-row{display:flex;gap:8px;align-items:center;cursor:pointer;padding:4px 0}
.aiap-radio-row input[type=radio]{flex-shrink:0}
.aiap-radio-row > span{font-size:13px;color:var(--txt);line-height:1.4}

.aiap-required{color:#d63638;font-weight:600;margin-left:2px}

/* Segment control (sensitivity) */
.aiap-segment{
    display:inline-flex;background:var(--bdr-l);border-radius:8px;padding:3px;gap:0;
    border:1px solid var(--bdr);
}
.aiap-segment-option{
    flex:1;cursor:pointer;text-align:center;padding:6px 12px;border-radius:6px;
    font-size:12px;font-weight:600;color:var(--txt-m);transition:all .15s;
    min-width:60px;
}
.aiap-segment-option:hover{color:var(--txt)}
.aiap-segment-option.is-active{background:#fff;color:var(--txt);box-shadow:0 1px 3px rgba(0,0,0,.06)}
.aiap-segment-option input{position:absolute;opacity:0;width:0;height:0}

/* SEO group */
.aiap-seo-group-label{
    display:block;font-size:11px;font-weight:700;letter-spacing:.1em;
    color:var(--txt-l);text-transform:uppercase;margin:14px 0 6px;
}
.aiap-seo-group-label:first-child{margin-top:0}
.aiap-seo-check{display:inline-flex;align-items:center;gap:6px;padding:5px 12px 5px 0;font-size:13px;color:var(--txt);cursor:pointer}

/* ============================================
   Banners (warning/error/info)
   ============================================ */
.aiap-banner{
    display:flex;align-items:center;gap:12px;
    padding:12px 16px;border-radius:10px;margin:0 0 16px;
    border:1px solid var(--bdr);background:var(--card);
    flex-wrap:wrap;
}
.aiap-banner-warning{background:#fffbeb;border-color:#fde68a;color:#92400e}
.aiap-banner-warning .dashicons{color:#92400e;font-size:18px;width:18px;height:18px}
.aiap-banner-error{background:#fef2f2;border-color:#fecaca;color:#991b1b}
.aiap-banner-error .dashicons{color:#991b1b;font-size:18px;width:18px;height:18px}
.aiap-banner-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px;font-size:13px}
.aiap-banner-text strong{font-size:13px;font-weight:700}
.aiap-banner-cta{
    display:inline-flex;align-items:center;gap:5px;
    padding:6px 12px;background:#1d2327;color:#fff;border-radius:6px;
    font-size:12px;font-weight:600;text-decoration:none;flex-shrink:0;
}
.aiap-banner-cta:hover{background:#000;color:#fff}
.aiap-banner-cta .dashicons{font-size:13px;width:13px;height:13px;color:#fff}

/* ============================================
   Image enable row (image_provider)
   ============================================ */
.aiap-image-enable-row{
    background:var(--card);border:1.5px solid var(--bdr);border-radius:10px;
    padding:12px 16px;margin:0 0 18px;display:flex;align-items:center;
}
.aiap-image-enable-row .aiap-toggle-switch{margin:0}

/* ============================================
   Quick Post (editor)
   ============================================ */
.aiap-quickpost{max-width:780px;margin:0 auto}
.aiap-quickpost-form{background:var(--card);border:1.5px solid var(--bdr);border-radius:14px;padding:18px;margin-bottom:18px}
.aiap-editor{margin-bottom:16px}
.aiap-editor-label{display:block;font-size:11px;font-weight:700;letter-spacing:.14em;color:var(--txt-l);text-transform:uppercase;margin-bottom:8px}
.aiap-editor-textarea{
    width:100%;font-family:inherit;font-size:15px;line-height:1.65;
    padding:14px 16px;border:1.5px solid var(--bdr);border-radius:10px;
    background:#fff;color:var(--txt);resize:vertical;
    transition:border-color .15s,box-shadow .15s;box-sizing:border-box;
}
.aiap-editor-textarea:focus{outline:0;border-color:var(--txt);box-shadow:0 0 0 3px rgba(29,35,39,.05)}
.aiap-editor-textarea-mono{font-family:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;line-height:1.6}
.aiap-editor-hint{font-size:12px;color:var(--txt-l);margin:6px 0 0}

.aiap-quickpost-options{display:grid;grid-template-columns:1fr;gap:14px;margin-bottom:18px;padding-top:14px;border-top:1px solid var(--bdr-l)}
@media (min-width: 768px){.aiap-quickpost-options{grid-template-columns:1fr 1fr;gap:18px}}

.aiap-quickpost-action{display:flex;justify-content:flex-end}
.aiap-btn-large{
    padding:11px 22px;font-size:14px;font-weight:700;
    background:var(--txt);color:#fff;border:0;border-radius:8px;cursor:pointer;
    display:inline-flex;align-items:center;gap:6px;transition:background .15s;
}
.aiap-btn-large:hover{background:#000}
.aiap-btn-large:disabled{background:var(--txt-l);cursor:not-allowed}
.aiap-btn-large .dashicons{font-size:15px;width:15px;height:15px}

/* ============================================
   Task list (prompts)
   ============================================ */
.aiap-task-list{display:flex;flex-direction:column;gap:8px}
.aiap-task-card{
    background:#fff;border:1px solid var(--bdr);border-radius:10px;
    padding:0;overflow:hidden;transition:border-color .15s;
}
.aiap-task-card:hover{border-color:var(--txt-l)}
.aiap-task-card.is-disabled{opacity:.7;background:#fafafa}
.aiap-task-card-row{display:flex;align-items:flex-start;gap:12px;padding:12px 14px}
.aiap-task-status{
    width:8px;height:8px;border-radius:50%;background:var(--bdr);flex-shrink:0;margin-top:6px;
}
.aiap-task-status.is-on{background:var(--green);box-shadow:0 0 0 3px rgba(16,185,129,.15)}
.aiap-task-card-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.aiap-task-card-state{font-size:10px;font-weight:700;letter-spacing:.08em;color:var(--txt-l);text-transform:uppercase}
.aiap-task-card.is-enabled .aiap-task-card-state{color:var(--green)}
.aiap-task-card-prompt{font-size:13px;color:var(--txt);line-height:1.5;font-weight:500;word-break:normal;overflow-wrap:break-word}
.aiap-task-card-meta{font-size:11px;color:var(--txt-l);display:flex;gap:8px;flex-wrap:wrap;margin-top:2px}
.aiap-task-card-actions{display:flex;gap:4px;flex-shrink:0}

.aiap-btn-icon-only{
    width:30px;height:30px;padding:0;border:1px solid var(--bdr);background:#fff;
    border-radius:6px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;
    color:var(--txt-m);transition:all .15s;
}
.aiap-btn-icon-only:hover{border-color:var(--txt-l);color:var(--txt);background:#fafafa}
.aiap-btn-icon-only .dashicons{font-size:15px;width:15px;height:15px;line-height:1}
.aiap-btn-danger-icon:hover{border-color:#fecaca;color:#991b1b;background:#fef2f2}

.aiap-task-edit{padding:0 14px}
.aiap-task-edit[open]{padding:14px;border-top:1px solid var(--bdr-l);background:#fafafa}
.aiap-task-edit-form .aiap-field{margin-bottom:14px}
.aiap-task-edit-form .aiap-field:last-child{margin-bottom:0}
.aiap-task-edit-action{display:flex;gap:8px;justify-content:flex-end;margin-top:14px}

/* Schedule grid */
.aiap-sched-grid{display:grid;grid-template-columns:1fr;gap:6px;margin:6px 0 0}
@media (min-width: 768px){.aiap-sched-grid{grid-template-columns:1fr 1fr;gap:8px 14px}}
.aiap-sched-row{display:flex;align-items:center;gap:8px}
.aiap-sched-day{font-size:11px;font-weight:700;color:var(--txt-m);width:28px;flex-shrink:0;text-transform:uppercase;letter-spacing:.04em}
.aiap-sched-row .aiap-input-text{flex:1;min-width:0;font-size:12px}

/* ============================================
   Empty state
   ============================================ */
.aiap-empty-state{
    text-align:center;padding:36px 20px;
    color:var(--txt-m);
}
.aiap-empty-state .dashicons{font-size:32px;width:32px;height:32px;color:var(--txt-l);margin-bottom:8px}
.aiap-empty-state p{margin:0;font-size:14px;font-weight:600;color:var(--txt)}
.aiap-empty-state-sub{margin-top:4px !important;font-size:12px !important;color:var(--txt-l) !important;font-weight:400 !important}

/* ============================================
   Log list
   ============================================ */
.aiap-log-list{list-style:none;margin:0;padding:0}
.aiap-log-item{
    display:flex;gap:12px;padding:14px 18px;
    border-bottom:1px solid var(--bdr-l);
}
.aiap-log-item:last-child{border-bottom:0}
.aiap-log-dot{
    width:8px;height:8px;border-radius:50%;flex-shrink:0;margin-top:6px;
    background:var(--txt-l);
}
.aiap-log-dot-success{background:var(--green);box-shadow:0 0 0 3px rgba(16,185,129,.15)}
.aiap-log-dot-error{background:var(--red);box-shadow:0 0 0 3px rgba(214,54,56,.15)}
.aiap-log-dot-warning,.aiap-log-dot-warn{background:#f59e0b;box-shadow:0 0 0 3px rgba(245,158,11,.15)}
.aiap-log-dot-info{background:var(--blue)}
.aiap-log-body{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.aiap-log-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.aiap-log-status-text{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--txt-m)}
.aiap-log-item-success .aiap-log-status-text{color:var(--green)}
.aiap-log-item-error .aiap-log-status-text{color:var(--red)}
.aiap-log-item-warning .aiap-log-status-text,.aiap-log-item-warn .aiap-log-status-text{color:#92400e}
.aiap-log-time{font-size:11px;color:var(--txt-l);font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}
.aiap-log-message{font-size:13px;color:var(--txt);margin:0;line-height:1.5;word-break:normal;overflow-wrap:break-word}

/* ============================================
   Hide legacy provider picker globally
   ============================================ */
.aiap-provider-picker{display:none}
.aiap-scroll-stack{padding:0}

/* ============================================
   Settings form max-width
   ============================================ */
.aiap-settings-form,.aiap-prompts-form,.aiap-quickpost{max-width:780px;margin:0 auto}

/* FAQ submenu */
.aiap-faq-wrap .aiap-card h2{margin-bottom:12px}
.aiap-faq-list{display:grid;gap:8px}
.aiap-faq-item{border:1px solid var(--bdr);border-radius:10px;background:#fff;overflow:hidden}
.aiap-faq-item summary{cursor:pointer;font-weight:600;padding:12px 14px;line-height:1.5}
.aiap-faq-item summary:hover{background:#f8fafc}
.aiap-faq-item p{margin:0;padding:0 14px 14px;color:var(--txt-m);line-height:1.7;white-space:normal}

/* Terms of Use submenu - consent warning */
.aiap-terms-consent{margin:0 0 16px;padding:16px 18px;background:#fef2f2;border:2px solid #ef4444;border-left-width:6px;border-radius:8px;color:#7f1d1d;line-height:1.7}
.aiap-terms-consent h2{margin:0 0 8px;font-size:16px;color:#991b1b;display:flex;align-items:center;gap:6px}
.aiap-terms-consent h2::before{content:"⚠";font-size:20px}
.aiap-terms-consent p{margin:0 0 6px;font-size:14px}
.aiap-terms-consent strong{color:#7f1d1d;font-weight:700}
.aiap-terms-consent p:last-child{margin-bottom:0}

/* Generated posts list - mobile auxiliary info inside primary (title) column.
   Desktop: hidden (data already shown in dedicated columns).
   Mobile (<=782px, where WP_List_Table collapses non-primary columns): visible
   so the user can identify each post even when other columns are folded. */
.aiap-row-aux{display:none;font-size:12px;color:#646970;margin-top:4px;font-weight:400;line-height:1.4}
@media screen and (max-width: 782px){
  .aiap-row-aux{display:block}
  /* Suppress the column-header lists that appear as vertical strips on mobile.
     WP_List_Table renders headers in both <thead> AND <tfoot>; theme CSS in
     this site overrides WP core's mobile rules and lets them expand into a
     stacked list of column names ("AI Generated Title / Created At / ..." etc).
     Targeting the dedicated class added via get_table_classes() so the rule
     is independent of any wrapper element. */
  table.aiap-generated-posts thead,
  table.aiap-generated-posts thead tr,
  table.aiap-generated-posts thead th,
  table.aiap-generated-posts tfoot,
  table.aiap-generated-posts tfoot tr,
  table.aiap-generated-posts tfoot th{display:none !important}
}

/* Execution log list (run_logs tab) */
.aiap-run-logs-empty{margin:8px 0;color:var(--txt-m);font-size:13px}
.aiap-run-logs-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}
.aiap-run-logs-item{border:1px solid var(--bdr);border-left-width:4px;border-radius:8px;background:#fff;padding:10px 12px}
.aiap-run-logs-item.is-success{border-left-color:#22c55e}
.aiap-run-logs-item.is-error{border-left-color:#ef4444;background:#fef2f2}
.aiap-run-logs-item.is-warning{border-left-color:#f59e0b;background:#fffbeb}
.aiap-run-logs-item.is-info{border-left-color:#3b82f6}
.aiap-run-logs-meta{display:flex;align-items:center;gap:8px;margin-bottom:4px;flex-wrap:wrap}
.aiap-run-logs-badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:600;letter-spacing:.02em;background:#e5e7eb;color:#374151}
.aiap-run-logs-item.is-success .aiap-run-logs-badge{background:#dcfce7;color:#166534}
.aiap-run-logs-item.is-error   .aiap-run-logs-badge{background:#fee2e2;color:#991b1b}
.aiap-run-logs-item.is-warning .aiap-run-logs-badge{background:#fef3c7;color:#92400e}
.aiap-run-logs-item.is-info    .aiap-run-logs-badge{background:#dbeafe;color:#1e40af}
.aiap-run-logs-time{font-size:12px;color:var(--txt-m);font-variant-numeric:tabular-nums}
.aiap-run-logs-msg{font-size:13px;color:var(--txt);line-height:1.6;word-break:break-word}

/* Plugins list page: Upgrade to Pro link */
.aiap-plugin-action-upgrade{color:#7c3aed;font-weight:600}

/* ============================================================
   Generated history: pagination control UX
   ------------------------------------------------------------
   レイアウト: [bulkactions(=非表示)] [範囲インジケータ] [ページ送り]
   - desktop: space-between で範囲表示=左 / ページ送り=右
   - mobile : 縦に積んで中央寄せ。first/last ボタンは隠す。
   ============================================================ */
.aiap-logs-table-section .tablenav{
  margin:0;
  padding:10px 16px;
  height:auto;
  min-height:0;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:10px 16px;
  background:#fff;
  border-bottom:1px solid var(--bdr, #e5e7eb);
  box-sizing:border-box;
}
.aiap-logs-table-section .tablenav.bottom{
  border-top:1px solid var(--bdr, #e5e7eb);
  border-bottom:0;
}
/* バルクアクションは現状 UI 上は使っていないため非表示 */
.aiap-logs-table-section .tablenav .alignleft.actions{display:none}

/* 範囲インジケータ ("Showing 21–40 of 150") */
.aiap-logs-table-section .aiap-tablenav-info{
  flex:1 1 auto;
  min-width:0;
  margin:0;
  font-size:13px;
  color:var(--txt-m, #52525b);
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* WP 標準の "150 items" は範囲インジケータと役割が重複するので隠す */
.aiap-logs-table-section .tablenav-pages .displaying-num{display:none}

/* ページ送りブロック全体 */
.aiap-logs-table-section .tablenav .tablenav-pages{
  flex:0 0 auto;
  float:none;
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin:0;
  color:var(--txt-m, #52525b);
}
.aiap-logs-table-section .tablenav-pages .pagination-links{
  display:inline-flex;
  align-items:center;
  gap:4px;
}

/* ページ送りボタン (first/prev/next/last) と無効状態の span */
.aiap-logs-table-section .tablenav-pages .button,
.aiap-logs-table-section .tablenav-pages .tablenav-pages-navspan{
  min-width:34px;
  width:34px;
  height:34px;
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:8px;
  box-sizing:border-box;
  line-height:1;
  font-size:18px;
  font-weight:500;
  background:#fff;
  color:var(--txt, #18181b);
  border:1px solid var(--bdr, #e4e4e7);
  box-shadow:0 1px 2px rgb(0 0 0 / 0.04);
  transition:background-color .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease;
}
/* «(最初) / »(最後) は ‹ › と字形が紛らわしいので、有効時に
   背景を薄く / 字を大きく入れて「端ジャンプ」だと一目で分かるようにする。 */
.aiap-logs-table-section .tablenav-pages a.first-page.button,
.aiap-logs-table-section .tablenav-pages a.last-page.button{
  background:var(--bg-soft, #f9fafb);
  font-size:20px;
}
.aiap-logs-table-section .tablenav-pages a.button:hover{
  background:var(--bg-hover, #f4f4f5);
  border-color:var(--txt-l, #a1a1aa);
  color:var(--txt, #18181b);
}
.aiap-logs-table-section .tablenav-pages a.button:focus-visible{
  outline:2px solid var(--blue, #2563eb);
  outline-offset:2px;
  border-color:var(--blue, #2563eb);
}
/* 無効状態 (1ページ目で « ‹ / 最終ページで › » が span として描画される) */
.aiap-logs-table-section .tablenav-pages .tablenav-pages-navspan{
  color:var(--txt-l, #a1a1aa);
  border-color:var(--bdr-l, #f4f4f5);
  background:var(--bg-soft, #f9fafb);
  box-shadow:none;
  cursor:not-allowed;
}

/* ページ番号入力 (current-page) と "/ N" 表示 */
.aiap-logs-table-section .tablenav-pages .paging-input{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin:0 4px;
  font-size:13px;
  font-variant-numeric:tabular-nums;
}
.aiap-logs-table-section .tablenav-pages .current-page{
  width:48px;
  min-width:48px;
  height:34px;
  padding:0 6px;
  margin:0;
  text-align:center;
  border-radius:8px;
  border:1px solid var(--bdr, #e4e4e7);
  background:#fff;
  font-weight:600;
  font-size:14px;
  font-variant-numeric:tabular-nums;
  color:var(--txt, #18181b);
  box-sizing:border-box;
  box-shadow:0 1px 2px rgb(0 0 0 / 0.04);
  transition:border-color .12s ease, box-shadow .12s ease;
}
.aiap-logs-table-section .tablenav-pages .current-page:focus{
  border-color:var(--blue, #2563eb);
  box-shadow:0 0 0 3px rgb(37 99 235 / 0.18);
  outline:none;
}
.aiap-logs-table-section .tablenav-paging-text{
  display:inline-flex;
  align-items:center;
  gap:4px;
  white-space:nowrap;
  margin:0;
  font-size:13px;
  color:var(--txt-m, #52525b);
}
.aiap-logs-table-section .tablenav-paging-text .total-pages{
  font-weight:600;
  color:var(--txt, #18181b);
}

/* ====== モバイル (<=782px) ====== */
@media screen and (max-width: 782px){
  .aiap-logs-table-section .aiap-section-body{padding:0;overflow:hidden}
  .aiap-logs-table-section .tablenav{
    padding:12px;
    flex-direction:column;
    align-items:stretch;
    gap:8px;
  }
  /* モバイルではバルクアクション領域は完全に潰す */
  .aiap-logs-table-section .bulkactions{display:none !important}

  /* 範囲表示はページ送りの上に中央寄せで小さく */
  .aiap-logs-table-section .aiap-tablenav-info{
    text-align:center;
    font-size:12px;
    white-space:normal;
    overflow:visible;
    text-overflow:clip;
  }

  /* ページ送りはタップしやすく大きめ・中央寄せ */
  .aiap-logs-table-section .tablenav .tablenav-pages{
    width:100%;
    justify-content:center;
    gap:8px;
  }
  .aiap-logs-table-section .tablenav-pages .pagination-links{gap:4px}
  /* モバイルでも «(最初) ‹(前へ) ›(次へ) »(最後) の4ボタンを表示する。
     端ジャンプボタンは多ページ時に直接入力より早くたどり着けるので隠さない。
     font-size を素直に上げることで、有効リンクと無効 span (.tablenav-pages-navspan)
     のどちらでも «‹›» 文字が同じ大きさで描画されるようにする (::before 不要)。 */
  .aiap-logs-table-section .tablenav-pages .button,
  .aiap-logs-table-section .tablenav-pages .tablenav-pages-navspan{
    min-width:40px;
    width:40px;
    height:40px;
    font-size:22px;
    border-radius:10px;
  }
  /* モバイルでも «(最初) »(最後) は背景を薄くして ‹ › と区別する */
  .aiap-logs-table-section .tablenav-pages a.first-page.button,
  .aiap-logs-table-section .tablenav-pages a.last-page.button{
    background:var(--bg-soft, #f9fafb);
    font-size:24px;
  }
  .aiap-logs-table-section .tablenav-pages .current-page{
    width:56px;
    min-width:56px;
    height:40px;
    font-size:16px;
    border-radius:10px;
  }
  .aiap-logs-table-section .tablenav-paging-text{
    font-size:14px;
    color:var(--txt, #18181b);
  }

  /* ====== モバイル: テーブル → カードリスト変換 ======
     Bug fix: 元コードでは tr/td/th だけ display:block にしていたため、親 <table>/<tbody>
     のテーブルレイアウトが残り、admin-modern.css の固定 min-width 解除が効いた状態でも
     table の本来の固有幅 (列の合計) で引き伸ばされて右側にはみ出していた。
     <table> と <tbody> も display:block にして純粋な縦積みカードリストに変換する。 */
  .aiap-logs-table-section .aiap-section-body{
    /* 念のため、何かが計算外に広がっても画面外までは出さない */
    max-width:100%;
    overflow:hidden;
  }
  table.aiap-generated-posts{
    display:block;
    width:100%;
    max-width:100%;
    margin:0;
    border:0;
    box-sizing:border-box;
  }
  table.aiap-generated-posts tbody{
    display:block;
    width:100%;
    max-width:100%;
  }
  table.aiap-generated-posts tbody tr{
    display:block;
    width:100%;
    max-width:100%;
    margin:0;
    padding:14px 16px;
    border-bottom:1px solid var(--bdr, #e5e7eb);
    background:#fff;
    box-sizing:border-box;
    overflow:hidden; /* 万一中身がはみ出してもカード単位でクリップ */
  }
  table.aiap-generated-posts tbody tr:last-child{border-bottom:0}
  table.aiap-generated-posts tbody td,
  table.aiap-generated-posts tbody th{
    /* Bug fix: WP コアのモバイル CSS は
         .wp-list-table tr td.column-primary ~ td:not(.check-column) { display:none }
       で非プライマリ列を強制非表示にしている(セレクタの特異度がプラグイン側より高いため、
       !important なしの display:block では負ける)。本テーブルは縦積みカード設計で全列を
       常に表示したいので、明示的に !important を付けて WP コアの折り畳みを無効化する。
       ただし .hidden(Screen Options で非表示指定された列)は除外し、ユーザー設定を尊重する。 */
    display:block;
    width:100% !important;   /* WP の inline width 指定を打ち消す */
    max-width:100%;
    padding:0 !important;
    border:0 !important;
    box-sizing:border-box;
  }
  table.aiap-generated-posts tbody td:not(.hidden),
  table.aiap-generated-posts tbody th:not(.hidden){
    display:block !important;
  }
  /* Bug fix: WP コアの ::before ルール
       .wp-list-table tr td:not(.column-primary)::before { content: attr(data-colname); position:absolute; left:10px; width:32%; }
     によって展開時にカラム名ラベル(「作成日時」「プロバイダ」等)が絶対配置で表示され、
     padding:0 にしているセル内容の上に重なってレイアウトが破綻する。
     PHP 側で handle_row_actions() を空にしてトグル自体は出さないが、保険として
     ::before の content を打ち消し、万が一 is-expanded が付与されてもラベルが出ないようにする。 */
  table.aiap-generated-posts tbody td::before,
  table.aiap-generated-posts tbody th::before{
    content:none !important;
  }
  /* Bug fix: 別経路でトグルボタンが残った場合の保険(handle_row_actions オーバーライドで
     通常は出ないが、サードパーティのフィルタ等で挿入される可能性に備える)。 */
  table.aiap-generated-posts .toggle-row{display:none !important}
  /* WP コアはプライマリ列に padding-right:50px(トグル用余白) を設定するが、
     トグルを廃止したのでこの余白も不要。 */
  table.aiap-generated-posts td.column-primary{padding-right:0 !important}

  table.aiap-generated-posts .check-column{margin:0 0 8px 0}
  table.aiap-generated-posts .check-column input[type=checkbox]{width:28px;height:28px;margin:0;border-radius:6px}
  table.aiap-generated-posts td.column-title strong{display:block;min-width:0}
  table.aiap-generated-posts td.column-title a{
    display:-webkit-box;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
    overflow:hidden;
    word-break:break-word;
    line-height:1.45;
    font-size:17px;
  }
  table.aiap-generated-posts .aiap-row-aux{
    display:block;
    margin-top:6px;
    font-size:13px;
    line-height:1.5;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  /* aiap-row-aux に作成日時・ステータス・プロバイダを集約済みなので、
     カードビューでの重複表示を避けるためにそれらの専用列はモバイルで隠す。
     タスク名・画像・公開リンク・操作は aux に含まれないので残す。 */
  table.aiap-generated-posts td.column-created_at,
  table.aiap-generated-posts td.column-writer,
  table.aiap-generated-posts td.column-status{display:none !important}
  /* 画像列にラベル代わりの上マージンを少し付け、操作ボタンとの間隔も整える。 */
  table.aiap-generated-posts td.column-task_name{margin-top:8px;font-size:13px;color:#52525b}
  table.aiap-generated-posts td.column-image{margin-top:8px}
  table.aiap-generated-posts td.column-published{margin-top:8px;display:flex !important;flex-wrap:wrap;gap:6px}
  table.aiap-generated-posts td.column-published .button-small{flex:0 0 auto}
  table.aiap-generated-posts td.column-actions{margin-top:8px}

  table.aiap-generated-posts .row-actions{margin-top:8px;font-size:12px}
}

/* ============================================================
   投稿履歴テーブル: レスポンシブ列幅調整
   - 共通ブレークポイントは 768 / 992 / 1200 / 1400 を使用
   - WordPress 管理画面のカード化だけ 782px を例外として使用
   - 操作ボタンは必ず表示し、画像列と重ねない
   ============================================================ */
table.aiap-generated-posts{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  table-layout:fixed !important;
  border-collapse:collapse;
}

.aiap-logs-table-section,
.aiap-logs-table-section .aiap-section-body,
.aiap-logs-table-section .wp-list-table{
  max-width:100%;
  overflow-x:hidden !important;
  box-sizing:border-box;
}

table.aiap-generated-posts th,
table.aiap-generated-posts td{
  box-sizing:border-box !important;
  min-width:0 !important;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:middle;
}

table.aiap-generated-posts .check-column{width:38px !important; padding-left:14px !important; padding-right:6px !important;}
table.aiap-generated-posts .column-title{width:29% !important;}
table.aiap-generated-posts .column-created_at{width:16% !important; white-space:nowrap;}
table.aiap-generated-posts .column-writer{width:9% !important; white-space:nowrap;}
table.aiap-generated-posts .column-task_name{width:13% !important; white-space:nowrap;}
table.aiap-generated-posts .column-status{width:8% !important; white-space:nowrap;}
table.aiap-generated-posts .column-image{
  width:64px !important;
  min-width:64px !important;
  max-width:64px !important;
  padding-left:4px !important;
  padding-right:4px !important;
  text-align:center !important;
  overflow:hidden !important;
}
table.aiap-generated-posts .column-actions{
  width:140px !important;
  min-width:140px !important;
  max-width:140px !important;
  padding-left:4px !important;
  padding-right:8px !important;
  text-align:right !important;
  overflow:hidden !important;
}

table.aiap-generated-posts td.column-title a{
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
  white-space:normal;
  word-break:break-word;
  line-height:1.35;
}

table.aiap-generated-posts td.column-task_name,
table.aiap-generated-posts td.column-status{
  overflow:hidden;
  text-overflow:ellipsis;
}

table.aiap-generated-posts .aiap-logs-thumb{
  display:block !important;
  width:54px !important;
  max-width:100% !important;
  height:54px !important;
  object-fit:cover !important;
  margin-left:auto !important;
  margin-right:auto !important;
  border-radius:6px;
}

table.aiap-generated-posts .aiap-action-buttons{
  display:flex !important;
  align-items:center !important;
  justify-content:flex-end !important;
  gap:6px !important;
  flex-wrap:nowrap !important;
  width:100% !important;
  max-width:100% !important;
  overflow:hidden !important;
}

table.aiap-generated-posts .aiap-action-buttons .button-small{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto !important;
  box-sizing:border-box !important;
  margin:0 !important;
  white-space:nowrap !important;
}

table.aiap-generated-posts .aiap-action-buttons .dashicons{
  width:16px;
  height:16px;
  font-size:16px;
  line-height:16px;
}

@media (max-width: 1200px){
  table.aiap-generated-posts th,
  table.aiap-generated-posts td{padding-left:5px !important; padding-right:5px !important;}
  table.aiap-generated-posts .check-column{width:34px !important; padding-left:8px !important; padding-right:2px !important;}
  table.aiap-generated-posts .column-title{width:28% !important;}
  table.aiap-generated-posts .column-created_at{width:15% !important;}
  table.aiap-generated-posts .column-writer{width:8% !important;}
  table.aiap-generated-posts .column-task_name{width:12% !important;}
  table.aiap-generated-posts .column-status{width:7% !important;}
  table.aiap-generated-posts .column-image{width:58px !important; min-width:58px !important; max-width:58px !important; padding-left:3px !important; padding-right:3px !important;}
  table.aiap-generated-posts .column-actions{width:98px !important; min-width:98px !important; max-width:98px !important; padding-left:3px !important; padding-right:5px !important;}
  table.aiap-generated-posts .aiap-logs-thumb{width:48px !important; height:48px !important;}
  table.aiap-generated-posts .aiap-action-buttons{gap:6px !important;}
  table.aiap-generated-posts .aiap-action-buttons .button-small{
    width:40px !important;
    min-width:40px !important;
    height:32px !important;
    min-height:32px !important;
    padding:0 !important;
  }
  table.aiap-generated-posts .aiap-action-buttons .aiap-action-label{display:none !important;}
}

@media (max-width: 992px){
  table.aiap-generated-posts th,
  table.aiap-generated-posts td{font-size:12px !important; padding-left:4px !important; padding-right:4px !important;}
  table.aiap-generated-posts .check-column{width:32px !important; padding-left:7px !important; padding-right:1px !important;}
  table.aiap-generated-posts .column-title{width:27% !important;}
  table.aiap-generated-posts .column-created_at{width:14% !important;}
  table.aiap-generated-posts .column-writer{width:7% !important;}
  table.aiap-generated-posts .column-task_name{width:10% !important;}
  table.aiap-generated-posts .column-status{width:6% !important;}
  table.aiap-generated-posts .column-image{width:52px !important; min-width:52px !important; max-width:52px !important; padding-left:3px !important; padding-right:3px !important;}
  table.aiap-generated-posts .column-actions{width:94px !important; min-width:94px !important; max-width:94px !important; padding-left:3px !important; padding-right:5px !important;}
  table.aiap-generated-posts .aiap-logs-thumb{width:44px !important; height:44px !important;}
  table.aiap-generated-posts .aiap-action-buttons{gap:5px !important;}
  table.aiap-generated-posts .aiap-action-buttons .button-small{
    width:39px !important;
    min-width:39px !important;
    height:30px !important;
    min-height:30px !important;
    padding:0 !important;
  }
}

@media screen and (max-width: 782px){
  table.aiap-generated-posts td.column-image,
  table.aiap-generated-posts td.column-actions{overflow:visible !important;}
  table.aiap-generated-posts td.column-image{max-width:100% !important;}
  table.aiap-generated-posts .aiap-logs-thumb{max-width:100% !important; height:auto;}
  table.aiap-generated-posts .aiap-action-buttons{
    display:flex !important;
    flex-wrap:wrap !important;
    gap:8px !important;
    justify-content:flex-start !important;
    max-width:100% !important;
  }
  table.aiap-generated-posts .aiap-action-buttons .button-small{
    flex:0 0 auto !important;
    min-height:34px !important;
  }
}

/* ============================================================
   RSS Feeds tab & task card RSS section
   ============================================================ */

.aiap-rss-tab .description {
    margin-bottom: 1em;
}

.aiap-rss-feed-form {
    margin-bottom: 2em;
    padding: 1em;
    background: #fbfbfb;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
}

/* RSS Feeds タブ: AI プロバイダ画面と統一した UX */

/* 「フィードを追加」カード */
.aiap-rss-add-card {
    margin: 0 0 12px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--bdr, #e2e4e7);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.aiap-rss-feed-form { margin: 0; }
.aiap-rss-add-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 12px 16px;
    margin-bottom: 14px;
}
@media (max-width: 768px) {
    .aiap-rss-add-grid { grid-template-columns: 1fr; }

    /* 追加フォーム下段：actions を1段では入りきらないので折り返し可能に */
    .aiap-rss-add-row {
        flex-direction: column;
        align-items: stretch;
    }
    .aiap-rss-add-actions {
        margin-left: 0;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    /* 登録済みフィードカード：ステータスバッジ＋トグルを次行へ折り返す */
    .aiap-rss-feed-card-head {
        flex-wrap: wrap;
    }
    .aiap-rss-feed-card-head .aiap-provider-tile-status {
        margin-left: auto;
    }
}
.aiap-rss-add-field { display: flex; flex-direction: column; gap: 6px; }
.aiap-rss-add-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--txt-m, #555);
    letter-spacing: .02em;
}
.aiap-rss-add-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding-top: 4px;
}
.aiap-rss-add-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--txt-m, #555);
}
.aiap-rss-add-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}
.aiap-rss-test-result {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    font-style: italic;
}
.aiap-rss-test-result.is-success { color: #1d6b3d; }
.aiap-rss-test-result.is-error   { color: #c92e2e; }

/* 「登録済みフィード」一覧 */
.aiap-rss-empty-state {
    margin: 8px 0 20px;
    padding: 24px;
    text-align: center;
    color: var(--txt-l, #888);
    font-size: 13px;
    background: #fafafa;
    border: 1px dashed var(--bdr, #e2e4e7);
    border-radius: 10px;
}
.aiap-rss-feed-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* フィードカード */
.aiap-rss-feed-card {
    margin: 0;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--bdr, #e2e4e7);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(15,23,42,.04);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.aiap-rss-feed-card:hover {
    border-color: var(--txt-l, #c0c0c0);
    box-shadow: 0 4px 16px -4px rgba(15,23,42,.08);
}
.aiap-rss-feed-card.is-disabled { opacity: 0.6; }

.aiap-rss-feed-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
    padding: 0 0 12px;
    border-bottom: 1px solid #f0f0f0;
}
.aiap-rss-feed-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff7ec;
    color: #e8851e;
    font-size: 18px;
}
.aiap-rss-feed-titlebox {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.aiap-rss-feed-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--txt, #222);
    line-height: 1.3;
}
.aiap-rss-feed-url {
    font-size: 11px;
    color: var(--txt-m, #777);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.aiap-rss-feed-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 12px;
    color: var(--txt-m, #555);
    white-space: nowrap;
}

/* メタ情報（最終取得・使用済み・直近エラー） */
.aiap-rss-feed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 0 0 12px;
    padding: 6px 0;
    font-size: 12px;
}
.aiap-rss-feed-meta-item {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.aiap-rss-feed-meta-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--txt-l, #999);
}
.aiap-rss-feed-meta-value {
    font-size: 12px;
    color: var(--txt, #333);
    font-feature-settings: "tnum" 1;
}
.aiap-rss-feed-meta-item-error .aiap-rss-feed-meta-label,
.aiap-rss-feed-meta-item-error .aiap-rss-feed-meta-value {
    color: #c92e2e;
}

/* アクションボタン群 */
.aiap-rss-feed-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.aiap-rss-inline-form { display: inline; margin: 0; }

/* 編集モード切替：is-editing が付くと閲覧用ビューを隠して編集フォームを表示 */
.aiap-rss-feed-edit-form { display: none; margin: 0; }
.aiap-rss-feed-card.is-editing > .aiap-rss-feed-card-head,
.aiap-rss-feed-card.is-editing > .aiap-rss-feed-card-body { display: none; }
.aiap-rss-feed-card.is-editing > .aiap-rss-feed-edit-form { display: block; }


.aiap-pro-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    background: #f0c674;
    color: #5d4720;
    border-radius: 3px;
    font-size: 0.85em;
    font-weight: 600;
}

.aiap-task-rss-feed {
    display: inline-block;
    margin-right: 1em;
}

.aiap-task-rss-detail[hidden] {
    display: none;
}

.aiap-task-rss-empty {
    color: #c92e2e;
    font-style: italic;
}

.aiap-pro-upsell {
    margin-bottom: 1em;
    padding: 0.8em 1em;
    background: #fff9e6;
    border-left: 4px solid #f0c674;
    border-radius: 2px;
}

/* ============================================================
   Task card accordion sections
   ============================================================ */

/* セクションコンテナ */
.aiap-task-section {
    margin: 0 0 8px;
    background: #fbfbfb;
    border: 1px solid #e2e4e7;
    border-radius: 4px;
    overflow: hidden;
}
.aiap-task-section summary::-webkit-details-marker { display: none; }
.aiap-task-section summary::marker { content: ''; }

/* ヘッダ */
.aiap-task-section__summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background-color 0.15s;
}
.aiap-task-section__summary:hover {
    background: #f0f0f0;
}
.aiap-task-section[open] > .aiap-task-section__summary {
    background: #f5f5f5;
    border-bottom: 1px solid #e2e4e7;
}

/* 三角アイコン回転 */
.aiap-task-section__toggle .dashicons {
    transition: transform 0.15s ease;
    color: #666;
}
.aiap-task-section[open] > .aiap-task-section__summary .aiap-task-section__toggle .dashicons {
    transform: rotate(90deg);
}

/* セクション識別アイコン・タイトル・サマリ */
.aiap-task-section__icon {
    color: #555;
    font-size: 18px;
}
.aiap-task-section__title {
    font-weight: 600;
    color: #333;
}
.aiap-task-section__configured-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.75em;
    font-weight: 600;
    color: #1d6b3d;
    background: #d4edda;
    border: 1px solid #b1d8bb;
    border-radius: 10px;
    line-height: 1.6;
    white-space: nowrap;
}
.aiap-task-section__summary-text {
    flex: 1;
    font-size: 0.9em;
    color: #888;
    font-weight: normal;
}

/* スマホ (~767px): スケジュールサマリー本文 (例: "— ランダム 2〜4 回 / 日") は
   ヘッダ要素 (トグル + アイコン + タイトル + 「設定済」バッジ) で残り幅を
   ほぼ食われ、3 行に折り返されて醜くなる。状態は「設定済」バッジで伝わるため
   スマホでは本文を非表示にし、詳細はセクションを開いて確認してもらう。 */
@media (max-width: 767px){
    .aiap-task-section__summary-text{
        display:none;
    }
}

/* セクション本体 */
.aiap-task-section__body {
    padding: 12px 14px 14px;
}

/* フォーカスリング */
.aiap-task-section__summary:focus {
    outline: none;
}
.aiap-task-section__summary:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

/* 余白 */
.aiap-task-section-group {
    margin-top: 16px;
}
.aiap-task-section-group .aiap-task-section:first-child {
    margin-top: 0;
}
