/* ============================================================
   AIFACTORY Banner Studio — Step 1 UI
   CELLMOM のアースカラートーン（CELLELO と同系統）に合わせる
   ============================================================ */

:root {
    --aif-primary: #F0E6DA;
    --aif-primary-light: #E8DDD0;
    --aif-accent: #8B6F47;
    --aif-accent-hover: #7A5F3A;
    --aif-accent-soft: rgba(139, 111, 71, 0.12);
    --aif-bg: #F5EDE3;
    --aif-surface: #FFFFFF;
    --aif-surface-alt: #FAF6F1;
    --aif-text: #3E2C1C;
    --aif-text-muted: #8C7A6B;
    --aif-border: rgba(139, 111, 71, 0.18);
    --aif-border-soft: rgba(139, 111, 71, 0.1);
    --aif-danger: #B45749;
    --aif-danger-soft: rgba(180, 87, 73, 0.12);
    --aif-success: #7A8A4A;
    --aif-warning: #C48B3C;
    --aif-shadow: 0 2px 10px rgba(92, 64, 51, 0.08);
    --aif-shadow-lg: 0 8px 28px rgba(92, 64, 51, 0.14);
    --aif-radius: 10px;
    --aif-radius-sm: 6px;
    --aif-transition: 0.18s cubic-bezier(.4, 0, .2, 1);
}

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

body.aif-page {
    font-family: 'Inter', 'Hiragino Sans', 'Meiryo', sans-serif;
    background: linear-gradient(135deg, #F5EDE3 0%, #EDE4D8 50%, #E8DDD0 100%);
    color: var(--aif-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-size: 13px;
}

/* ── Header ── */
.aif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--aif-primary);
    border-bottom: 1px solid var(--aif-border);
    box-shadow: 0 1px 4px rgba(139, 111, 71, 0.06);
}

.aif-header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}

.aif-back-link {
    color: var(--aif-text-muted);
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: var(--aif-radius-sm);
    transition: var(--aif-transition);
}

.aif-back-link:hover {
    background: var(--aif-accent-soft);
    color: var(--aif-text);
}

.aif-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--aif-accent);
}

.aif-logo-icon { color: var(--aif-accent); }

.aif-title {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.04em;
    color: var(--aif-text);
}
.aif-title em {
    font-style: normal;
    font-weight: 500;
    color: var(--aif-text-muted);
    margin-left: 4px;
    font-size: 13px;
}

.aif-user-badge {
    color: var(--aif-text-muted);
    font-size: 12px;
}

/* ── Main ── */
.aif-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
/* 案件詳細ページ: エディタタブのみ viewport 内に収める。他タブは通常スクロール */
body.aif-page-detail .aif-main.is-editor-active {
    height: calc(100vh - 56px);
    overflow: hidden;
}
body.aif-page-detail .aif-main.is-editor-active > .pd-tab:not([hidden]) {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ── Toolbar ── */
.aif-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.aif-toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.aif-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--aif-text);
    letter-spacing: 0.02em;
}

.aif-count {
    font-size: 12px;
    color: var(--aif-text-muted);
    background: var(--aif-accent-soft);
    padding: 3px 10px;
    border-radius: 999px;
}

.aif-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.aif-filter-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Inputs ── */
.aif-input {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface);
    color: var(--aif-text);
    font-size: 13px;
    font-family: inherit;
    transition: var(--aif-transition);
    min-width: 220px;
}
.aif-input-sm { min-width: 150px; }
.aif-input:focus {
    outline: none;
    border-color: var(--aif-accent);
    box-shadow: 0 0 0 3px var(--aif-accent-soft);
}
textarea.aif-input { padding: 8px 12px; min-height: 60px; resize: vertical; }

/* ── Buttons ── */
.aif-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--aif-radius-sm);
    background: transparent;
    color: var(--aif-text);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--aif-transition);
    white-space: nowrap;
}

.aif-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.aif-btn-primary {
    background: var(--aif-accent);
    color: #FFF;
    border-color: var(--aif-accent);
}
.aif-btn-primary:hover:not(:disabled) {
    background: var(--aif-accent-hover);
    border-color: var(--aif-accent-hover);
}

.aif-btn-ghost {
    background: transparent;
    color: var(--aif-text-muted);
    border-color: var(--aif-border);
}
.aif-btn-ghost:hover:not(:disabled) {
    background: var(--aif-accent-soft);
    color: var(--aif-text);
}

.aif-btn-danger {
    background: var(--aif-danger);
    color: #FFF;
    border-color: var(--aif-danger);
}
.aif-btn-danger:hover:not(:disabled) { opacity: 0.9; }

.aif-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--aif-radius-sm);
    background: transparent;
    color: var(--aif-text-muted);
    cursor: pointer;
    transition: var(--aif-transition);
}
.aif-btn-icon:hover {
    background: var(--aif-accent-soft);
    color: var(--aif-text);
}
.aif-btn-icon.danger:hover { color: var(--aif-danger); }

/* ── Table ── */
.aif-table-wrap {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    box-shadow: var(--aif-shadow);
    overflow: hidden;
}

.aif-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.aif-table thead th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    color: var(--aif-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--aif-surface-alt);
    border-bottom: 1px solid var(--aif-border);
    white-space: nowrap;
}

.aif-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--aif-border-soft);
    vertical-align: middle;
    color: var(--aif-text);
}

.aif-table tbody tr:last-child td { border-bottom: 0; }

.aif-table tbody tr:hover { background: var(--aif-surface-alt); }

.aif-table .col-afb { width: 130px; font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--aif-text-muted); }
.aif-table .col-name { min-width: 200px; }
.aif-table .col-actions { width: 90px; text-align: right; }

.aif-table .aif-empty-row td {
    text-align: center;
    color: var(--aif-text-muted);
    padding: 40px 12px;
    font-size: 13px;
}

a.aif-project-name,
.aif-project-name {
    color: var(--aif-text);
    font-weight: 600;
    text-decoration: none;
}
a.aif-project-name:hover {
    color: var(--aif-accent);
    text-decoration: underline;
}

/* ── Status Badge ── */
.aif-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--aif-accent-soft);
    color: var(--aif-accent);
    letter-spacing: 0.02em;
}

.aif-badge[data-status="approved"],
.aif-badge[data-status="exported"] {
    background: rgba(122, 138, 74, 0.14);
    color: var(--aif-success);
}
.aif-badge[data-status="review"],
.aif-badge[data-status="editing"] {
    background: rgba(196, 139, 60, 0.14);
    color: var(--aif-warning);
}
.aif-badge[data-status="archived"] {
    background: rgba(100, 100, 100, 0.12);
    color: #777;
}

/* ── Modal ── */
.aif-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(62, 44, 28, 0.35);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.aif-modal-overlay[hidden] { display: none; }

.aif-modal {
    background: var(--aif-surface);
    border-radius: var(--aif-radius);
    box-shadow: var(--aif-shadow-lg);
    width: 720px;
    max-width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.aif-modal-sm { width: 440px; }

.aif-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--aif-border);
    background: var(--aif-primary);
}
.aif-modal-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--aif-text);
    letter-spacing: 0.02em;
}

.aif-modal-close {
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: var(--aif-text-muted);
    border-radius: var(--aif-radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--aif-transition);
}
.aif-modal-close:hover { background: var(--aif-accent-soft); color: var(--aif-text); }

.aif-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.aif-modal-body p { line-height: 1.6; color: var(--aif-text); }
.aif-confirm-target {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--aif-surface-alt);
    border-left: 3px solid var(--aif-accent);
    border-radius: var(--aif-radius-sm);
    font-weight: 600;
    font-size: 13px;
}

.aif-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--aif-border);
    background: var(--aif-surface-alt);
}

/* ── Form Grid ── */
.aif-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.aif-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aif-field-wide { grid-column: 1 / -1; }

.aif-field > span {
    font-size: 12px;
    color: var(--aif-text-muted);
    font-weight: 600;
}
.aif-field > span em {
    color: var(--aif-danger);
    font-style: normal;
    margin-left: 2px;
}
.aif-field input,
.aif-field select,
.aif-field textarea {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface);
    color: var(--aif-text);
    font-size: 13px;
    font-family: inherit;
    transition: var(--aif-transition);
}
.aif-field textarea { padding: 8px 10px; height: auto; resize: vertical; }
.aif-field input:focus,
.aif-field select:focus,
.aif-field textarea:focus {
    outline: none;
    border-color: var(--aif-accent);
    box-shadow: 0 0 0 3px var(--aif-accent-soft);
}

/* ── Toast ── */
.aif-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}
.aif-toast {
    min-width: 240px;
    max-width: 360px;
    padding: 10px 14px;
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface);
    color: var(--aif-text);
    font-size: 13px;
    box-shadow: var(--aif-shadow-lg);
    border-left: 3px solid var(--aif-accent);
    pointer-events: auto;
    animation: aif-toast-in 0.2s ease;
}
.aif-toast.error { border-left-color: var(--aif-danger); }
.aif-toast.success { border-left-color: var(--aif-success); }

@keyframes aif-toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Tabs (一覧ページ用) ── */
.aif-tabs {
    display: flex;
    gap: 2px;
    margin-left: 12px;
    padding: 3px;
    background: rgba(139, 111, 71, 0.1);
    border-radius: 999px;
}
.aif-tab {
    padding: 5px 14px;
    border: 0;
    background: transparent;
    color: var(--aif-text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 999px;
    transition: var(--aif-transition);
    letter-spacing: 0.04em;
}
.aif-tab:hover { color: var(--aif-text); }
.aif-tab.is-active {
    background: var(--aif-surface);
    color: var(--aif-accent);
    box-shadow: 0 1px 3px rgba(92,64,51,0.12);
}

/* ── Steps (案件詳細ページ用) ── */
.pd-steps {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 16px;
}
.pd-step {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 0;
    background: transparent;
    color: var(--aif-text-muted);
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border-radius: 999px;
    transition: var(--aif-transition);
    white-space: nowrap;
}
.pd-step:hover { color: var(--aif-text); background: rgba(139,111,71,0.06); }
.pd-step.is-active {
    background: var(--aif-surface);
    color: var(--aif-accent);
    box-shadow: 0 1px 3px rgba(92,64,51,0.12);
}
.pd-step.is-done {
    color: var(--aif-success);
}
.pd-step.is-done .pd-step-num { display: none; }
.pd-step.is-done .pd-step-check { display: inline-flex !important; }
.pd-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--aif-border);
    color: var(--aif-text-muted);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}
.pd-step.is-active .pd-step-num {
    background: var(--aif-accent);
    color: #fff;
}
.pd-step.is-done .pd-step-num { display: none; }
.pd-step-check {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(122,138,74,0.18);
    color: var(--aif-success);
    flex-shrink: 0;
}
.pd-step-label { letter-spacing: 0.04em; }
.pd-step-arrow {
    color: var(--aif-border);
    font-size: 14px;
    font-weight: 300;
    user-select: none;
}

/* ── Guide message ── */
.pd-guide {
    padding: 12px 16px;
    border-radius: var(--aif-radius-sm);
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.pd-guide:empty { display: none; }
.pd-guide.guide-info {
    background: var(--aif-accent-soft);
    color: var(--aif-accent);
    border: 1px solid rgba(139,111,71,0.15);
}
.pd-guide.guide-success {
    background: rgba(122,138,74,0.1);
    color: var(--aif-success);
    border: 1px solid rgba(122,138,74,0.2);
}
.pd-guide.guide-warn {
    background: rgba(196,139,60,0.1);
    color: var(--aif-warning);
    border: 1px solid rgba(196,139,60,0.2);
}
.pd-guide .guide-icon {
    flex-shrink: 0;
    margin-top: 1px;
}
.pd-guide .guide-text { flex: 1; }
.pd-guide .guide-action {
    flex-shrink: 0;
}
.pd-guide .guide-action button {
    padding: 4px 12px;
    height: 28px;
}

/* ── View container ── */
.aif-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.aif-view[hidden] { display: none !important; }
section.pd-tab[hidden] { display: none !important; }

/* ── Brand Grid ── */
.aif-brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}
.aif-brand-card {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    padding: 16px;
    box-shadow: var(--aif-shadow);
    cursor: pointer;
    transition: var(--aif-transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.aif-brand-card:hover {
    border-color: var(--aif-accent);
    transform: translateY(-1px);
    box-shadow: var(--aif-shadow-lg);
}
.aif-brand-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.aif-brand-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--aif-text);
}
.aif-brand-card-meta {
    font-size: 11px;
    color: var(--aif-text-muted);
}
.aif-brand-card-desc {
    font-size: 12px;
    color: var(--aif-text-muted);
    line-height: 1.5;
    min-height: 1.5em;
}
.aif-brand-palette-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.aif-brand-palette-swatch {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 1px solid var(--aif-border);
}

/* ── Asset Grid ── */
.aif-asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}
.aif-asset-grid-sm { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); max-height: 420px; overflow-y: auto; }

.aif-asset-card {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--aif-transition);
    display: flex;
    flex-direction: column;
    box-shadow: var(--aif-shadow);
}
.aif-asset-card:hover {
    border-color: var(--aif-accent);
    transform: translateY(-1px);
}
.aif-asset-card.is-selected {
    border-color: var(--aif-accent);
    box-shadow: 0 0 0 2px var(--aif-accent-soft);
}
.aif-asset-preview {
    aspect-ratio: 1 / 1;
    background: var(--aif-surface-alt) center/contain no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--aif-text-muted);
    font-size: 11px;
    border-bottom: 1px solid var(--aif-border-soft);
    position: relative;
}
.aif-asset-preview .role-tag {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.06em;
}
.aif-asset-info {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 54px;
}
.aif-asset-info-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--aif-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.aif-asset-info-meta {
    font-size: 10.5px;
    color: var(--aif-text-muted);
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
}
.aif-asset-card-actions {
    display: flex;
    gap: 2px;
}

/* ── Thumbnails row (project modal) ── */
.aif-asset-thumb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 82px;
    padding: 8px;
    border: 1px dashed var(--aif-border);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface-alt);
}
.aif-asset-thumb {
    width: 72px;
    height: 72px;
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface) center/contain no-repeat;
    position: relative;
    font-size: 9.5px;
    color: var(--aif-text-muted);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-align: center;
    padding: 2px;
}
.aif-asset-thumb .detach-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: var(--aif-danger);
    color: #fff;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Empty state / Subheader ── */
.aif-empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--aif-text-muted);
    font-size: 13px;
    grid-column: 1/-1;
}
.aif-subheader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 8px;
    gap: 12px;
}
.aif-subheader h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--aif-text);
    letter-spacing: 0.04em;
}
.aif-hint {
    font-size: 11px;
    color: var(--aif-text-muted);
}

/* ── Rules editor ── */
.aif-rule-block {
    padding: 12px 14px;
    border: 1px solid var(--aif-border-soft);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface-alt);
    margin-bottom: 10px;
}
.aif-field-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--aif-text);
    margin-bottom: 8px;
    letter-spacing: 0.04em;
}
.aif-palette-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.aif-palette-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 3px;
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: 999px;
    font-size: 11px;
}
.aif-palette-item .swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--aif-border-soft);
}
.aif-palette-item .remove {
    border: 0;
    background: transparent;
    color: var(--aif-text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 0 4px;
}
.aif-palette-add {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.aif-palette-add input[type="color"] {
    width: 36px;
    height: 32px;
    padding: 2px;
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    background: var(--aif-surface);
    cursor: pointer;
}

/* ── Additional Button variants ── */
.aif-btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.aif-btn-danger-ghost {
    background: transparent;
    color: var(--aif-danger);
    border-color: var(--aif-danger-soft);
}
.aif-btn-danger-ghost:hover:not(:disabled) {
    background: var(--aif-danger-soft);
}

/* ── Generation sections ── */
.aif-gen-section {
    border-top: 1px solid var(--aif-border-soft);
    padding-top: 16px;
    margin-top: 4px;
}

.aif-bg-results, .aif-copy-results {
    margin-top: 12px;
}

.aif-bg-gallery {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.aif-bg-thumb {
    width: 160px;
    height: 160px;
    border: 2px solid var(--aif-border);
    border-radius: var(--aif-radius);
    background: var(--aif-surface-alt) center/cover no-repeat;
    cursor: pointer;
    transition: var(--aif-transition);
    position: relative;
}
.aif-bg-thumb:hover { border-color: var(--aif-accent); transform: translateY(-1px); }
.aif-bg-thumb.is-selected {
    border-color: var(--aif-accent);
    box-shadow: 0 0 0 3px var(--aif-accent-soft);
}
.aif-bg-thumb .select-tag {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: var(--aif-accent);
    color: #fff;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
}

/* copy results */
.aif-copy-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.aif-copy-card {
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    padding: 12px 14px;
    background: var(--aif-surface-alt);
    cursor: pointer;
    transition: var(--aif-transition);
}
.aif-copy-card:hover { border-color: var(--aif-accent); }
.aif-copy-card.is-selected {
    border-color: var(--aif-accent);
    background: rgba(139,111,71,0.06);
    box-shadow: 0 0 0 2px var(--aif-accent-soft);
}
.aif-copy-headline {
    font-size: 16px;
    font-weight: 700;
    color: var(--aif-text);
    margin-bottom: 4px;
}
.aif-copy-subcopy {
    font-size: 12px;
    color: var(--aif-text-muted);
    margin-bottom: 6px;
    line-height: 1.5;
}
.aif-copy-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}
.aif-copy-meta-tag {
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--aif-accent-soft);
    color: var(--aif-accent);
}
.aif-copy-meta-tag.warn {
    background: var(--aif-danger-soft);
    color: var(--aif-danger);
}

.aif-gen-loading {
    padding: 20px;
    text-align: center;
    color: var(--aif-text-muted);
}

/* ── Project Detail page ── */
.pd-overview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.pd-card {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    padding: 16px 18px;
    box-shadow: var(--aif-shadow);
}
.pd-card-brand { grid-column: 1 / -1; }
.pd-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--aif-text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 12px;
}
.pd-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.pd-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--aif-text-muted);
    margin-bottom: 2px;
}
.pd-field-value {
    font-size: 13px;
    color: var(--aif-text);
    padding-bottom: 6px;
}
.pd-gen-panel {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    padding: 18px;
    box-shadow: var(--aif-shadow);
    margin-bottom: 16px;
}

/* バージョン（世代）グループ */
.pd-version-group {
    margin-bottom: 20px;
}
.pd-version-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--aif-border-soft);
}
.pd-version-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--aif-accent);
    padding: 2px 10px;
    background: var(--aif-accent-soft);
    border-radius: 999px;
}
.pd-version-meta {
    font-size: 11px;
    color: var(--aif-text-muted);
}
.pd-version-prompt {
    font-size: 11px;
    color: var(--aif-text-muted);
    font-style: italic;
    max-width: 600px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Variant Grid ── */
.pd-variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.pd-variant-card {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--aif-transition);
    box-shadow: var(--aif-shadow);
}
.pd-variant-card:hover { border-color: var(--aif-accent); transform: translateY(-1px); }
.pd-variant-preview {
    aspect-ratio: 1 / 1;
    position: relative;
    background: var(--aif-surface-alt);
    overflow: hidden;
}
.pd-variant-preview-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: top left;
}
.pd-variant-el {
    position: absolute;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
}
.pd-variant-card-footer {
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--aif-border-soft);
}
.pd-variant-card-label { font-size: 12px; font-weight: 600; color: var(--aif-text); }
.pd-variant-card-meta { font-size: 11px; color: var(--aif-text-muted); }

/* ── Banner Editor ── */
.pd-editor-container {
    display: grid;
    grid-template-columns: 200px 1fr 240px;
    gap: 0;
    flex: 1 1 auto;
    /* is-editor-active でない場合のフォールバック */
    min-height: 500px;
    height: 100%;
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    overflow: hidden;
    box-shadow: var(--aif-shadow);
}
body.aif-page-detail .aif-main.is-editor-active .pd-editor-container {
    min-height: 0; /* viewport 固定モードでは flex:1 の計算が効くように */
}
.pd-editor-layers {
    border-right: 1px solid var(--aif-border);
    padding: 14px;
    overflow-y: auto;
}
.pd-editor-layers .pd-card-title { margin-bottom: 10px; }
.pd-layer-item {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: var(--aif-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--aif-text-muted);
    transition: var(--aif-transition);
    margin-bottom: 2px;
}
.pd-layer-item:hover { background: var(--aif-accent-soft); color: var(--aif-text); }
.pd-layer-item.is-selected { background: var(--aif-accent-soft); color: var(--aif-accent); font-weight: 600; }
.pd-layer-item .layer-type { font-size: 10px; text-transform: uppercase; opacity: 0.7; min-width: 50px; }

.pd-editor-canvas-wrap {
    display: flex;
    flex-direction: column;
    background: #e0d8cf;
    overflow: hidden;
}
.pd-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--aif-surface);
    border-bottom: 1px solid var(--aif-border);
}
.pd-canvas-scroll {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pd-canvas {
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    background: #fff;
    flex-shrink: 0;
}
.pd-canvas-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}
.pd-el {
    position: absolute;
    cursor: move;
    outline: 2px solid transparent;
    outline-offset: 1px;
    transition: outline-color 0.1s;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
}
.pd-el:hover { outline-color: rgba(139,111,71,0.4); }
.pd-el.is-selected { outline-color: var(--aif-accent); outline-style: solid; }
.pd-el.is-dragging { opacity: 0.85; cursor: grabbing; }

.pd-editor-props {
    border-left: 1px solid var(--aif-border);
    padding: 14px;
    overflow-y: auto;
}
.pd-editor-props .pd-card-title { margin-bottom: 10px; }
.pd-prop-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.pd-prop-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--aif-text-muted);
    min-width: 50px;
}
.pd-prop-input {
    flex: 1;
    height: 28px;
    padding: 0 6px;
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius-sm);
    font-size: 12px;
    font-family: 'SF Mono', monospace;
    background: var(--aif-surface);
    color: var(--aif-text);
}
.pd-prop-input:focus { outline: none; border-color: var(--aif-accent); }

/* ── Export grid ── */
.pd-export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}
.pd-export-card {
    background: var(--aif-surface);
    border: 1px solid var(--aif-border);
    border-radius: var(--aif-radius);
    overflow: hidden;
    box-shadow: var(--aif-shadow);
}
.pd-export-card-preview {
    aspect-ratio: 1 / 1;
    position: relative;
    background: var(--aif-surface-alt);
    overflow: hidden;
}
.pd-export-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pd-export-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--aif-text);
}
.pd-export-card-meta {
    font-size: 11px;
    color: var(--aif-text-muted);
    display: flex;
    gap: 8px;
}
.pd-export-card-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.pd-qa-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
}
.pd-qa-badge.qa-ok { background: rgba(122,138,74,0.14); color: var(--aif-success); }
.pd-qa-badge.qa-warn { background: rgba(196,139,60,0.14); color: var(--aif-warning); }
.pd-qa-badge.qa-error { background: var(--aif-danger-soft); color: var(--aif-danger); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .aif-form-grid { grid-template-columns: 1fr; }
    .aif-filter-group { flex-wrap: wrap; }
    .aif-input { min-width: 180px; }
    .aif-tabs { margin-left: 0; }
}
