:root {
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #059669;
    --border: #e5e7eb;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(160deg, #eef2ff 0%, var(--bg) 45%, #f8fafc 100%);
    color: var(--text);
    min-height: 100vh;
}

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

.container {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.brand {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    padding: 8px 14px;
    border-radius: 999px;
    color: var(--muted);
    transition: 0.2s ease;
}

.nav a:hover,
.nav a.active {
    background: #dbeafe;
    color: var(--primary);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}

.card h1 {
    margin: 0 0 8px;
    font-size: 24px;
}

.card .subtitle {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 14px;
}

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.form-group textarea {
    min-height: 110px;
    resize: vertical;
    line-height: 1.6;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-secondary {
    background: #f3f4f6;
    color: var(--text);
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(420px, 100%);
}

body.page-login .login-card .notice {
    margin-bottom: 16px;
}

body.page-login .form-group-error label {
    color: #991b1b;
}

body.page-login .form-group-error input {
    border-color: #f87171;
    background: #fffbfb;
}

body.page-login .form-group-error input:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
}

.result-box {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px dashed var(--border);
}

.result-question {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 10px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.answer-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.answer-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: #fff;
}

.answer-item .label {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: #eff6ff;
    padding: 4px 8px;
    border-radius: 999px;
}

.answer-item .content {
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.hint {
    font-size: 13px;
    color: var(--muted);
    margin-top: 8px;
}

/* ---------- 检索结果（与录入页共用 page-add） ---------- */

body.page-add .result-panel {
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body.page-add .result-panel-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 12px;
}

body.page-add .result-panel-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

body.page-add .result-summary {
    margin: 0;
    font-size: 12px;
    color: var(--muted);
}

body.page-add .result-summary strong {
    color: var(--primary);
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-row {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fafbfc;
}

.result-row-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.result-row-no {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    background: #e5e7eb;
    padding: 2px 8px;
    border-radius: 6px;
    line-height: 1.6;
}

.result-row-question {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
}

.result-row-answers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 4px;
    border-left: 3px solid #dbeafe;
    margin-left: 2px;
}

.result-answer-line {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.55;
}

.result-answer-label {
    flex-shrink: 0;
    min-width: 52px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
}

.result-answer-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.result-no-answer,
.result-empty {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- 录入页紧凑布局 ---------- */
body.page-add {
    min-height: 100vh;
}

body.page-add .container {
    width: min(1100px, calc(100% - 24px));
    padding: 10px 0 16px;
}

body.page-add .container > .alert {
    display: none;
}

body.page-add .topbar {
    margin-bottom: 10px;
}

body.page-add .brand {
    font-size: 17px;
}

body.page-add .nav a {
    padding: 6px 12px;
    font-size: 13px;
}

body.page-add .card-add {
    padding: 14px 18px;
}

body.page-add .card-add h1 {
    font-size: 18px;
    margin: 0;
}

.card-head-inline {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 10px;
}

body.page-add .card-head-inline .subtitle {
    margin: 0;
    font-size: 12px;
}

body.page-add .field-hint {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    animation: notice-in 0.35s ease;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.notice.is-hiding {
    opacity: 0;
    transform: translateY(-4px);
}

@keyframes notice-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notice-success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.notice-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.notice-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.7);
}

.notice-body {
    flex: 1;
    min-width: 0;
}

.notice-body strong {
    display: block;
    font-size: 15px;
    margin-bottom: 2px;
}

.notice-body p {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
}

.form-add {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-field {
    margin: 0;
}

.field-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.field-label-row label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.form-add textarea {
    width: 100%;
    min-height: 52px;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid var(--border);
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    background: #fff;
}

.form-add textarea:focus,
.form-add input[type="text"]:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-add input[type="text"] {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    background: #fff;
}

.form-answers-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.btn-paste {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f9fafb;
    color: var(--muted);
    cursor: pointer;
    transition: 0.15s ease;
}

.btn-paste:hover {
    color: var(--primary);
    border-color: #93c5fd;
    background: #eff6ff;
}

.btn-paste:active {
    transform: scale(0.96);
}

.paste-tip {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 2;
    pointer-events: none;
}

.paste-tip-ok {
    background: #065f46;
    color: #fff;
}

.paste-tip-err {
    background: #991b1b;
    color: #fff;
}

.form-actions-inline {
    margin-top: 4px;
    gap: 10px;
}

body.page-add .btn {
    padding: 9px 16px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .form-answers-grid {
        grid-template-columns: 1fr;
    }

    .card-head-inline {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .card {
        padding: 20px;
    }
}
