:root {
    --blue: #2457a6;
    --blue-dark: #183f7a;
    --blue-soft: #eef4fc;
    --ink: #1d2939;
    --muted: #667085;
    --line: #d8dee8;
    --surface: #fff;
    --page: #f4f6f9;
    --green: #267a4b;
    --amber: #9a5b00;
    --danger: #a12d2d;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(31, 42, 68, .08)
}

* {
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none
}

*::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0
}

html {
    min-height: 100%;
    overflow-y: auto
}

body {
    margin: 0;
    min-height: 100%;
    overflow-y: auto;
    background: var(--page);
    color: var(--ink);
    font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6
}

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line)
}

.topbar__inner {
    max-width: 1280px;
    margin: auto;
    padding: 12px 28px;
    display: flex;
    justify-content: space-between;
    gap: 32px;
    align-items: center
}

.eyebrow,
.step {
    margin: 0;
    color: var(--blue);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em
}

.topbar h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.35
}

.subtitle {
    margin: 0;
    color: var(--muted)
}

.privacy-note {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #c7d8ef;
    background: var(--blue-soft);
    padding: 10px 14px;
    border-radius: 10px;
    min-width: 255px;
    font-size: 14px;
    line-height: 1.45
}

.privacy-mark {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #a9c2e5;
    border-radius: 50%;
    color: var(--blue-dark);
    font-size: 12px;
    font-weight: 700
}

.page-shell {
    max-width: 1280px;
    margin: auto;
    min-height: calc(100dvh - 57px);
    padding: 14px 28px 10px;
    overflow: visible
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
    align-items: stretch
}

.form-panel {
    display: contents
}

.form-section,
.preview-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow)
}

.form-section {
    padding: 12px 16px
}

.profile-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
    row-gap: 6px
}

.profile-section>.section-heading,
.profile-section>#custom-textbook-wrap {
    grid-column: 1/-1
}

.profile-section>.quick-field {
    margin-bottom: 0
}

.profile-section .segment-options {
    gap: 5px
}

.profile-section .segment-options label span {
    min-height: 32px;
    padding: 3px 7px;
    font-size: 13px
}

.section-heading,
.preview-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 8px
}

.section-heading h2,
.preview-header h2 {
    font-size: 20px;
    line-height: 1.4;
    margin: 1px 0
}

.saved-hint {
    font-size: 13px;
    color: var(--green);
    padding-top: 8px
}

.field-grid {
    display: grid;
    gap: 16px
}

.field-grid--three {
    grid-template-columns: repeat(3, 1fr)
}

.field-grid--two {
    grid-template-columns: repeat(2, 1fr);
    margin-top: 20px
}

.field {
    display: flex;
    flex-direction: column;
    gap: 7px
}

.field>span,
.choice-group legend {
    font-weight: 700;
    font-size: 14px
}

.field b {
    color: var(--danger)
}

.quick-field {
    border: 0;
    padding: 0;
    margin: 0 0 7px
}

.quick-field:last-child {
    margin-bottom: 0
}

.quick-field legend {
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 700
}

.quick-field legend b {
    color: var(--danger)
}

.segment-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 8px
}

.segment-options--two {
    grid-template-columns: repeat(2, 1fr)
}

.segment-options--three {
    grid-template-columns: repeat(3, 1fr)
}

.segment-options--four {
    grid-template-columns: repeat(4, 1fr)
}

.segment-options label {
    cursor: pointer
}

.segment-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none
}

.segment-options label span {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #344054;
    text-align: center;
    font-size: 14px
}

.segment-options input:checked+span {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-weight: 700
}

.segment-options input:focus-visible+span {
    outline: 3px solid rgba(36, 87, 166, .25);
    outline-offset: 2px
}

.empty-choice {
    grid-column: 1/-1;
    margin: 0;
    padding: 10px 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 14px
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid #aeb8c7;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    min-height: 44px
}

textarea {
    resize: vertical
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(36, 87, 166, .25);
    outline-offset: 2px;
    border-color: var(--blue)
}

input:disabled {
    background: #f1f3f6;
    color: #596579
}

.field--topic textarea {
    font-size: 17px;
    border-width: 2px;
    border-color: #7b9bc8;
    min-height: 68px
}

.field small {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 12px
}

.hidden {
    display: none
}

.choice-group {
    border: 0;
    padding: 0;
    margin: 22px 0 0
}

.choice-group legend {
    margin-bottom: 10px
}

.muted {
    color: var(--muted);
    font-weight: 400
}

.choice-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px
}

.choice-cards label,
.tag-options label {
    cursor: pointer
}

.choice-cards input,
.tag-options input {
    position: absolute;
    opacity: 0;
    pointer-events: none
}

.choice-cards label>span {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 11px 12px;
    min-height: 66px
}

.choice-cards small {
    font-size: 12px;
    color: var(--muted);
    font-weight: 400
}

.choice-cards input:checked+span,
.tag-options input:checked+span {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue-dark)
}

.choice-cards input:focus-visible+span,
.tag-options input:focus-visible+span {
    outline: 3px solid rgba(36, 87, 166, .25)
}

.tag-options {
    display: flex;
    flex-wrap: wrap;
    gap: 9px
}

.tag-options span {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 8px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-size: 14px
}

.recommendation {
    font-size: 13px;
    color: var(--blue-dark);
    background: #f5f8fc;
    border-left: 3px solid var(--blue);
    padding: 8px 10px;
    margin: 12px 0 0
}

.advanced {
    padding: 0;
    overflow: hidden
}

.advanced summary {
    list-style: none;
    cursor: pointer;
    min-height: 72px;
    padding: 16px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center
}

.advanced summary::-webkit-details-marker {
    display: none
}

.advanced summary span:first-child {
    display: flex;
    flex-direction: column
}

.advanced summary small {
    color: var(--muted);
    font-weight: 400
}

.summary-action {
    color: var(--blue);
    font-weight: 700
}

.advanced[open] .summary-action {
    font-size: 0
}

.advanced[open] .summary-action:after {
    content: "收起设置";
    font-size: 16px
}

.advanced-grid {
    border-top: 1px solid var(--line);
    padding: 20px 22px 22px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px
}

.advanced-grid--stacked {
    grid-template-columns: 1fr;
    gap: 4px
}

.field--wide {
    grid-column: 1/-1
}

.preview-panel {
    position: static;
    top: 0;
    height: auto;
    min-height: 0
}

.preview-card {
    min-height: 520px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    min-height: 0
}

.preview-header {
    margin-bottom: 12px
}

.preview-header>span {
    font-size: 13px;
    color: var(--muted);
    padding-top: 8px
}

.missing-message {
    font-size: 14px;
    border-radius: 8px;
    padding: 9px 11px;
    margin-bottom: 10px;
    background: #fff7e8;
    color: #714500;
    border: 1px solid #efcf91
}

.missing-message.ready {
    background: #edf8f1;
    color: #245e3c;
    border-color: #b9ddc6
}

.included-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 10px 0
}

.included-list span {
    font-size: 12px;
    color: #43526a;
    background: #eef1f5;
    padding: 4px 8px;
    border-radius: 4px
}

#prompt-preview {
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 1 1 auto;
    background: #f8fafc;
    border-color: #cbd3df;
    border-radius: 8px;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px;
    line-height: 1.7;
    padding: 10px 12px
}

.primary-button {
    width: 100%;
    min-height: 50px;
    margin-top: 12px;
    border: 0;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    cursor: pointer
}

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

.primary-button:disabled {
    background: #98a2b3;
    cursor: not-allowed
}

.secondary-actions {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 10px
}

.secondary-actions button {
    background: transparent;
    border: 0;
    color: #526071;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    padding: 8px 0
}

.secondary-actions button:last-child {
    color: var(--danger)
}

.review-note {
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding-top: 12px;
    margin: 8px 0 0
}

.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0
}

dialog {
    border: 0;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .22);
    max-width: 450px;
    padding: 0
}

dialog::backdrop {
    background: rgba(15, 23, 42, .45)
}

dialog form {
    padding: 24px
}

dialog h2 {
    margin: 0 0 8px;
    font-size: 20px
}

dialog p {
    color: var(--muted)
}

dialog form>div {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px
}

dialog button {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px 16px;
    cursor: pointer
}

.danger-button {
    background: var(--danger) !important;
    color: #fff;
    border-color: var(--danger) !important
}

@media(max-width:960px) {

    html,
    body {
        overflow-y: auto
    }

    .workspace {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr)
    }

    .preview-panel {
        position: static;
        height: auto
    }

    .field-grid--three {
        grid-template-columns: repeat(2, 1fr)
    }

    .topbar__inner {
        align-items: flex-start
    }
}

@media(max-width:640px) {
    body {
        font-size: 15px
    }

    .topbar__inner,
    .page-shell {
        padding-left: 16px;
        padding-right: 16px
    }

    .topbar__inner {
        flex-direction: column;
        gap: 16px
    }

    .privacy-note {
        width: 100%
    }

    .topbar h1 {
        font-size: 23px
    }

    .field-grid--three,
    .field-grid--two,
    .advanced-grid,
    .choice-cards {
        grid-template-columns: 1fr
    }

    .segment-options--four {
        grid-template-columns: repeat(2, 1fr)
    }

    .form-section,
    .preview-card {
        padding: 12px
    }

    .profile-section {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 8px
    }

    .profile-section .segment-options {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .advanced {
        padding: 0
    }

    .advanced-grid {
        padding: 18px
    }

    .section-heading {
        flex-direction: column;
        gap: 4px
    }

    .saved-hint {
        padding: 0
    }

    .secondary-actions {
        flex-direction: column;
        gap: 0;
        align-items: flex-start
    }

    .workspace {
        min-width: 0;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
        gap: 8px
    }

    .preview-card {
        min-height: 480px;
        overflow: visible
    }

    .review-note,
    .included-list {
        display: none
    }

    .primary-button {
        min-height: 42px
    }
}

@media(prefers-reduced-motion:reduce) {
    html {
        scroll-behavior: auto
    }

    * {
        transition: none !important
    }
}

.header-tool-button {
    min-height: 40px;
    padding: 7px 14px;
    border: 1px solid var(--blue);
    border-radius: 8px;
    background: #fff;
    color: var(--blue-dark);
    font-weight: 700;
    cursor: pointer
}

.header-tool-button:hover {
    background: var(--blue-soft)
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center
}

.tool-dialog {
    width: min(640px, calc(100vw - 32px));
    max-width: 640px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto
}

.tool-dialog__content {
    padding: 22px
}

.tool-dialog__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px
}

.tool-dialog__header h2 {
    margin: 1px 0;
    font-size: 21px
}

.tool-dialog__header .step {
    margin: 0
}

.dialog-close {
    min-width: 64px;
    background: #fff;
    color: var(--muted)
}

.tool-description {
    margin: 8px 0 16px;
    color: var(--muted);
    font-size: 14px
}

footer {
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    width: 100%;
}

footer a {
    color: #666;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links span {
    display: inline-block;
    margin: 0 0.1rem;
}

@media (max-width: 768px) {

    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-links span {
        display: none;
    }
}

.tool-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 12px
}

.tool-error {
    min-height: 24px;
    margin: 4px 0;
    color: var(--danger);
    font-size: 13px
}

.code-preview {
    min-height: 150px;
    resize: vertical;
    background: #f8fafc;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6
}

.wps-guide {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #f8fafc
}

.wps-guide h3 {
    margin: 0 0 8px;
    font-size: 16px
}

.wps-guide ol {
    margin: 0;
    padding-left: 22px;
    color: #475467;
    font-size: 14px
}

.wps-guide li+li {
    margin-top: 5px
}

.wps-guide code {
    padding: 1px 5px;
    border: 1px solid #d5dce7;
    border-radius: 4px;
    background: #fff;
    color: var(--blue-dark);
    font-family: Consolas, "Courier New", monospace
}

.ai-nav-dialog {
    width: min(980px, calc(100vw - 32px));
    max-width: 980px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto
}

.ai-nav-shell {
    padding: 22px
}

.nav-search input {
    font-size: 15px;
    border-width: 2px;
    border-color: #9db3d1
}

.nav-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 12px 0 8px
}

.nav-category-button {
    min-height: 36px;
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: #475467;
    cursor: pointer
}

.nav-category-button.active {
    border-color: var(--blue);
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-weight: 700
}

.nav-result-count {
    min-height: 24px;
    color: var(--muted);
    font-size: 13px
}

.ai-tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px
}

.ai-tool-group {
    grid-column: 1/-1
}

.ai-tool-group h3 {
    margin: 8px 0 7px;
    padding-left: 9px;
    border-left: 3px solid var(--blue);
    color: #344054;
    font-size: 15px
}

.ai-tool-group__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px
}

.ai-tool-card {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 76px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: inherit;
    text-decoration: none
}

.ai-tool-card:hover {
    border-color: #8ca9cf;
    background: #f7faff
}

.ai-tool-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    object-fit: contain;
    background: #f2f4f7
}

.ai-tool-icon--text {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-soft);
    color: var(--blue-dark);
    font-weight: 700
}

.ai-tool-card strong,
.ai-tool-card small {
    display: block
}

.ai-tool-card strong {
    line-height: 1.35
}

.ai-tool-card small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4
}

.nav-empty {
    grid-column: 1/-1;
    padding: 28px;
    border: 1px dashed var(--line);
    border-radius: 9px;
    color: var(--muted);
    text-align: center
}

.nav-footnote {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 12px
}

@media(max-width:640px) {
    .topbar h1 {
        font-size: 19px
    }

    .header-tool-button {
        flex: 0 0 auto;
        padding: 6px 9px;
        font-size: 13px
    }

    .header-actions {
        gap: 5px
    }

    .header-actions .header-tool-button {
        font-size: 12px
    }

    .tool-fields {
        grid-template-columns: 1fr
    }

    .ai-tool-grid {
        grid-template-columns: 1fr
    }

    .ai-tool-group__grid {
        grid-template-columns: 1fr
    }
}

@media(max-width:720px) {

    .tool-dialog,
    .ai-nav-dialog {
        width: 100vw;
        max-width: none;
        height: 100dvh;
        max-height: none;
        margin: 0;
        padding: 0;
        border-radius: 0;
        overflow-y: auto;
        overscroll-behavior: contain
    }

    .tool-dialog::backdrop,
    .ai-nav-dialog::backdrop {
        background: rgba(15, 23, 42, .58)
    }

    .tool-dialog__content,
    .ai-nav-shell {
        min-height: 100%;
        padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom))
    }

    .tool-dialog__header {
        position: sticky;
        top: 0;
        z-index: 5;
        margin: max(-14px, calc(env(safe-area-inset-top) * -1)) -14px 10px;
        padding: max(12px, env(safe-area-inset-top)) 14px 10px;
        border-bottom: 1px solid var(--line);
        background: #fff
    }

    .tool-dialog__header h2 {
        font-size: 19px
    }

    .dialog-close {
        min-width: 56px;
        min-height: 40px;
        padding: 6px 10px
    }

    .tool-description {
        margin: 6px 0 12px;
        font-size: 13px
    }

    .tool-fields {
        grid-template-columns: minmax(0, 1fr) 92px;
        gap: 8px
    }

    .tool-fields input,
    .nav-search input {
        min-height: 46px;
        font-size: 16px
    }

    .code-preview {
        min-height: 118px;
        max-height: 32dvh;
        font-size: 12px;
        line-height: 1.5
    }

    #copy-wps-code {
        min-height: 48px
    }

    .wps-guide {
        margin-top: 14px;
        padding: 12px
    }

    .wps-guide ol {
        padding-left: 20px;
        font-size: 13px
    }

    .wps-guide li+li {
        margin-top: 7px
    }

    .nav-search {
        position: sticky;
        top: 67px;
        z-index: 4;
        display: block;
        padding: 5px 0 8px;
        background: #fff
    }

    .nav-categories {
        flex-wrap: nowrap;
        margin: 6px -14px 8px;
        padding: 0 14px 4px;
        overflow-x: auto;
        scroll-snap-type: x proximity
    }

    .nav-category-button {
        flex: 0 0 auto;
        min-height: 40px;
        scroll-snap-align: start
    }

    .ai-tool-grid,
    .ai-tool-group__grid {
        grid-template-columns: 1fr;
        gap: 8px
    }

    .ai-tool-group h3 {
        margin-top: 12px
    }

    .ai-tool-card {
        min-height: 68px;
        padding: 9px
    }

    .nav-footnote {
        padding-bottom: env(safe-area-inset-bottom)
    }
}

@media(max-width:420px) {
    .tool-fields {
        grid-template-columns: 1fr
    }

    .field--page input {
        max-width: 120px
    }

    .header-actions {
        flex-wrap: wrap;
        justify-content: flex-end
    }
}