:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #667085;
    --line: #d9dee7;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, "Microsoft YaHei", sans-serif;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 18px;
}

.page-head,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.section-head.compact {
    align-items: center;
    margin-bottom: 10px;
}

.section-head.compact h2 {
    font-size: 16px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 28px;
    line-height: 1.25;
}

h2 {
    font-size: 20px;
}

p,
label,
legend,
select,
input,
textarea,
button {
    font-size: 14px;
}

p {
    color: var(--muted);
    margin-top: 8px;
}

.grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

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

fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    min-width: 0;
}

legend {
    color: var(--text);
    font-weight: 700;
    padding: 0 6px;
}

label {
    display: block;
    color: var(--text);
    margin-top: 12px;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: 18px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 6px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

.choice input,
.segmented input {
    width: auto;
    margin: 0;
}

.mt {
    margin-top: 14px;
}

.segmented {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 8px;
}

.segmented label {
    margin: 0;
}

.segmented span {
    display: block;
    padding: 10px 14px;
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented input:checked + span {
    background: var(--accent);
    color: #fff;
}

.source-block {
    margin-top: 16px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 18px;
}

button {
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    padding: 11px 16px;
}

button:hover {
    background: var(--accent-dark);
}

button.secondary {
    background: #475467;
}

button.secondary:hover {
    background: #344054;
}

.icon-button {
    min-width: 72px;
}

.inline-actions,
.job-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

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

.autosave-toast {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 1000;
    transform: translate(-50%, -50%);
    min-width: 140px;
    border-radius: 8px;
    background: rgba(23, 32, 42, 0.92);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(16, 24, 40, 0.22);
}

.replace-panel {
    border-top: 1px solid var(--line);
    margin-top: 16px;
    padding-top: 14px;
}

.replacement-rows {
    display: grid;
    gap: 10px;
}

.replacement-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.replacement-row input {
    margin-top: 0;
}

.crawl-preview {
    margin-top: 12px;
}

.rule-summary {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    margin-top: 12px;
    padding: 12px;
}

.preview-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.preview-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.field-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.field-picker label,
.preview-head label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 0;
}

.field-picker input,
.preview-head input {
    width: auto;
    margin-top: 0;
}

.preview-item strong {
    display: block;
    margin-bottom: 6px;
}

.preview-item img {
    display: block;
    width: 96px;
    height: 72px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-top: 8px;
}

#status {
    color: var(--muted);
}

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

.hidden {
    display: none !important;
}

.jobs {
    display: grid;
    gap: 12px;
}

.job {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.job-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.job-title {
    font-weight: 700;
}

.badge {
    display: inline-block;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 8px;
    color: var(--muted);
    margin-right: 6px;
}

.files {
    margin-top: 12px;
    max-height: 220px;
    overflow: auto;
    border-top: 1px solid var(--line);
    padding-top: 8px;
}

.file-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 100px;
    gap: 12px;
    padding: 6px 0;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 760px) {
    .grid.two,
    .file-row,
    .replacement-row {
        grid-template-columns: 1fr;
    }

    .page-head,
    .section-head,
    .job-head {
        display: block;
    }

    .icon-button {
        margin-top: 12px;
    }
}
