:root {
    --primary: #1fa599;         /* 表紙の綺麗なティールグリーン */
    --primary-hover: #167f75;
    --accent: #fca113;          /* 電球の鮮やかなオレンジ */
    --accent-hover: #e58f06;
    --bg: #eff6f5;              /* ほんのり緑がかった上品な背景白 */
    --card-bg: #ffffff;
    --text: #2d3748;
    --border: #cbd5e1;
    --success: #2bc47a;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 50px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.container { 
    max-width: 700px; 
    width: 100%; 
}

/* 本の装丁を意識したヘッダーデザイン */
.book-header {
    display: flex;
    align-items: center;
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(31, 165, 153, 0.1);
    margin-bottom: 40px;
    gap: 30px;
    border-left: 8px solid var(--primary);
}

.book-cover-img {
    width: 120px;
    height: auto;
    border-radius: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    display: block;
}

.header-right h1 {
    margin: 0 0 5px 0;
    font-size: 2.2rem;
    color: var(--primary);
}

.book-subtitle {
    margin: 0 0 8px 0;
    font-size: 1.2rem;
    font-weight: bold;
    color: #4a5568;
}

.author-credit {
    margin: 0;
    font-size: 0.9rem;
    color: #718096;
}

/* 縦並びのタイムライン・ステップ構造 */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* ログイン画面：新規登録とログインを横並びにする */
.auth-timeline {
    flex-direction: row;
    align-items: flex-start;
}

.auth-timeline .step-card {
    flex: 1;
}

/* 「新規アカウント作成」「ログイン」を見出しとして表示 */
.auth-heading {
    margin: 0 0 5px 0;
}

@media (max-width: 640px) {
    .auth-timeline {
        flex-direction: column;
    }
}

.step-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border: 1px solid #e2e8f0;
    position: relative;
}

/* ステップ3（メイン機能）を目立たせる */
.highlight-card {
    border: 2px solid var(--primary);
    background: #fcfefe;
}

.step-number {
    position: absolute;
    top: -12px;
    left: 25px;
    background: #718096;
    color: white;
    padding: 2px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.step-number.spec {
    background: var(--primary);
}

/* index画面のセクション見出し：バッジを見出しとして大きく表示 */
.step-number.spec.section-title {
    position: static;
    top: auto;
    left: auto;
    display: inline-block;
    margin: 0 0 20px 0;
    padding: 8px 22px;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

h2 {
    margin: 5px 0 5px 0;
    font-size: 1.4rem;
    color: #2d3748;
}

.step-desc {
    margin: 0 0 20px 0;
    font-size: 0.9rem;
    color: #718096;
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #4a5568;
}

input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 1rem;
    transition: border 0.2s;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
}

textarea {
    resize: vertical;
    height: 120px;
}

/* ボタンのデザイン */
button {
    width: 100%;
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

button:active {
    transform: scale(0.99);
}

.btn-main {
    background-color: var(--primary);
}

.btn-main:hover {
    background-color: var(--primary-hover);
}

.btn-accent {
    background-color: var(--accent);
}

.btn-accent:hover {
    background-color: var(--accent-hover);
}

/* ステータスバッジ（オレンジのアクセント） */
.status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    background-color: #fff3e0;
    color: #e65100;
    margin-bottom: 20px;
    border: 1px solid #ffe0b2;
}

.status-badge.logged-in {
    background-color: #d1fae5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

/* 結果表示ボックス */
.result-box {
    margin-top: 20px;
    padding: 15px;
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.result-box.ai-box {
    border-left-color: var(--accent);
    background: #fffdf9;
}

.disabled-overlay {
    opacity: 0.4;
    pointer-events: none;
}

/* ログアウトボタン横並びレイアウト */
.auth-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

/* auth-bar内ではステータスバッジの下マージンを消して縦位置を揃える */
.auth-bar .status-badge {
    margin-bottom: 0;
}

.btn-logout {
    width: auto;
    background-color: #e2e8f0;
    color: #4a5568;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: bold;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background-color: #cbd5e1;
}

/* チャット履歴 */
.history-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-item {
    padding: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

/* Qごとに開閉できるサマリー部分 */
.history-summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

/* デフォルトの三角マーカーを消して自作の矢印に置き換える */
.history-summary::-webkit-details-marker {
    display: none;
}

.history-summary::before {
    content: "▶";
    flex-shrink: 0;
    font-size: 0.7rem;
    color: #94a3b8;
    transition: transform 0.15s;
}

.history-item[open] > .history-summary::before {
    transform: rotate(90deg);
}

.history-date {
    font-size: 0.75rem;
    color: #94a3b8;
    flex-shrink: 0;
}

.history-q {
    font-size: 0.95rem;
    color: #2d3748;
    white-space: pre-wrap;
}

.history-a {
    font-size: 0.95rem;
    color: #4a5568;
    margin-top: 12px;
    padding-left: 12px;
    border-left: 3px solid var(--accent);
    white-space: pre-wrap;
}

/* Markdown整形表示（AI回答・履歴の回答） */
.md {
    white-space: normal;
}
.md p {
    margin: 0 0 10px;
}
.md p:last-child {
    margin-bottom: 0;
}
.md ul, .md ol {
    margin: 8px 0;
    padding-left: 1.5em;
}
.md li {
    margin: 4px 0;
}
.md li::marker {
    color: var(--accent);
}
.md strong {
    font-weight: 700;
    color: #1f2937;
}
.md code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}
.md .md-h {
    margin: 12px 0 6px;
}
.history-a .md {
    margin-top: 6px;
}