/* ========================================
   小論文採点AI - スタイルシート
   ======================================== */

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --accent-primary: #4a90e2;
    --accent-secondary: #7b68ee;
    --accent-gradient: linear-gradient(135deg, #4a90e2 0%, #7b68ee 100%);
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --border-color: #2a2a4a;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.8;
}

/* ヘッダー */
.header {
    height: 50px;
    /* 高さ固定 */
    display: flex;
    align-items: center;
    padding: 0 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-secondary);
}

.subtitle {
    display: none;
}

/* メインコンテナ */
.container {
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* PC: 左右分割・画面固定 */
@media (min-width: 768px) {
    body {
        height: 100vh;
        overflow: hidden;
    }

    .container {
        height: calc(100vh - 50px);
        flex-direction: row;
        align-items: stretch;
        /* 高さを揃える */
    }

    .input-section,
    .output-section {
        flex: 1;
        width: 50%;
        height: 100%;
        overflow-y: auto;
        /* PCのみ内部スクロール */
        padding: 1.5rem;
    }

    /* 入力セクションレイアウト */
    .input-section {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .input-section .card:nth-of-type(2) {
        flex: 1;
        /* PCのみ伸縮させる */
        display: flex;
        flex-direction: column;
        min-height: 200px;
    }

    #ronbun {
        flex: 1;
        height: 100%;
    }

    /* スクロールバー装飾 */
    .input-section::-webkit-scrollbar,
    .output-section::-webkit-scrollbar {
        width: 8px;
    }

    .input-section::-webkit-scrollbar-thumb,
    .output-section::-webkit-scrollbar-thumb {
        background: #333355;
        border-radius: 4px;
    }

    .input-section::-webkit-scrollbar-track,
    .output-section::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* モバイル: 通常スクロール */
@media (max-width: 767px) {
    .container {
        height: auto;
        /* 高さはコンテンツなり */
    }

    .input-section,
    .output-section {
        width: 100%;
        height: auto;
        /* 固定しない */
        overflow: visible;
        /* スクロールバー出さない */
        padding: 1rem;
    }

    .input-section {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
}

/* セクション共通 */
.input-section,
.output-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* カード */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

/* 課題カード: 高さをあまり取らない */
.input-section .card:nth-of-type(1) {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

#kadai {
    height: 80px;
    min-height: 80px;
    resize: none;
}

/* 小論文カード: 残りのスペースを埋める */
/* PCの場合はメディアクエリ内でflex:1が指定されるため、ここは基本設定のみ */
.input-section .card:nth-of-type(2) {
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

/* 出力セクション */
.output-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* テキストエリア */
textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: #ffffff;
    /* 白背景 */
    color: #333333;
    /* 黒文字 */
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

textarea::placeholder {
    color: var(--text-secondary);
}

#ronbun {
    flex: 1;
    /* 親に合わせて伸縮 */
    height: 100%;
    min-height: 100px;
    resize: none;
    /* 手動リサイズ禁止 */
}

/* ボタン: 固定高さで最下部に配置 */
#btn-start {
    flex: 0 0 auto;
    margin-top: auto;
}

/* ボタン */
.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--accent-gradient);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* スピナー（ボタン用） */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* スピナー（カード用） */
.step-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    gap: 1rem;
    color: var(--text-secondary);
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 出力カード初期状態 */
.output-card {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.output-card.active {
    opacity: 1;
}

/* スコアグリッド */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.score-item {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.score-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.score-value {
    font-size: 2rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-max {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 合計スコア */
.total-score {
    text-align: center;
    padding: 1.5rem;
    background: var(--accent-gradient);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.total-score .label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.total-score .value {
    font-size: 2.5rem;
    font-weight: 700;
}

/* 評価理由 */
.reasons {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1rem;
    line-height: 1.9;
    white-space: normal;
}

.reasons h3 {
    font-size: 0.95rem;
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
}

.reasons p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.reasons p:last-child {
    margin-bottom: 0;
}

/* Step2, Step3 コンテンツ */
.step-content {
    line-height: 1.9;
    white-space: normal;
}

.step-content h3 {
    color: var(--accent-primary);
    margin: 1rem 0 0.5rem;
    font-size: 1rem;
}

.step-content p {
    margin-bottom: 1rem;
}

.step-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.step-content li {
    margin-bottom: 0.5rem;
}

/* フッター */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

/* スマホ向け調整 */
@media (max-width: 767px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .card {
        padding: 1rem;
    }

    .scores-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .total-score .value {
        font-size: 2rem;
    }
}