/* ページ全体 */
.pdca-show { max-width: 1100px; margin: 0 auto; padding: 1rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ヘッダー */
.pdca-header {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px 20px;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.pdca-header img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.pdca-header-info { flex: 1; min-width: 0; }
.pdca-header-info h1 { font-size: 1.1rem; margin: 0 0 4px; }
.pdca-header-info .sub { font-size: .82rem; color: #888; }
.pdca-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* PDCAステータスセレクター */
.pdca-status-bar {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px 20px;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.pdca-status-bar label { font-size: .85rem; font-weight: 700; color: #555; margin: 0; }
.pdca-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.pdca-step {
    padding: 6px 18px; border-radius: 20px; border: 2px solid #e5e7eb;
    font-size: .85rem; font-weight: 700; cursor: pointer; transition: all .15s;
    background: #f9fafb; color: #666;
}
.pdca-step.active { color: #fff; border-color: transparent; }
.pdca-step[data-status="plan"].active  { background: #3b82f6; }
.pdca-step[data-status="do"].active    { background: #10b981; }
.pdca-step[data-status="check"].active { background: #f59e0b; }
.pdca-step[data-status="act"].active   { background: #8b5cf6; }

/* 2カラムレイアウト */
.pdca-body { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 768px) { .pdca-body { grid-template-columns: 1fr; } }

/* カード共通 */
.pdca-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    display: flex; flex-direction: column; overflow: hidden;
}
.pdca-card-head {
    padding: 12px 16px; border-bottom: 1px solid #f0f0f0;
    font-size: .9rem; font-weight: 700; color: #333;
    background: #f9fafb;
}
.pdca-card-head--clickable {
    cursor: pointer; user-select: none;
    transition: background .15s;
}
.pdca-card-head--clickable:hover { background: #eef2ff; }

/* 分析テキスト */
.analysis-body {
    padding: 16px; overflow-y: auto; max-height: 500px;
    font-size: .88rem; line-height: 1.75; color: #333;
    white-space: pre-wrap; word-break: break-word;
}
.analysis-body h3 {
    font-size: .95rem; color: #4338ca; margin: 1rem 0 .4rem;
    padding-bottom: 3px; border-bottom: 2px solid #e0e7ff;
}

/* メモ */
.memo-body { padding: 12px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.memo-body textarea {
    flex: 1; min-height: 180px; resize: vertical;
    border: 1px solid #d1d5db; border-radius: 6px;
    padding: 10px; font-size: .88rem; line-height: 1.6;
    font-family: inherit;
}
.memo-body textarea:focus { outline: none; border-color: #6366f1; }
.btn-save-memo {
    padding: 8px 20px; background: #6366f1; color: #fff;
    border: none; border-radius: 6px; font-size: .88rem;
    cursor: pointer; align-self: flex-end; transition: background .2s;
}
.btn-save-memo:hover { background: #4f46e5; }
.memo-saved { font-size: .78rem; color: #10b981; display: none; }

/* チャット（フルカラム） */
.chat-section {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 10px;
    display: flex; flex-direction: column; height: 520px;
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 14px 16px;
    display: flex; flex-direction: column; gap: 12px;
}
.msg { display: flex; gap: 10px; max-width: 85%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
    padding: 10px 14px; border-radius: 14px;
    font-size: .88rem; line-height: 1.65; word-break: break-word;
    white-space: pre-wrap;
}
.msg.user .msg-bubble { background: #6366f1; color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant .msg-bubble { background: #f3f4f6; color: #333; border-bottom-left-radius: 4px; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; flex-shrink: 0;
    align-self: flex-end;
}
.msg.user .msg-avatar { background: #6366f1; color: #fff; }
.msg.assistant .msg-avatar { background: #e0e7ff; color: #4338ca; }
.chat-footer {
    padding: 12px 16px; border-top: 1px solid #f0f0f0;
    display: flex; gap: 8px;
}
.chat-footer textarea {
    flex: 1; border: 1px solid #d1d5db; border-radius: 8px;
    padding: 10px 12px; font-size: .88rem; resize: none;
    font-family: inherit; line-height: 1.5; height: 56px;
    transition: border-color .2s;
}
.chat-footer textarea:focus { outline: none; border-color: #6366f1; }
.btn-send {
    padding: 0 18px; background: #6366f1; color: #fff;
    border: none; border-radius: 8px; font-size: .9rem;
    cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.btn-send:hover { background: #4f46e5; }
.btn-send:disabled { background: #a5b4fc; cursor: not-allowed; }
.typing-indicator { display: none; align-self: flex-start; }
.typing-indicator span {
    display: inline-block; width: 6px; height: 6px;
    border-radius: 50%; background: #a5b4fc; margin: 0 2px;
    animation: bounce .8s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

/* 今すぐやること */
.action-panel {
    background: linear-gradient(135deg, #fef3c7, #fff7ed);
    border: 2px solid #fbbf24;
    border-radius: 10px;
    padding: 16px 20px;
}
.action-panel-title {
    font-size: 1rem; font-weight: 800; color: #92400e;
    margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.action-list {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; gap: 8px;
}
.action-list li {
    display: flex; align-items: flex-start; gap: 10px;
    background: #fff; border-radius: 8px;
    padding: 10px 14px; font-size: .9rem; color: #333; line-height: 1.55;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.action-num {
    width: 22px; height: 22px; border-radius: 50%;
    background: #f59e0b; color: #fff;
    font-size: .75rem; font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 1px;
}
.action-check {
    width: 18px; height: 18px; border-radius: 4px;
    border: 2px solid #d1d5db; cursor: pointer; flex-shrink: 0;
    margin-top: 2px; accent-color: #10b981;
}
.action-list li.done { opacity: .5; }
.action-list li.done .action-text { text-decoration: line-through; color: #aaa; }

/* AI分析レポート 全画面モーダル */
.analysis-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; box-sizing: border-box;
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.analysis-modal.is-open {
    opacity: 1; visibility: visible;
}
.analysis-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55);
    cursor: pointer;
}
.analysis-modal__inner {
    position: relative; z-index: 1;
    width: 100%; max-width: 900px; max-height: 90vh;
    background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex; flex-direction: column; overflow: hidden;
}
.analysis-modal__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #e5e7eb;
    background: #f9fafb; flex-shrink: 0;
}
.analysis-modal__header h2 { margin: 0; font-size: 1.1rem; color: #333; }
.analysis-modal__close {
    width: 40px; height: 40px; border: none; border-radius: 8px;
    background: #e5e7eb; color: #555; font-size: 1.5rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.analysis-modal__close:hover { background: #d1d5db; color: #333; }
.analysis-modal__body {
    padding: 24px; overflow-y: auto; flex: 1;
    font-size: .95rem; line-height: 1.8; color: #333;
    white-space: pre-wrap; word-break: break-word;
}
.analysis-modal__body h3 {
    font-size: 1rem; color: #4338ca; margin: 1.25rem 0 .5rem;
    padding-bottom: 4px; border-bottom: 2px solid #e0e7ff;
}
.analysis-modal__body h3:first-child { margin-top: 0; }

/* チャット 全画面モーダル */
.chat-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 24px; box-sizing: border-box;
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.chat-modal.is-open {
    opacity: 1; visibility: visible;
}
.chat-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55);
    cursor: pointer;
}
.chat-modal__inner {
    position: relative; z-index: 1;
    width: 100%; max-width: 700px; height: 90vh; max-height: 700px;
    background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-modal__header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid #e5e7eb;
    background: #f9fafb; flex-shrink: 0;
}
.chat-modal__header h2 { margin: 0; font-size: 1.1rem; color: #333; }
.chat-modal__close {
    width: 40px; height: 40px; border: none; border-radius: 8px;
    background: #e5e7eb; color: #555; font-size: 1.5rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.chat-modal__close:hover { background: #d1d5db; color: #333; }
.chat-modal__body {
    flex: 1; display: flex; flex-direction: column; min-height: 0;
    padding: 0;
}
.chat-modal__body .chat-messages { flex: 1; min-height: 0; }
.chat-modal__body .chat-footer { flex-shrink: 0; }

/* ===== レスポンシブ (スマホ 640px以下) ===== */
@media (max-width: 640px) {
    .pdca-show { padding: 0.625rem; gap: 0.875rem; }

    /* ヘッダー */
    .pdca-header { padding: 12px 14px; gap: 10px; }
    .pdca-header img { width: 40px; height: 40px; }
    .pdca-header-info h1 { font-size: 1rem; }
    .pdca-header-info .sub { font-size: .78rem; }
    .pdca-header-actions { width: 100%; justify-content: flex-start; }

    /* PDCAステータス */
    .pdca-status-bar { padding: 10px 14px; gap: 8px; }
    .pdca-step { padding: 5px 12px; font-size: .8rem; }

    /* 今すぐやること */
    .action-panel { padding: 12px 14px; }
    .action-panel-title { font-size: .9rem; }
    .action-list li { padding: 8px 12px; font-size: .85rem; }

    /* 分析テキスト */
    .analysis-body { max-height: 300px; padding: 12px; font-size: .85rem; }

    /* メモ */
    .memo-body textarea { min-height: 120px; }

    /* チャット */
    .chat-section { height: 400px; }
    .chat-footer { padding: 10px 12px; }
    .chat-footer textarea { height: 44px; font-size: .85rem; }
    .btn-send { padding: 0 14px; font-size: .85rem; }
    .msg { max-width: 92%; }
    .msg-bubble { font-size: .85rem; padding: 8px 12px; }

    /* モーダルをボトムシート風にフルスクリーン表示 */
    .analysis-modal,
    .chat-modal {
        padding: 0;
        align-items: flex-end;
    }
    .analysis-modal__inner {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 92vh;
    }
    .analysis-modal__header,
    .chat-modal__header { padding: 14px 16px; }
    .analysis-modal__body { padding: 16px; font-size: .88rem; }

    .chat-modal__inner {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        height: 92vh;
        max-height: 92vh;
    }
}
