/* =========================================
   基本設定
========================================= */

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    background: #f4f6f8;
    color: #222;
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Yu Gothic",
        "YuGothic",
        "Hiragino Kaku Gothic ProN",
        Meiryo,
        sans-serif;

    line-height: 1.7;
}


/* =========================================
   共通
========================================= */

.container {
    width: min(1100px, 92%);
    margin: 0 auto;
}


/* =========================================
   ヘッダー
========================================= */

.site-header {
    padding: 32px 0;
    background: #243b55;
    color: #fff;
}

.site-header h1 {
    margin: 0;
    font-size: 2rem;
}

.subtitle {
    margin: 6px 0 0;
    opacity: 0.85;
}


/* =========================================
   メイン
========================================= */

main {
    padding-top: 30px;
    padding-bottom: 50px;
}


/* =========================================
   カード
========================================= */

.card {
    margin-bottom: 24px;
    padding: 26px;
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 2px 10px rgba(0, 0, 0, 0.08);
}

.card h2 {
    margin-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
    font-size: 1.35rem;
}


/* =========================================
   ステータス
========================================= */

.status-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(220px, 1fr));

    gap: 14px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 12px 16px;

    background: #f7f7f7;
    border-radius: 8px;
}

.status-badge {
    padding: 4px 10px;

    background: #ddd;
    border-radius: 20px;

    font-size: 0.85rem;
    font-weight: bold;
}

.status-badge.loading {
    background: #fff3cd;
    color: #856404;
}

.status-badge.ok {
    background: #d4edda;
    color: #155724;
}

.status-badge.error {
    background: #f8d7da;
    color: #721c24;
}


/* =========================================
   ファイル選択
========================================= */

input[type="file"] {
    width: 100%;

    margin-bottom: 15px;
    padding: 14px;

    background: #f8f9fa;

    border: 1px dashed #aaa;
    border-radius: 8px;
}


/* =========================================
   オプション
========================================= */

.option-area {
    margin: 12px 0 20px;
}

.option-area label {
    cursor: pointer;
}


/* =========================================
   画像表示
========================================= */

.image-grid {
    display: grid;

    grid-template-columns:
        repeat(auto-fit, minmax(280px, 1fr));

    gap: 24px;
}

.image-box h3 {
    margin-bottom: 8px;
}

.preview-frame {
    position: relative;

    display: flex;

    align-items: center;
    justify-content: center;

    min-height: 300px;

    overflow: hidden;

    background:
        repeating-conic-gradient(
            #eee 0% 25%,
            #fff 0% 50%
        )
        50% / 20px 20px;

    border: 1px solid #ddd;
    border-radius: 8px;
}

#sourceImage {
    display: none;

    max-width: 100%;
    max-height: 500px;

    object-fit: contain;
}

#processedCanvas {
    display: none;

    width: 280px;
    height: 280px;

    max-width: 90%;
    max-height: 90%;

    object-fit: contain;

    image-rendering: pixelated;
}

.placeholder {
    padding: 20px;

    color: #777;
    text-align: center;
}


/* =========================================
   ボタン
========================================= */

.button-area {
    display: flex;
    flex-wrap: wrap;

    gap: 12px;

    margin-top: 25px;
}

button {
    min-width: 180px;

    padding: 12px 22px;

    border: none;
    border-radius: 7px;

    background: #666;
    color: #fff;

    font-size: 1rem;

    cursor: pointer;

    transition:
        opacity 0.2s,
        transform 0.1s;
}

button:hover:not(:disabled) {
    opacity: 0.85;
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    background: #bbb;
    cursor: not-allowed;
}

.primary-button {
    background: #0069d9;
}


/* =========================================
   認識結果
========================================= */

.result-area {
    display: grid;

    grid-template-columns:
        minmax(220px, 0.8fr)
        minmax(300px, 1.2fr);

    gap: 25px;
}

.main-result {
    padding: 25px;

    background: #f8f9fa;
    border-radius: 10px;

    text-align: center;
}

.result-label {
    font-weight: bold;
}

.result-character {
    margin: 10px 0;

    font-family:
        "Yu Mincho",
        "YuMincho",
        "Hiragino Mincho ProN",
        serif;

    font-size: 6rem;
    line-height: 1.2;
}

.confidence {
    font-size: 1.1rem;
}


/* =========================================
   表
========================================= */

table {
    width: 100%;

    border-collapse: collapse;
}

th,
td {
    padding: 10px;

    border: 1px solid #ddd;

    text-align: center;
}

th {
    background: #f2f2f2;
}


/* =========================================
   ログ
========================================= */

#logArea {
    min-height: 130px;
    max-height: 320px;

    margin: 0;
    padding: 16px;

    overflow: auto;

    background: #151515;
    color: #b6ffb6;

    border-radius: 7px;

    white-space: pre-wrap;
    word-break: break-word;
}


/* =========================================
   注意事項
========================================= */

.notice {
    background: #fffdf2;
}


/* =========================================
   フッター
========================================= */

footer {
    padding: 24px;

    background: #222;
    color: #aaa;

    text-align: center;
}


/* =========================================
   スマートフォン
========================================= */

@media (max-width: 700px) {

    .site-header h1 {
        font-size: 1.6rem;
    }

    .card {
        padding: 18px;
    }

    .result-area {
        grid-template-columns: 1fr;
    }

    .result-character {
        font-size: 5rem;
    }

    .preview-frame {
        min-height: 240px;
    }

    button {
        width: 100%;
    }
}