:root {
    --background: #f4f5f1;
    --surface: #ffffff;
    --surface-soft: #f8f9f6;
    --text: #20251f;
    --muted: #6d756c;
    --border: #dde1da;
    --primary: #294f3b;
    --primary-hover: #1f3f2e;
    --accent: #dbe7dc;
    --danger: #a54444;
    --danger-soft: #f9eaea;
    --shadow: 0 10px 30px rgba(28, 44, 33, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Kaku Gothic ProN",
        "Yu Gothic",
        sans-serif;
}

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

a {
    color: inherit;
    text-decoration: none;
}

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 34px 24px;
    background: #1f3027;
    color: #ffffff;
}

.sidebar-brand {
    padding: 0 10px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-label {
    margin: 0 0 7px;
    color: #aebcaf;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.sidebar-brand h1 {
    margin: 0;
    font-size: 27px;
    letter-spacing: 0.04em;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
    margin-top: 26px;
}

.sidebar-nav > a,
.sidebar-nav .nav-group a {
    display: block;
    padding: 12px 14px;
    border-radius: 10px;
    color: #dce4de;
    font-size: 14px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.nav-group {
    margin-top: 14px;
}

.nav-group p {
    margin: 0 0 6px;
    padding: 0 14px;
    color: #93a396;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.main-content {
    width: 100%;
    max-width: 1380px;
    padding: 48px 54px 70px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

.page-header h2 {
    margin: 0;
    font-size: 32px;
    letter-spacing: 0.01em;
}

.page-description {
    max-width: 720px;
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.primary-button,
.secondary-button,
.action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.primary-button {
    min-height: 48px;
    padding: 0 22px;
    background: var(--primary);
    color: #ffffff;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.secondary-button {
    min-height: 44px;
    padding: 0 19px;
    background: #ffffff;
    color: var(--primary);
    border: 1px solid var(--border);
}

.text-button {
    color: var(--muted);
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.message-box,
.error-box {
    margin-bottom: 24px;
    padding: 17px 20px;
    border: 1px solid #c8dbc9;
    border-radius: 12px;
    background: #edf6ed;
    color: #31543a;
}

.message-error,
.error-box {
    border-color: #efcaca;
    background: var(--danger-soft);
    color: #8e3535;
}

.error-box strong {
    display: block;
    margin-bottom: 8px;
}

.error-box ul {
    margin: 0;
    padding-left: 22px;
    line-height: 1.7;
}

.summary-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.summary-card {
    min-width: 150px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.summary-card p {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 12px;
}

.summary-card strong {
    font-size: 28px;
}

.summary-card span {
    margin-left: 3px;
    color: var(--muted);
}

.filter-card,
.form-card,
.faq-card,
.empty-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.filter-card {
    margin-bottom: 22px;
    padding: 20px;
}

.filter-form {
    display: grid;
    grid-template-columns:
        minmax(260px, 1fr)
        180px
        220px
        auto;
    align-items: end;
    gap: 14px;
}

.filter-field {
    display: grid;
    gap: 7px;
}

.filter-field label,
.form-field > label {
    color: #495148;
    font-size: 13px;
    font-weight: 700;
}

input[type="text"],
input[type="search"],
select,
textarea {
    width: 100%;
    border: 1px solid #cfd5cd;
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    outline: none;
}

input[type="text"],
input[type="search"],
select {
    min-height: 46px;
    padding: 0 13px;
}

textarea {
    padding: 13px;
    resize: vertical;
    line-height: 1.7;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(41, 79, 59, 0.12);
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 13px;
}

.faq-list {
    display: grid;
    gap: 15px;
}

.faq-card {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    padding: 24px;
}

.faq-main {
    min-width: 0;
}

.faq-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 11px;
}

.faq-id,
.category-badge,
.tag {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.faq-id {
    color: var(--muted);
}

.category-badge {
    padding: 5px 10px;
    background: #edf0ec;
    color: #586157;
}

.faq-card h3 {
    margin: 0;
    font-size: 19px;
    line-height: 1.5;
}

.faq-answer {
    max-width: 850px;
    margin: 9px 0 14px;
    color: #4e564e;
    line-height: 1.75;
    white-space: pre-wrap;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.tag {
    padding: 5px 9px;
}

.scene-tag {
    background: #e8f0e9;
    color: #365a40;
}

.facility-tag {
    background: #f3eee4;
    color: #745f37;
}

.keyword-details {
    margin-top: 15px;
    color: var(--muted);
    font-size: 12px;
}

.keyword-details summary {
    cursor: pointer;
}

.keyword-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.keyword-list span {
    padding: 4px 8px;
    border-radius: 7px;
    background: var(--surface-soft);
}

.faq-actions {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.action-button {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #4b554d;
    font-size: 13px;
}

.edit-button {
    background: var(--primary);
    color: #ffffff;
}

.delete-button {
    color: var(--danger);
}

.empty-card {
    padding: 60px 30px;
    text-align: center;
}

.empty-card h3 {
    margin: 0 0 10px;
}

.empty-card p {
    margin: 0;
    color: var(--muted);
}

.form-page {
    max-width: 1100px;
}

.faq-form {
    display: grid;
    gap: 20px;
}

.form-card {
    padding: 28px;
}

.form-section-heading {
    display: flex;
    gap: 14px;
    margin-bottom: 25px;
}

.form-section-heading > span {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}

.form-section-heading h3 {
    margin: 2px 0 5px;
    font-size: 18px;
}

.form-section-heading p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.form-field {
    margin-top: 21px;
}

.form-field:first-of-type {
    margin-top: 0;
}

.required {
    margin-left: 5px;
    color: var(--danger);
    font-size: 11px;
}

.form-field input,
.form-field textarea {
    margin-top: 8px;
}

.field-help {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.checkbox-group,
.facility-options {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.checkbox-group {
    grid-template-columns: 1fr 1fr;
}

.facility-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-card {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-soft);
    cursor: pointer;
}

.checkbox-card input {
    width: 17px;
    height: 17px;
    margin: 3px 0 0;
    accent-color: var(--primary);
}

.checkbox-card span {
    display: grid;
    gap: 3px;
}

.checkbox-card strong {
    font-size: 14px;
}

.checkbox-card small {
    color: var(--muted);
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 22px;
    padding-top: 5px;
}

.save-button {
    min-width: 180px;
}

.save-button:disabled {
    cursor: wait;
    opacity: 0.75;
}

@media (max-width: 1050px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 20px;
    }

    .sidebar-brand {
        padding-bottom: 16px;
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        margin-top: 15px;
    }

    .nav-group {
        display: contents;
    }

    .nav-group p {
        display: none;
    }

    .main-content {
        padding: 32px 24px 60px;
    }

    .filter-form {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 720px) {
    .page-header,
    .faq-card {
        flex-direction: column;
    }

    .page-header .primary-button,
    .page-header .secondary-button {
        width: 100%;
    }

    .summary-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .filter-form,
    .form-grid,
    .checkbox-group,
    .facility-options {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        justify-content: space-between;
    }

    .faq-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .faq-actions form {
        flex: 1;
    }

    .faq-actions .action-button {
        width: 100%;
    }

    .form-card {
        padding: 21px;
    }

    .form-footer {
        flex-direction: column-reverse;
    }

    .form-footer > * {
        width: 100%;
        text-align: center;
    }
}

/* FAQ AI下書き作成 */
.ai-draft-area {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 11px;
}

.ai-draft-button {
    min-height: 42px;
    padding: 0 17px;
    border: 1px solid #9db9a6;
    border-radius: 10px;
    background: #edf5ef;
    color: #294f3b;
    cursor: pointer;
    font-weight: 700;
}

.ai-draft-button:hover {
    background: #e1eee4;
}

.ai-draft-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.ai-draft-status {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.ai-draft-status.loading {
    color: #6d756c;
}

.ai-draft-status.success {
    color: #31543a;
}

.ai-draft-status.error {
    color: var(--danger);
}

@media (max-width: 720px) {
    .ai-draft-area {
        align-items: stretch;
        flex-direction: column;
    }

    .ai-draft-button {
        width: 100%;
    }
}

/* ==================================================
   AI Lab Form UI Override (Sprint1)
================================================== */

/* ---------- サイドバー非表示 ---------- */

.form-page {
    max-width: none;
}

.form-page .sidebar,
.form-page .sidebar-brand,
.form-page .sidebar-nav {
    display: none;
}

.form-page.admin-layout {
    display: block;
}

/* ---------- メイン ---------- */

.form-page.main-content,
.main-content.form-page {
    max-width: 1380px;
    margin: 0 auto;
    padding: 28px;
}

/* ---------- 固定ヘッダー ---------- */

.form-page .page-header {

    position: sticky;

    top: 0;

    z-index: 100;

    margin:

        -28px

        -28px

        24px;

    padding:

        18px

        28px;

    background:

        rgba(

            243,

            244,

            246,

            0.96

        );

    backdrop-filter: blur(14px);

    -webkit-backdrop-filter: blur(14px);

    border-bottom:

        1px solid

        rgba(

            227,

            230,

            235,

            0.92

        );
}

/* ---------- カード ---------- */

.form-card {

    border-radius: 18px;

    box-shadow:

        0 8px 24px

        rgba(

            18,

            24,

            32,

            0.05

        );

}

/* ---------- 保存 ---------- */

.save-button {

    min-width: 220px;

    min-height: 52px;

    font-size: 15px;

    font-weight: 800;

    border-radius: 12px;

}

/* ---------- AIボタン ---------- */

.ai-draft-button {

    border-radius: 10px;

    min-height: 44px;

    font-weight: 800;

}

/* ---------- モバイル ---------- */

@media (max-width:900px){

.form-page .page-header{

position:static;

}

}


/* ==================================================
   AI Lab FAQ Form Header Fix
================================================== */

.admin-layout {
    display: block;
    min-height: 100vh;
    background: #f3f4f6;
}

.main-content.form-page {
    width: min(1440px, calc(100% - 40px));
    max-width: none;
    margin: 0 auto;
    padding: 0 0 64px;
}

.form-page .page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin: 0 -12px 24px;
    padding: 20px 12px 16px;
    border-bottom: 1px solid rgba(227, 230, 235, 0.92);
    background: rgba(243, 244, 246, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.form-page .page-title-area {
    min-width: 0;
}

.form-page .eyebrow {
    margin: 0 0 5px;
    color: #69717d;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.form-page-title {
    margin: 0;
    color: #20242a;
    font-size: clamp(28px, 4vw, 38px);
    line-height: 1.2;
    letter-spacing: -0.035em;
}

.form-page .page-description {
    margin: 7px 0 0;
    color: #69717d;
    font-size: 14px;
}

.form-page .header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.lab-nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid #e3e6eb;
    border-radius: 11px;
    background: #ffffff;
    color: #20242a;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.lab-nav-button:hover {
    border-color: #d2d6dc;
    background: #f8f9fb;
}

.lab-nav-current {
    border-color: #20242a;
    background: #20242a;
    color: #ffffff;
}

.form-page .faq-form {
    max-width: none;
}

.form-page .form-card {
    border: 1px solid #e3e6eb;
    border-radius: 20px;
    background: #ffffff;
    box-shadow:
        0 1px 2px rgba(18, 24, 32, 0.03),
        0 8px 24px rgba(18, 24, 32, 0.05);
}

.form-page .save-button {
    min-width: 220px;
    min-height: 52px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 800;
}

.form-page .ai-draft-button {
    min-height: 44px;
    border-radius: 10px;
    font-weight: 800;
}

@media (max-width: 900px) {
    .main-content.form-page {
        width: calc(100% - 24px);
    }

    .form-page .page-header {
        position: static;
        flex-direction: column;
    }

    .form-page .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .form-page .header-actions .lab-nav-button {
        flex: 1;
    }
}


/* ==================================================
   AI Lab Unified Form Header v1
================================================== */

html,
body {
    margin: 0;
}

body {
    padding-top: 0 !important;
}

.main-content.form-page {
    padding-top: 0 !important;
}

.form-page .page-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;

    margin-top: 0 !important;
    padding-top: 20px !important;
    padding-bottom: 16px !important;

    border-bottom:
        1px solid #c7ccd3 !important;

    background:
        rgba(220, 224, 229, 0.97) !important;

    box-shadow:
        0 5px 18px
        rgba(24, 31, 40, 0.07);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

@media (max-width: 900px) {
    .form-page .page-header {
        position: static !important;
    }
}
