/* Presentation AI v1 */
:root {
    --primary: #1A56DB;
    --primary-light: #3B82F6;
    --primary-dark: #1E40AF;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --text: #1e293b;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --input-bg: #ffffff;
    --toast-bg: rgba(0,0,0,0.8);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.4);
    --input-bg: #1e293b;
    --toast-bg: rgba(30,41,59,0.9);
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* Header */
header {
    display: flex; justify-content: space-between; align-items: center;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px 16px;
    background: var(--primary); color: white;
    box-shadow: var(--shadow); z-index: 10;
}
#app-title { font-size: 1.1rem; font-weight: 700; }
#header-actions { display: flex; gap: 8px; }
.header-btn {
    background: rgba(255,255,255,0.2); border: none; color: white;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 1rem; transition: background 0.2s;
}
.header-btn:hover { background: rgba(255,255,255,0.3); }

/* Views */
.view { display: none; flex: 1; overflow-y: auto; }
.view.active { display: flex; flex-direction: column; }

/* Auth */
.auth-wrap {
    max-width: 400px; margin: 80px auto; padding: 40px;
    background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 16px; text-align: center;
}
.auth-wrap h2 { font-size: 1.5rem; }
.auth-desc { color: var(--text-dim); font-size: 0.9rem; }
.error-msg { color: var(--danger); font-size: 0.85rem; }
.btn-google {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    text-decoration: none;
}

/* Buttons */
.btn-primary {
    background: var(--primary); color: white; border: none;
    padding: 12px 24px; border-radius: 8px; font-size: 1rem;
    cursor: pointer; transition: background 0.2s; font-weight: 500;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
    background: transparent; color: var(--primary); border: 1px solid var(--primary);
    padding: 12px 24px; border-radius: 8px; font-size: 1rem;
    cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { background: rgba(26,86,219,0.1); }
.btn-small {
    padding: 6px 14px; border-radius: 6px; font-size: 0.85rem;
    border: 1px solid var(--border); background: var(--bg-card); color: var(--text); cursor: pointer;
}
.btn-small:hover { border-color: var(--primary); color: var(--primary); }
.btn-large { padding: 16px 32px; font-size: 1.1rem; }
.btn-danger { background: var(--danger); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.icon-btn {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: var(--text); padding: 4px 8px;
}

/* Home */
.home-wrap { padding: 20px 16px; max-width: 600px; margin: 0 auto; width: 100%; }
.start-section { margin-bottom: 32px; }
.start-section h2 { font-size: 1.2rem; margin-bottom: 16px; }
.sample-topics { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.sample-topic {
    padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text); cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.sample-topic:hover { border-color: var(--primary); color: var(--primary); }
.topic-input-wrap { display: flex; gap: 8px; }
.topic-input-wrap input {
    flex: 1; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem;
    background: var(--input-bg); color: var(--text);
}

/* Project list */
.home-section { margin-bottom: 24px; }
.home-section h3 { font-size: 1rem; margin-bottom: 12px; color: var(--text-dim); }
.project-item {
    display: flex; align-items: center; padding: 14px;
    background: var(--bg-card); border-radius: 8px; margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: pointer; transition: box-shadow 0.2s;
    position: relative;
}
.project-item:hover { box-shadow: var(--shadow); }
.project-item-main { flex: 1; }
.project-item-title { font-size: 0.95rem; font-weight: 500; }
.project-item-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; display: flex; gap: 12px; }
.project-status {
    padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 500;
}
.status-draft { background: #f1f5f9; color: #64748b; }
.status-outline_ready { background: #fef3c7; color: #92400e; }
.status-generating { background: #dbeafe; color: #1e40af; }
.status-completed { background: #d1fae5; color: #065f46; }
.project-delete-btn {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-dim); font-size: 1.2rem;
    cursor: pointer; opacity: 0; transition: opacity 0.2s;
}
.project-item:hover .project-delete-btn { opacity: 1; }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.session-info {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.info-topic { font-weight: 500; flex: 1; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info-chip {
    padding: 2px 10px; border-radius: 12px; font-size: 0.75rem;
    background: rgba(26,86,219,0.1); color: var(--primary);
}

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: 85%; }
.msg-user { align-self: flex-end; }
.msg-ai { align-self: flex-start; }
.msg-user .msg-text {
    background: var(--primary); color: white; padding: 10px 14px;
    border-radius: 16px 16px 4px 16px; font-size: 0.9rem; line-height: 1.5;
}
.msg-ai .msg-text {
    background: var(--bg-card); padding: 10px 14px;
    border-radius: 16px 16px 16px 4px; font-size: 0.9rem; line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.msg-ai .msg-text p { margin: 4px 0; }
.msg-ai .msg-text ul { padding-left: 20px; margin: 4px 0; }
.loading .msg-text::after {
    content: '...'; animation: dots 1s steps(3, end) infinite;
}
@keyframes dots { 0% { content: '.'; } 33% { content: '..'; } 66% { content: '...'; } }

/* Input area */
.input-area {
    display: flex; gap: 8px; padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: var(--bg-card); border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.mic-btn {
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--bg-card);
    font-size: 1.2rem; cursor: pointer; transition: all 0.2s;
    flex-shrink: 0;
}
.mic-btn.active { background: var(--danger); border-color: var(--danger); animation: pulse-mic 1s infinite; }
@keyframes pulse-mic { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
#msg-input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 22px; font-size: 0.9rem; outline: none;
    background: var(--input-bg); color: var(--text);
    resize: none; overflow-y: hidden; max-height: 120px;
    line-height: 1.4; font-family: inherit;
}
#msg-input:focus { border-color: var(--primary); }
.send-btn {
    background: var(--primary); color: white; border: none;
    padding: 10px 20px; border-radius: 22px; font-size: 0.9rem;
    cursor: pointer; font-weight: 500;
}
.send-btn:hover { background: var(--primary-dark); }

/* Outline */
.outline-wrap { padding: 16px; max-width: 700px; margin: 0 auto; width: 100%; }
.outline-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.outline-header h2 { flex: 1; font-size: 1.1rem; }
.outline-actions { display: flex; gap: 8px; }
.outline-cards { display: flex; flex-direction: column; gap: 12px; }
.outline-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); border-left: 4px solid var(--primary);
    cursor: grab; transition: transform 0.2s;
}
.outline-card:hover { transform: translateX(4px); }
.outline-card.type-title { border-left-color: var(--primary); }
.outline-card.type-content { border-left-color: var(--primary-light); }
.outline-card.type-summary { border-left-color: var(--success); }
.outline-card-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.outline-card-type {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-dim); font-weight: 600;
}
.outline-card-num { font-size: 0.75rem; color: var(--text-dim); }
.outline-card-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.outline-card-subtitle { font-size: 0.85rem; color: var(--text-dim); }
.outline-card-bullets { list-style: disc; padding-left: 20px; margin-top: 8px; }
.outline-card-bullets li { font-size: 0.85rem; margin: 4px 0; color: var(--text); }
.outline-card-actions {
    display: flex; gap: 4px; margin-top: 8px; justify-content: flex-end;
}
.outline-card-actions button {
    background: none; border: 1px solid var(--border); border-radius: 4px;
    padding: 4px 8px; font-size: 0.75rem; cursor: pointer; color: var(--text-dim);
}
.outline-card-actions button:hover { border-color: var(--primary); color: var(--primary); }
.outline-card-imgsrc { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.image-source-badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; }
.badge-unsplash { background: #e3f2fd; color: #1565c0; }
.badge-ai { background: #fce4ec; color: #c62828; }
.btn-toggle-src { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 0.7rem; cursor: pointer; color: var(--text-dim); }
.btn-toggle-src:hover { border-color: var(--primary); color: var(--primary); }

.outline-edit-bar {
    display: flex; gap: 8px; margin-top: 16px; padding: 12px;
    background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
}
.outline-edit-bar input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; background: var(--input-bg); color: var(--text);
}

/* Generating */
.generating-wrap {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 24px;
}
.generating-spinner {
    width: 60px; height: 60px; border: 4px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.generating-text { font-size: 1.1rem; color: var(--text-dim); }

/* Complete */
.complete-wrap {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 16px; padding: 20px;
}
.complete-icon { font-size: 4rem; }
.complete-wrap h2 { font-size: 1.5rem; }
.complete-info { color: var(--text-dim); font-size: 0.9rem; }

/* Toast */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--toast-bg); color: white; padding: 10px 20px;
    border-radius: 20px; font-size: 0.85rem; z-index: 200;
    transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* Templates */
.template-upload-wrap { margin-bottom: 12px; }
.template-item {
    display: flex; align-items: center; padding: 12px 14px;
    background: var(--bg-card); border-radius: 8px; margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: relative;
}
.template-item-main { flex: 1; }
.template-item-title { font-size: 0.9rem; font-weight: 500; }
.template-item-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.template-delete-btn {
    background: none; border: none; color: var(--text-dim); font-size: 1.2rem;
    cursor: pointer; opacity: 0; transition: opacity 0.2s; padding: 4px 8px;
}
.template-item:hover .template-delete-btn { opacity: 1; }
.template-select {
    padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg-card); color: var(--text); font-size: 0.85rem;
    cursor: pointer; max-width: 160px;
}

/* Attach button */
.attach-btn {
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid var(--border); background: var(--bg-card);
    font-size: 1.2rem; cursor: pointer; transition: all 0.2s;
    flex-shrink: 0; position: relative;
}
.attach-btn:hover { border-color: var(--primary); }

/* Attach menu */
.attach-menu {
    position: absolute; bottom: 70px; left: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow); z-index: 50;
    overflow: hidden;
}
.attach-menu-item {
    display: block; width: 100%; padding: 10px 20px;
    border: none; background: none; color: var(--text);
    font-size: 0.9rem; cursor: pointer; text-align: left;
    white-space: nowrap;
}
.attach-menu-item:hover { background: rgba(26,86,219,0.08); }

/* Paste modal */
.paste-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.paste-modal.hidden { display: none !important; }
.paste-modal-content {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow); width: 100%; max-width: 600px;
    padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.paste-modal-header {
    display: flex; justify-content: space-between; align-items: center;
}
.paste-modal-header h3 { font-size: 1.1rem; }
#paste-textarea {
    width: 100%; padding: 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; resize: vertical;
    background: var(--input-bg); color: var(--text);
    font-family: inherit; min-height: 150px;
}
.paste-modal-footer {
    display: flex; justify-content: space-between; align-items: center;
}
#paste-char-count { font-size: 0.8rem; color: var(--text-dim); }

/* Document system message */
.msg-system { align-self: center; }
.msg-doc-info {
    background: rgba(26,86,219,0.08) !important; color: var(--text) !important;
    padding: 8px 16px !important; border-radius: 16px !important;
    font-size: 0.85rem !important; text-align: center;
}

/* Drag & drop */
.chat-messages.drag-over {
    outline: 3px dashed var(--primary); outline-offset: -3px;
    background: rgba(26,86,219,0.03);
}

/* Document start buttons */
.doc-start-wrap {
    display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}
.btn-doc-start {
    padding: 10px 18px !important; font-size: 0.9rem !important;
}

/* Generic modal (preview 用。paste-modal とは別系統) */
.modal {
    position: fixed; inset: 0;
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none !important; }
.modal-overlay {
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.modal-content {
    position: relative;
    background: var(--bg, #fff);
    border-radius: 8px;
    max-width: 95vw;
    max-height: 92vh;
    display: flex; flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.modal-header h3 { margin: 0; font-size: 1.05rem; }
.icon-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 1.4rem; line-height: 1;
    padding: 4px 10px;
    color: var(--text, #1e293b);
}
.icon-btn:hover { background: rgba(0,0,0,0.05); border-radius: 4px; }

/* Preview modal (PPTX プレビュー用) */
.preview-modal-content {
    width: 95vw;
    max-width: 1400px;
    height: 85vh;
}
.preview-body {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    background: #f1f5f9;
    overflow: hidden;
}
.preview-slide-wrap {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    height: 100%;
    overflow: hidden;
    padding: 12px;
}
.preview-img {
    max-width: 100%;
    max-height: 100%;
    width: auto; height: auto;
    object-fit: contain;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #fff;
}
.preview-nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 50%;
    width: 44px; height: 44px;
    font-size: 1.6rem; line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex; align-items: center; justify-content: center;
    color: var(--text, #1e293b);
    transition: background 0.15s;
}
.preview-nav:hover { background: #fff; }
.preview-nav.prev { left: 12px; }
.preview-nav.next { right: 12px; }
.preview-footer {
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid var(--border, #e2e8f0);
    color: var(--text-dim, #64748b);
    font-size: 0.85rem;
}
@media (max-width: 640px) {
    .preview-modal-content { height: 90vh; }
    .preview-nav { width: 36px; height: 36px; font-size: 1.3rem; }
}

/* プロジェクト検索 UI (Wave #2) */
.projects-header {
    display: flex; flex-direction: column; gap: 10px;
    margin-bottom: 14px;
}
.projects-header h3 { margin: 0; }
.projects-search {
    display: flex; flex-direction: column; gap: 8px;
}
#project-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg, #fff);
}
#project-search:focus {
    outline: none;
    border-color: var(--primary, #1A56DB);
    box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.15);
}
.tag-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    min-height: 28px;
}
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--bg, #fff);
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text, #334155);
    transition: all 0.15s;
}
.tag-chip:hover {
    background: #f1f5f9;
    border-color: var(--primary, #1A56DB);
}
.tag-chip.active {
    background: var(--primary, #1A56DB);
    color: #fff;
    border-color: var(--primary, #1A56DB);
}
.tag-chip-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.7rem;
}
.tag-chip.active .tag-chip-count {
    background: rgba(255, 255, 255, 0.3);
}
.tag-chip-clear {
    color: var(--text-dim, #64748b);
}

/* プロジェクトアイテム内のタグ表示 */
.project-tag {
    display: inline-block;
    padding: 1px 8px;
    margin-left: 4px;
    background: #eef2ff;
    color: #4338ca;
    border-radius: 999px;
    font-size: 0.7rem;
    line-height: 1.5;
}
.project-tag-edit-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 0.9rem;
    padding: 4px 8px;
    color: var(--text-dim, #64748b);
    margin-right: 4px;
    opacity: 0.5;
    transition: opacity 0.15s;
}
.project-tag-edit-btn:hover { opacity: 1; }

/* Common */
.hidden { display: none !important; }
.empty-msg { text-align: center; color: var(--text-dim); padding: 20px; font-size: 0.9rem; }

/* Mobile */
@media (max-width: 480px) {
    .auth-wrap { margin: 30px 16px; }
    .message { max-width: 90%; }
    .msg-user .msg-text, .msg-ai .msg-text { font-size: 0.95rem; }
    #msg-input { font-size: 1rem; }
    .outline-card { padding: 12px; }
}
@media (hover: none) {
    .project-delete-btn { opacity: 0.6; }
}
