:root {
    --app-bg: #f7f8fb;
    --app-surface: #ffffff;
    --app-text: #273142;
    --app-muted: #6b7280;
    --app-border: #e5e7eb;
    --app-primary: #4867d6;
    --app-primary-hover: #3e59bd;
    --app-primary-soft: #eef2ff;
    --app-radius: 14px;
}


/* --------------------------------------------------
   Base
-------------------------------------------------- */

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Hiragino Kaku Gothic ProN",
        "Hiragino Sans",
        "Yu Gothic UI",
        "Meiryo",
        sans-serif;
    font-size: 0.92rem;
    line-height: 1.65;
}

a {
    color: var(--app-primary);
}

a:hover {
    color: var(--app-primary-hover);
}

.btn {
    font-size: 0.86rem;
}

.btn-primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--app-primary-hover);
    border-color: var(--app-primary-hover);
}


/* --------------------------------------------------
   Navbar
-------------------------------------------------- */

.app-navbar {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(8px);
}

.app-navbar .navbar-brand {
    color: var(--app-text);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.app-navbar .nav-link {
    color: #4b5563;
    font-size: 0.88rem;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
    color: var(--app-primary);
}

.app-user-name {
    color: var(--app-muted);
    font-size: 0.82rem;
}


/* --------------------------------------------------
   Flash
-------------------------------------------------- */

.app-flash-wrap {
    padding: 1rem 1rem 0;
}

.app-flash-width {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.app-flash {
    margin: 0;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    border-radius: 12px;
    font-size: 0.86rem;
}


/* --------------------------------------------------
   FAQ search
-------------------------------------------------- */

.app-main-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem 3rem;
}

.welcome-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.welcome-note {
    margin: 0.3rem 0 0;
    color: var(--app-muted);
    font-size: 0.86rem;
}

.search-panel {
    margin-top: 1.2rem;
    padding: 1.35rem;
    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #f5f7ff 100%
        );
    border: 1px solid #e1e6f4;
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(35, 49, 92, 0.06);
}

.search-label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.86rem;
    font-weight: 700;
}

.search-input {
    min-height: 46px;
    border-color: #d9deea;
    border-radius: 12px;
    font-size: 0.95rem;
}

.search-input:focus {
    border-color: #9db0f2;
    box-shadow: 0 0 0 0.2rem rgba(72, 103, 214, 0.12);
}

.btn-search {
    min-height: 46px;
    padding-right: 1.3rem;
    padding-left: 1.3rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 700;
}

.search-help {
    margin-top: 0.55rem;
    color: var(--app-muted);
    font-size: 0.8rem;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.7rem 0 0.75rem;
}

.section-heading h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.result-count {
    color: var(--app-muted);
    font-size: 0.78rem;
}

.result-card {
    margin-bottom: 0.75rem;
    padding: 1rem 1.1rem;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 2px 10px rgba(31, 41, 55, 0.025);
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        border-color 0.15s ease;
}

.result-card:hover {
    transform: translateY(-1px);
    border-color: #cfd7ef;
    box-shadow: 0 7px 20px rgba(31, 41, 55, 0.06);
}

.result-topline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.result-question {
    margin: 0;
    font-size: 0.96rem;
    font-weight: 700;
    line-height: 1.55;
}

.result-answer {
    margin: 0.55rem 0 0;
    color: #445064;
    font-size: 0.88rem;
    line-height: 1.75;
    white-space: pre-wrap;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.meta-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0.15rem 0.5rem;
    background: #f3f4f6;
    color: #5f6877;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.meta-badge.primary {
    background: var(--app-primary-soft);
    color: #4356a5;
}

.score {
    flex: 0 0 auto;
    padding: 0.2rem 0.5rem;
    background: #f8fafc;
    color: #667085;
    border-radius: 999px;
    font-size: 0.72rem;
    white-space: nowrap;
}

.source-link {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.8rem;
    text-decoration: none;
}

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

.tips {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    background: #fff8e8;
    color: #695326;
    border: 1px solid #f7e4b6;
    border-radius: var(--app-radius);
    font-size: 0.82rem;
}

.empty-state {
    padding: 2rem 1rem;
    background: #fff;
    color: var(--app-muted);
    border: 1px dashed #d7dce5;
    border-radius: var(--app-radius);
    text-align: center;
}


/* --------------------------------------------------
   Logged-out home
-------------------------------------------------- */

.login-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 190px);
    padding: 2rem 0;
}

.login-card {
    width: min(100%, 470px);
    padding: 2.5rem 2rem;
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 20px;
    box-shadow: 0 12px 36px rgba(35, 49, 92, 0.07);
    text-align: center;
}

.login-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 1rem;
    background: var(--app-primary-soft);
    color: var(--app-primary);
    border-radius: 50%;
    font-size: 1.35rem;
    font-weight: 800;
}

.login-title {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.login-copy {
    margin: 0.8rem 0 1.4rem;
    color: #536071;
    font-size: 0.9rem;
}

.login-main-button {
    min-width: 190px;
    padding: 0.65rem 1.2rem;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 700;
}

.login-note {
    margin: 0.8rem 0 0;
    color: var(--app-muted);
    font-size: 0.76rem;
}


/* --------------------------------------------------
   Review pages
-------------------------------------------------- */

.review-wrap {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.6rem 1rem 3rem;
}

.edit-wrap {
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    padding: 1.6rem 1rem 3rem;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.page-note {
    margin: 0.25rem 0 0;
    color: var(--app-muted);
    font-size: 0.8rem;
}

.page-count {
    color: var(--app-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.page-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 2px 10px rgba(31, 41, 55, 0.025);
}

.app-table {
    min-width: 1100px;
    margin-bottom: 0;
    font-size: 0.8rem;
}

.app-table thead th {
    padding: 0.62rem 0.7rem;
    background: #f8f9fb;
    color: #596273;
    border-bottom-width: 1px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}

.app-table tbody td {
    padding: 0.68rem 0.7rem;
    vertical-align: middle;
}

.app-table tbody tr:last-child td {
    border-bottom: 0;
}

.col-question {
    min-width: 230px;
}

.col-answer {
    min-width: 300px;
}

.cell-text {
    min-width: 180px;
    max-width: 360px;
    line-height: 1.55;
}

.table-link {
    font-size: 0.78rem;
    text-decoration: none;
}

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

.table-help {
    margin-top: 0.6rem;
    color: var(--app-muted);
    font-size: 0.76rem;
}

.candidate-row {
    cursor: pointer;
}

.candidate-row:hover td {
    background: #fafbff;
}

.candidate-actions {
    min-width: 270px;
    text-align: right;
    white-space: nowrap;
}

.status-badge {
    display: inline-block;
    padding: 0.16rem 0.45rem;
    background: var(--app-primary-soft);
    color: #4356a5;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}


/* --------------------------------------------------
   History
-------------------------------------------------- */

.history-row > td {
    padding: 0 !important;
    background: #f7f9fd !important;
}

.history-panel {
    margin: 0.55rem;
    padding: 0.9rem;
    background: #fff;
    border: 1px solid #dfe4ef;
    border-radius: 11px;
}

.history-title {
    margin-bottom: 0.55rem;
    color: #4b5563;
    font-size: 0.78rem;
    font-weight: 700;
}

.history-table {
    min-width: 1000px;
}

.current-history-row td {
    background: #eef3ff !important;
}


/* --------------------------------------------------
   Edit form
-------------------------------------------------- */

.edit-card {
    padding: 1.25rem 1.35rem;
}

.app-form-label {
    margin-bottom: 0.3rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.app-form-control {
    border-color: #dfe3eb;
    font-size: 0.88rem;
}

.app-form-control:focus {
    border-color: #9db0f2;
    box-shadow: 0 0 0 0.2rem rgba(72, 103, 214, 0.1);
}

textarea.app-form-control {
    line-height: 1.65;
}

.source-panel {
    margin-top: 1.4rem;
    padding: 0.9rem 1rem;
    background: #f8f9fb;
    border: 1px solid var(--app-border);
    border-radius: 11px;
}

.source-title {
    margin-bottom: 0.35rem;
    color: #566172;
    font-size: 0.76rem;
    font-weight: 700;
}

.source-document-link {
    font-size: 0.84rem;
    text-decoration: none;
}

.source-document-link:hover {
    text-decoration: underline;
}

.source-empty {
    color: var(--app-muted);
    font-size: 0.84rem;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.35rem;
}


/* --------------------------------------------------
   Modal
-------------------------------------------------- */

.app-modal-content {
    border: 0;
    border-radius: 15px;
    box-shadow: 0 16px 50px rgba(31, 41, 55, 0.16);
}

.modal-note {
    margin-bottom: 0.55rem;
    color: var(--app-muted);
    font-size: 0.82rem;
}

.reject-question {
    margin-bottom: 1rem;
    padding: 0.7rem 0.8rem;
    background: #f8f9fb;
    border-radius: 9px;
    font-size: 0.86rem;
    font-weight: 600;
}


/* --------------------------------------------------
   Footer
-------------------------------------------------- */

.app-footer {
    padding: 1.5rem 1rem 2rem;
    color: #8a93a3;
    font-size: 0.76rem;
    text-align: center;
}


/* --------------------------------------------------
   Responsive
-------------------------------------------------- */

@media (max-width: 767.98px) {

    body {
        font-size: 0.9rem;
    }

    .app-main-wrap,
    .review-wrap,
    .edit-wrap {
        padding-top: 1.2rem;
    }

    .welcome-title {
        font-size: 1.2rem;
    }

    .search-panel {
        padding: 1rem;
        border-radius: 15px;
    }

    .result-card {
        padding: 0.9rem;
    }

    .result-topline {
        display: block;
    }

    .score {
        display: inline-block;
        margin-top: 0.45rem;
    }

    .login-hero {
        min-height: auto;
        padding: 1rem 0;
    }

    .login-card {
        padding: 2rem 1.25rem;
        border-radius: 16px;
    }

    .app-user-name {
        display: none;
    }

    .page-heading {
        align-items: flex-start;
    }

    .edit-card {
        padding: 1rem;
    }
}
