/* =========================================================
   AI-Soup application.css
   Mobile-first cleaned version
   ========================================================= */

/* =========================================================
   1. Base
   ========================================================= */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    background: #f6f6f6;
    color: #222;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}

a {
    color: inherit;
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
input[type="submit"] {
    cursor: pointer;
}

img {
    max-width: 100%;
    height: auto;
}

/* =========================================================
   2. Layout
   ========================================================= */

.page {
    width: min(100% - 32px, 760px);
    max-width: 760px;
    margin: 24px auto;
    padding: 24px;
    background: #fff;
    border-radius: 16px;
}

.flash {
    width: min(100% - 32px, 760px);
    max-width: 760px;
    margin: 16px auto 0;
    padding: 12px 16px;
    border-radius: 10px;
    font-weight: 700;
}

.flash-notice {
    background: #f0fff4;
    border: 1px solid #8fd19e;
    color: #22543d;
}

.flash-alert {
    background: #fff0f0;
    border: 1px solid #e0a0a0;
    color: #7f1d1d;
}

/* =========================================================
   3. Header / Global menu
   ========================================================= */

.site-header {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
}

.site-header-inner {
    width: min(100% - 32px, 760px);
    max-width: 760px;
    margin: 0 auto;
    padding: 14px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    color: #222;
    font-size: 18px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.global-menu {
    position: relative;
}

.global-menu summary {
    list-style: none;
}

.global-menu summary::-webkit-details-marker {
    display: none;
}

.global-menu-button {
    width: 42px;
    height: 42px;
    border: 1px solid #ddd;
    border-radius: 999px;
    background: #fff;
    color: #222;
    font-size: 24px;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
}

.global-menu-panel {
    position: absolute;
    right: 0;
    top: 48px;
    z-index: 100;
    min-width: 200px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
}

.global-menu-panel form {
    margin: 0;
}

.global-menu-link,
.global-menu-button-item,
.global-menu-user {
    display: block;
    width: 100%;
    padding: 11px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #222;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
}

.global-menu-button-item {
    cursor: pointer;
}

.global-menu-link:hover,
.global-menu-button-item:hover {
    background: #f4f4f4;
}

.global-menu-user {
    margin-bottom: 4px;
    color: #666;
    font-weight: 600;
    border-bottom: 1px solid #eee;
}

.global-menu-separator {
    height: 1px;
    margin: 6px 0;
    background: #eee;
}

.danger-menu-button {
    color: #b42318;
}

/* 古いヘッダー構造が残っていても表示崩れさせない */
.auth-area {
    display: none;
}

/* =========================================================
   4. Buttons / Links
   ========================================================= */

.primary-link,
.primary-button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid #222;
    background: #222;
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.primary-link:hover,
.primary-button:hover,
.btn:hover {
    opacity: 0.85;
}

.btn {
    box-sizing: border-box;
    font-size: 15px;
}

.btn-primary {
    border-color: #222;
    background: #222;
    color: #fff;
}

.btn-secondary {
    border-color: #ccc;
    background: #fff;
    color: #222;
}

.back-link {
    color: #222;
    font-weight: 800;
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.danger-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    background: #7f1d1d;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.danger-button:hover {
    opacity: 0.85;
}

/* =========================================================
   5. Forms
   ========================================================= */

.soup-form,
.answer-form {
    margin-top: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 800;
}

.form-group input[type="text"],
.form-group textarea,
.answer-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font: inherit;
}

.form-group textarea,
.answer-form textarea {
    min-height: 120px;
}

.error-box {
    margin-bottom: 16px;
    padding: 12px;
    background: #fff0f0;
    border: 1px solid #e0a0a0;
    border-radius: 10px;
}

.success-box {
    padding: 20px;
    background: #f0fff4;
    border: 1px solid #8fd19e;
    border-radius: 10px;
}

.success-box h2 {
    margin-top: 0;
}

/* =========================================================
   6. Index page
   ========================================================= */

.index-page .page-header {
    margin-bottom: 28px;
}

.index-page .page-header h1 {
    margin: 0 0 10px;
    font-size: 36px;
    line-height: 1.2;
}

.index-page .page-header p {
    margin: 0 0 20px;
    color: #555;
    line-height: 1.8;
}

.new-question-area {
    width: 100%;
}

.new-question-link {
    width: 100%;
    min-height: 52px;
    border-radius: 14px;
    text-align: center;
}

.soup-list {
    margin-top: 28px;
}

.soup-list h2 {
    margin: 0 0 18px;
    font-size: 28px;
    line-height: 1.3;
}

.soup-card {
    margin-bottom: 16px;
    padding: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
}

.soup-card-title {
    margin: 0 0 12px;
    font-size: 20px;
    line-height: 1.4;
}

.soup-question-body {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    color: #444;
    line-height: 1.7;
}

.soup-question-body p {
    margin: 0;
}

.card-link {
    display: inline-block;
    margin-top: 18px;
    color: #222;
    font-weight: 800;
    text-decoration: underline;
}

/* =========================================================
   7. Show page
   ========================================================= */

.soup-show-page {
    margin-top: 16px;
    padding-top: 16px;
}

.soup-main-card {
    margin-top: 0;
    padding: 18px;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    background: #fff;
}

.soup-title {
    margin: 0 0 8px;
    font-size: 24px;
    line-height: 1.35;
}

.rating-compact {
    display: inline-grid;
    gap: 3px;
    margin-bottom: 12px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #f4f4f4;
    color: #555;
    font-size: 11px;
    line-height: 1.4;
}

.soup-body {
    margin: 0;
    padding: 0;
    border-left: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.75;
}

.soup-body p {
    margin: 0;
}

.compact-section,
.question-form,
.question-history,
.rating-form,
.answer-reveal {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid #e5e5e5;
    border-radius: 16px;
    background: #fff;
}

.compact-section h2,
.question-form h2,
.question-history h2,
.rating-form h2,
.answer-reveal h2 {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 1.35;
}

/* ---------- Question form ---------- */

.question-form form {
    display: grid;
    gap: 12px;
}

.question-form label {
    display: none;
}

.question-form textarea {
    width: 100%;
    min-height: 86px;
    padding: 12px;
    border: 1px solid #bbb;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.6;
    resize: vertical;
}

.question-form textarea::placeholder {
    color: #999;
}

.question-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.question-form input[type="submit"].btn {
    width: 100%;
}

/* ---------- Question history ---------- */

.question-card {
    margin-top: 10px;
    padding: 13px 14px;
    border: 1px solid #e2e2e2;
    border-radius: 14px;
    background: #fafafa;
}

.question-card p {
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.65;
}

.question-card .answer {
    color: #444;
    font-weight: 700;
}

/* ---------- Rating form ---------- */

.rating-form form {
    display: grid;
    gap: 12px;
}

.rating-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
}

.rating-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #bbb;
    border-radius: 10px;
    background: #fff;
    font-size: 15px;
}

/* =========================================================
   8. Legacy cleanup
   ========================================================= */

/* 問題ページ内メニューはヘッダーに統合済み */
.soup-mobile-menu {
    display: none !important;
}

/* 古いページ操作ボタン群が残っても暴れないように */
.page-actions,
.owner-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.page-actions form,
.owner-actions form {
    margin: 0;
}

/* =========================================================
   9. Responsive
   ========================================================= */

@media (max-width: 640px) {
    .site-header-inner {
        width: 100%;
        padding: 12px 16px;
    }

    .page {
        width: 100%;
        margin: 0 auto;
        padding: 16px;
        border-radius: 0;
    }

    .flash {
        width: calc(100% - 32px);
        margin-top: 12px;
    }

    .index-page .page-header h1 {
        font-size: 32px;
    }

    .soup-list h2 {
        font-size: 26px;
    }

    .soup-card {
        padding: 18px;
    }

    .soup-show-page {
        padding-top: 10px;
    }

    .soup-main-card,
    .compact-section,
    .question-form,
    .question-history,
    .rating-form,
    .answer-reveal {
        padding: 16px;
        border-radius: 14px;
    }

    .soup-title {
        font-size: 22px;
    }

    .rating-compact {
        font-size: 11px;
    }

    .question-action-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 380px) {
    .question-action-row {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }
}