/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', 'Noto Sans JP', sans-serif;
    background: #0a0a14;
    color: #e2e8f0;
    line-height: 1.6;
    min-height: 100vh;
}
a { color: #818cf8; text-decoration: none; }
a:hover { color: #a5b4fc; }

/* === Navbar === */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: #111827;
    border-bottom: 1px solid #1f2937;
}
.nav-brand { font-size: 1.25rem; font-weight: 700; color: #818cf8; }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: #9ca3af; font-size: 0.9rem; }
.nav-links a:hover { color: #e2e8f0; }

/* === Main Layout === */
main { max-width: 900px; margin: 0 auto; padding: 2rem 1.5rem; }
.container { width: 100%; }
.text-muted { color: #9ca3af; font-size: 0.9rem; }

/* === Buttons === */
.btn-primary, .btn-secondary {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary { background: #6366f1; color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-primary:disabled { background: #4b5563; cursor: wait; }
.btn-secondary { background: transparent; color: #818cf8; border: 1px solid #818cf8; }
.btn-secondary:hover { background: #818cf81a; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; width: 100%; }
.btn-danger-sm { background: #dc2626; color: #fff; border: none; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; cursor: pointer; }
.btn-danger-sm:hover { background: #b91c1c; }

/* === Hero === */
.hero { text-align: center; padding: 3rem 0 2rem; }
.hero h1 { font-size: 2.5rem; color: #818cf8; margin-bottom: 0.5rem; }
.hero-sub { font-size: 1.2rem; color: #9ca3af; }

/* === Feature Cards === */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; margin: 2rem 0; }
.feature-card { background: #1a1a2e; border: 1px solid #2d2d44; border-radius: 12px; padding: 2rem; cursor: pointer; transition: border-color 0.2s, transform 0.2s; }
.feature-card:hover { border-color: #6366f1; transform: translateY(-2px); }
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { color: #e2e8f0; margin-bottom: 0.5rem; }
.feature-card p { color: #9ca3af; font-size: 0.9rem; }

/* === Steps === */
.how-it-works { margin-top: 3rem; text-align: center; }
.how-it-works h2 { margin-bottom: 1.5rem; color: #818cf8; }
.steps { display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap; }
.step { text-align: center; max-width: 220px; }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #6366f1; color: #fff; font-weight: 700; font-size: 1.1rem; margin-bottom: 0.5rem; }
.step p { color: #9ca3af; font-size: 0.9rem; }

/* === Auth === */
.auth-container { max-width: 400px; margin: 3rem auto; background: #1a1a2e; border-radius: 12px; padding: 2.5rem; }
.auth-container h2 { text-align: center; margin-bottom: 1.5rem; }
.auth-container form { display: flex; flex-direction: column; gap: 1rem; }
.auth-container input { padding: 0.75rem 1rem; border: 1px solid #374151; border-radius: 8px; background: #111827; color: #e2e8f0; font-size: 1rem; }
.auth-container input:focus { outline: none; border-color: #6366f1; }
.auth-switch { text-align: center; margin-top: 1rem; color: #9ca3af; font-size: 0.9rem; }
#auth-message { text-align: center; margin-top: 1rem; font-size: 0.9rem; }
#auth-message.error { color: #f87171; }
#auth-message.success { color: #34d399; }

/* === Tabs === */
.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid #2d2d44; padding-bottom: 0.5rem; }
.tab { padding: 0.5rem 1.25rem; border: none; background: transparent; color: #9ca3af; font-size: 0.95rem; cursor: pointer; border-radius: 6px 6px 0 0; transition: all 0.2s; }
.tab.active { background: #1a1a2e; color: #818cf8; }
.tab:hover { color: #e2e8f0; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-desc { color: #9ca3af; margin-bottom: 1.5rem; }

/* === Question Cards === */
.question-card, .strength-card { background: #1a1a2e; border: 1px solid #2d2d44; border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.q-num { color: #6366f1; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; }
.q-text { font-size: 1.05rem; margin-bottom: 0.75rem; }
.options { display: flex; flex-direction: column; gap: 0.5rem; }
.option { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border: 1px solid #374151; border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.option:hover { border-color: #6366f1; background: #6366f10d; }
.option input[type="radio"] { accent-color: #6366f1; }
.option input[type="radio"]:checked + span { color: #818cf8; }

/* === Strengths Rating === */
.strength-card h3 { color: #818cf8; margin-bottom: 0.25rem; }
.strength-desc { color: #6b7280; font-size: 0.85rem; margin-bottom: 0.75rem; }
.statement { margin-bottom: 0.75rem; }
.statement p { font-size: 0.95rem; margin-bottom: 0.4rem; }
.rating-legend { display: flex; justify-content: space-between; color: #6b7280; font-size: 0.8rem; margin-bottom: 1rem; }
.rating-group { display: flex; gap: 0.75rem; }
.rating-label { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid #374151; border-radius: 50%; cursor: pointer; transition: all 0.2s; font-size: 0.85rem; }
.rating-label:hover { border-color: #6366f1; background: #6366f10d; }
.rating-label input { display: none; }
.rating-label:has(input:checked) { background: #6366f1; border-color: #6366f1; color: #fff; }

/* === Upload === */
.upload-area { border: 2px dashed #374151; border-radius: 12px; padding: 2rem; text-align: center; margin-bottom: 1rem; }
.upload-area input[type="file"] { margin-bottom: 0.5rem; }
.upload-area p { color: #6b7280; font-size: 0.9rem; }

/* === Results === */
.result-area { margin-top: 2rem; padding: 2rem; background: #111827; border: 1px solid #2d2d44; border-radius: 12px; }
.result-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.type-badge, .type-badge-lg { background: #6366f1; color: #fff; padding: 0.25rem 0.75rem; border-radius: 6px; font-weight: 700; }
.type-badge-lg { font-size: 1.5rem; padding: 0.5rem 1rem; }
.result-actions { display: flex; gap: 1rem; margin-top: 1.5rem; justify-content: center; }

/* === Dimensions Bar === */
.dimensions { display: flex; flex-direction: column; gap: 1rem; }
.dim-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.dim-label { min-width: 100px; font-weight: 600; font-size: 0.9rem; color: #818cf8; }
.dim-bar { flex: 1; height: 8px; background: #374151; border-radius: 4px; min-width: 120px; }
.dim-fill { height: 100%; background: #6366f1; border-radius: 4px; transition: width 0.5s; }
.dim-desc { color: #9ca3af; font-size: 0.85rem; width: 100%; margin-left: 100px; }

/* === Strengths Ranking === */
.strengths-ranking { display: flex; flex-direction: column; gap: 0.75rem; }
.strength-rank-item { display: flex; align-items: flex-start; gap: 1rem; }
.rank { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; border-radius: 50%; background: #6366f1; color: #fff; font-weight: 700; font-size: 0.85rem; }
.strength-rank-item strong { color: #e2e8f0; }
.strength-rank-item p { color: #9ca3af; font-size: 0.85rem; margin-top: 0.1rem; }

/* === Profile === */
.profile-type { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; }
.section-card { background: #1a1a2e; border: 1px solid #2d2d44; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.section-card h3 { color: #818cf8; margin-bottom: 1rem; }
.prompt-preview { background: #111827; padding: 1rem; border-radius: 8px; font-size: 0.8rem; color: #9ca3af; white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; }
.empty-state { text-align: center; padding: 3rem 0; }
.empty-state p { color: #9ca3af; margin-bottom: 1.5rem; font-size: 1.1rem; }
.version-badge { background: #374151; color: #9ca3af; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.8rem; align-self: center; }

/* === Evolution Timeline === */
.evolution-desc { color: #9ca3af; font-size: 0.9rem; margin-bottom: 1rem; }
.evolution-timeline { display: flex; flex-direction: column; gap: 0.5rem; }
.evolution-item { display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: #111827; border-radius: 8px; border-left: 3px solid #6366f1; }
.evo-version { min-width: 60px; font-weight: 700; color: #818cf8; font-size: 0.85rem; }
.evo-detail { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.evo-type { background: #6366f1; color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.evo-strengths { color: #9ca3af; font-size: 0.8rem; }
.evo-date { color: #6b7280; font-size: 0.75rem; }

/* =============================================================
   NEW: Chat Layout (session sidebar + chat area)
   ============================================================= */
.chat-layout {
    display: flex;
    height: calc(100vh - 60px);
    max-width: 100%;
}
.chat-layout main, .chat-layout .container { max-width: none; padding: 0; }

/* Session Sidebar */
.session-sidebar {
    width: 260px;
    min-width: 260px;
    background: #111827;
    border-right: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.session-sidebar.collapsed { display: none; }
.btn-new-chat {
    display: block;
    width: calc(100% - 1rem);
    margin: 0.5rem;
    padding: 0.6rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
}
.btn-new-chat:hover { background: #4f46e5; }
.session-list { flex: 1; overflow-y: auto; padding: 0.25rem; }
.session-item {
    position: relative;
    padding: 0.6rem 0.75rem;
    margin: 0.15rem 0.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}
.session-item:hover { background: #1f2937; }
.session-item.active { background: #1e293b; border-left: 3px solid #6366f1; }
.session-item-title { font-size: 0.85rem; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 1.5rem; }
.session-item-meta { font-size: 0.7rem; color: #6b7280; margin-top: 0.15rem; display: flex; gap: 0.5rem; align-items: center; }
.session-delete { position: absolute; top: 0.5rem; right: 0.5rem; background: none; border: none; color: #6b7280; font-size: 1rem; cursor: pointer; display: none; }
.session-item:hover .session-delete { display: block; }
.session-delete:hover { color: #f87171; }

/* Chat Main */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #1f2937;
    background: #111827;
    min-height: 48px;
}
.chat-header-left { display: flex; align-items: center; gap: 0.75rem; }
.chat-header-right { display: flex; align-items: center; gap: 0.75rem; }
.chat-title { font-size: 0.95rem; font-weight: 600; color: #e2e8f0; }
.btn-sidebar-toggle { background: none; border: none; color: #9ca3af; font-size: 1.2rem; cursor: pointer; display: none; }
.btn-settings { background: none; border: none; color: #9ca3af; font-size: 1.2rem; cursor: pointer; }
.btn-settings:hover { color: #e2e8f0; }

/* Model Badge */
.model-badge { background: #1e293b; color: #818cf8; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.model-badge-sm { background: #1e293b; color: #818cf8; padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.65rem; }
.session-cost { color: #34d399; font-size: 0.75rem; }

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.chat-placeholder { text-align: center; color: #6b7280; padding: 3rem 1rem; }
.chat-placeholder p { margin-bottom: 0.5rem; }

.msg { padding: 0.75rem 1rem; border-radius: 10px; max-width: 80%; }
.msg-user { background: #6366f1; color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.msg-assistant { background: #1a1a2e; color: #e2e8f0; align-self: flex-start; border-bottom-left-radius: 3px; border: 1px solid #2d2d44; }
.msg-content { font-size: 0.9rem; line-height: 1.6; }
.msg-cost { font-size: 0.7rem; color: #6b7280; margin-top: 0.4rem; padding-top: 0.3rem; border-top: 1px solid #2d2d44; }

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid #1f2937;
    background: #111827;
}
.chat-input-area textarea {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid #374151;
    border-radius: 8px;
    background: #1a1a2e;
    color: #e2e8f0;
    font-size: 0.9rem;
    resize: none;
    font-family: inherit;
}
.chat-input-area textarea:focus { outline: none; border-color: #6366f1; }
.chat-input-area button {
    padding: 0.6rem 1.2rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}
.chat-input-area button:hover { background: #4f46e5; }
.chat-input-area button:disabled { background: #4b5563; cursor: wait; }

/* === Settings Modal === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-content {
    background: #1a1a2e;
    border: 1px solid #2d2d44;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid #2d2d44; }
.modal-header h3 { color: #818cf8; margin: 0; }
.modal-header button { background: none; border: none; color: #9ca3af; font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 1.25rem; }
.modal-body label { display: block; color: #9ca3af; font-size: 0.85rem; margin-bottom: 0.3rem; margin-top: 0.75rem; }
.modal-body select, .modal-body textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #374151;
    border-radius: 6px;
    background: #111827;
    color: #e2e8f0;
    font-size: 0.9rem;
    font-family: inherit;
}
.modal-body select:focus, .modal-body textarea:focus { outline: none; border-color: #6366f1; }
.model-price-info { color: #6b7280; font-size: 0.75rem; margin-top: 0.25rem; }
.rag-checkbox-list { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.3rem; }
.rag-checkbox-list label { display: flex; align-items: center; gap: 0.5rem; color: #e2e8f0; font-size: 0.9rem; cursor: pointer; }
.modal-footer { padding: 0.75rem 1.25rem; border-top: 1px solid #2d2d44; text-align: right; }
.modal-footer button { padding: 0.5rem 1.5rem; background: #6366f1; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }

/* === RAG Page === */
.rag-create { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.rag-create input { flex: 1; min-width: 150px; padding: 0.5rem 0.75rem; border: 1px solid #374151; border-radius: 6px; background: #111827; color: #e2e8f0; font-size: 0.9rem; }
.rag-create input:focus { outline: none; border-color: #6366f1; }
.rag-create button { padding: 0.5rem 1rem; background: #6366f1; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; }
.rag-collection-card { background: #1a1a2e; border: 1px solid #2d2d44; border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.rag-collection-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.rag-collection-header h3 { color: #818cf8; margin: 0; font-size: 1rem; }
.rag-upload-area { display: flex; gap: 0.5rem; align-items: center; margin: 0.75rem 0; flex-wrap: wrap; }
.rag-upload-area input[type="file"] { color: #9ca3af; font-size: 0.85rem; }
.rag-upload-area button { padding: 0.4rem 0.8rem; background: #6366f1; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
.rag-docs { margin-top: 0.5rem; }
.rag-doc-item { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0.6rem; background: #111827; border-radius: 4px; margin-bottom: 0.25rem; font-size: 0.85rem; }

/* === Cost Chart === */
.cost-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.cost-bar-group { display: flex; align-items: center; gap: 0.75rem; }
.cost-bar-label { min-width: 60px; font-size: 0.8rem; color: #9ca3af; }
.cost-bar-container { flex: 1; height: 16px; background: #111827; border-radius: 4px; overflow: hidden; }
.cost-bar-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #818cf8); border-radius: 4px; transition: width 0.5s; }
.cost-bar-value { min-width: 200px; font-size: 0.75rem; color: #6b7280; }

/* === Responsive === */
@media (max-width: 768px) {
    .session-sidebar { position: fixed; left: 0; top: 60px; bottom: 0; z-index: 50; transform: translateX(0); transition: transform 0.2s; }
    .session-sidebar.collapsed { transform: translateX(-100%); display: flex; }
    .btn-sidebar-toggle { display: block; }
    .chat-layout main { max-width: 100%; }
    .msg { max-width: 90%; }
}
@media (max-width: 640px) {
    .navbar { padding: 0.75rem 1rem; }
    .nav-links { gap: 0.75rem; font-size: 0.8rem; }
    main { padding: 1rem; }
    .hero h1 { font-size: 1.8rem; }
    .tabs { flex-wrap: wrap; }
    .dim-desc { margin-left: 0; }
    .dim-row { flex-direction: column; align-items: flex-start; }
    .cost-bar-value { min-width: auto; }
    .cost-bar-group { flex-wrap: wrap; }
}
