/*
 * rc32: AI補正・外側の線・色を変える・寸法線と、画像アップロード画面の並び（UVDTF・DTF と共通の型）。
 * 前半は body 直下に出す AI補正ダイアログ・比較画面（DTF の dtf-ai.css と同じ内容）。
 * 後半は見積画面 #psq-app-root の中。wizard-style.css の指定より強くなるよう #psq-app-root .クラス の詳細度で書く。
 */
/* ── マスコット（進行表示の中で使う。document・Shadow DOM の両方） ── */
.psw-ai-mascot-dancer { transform-origin: 40px 68px; animation: psw-ai-hop 1.25s ease-in-out infinite; }
.psw-ai-mascot-brush { transform-origin: 67px 36px; animation: psw-ai-brush .65s ease-in-out infinite alternate; }
.psw-ai-mascot-eyes { transform-box: fill-box; transform-origin: center; animation: psw-ai-blink 3.6s infinite; }
.psw-ai-mascot-sparkle { animation: psw-ai-sparkle 1.4s ease-in-out infinite alternate; }
@keyframes psw-ai-hop { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-5px) rotate(4deg); } }
@keyframes psw-ai-brush { to { transform: rotate(-15deg); } }
@keyframes psw-ai-blink { 0%,43%,49%,100% { transform: scaleY(1); } 46% { transform: scaleY(.12); } }
@keyframes psw-ai-sparkle { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .psw-ai-mascot-dancer, .psw-ai-mascot-brush, .psw-ai-mascot-eyes, .psw-ai-mascot-sparkle { animation: none; }
}

/* ── AI補正ダイアログ（body 直下） ── */
.psw-ai-dialog { font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif; }
.psw-ai-dialog .psw-ai-billing { padding: 0; margin: 0; border: 0; background: none; }
.psw-ai-dialog .psw-ai-billing p { margin: 0 0 0.6rem; padding: 0.55rem 0.7rem; border-radius: 8px; background: #f8fafc; font-size: 0.85rem; line-height: 1.5; color: #334155; }
.psw-ai-dialog .psw-ai-billing p[hidden] { display: none; }
.psw-ai-dialog .psw-ai-billing button {
    display: block; width: 100%; min-height: 2.9rem; margin: 0 0 0.5rem; padding: 0.6rem 0.9rem; border: 1px solid #d1d5db; border-radius: 10px;
    background: #fff; color: #374151; font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.psw-ai-dialog .psw-ai-billing button:first-of-type { border-color: #4f46e5; background: #4f46e5; color: #fff; }
.psw-ai-dialog .psw-ai-billing button:disabled { opacity: 0.55; cursor: default; }
.psw-ai-dialog .psw-ai-activity { display: none; }
.psw-ai-dialog .psw-ai-review-open {
    display: block; width: 100%; min-height: 2.9rem; margin: 0 0 0.5rem; border: 1px solid #c7d2fe; border-radius: 10px;
    background: #eef2ff; color: #3730a3; font: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.psw-ai-dialog .psw-ai-review-open[hidden] { display: none; }
.psw-ai-dialog .psw-ai-notice { margin: 0.25rem 0 0; font-size: 0.8rem; line-height: 1.5; color: #4b5563; }
.psw-ai-dialog .psw-ai-notice:empty { display: none; }
.psw-ai-dialog .qui-help-pop span, .psw-ai-dialog .qui-help-pop > span > span { display: block; margin-bottom: 0.4rem; }
.psw-ai-dialog .psw-ai-instruction { display: block; margin: 0 0 0.75rem; }
.psw-ai-dialog .psw-ai-instruction > span { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: 700; color: #374151; }
.psw-ai-dialog .psw-ai-instruction textarea,
.psw-ai-review .psw-ai-refine textarea {
    display: block; width: 100%; box-sizing: border-box; min-height: 3.4rem; padding: 0.55rem 0.7rem; border: 1px solid #d1d5db; border-radius: 10px;
    font: inherit; font-size: 16px; line-height: 1.5; resize: vertical; color: #111827; background: #fff;
}
.psw-ai-dialog .psw-ai-instruction small { display: block; margin-top: 0.2rem; text-align: right; font-size: 0.72rem; color: #9ca3af; }

/* ── 比較画面（body 直下） ── */
html.psw-ai-review-open { overflow: hidden; }
.psw-ai-review { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .72); font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', sans-serif; }
.psw-ai-review:focus { outline: none; }
.psw-ai-review-panel { display: flex; flex-direction: column; width: min(960px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: hidden; border-radius: 12px; background: #fff; color: #1f2937; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.psw-ai-review header { padding: 16px 20px 8px; }
.psw-ai-review h2 { margin: 0; font-size: 18px; line-height: 1.4; color: #312e81; }
.psw-ai-review header p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: #4b5563; }
.psw-ai-review-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 20px; }
.psw-ai-review-tabs, .psw-ai-review-bg { display: flex; gap: 6px; }
.psw-ai-review-tabs { flex: 1 1 220px; }
.psw-ai-review-tools button { min-height: 40px; padding: 8px 14px; border: 1px solid #a5b4fc; border-radius: 8px; background: #fff; color: #3730a3; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.psw-ai-review-tabs button { flex: 1; }
.psw-ai-review-tools button[aria-pressed="true"] { background: #3730a3; border-color: #3730a3; color: #fff; }
.psw-ai-review-stage { position: relative; flex: 1 1 auto; min-height: 240px; height: 60vh; margin: 0 20px; overflow: auto; display: flex; align-items: center; justify-content: center; border: 1px solid #e5e7eb; border-radius: 8px; }
.psw-ai-review-stage img { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; }
.psw-ai-review-stage.is-actual { display: block; }
.psw-ai-review-stage.is-actual img { max-width: none; max-height: none; margin: 0 auto; }
.psw-ai-review-stage.is-checker { background-color: #fff; background-image: linear-gradient(45deg,#e2e8f0 25%,transparent 25%),linear-gradient(-45deg,#e2e8f0 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e2e8f0 75%),linear-gradient(-45deg,transparent 75%,#e2e8f0 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; }
.psw-ai-review-stage.is-dark { background: #111827; }
.psw-ai-review-stage.is-light { background: #fff; }
.psw-ai-review-status { margin: 10px 20px 0; font-size: 13px; line-height: 1.6; color: #374151; }
.psw-ai-review footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.psw-ai-review footer button { min-height: 44px; padding: 10px 18px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #374151; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.psw-ai-review footer .psw-ai-review-primary { border-color: #4f46e5; background: #4f46e5; color: #fff; }
.psw-ai-review footer button:disabled { opacity: .5; cursor: not-allowed; }
.psw-ai-review footer button[hidden] { display: none; }
.psw-ai-review footer [data-refine] { border-color: #a5b4fc; color: #3730a3; background: #eef2ff; }
.psw-ai-review .psw-ai-review-instruction { margin: 0.4rem 0 0; padding: 0.4rem 0.6rem; border-radius: 8px; background: #eef2ff; color: #3730a3; font-size: 12px; line-height: 1.5; }
.psw-ai-review .psw-ai-refine { margin: 10px 20px 0; padding: 0.75rem; border: 1px solid #c7d2fe; border-radius: 10px; background: #f5f7ff; }
.psw-ai-review .psw-ai-refine[hidden] { display: none; }
.psw-ai-review .psw-ai-refine-lead { margin: 0 0 0.5rem; font-size: 12px; line-height: 1.6; color: #374151; }
.psw-ai-review .psw-ai-refine-caution { margin: 0 0 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; background: #fffbeb; color: #92400e; font-size: 12px; line-height: 1.6; }
.psw-ai-review .psw-ai-refine-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 0.5rem; }
.psw-ai-review .psw-ai-refine-actions button { min-height: 44px; padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #374151; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.psw-ai-review .psw-ai-refine-actions .psw-ai-review-primary { border-color: #4f46e5; background: #4f46e5; color: #fff; }
.psw-ai-review .psw-ai-refine-msg { margin: 0.4rem 0 0; font-size: 12px; color: #b91c1c; }
.psw-ai-review.is-refining .psw-ai-review-tabs [data-before] { opacity: 0.4; pointer-events: none; }
.psw-ai-review.is-refining [data-zoom] { opacity: 0.4; pointer-events: none; }
@media (max-width: 640px) {
    .psw-ai-review { padding: 0; }
    .psw-ai-review-panel { max-height: 100vh; max-height: 100dvh; height: 100%; border-radius: 0; }
    .psw-ai-review-stage { margin: 0 12px; height: auto; }
    .psw-ai-review header, .psw-ai-review-tools { padding-left: 12px; padding-right: 12px; }
    .psw-ai-review-status { margin: 8px 12px 0; }
    .psw-ai-review .psw-ai-refine { margin: 8px 12px 0; }
    .psw-ai-review footer { flex-wrap: wrap; padding: 10px 12px 14px; }
    .psw-ai-review footer button { flex: 1; }
    .psw-ai-review footer [data-refine] { flex: 1 1 100%; order: -1; }
}
/* AI補正ボタン: 塗りつぶし＋グラデーション、周囲が脈打つように光り、✦がきらめく（UVDTF・DTF と同じ） */
#psq-app-root .psw-gen-toolbar .psw-ai-tool,
#psq-app-root .psw-gen-toolbar .psw-ai-tool:hover {
    display: inline-flex !important; align-items: center !important; justify-content: center !important; position: relative;
    width: auto !important; height: 2.25rem !important; min-width: 6.25rem !important; padding: 0 0.85rem !important; gap: 0.3rem !important; margin: 0 !important;
    border: 0 !important; border-radius: 999px !important; white-space: nowrap !important; cursor: pointer;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #d946ef 100%) !important;
    color: #fff !important; font-size: 0.82rem !important; font-weight: 800 !important; letter-spacing: 0.02em !important;
    animation: psw-ai-glow 1.8s ease-in-out infinite;
}
#psq-app-root .psw-gen-toolbar .psw-ai-tool:hover { filter: brightness(1.08); }
#psq-app-root .psw-gen-toolbar .psw-ai-tool svg { width: 1.05rem !important; height: 1.05rem !important; fill: #fff !important; stroke: none !important; animation: psw-ai-twinkle 1.6s ease-in-out infinite; transform-origin: center; filter: drop-shadow(0 0 3px rgba(255,255,255,0.9)); }
#psq-app-root .psw-gen-toolbar .psw-ai-tool [data-label] { font-variant-numeric: tabular-nums; color: #fff !important; }
#psq-app-root .psw-gen-toolbar .psw-ai-tool::before {
    content: ""; position: absolute; inset: 0; border-radius: 999px; pointer-events: none;
    background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,0.6) 50%, transparent 70%) no-repeat;
    background-size: 250% 100%; animation: psw-ai-sweep 2.2s ease-in-out infinite;
}
@keyframes psw-ai-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.55), 0 2px 8px rgba(99, 102, 241, 0.45); }
    50%      { box-shadow: 0 0 0 7px rgba(139, 92, 246, 0), 0 0 18px 4px rgba(217, 70, 239, 0.55); }
}
@keyframes psw-ai-sweep { 0% { background-position: 150% 0; } 55%, 100% { background-position: -100% 0; } }
@keyframes psw-ai-twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 50% { transform: scale(1.3) rotate(18deg); opacity: 0.85; } }
#psq-app-root .psw-gen-toolbar .psw-ai-tool.is-busy, #psq-app-root .psw-gen-toolbar .psw-ai-tool.is-busy svg { animation: none; }
#psq-app-root .psw-gen-toolbar .psw-ai-tool.is-busy::before { display: none; }
@media (prefers-reduced-motion: reduce) {
    #psq-app-root .psw-gen-toolbar .psw-ai-tool, #psq-app-root .psw-gen-toolbar .psw-ai-tool svg { animation: none; }
    #psq-app-root .psw-gen-toolbar .psw-ai-tool::before { display: none; }
}
@media (max-width: 640px) {
    #psq-app-root .psw-gen-toolbar .psw-ai-tool-slot { order: -2; }
    #psq-app-root .psw-gen-toolbar .psw-ai-divider { order: -1; }
    #psq-app-root .psw-gen-toolbar .psw-ai-tool, #psq-app-root .psw-gen-toolbar .psw-ai-tool:hover { height: 2.5rem !important; }
    #psq-app-root .psw-gen-toolbar.qui-toolbar.qui-more-right { -webkit-mask-image: linear-gradient(to right, #000 82%, transparent); mask-image: linear-gradient(to right, #000 82%, transparent); }
    #psq-app-root .psw-gen-toolbar.qui-toolbar.qui-more-left { -webkit-mask-image: linear-gradient(to left, #000 82%, transparent); mask-image: linear-gradient(to left, #000 82%, transparent); }
    #psq-app-root .psw-gen-toolbar.qui-toolbar.qui-more-left.qui-more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 82%, transparent); mask-image: linear-gradient(to right, transparent, #000 12%, #000 82%, transparent); }
    #psq-app-root .psw-gen-toolbar .qui-toolbar-spacer { display: none !important; }
}

/* キャンバス: 寸法線の分だけ上と右に余白を取る */