:root {
    --background: #202020;
    --white: #f0f0f0;
    --button: #404040;
    --border: #303030;
    --f: #b2c9c2;
    --site-masthead-height: 168px;
}

/* 可增减组件的统一工作台 */
#generatorWorkbench.generatorWorkbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(560px, 38vw, 720px);
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px 18px;
    height: calc(100dvh - var(--site-masthead-height) - 44px);
    min-height: 640px;
    padding: 18px;
    overflow: hidden;
    box-sizing: border-box;
}

#generatorWorkbench .componentPage,
#generatorWorkbench #diploSection.generatorWorkspace,
#generatorWorkbench #poliSection.generatorWorkspace {
    display: contents;
}

#generatorWorkbench .componentPage[hidden] {
    display: none !important;
}

#generatorWorkbench .componentPage .workspacePreview {
    grid-column: 1;
    grid-row: 1 / 3;
}

#generatorWorkbench .componentPage .workflowSidebar {
    grid-column: 2;
    grid-row: 2;
    height: 100%;
}

.componentDock {
    position: relative;
    z-index: 8;
    grid-column: 2;
    grid-row: 1;
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 7px;
    box-sizing: border-box;
}

.componentDockHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    min-height: 44px;
    gap: 12px;
    padding: 0 7px 0 13px;
    box-sizing: border-box;
}

.componentDockHeader > span {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.componentDockHeader small {
    overflow: hidden;
    font-size: 9px;
    letter-spacing: 0.14em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.componentDockHeader strong {
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.componentLibraryToggle {
    flex: none;
    min-width: 104px;
    min-height: 34px;
    padding: 5px 14px;
    cursor: pointer;
}

.componentTabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
    gap: 4px;
    min-width: 0;
}

.componentTabSlot {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    min-width: 0;
}

.componentTabSlot[hidden],
.componentTabsEmpty[hidden],
.componentLibrary[hidden],
.componentLibrary button[hidden],
.componentLibrary span[hidden] {
    display: none !important;
}

.componentTab,
.componentRemove,
.componentLibrary button {
    min-width: 0;
    border: 0;
    cursor: pointer;
}

.componentTab {
    min-height: 42px;
    padding: 7px 12px;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 15px;
    letter-spacing: 0.08em;
}

.componentRemove {
    width: 34px;
    min-height: 42px;
    padding: 0;
}

.componentTabsEmpty {
    grid-column: 1 / -1;
    min-height: 42px;
    align-content: center;
    padding: 0 12px;
    box-sizing: border-box;
    color: #9fa8a3;
    font-size: 11px;
}

.componentLibrary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    min-width: 0;
    padding-top: 2px;
}

.componentLibrary button {
    min-height: 38px;
    padding: 7px 10px;
    color: #e8edeb;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 11px;
}

.componentLibrary span {
    grid-column: 1 / -1;
    min-height: 34px;
    align-content: center;
    padding: 0 10px;
    color: #8f9b97;
    font-size: 10px;
    text-align: center;
}

.workbenchEmptyState {
    display: grid;
    place-content: center;
    justify-items: center;
    min-width: 0;
    min-height: 0;
    gap: 9px;
    padding: 28px;
    box-sizing: border-box;
    color: #c9d0cd;
    text-align: center;
}

.workbenchEmptyState[hidden] {
    display: none !important;
}

.workbenchEmptyState strong {
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 22px;
    font-weight: 500;
}

.workbenchEmptyState span {
    max-width: 360px;
    color: #8f9b97;
    font-size: 12px;
    line-height: 1.55;
}

.workbenchEmptyState button {
    min-width: 150px;
    min-height: 40px;
    padding: 8px 16px;
    cursor: pointer;
}

.workbenchEmptyPreview {
    grid-column: 1;
    grid-row: 1 / 3;
}

.workbenchEmptyTools {
    grid-column: 2;
    grid-row: 2;
}

.nationalSpiritManagerHost:empty {
    display: none;
}

/* 外交界面下方的原版国家精神区域 */
#diploScreenshot {
    height: 422px;
}

#diploNationalSpiritPanel {
    position: absolute;
    left: 6px;
    top: 311px;
    z-index: 4;
    width: 520px;
    height: 111px;
    overflow: hidden;
    background: url("./assets/interface-ui/diplo-national-spirits-bg-zh.webp") center / 520px 111px no-repeat;
}

#diplonationalSpirit {
    position: absolute;
    left: 12px;
    top: 27px;
    display: flex;
    width: 496px;
    height: 60px;
    align-items: flex-start;
    gap: 2px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

#diplonationalSpirit::-webkit-scrollbar {
    display: none;
}

#diplonationalSpirit .nationalSpiritItem {
    flex-basis: 60px;
    height: 60px;
}

#diploNationalSpiritScroller {
    left: 12px;
    top: 88px;
    width: 496px;
}

@media screen and (max-width: 1179px) {
    #generatorWorkbench.generatorWorkbench {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        padding: 12px;
        overflow: visible;
    }

    #generatorWorkbench .componentPage,
    #generatorWorkbench #diploSection.generatorWorkspace,
    #generatorWorkbench #poliSection.generatorWorkspace {
        display: contents;
    }

    #generatorWorkbench .componentPage[hidden] {
        display: none !important;
    }

    #generatorWorkbench .componentPage .workspacePreview {
        flex: none;
        min-height: 560px;
    }

    #generatorWorkbench[data-active-component="politics"] .componentPage .workspacePreview {
        min-height: 600px;
    }

    #generatorWorkbench .componentPage .workflowSidebar {
        height: auto;
        overflow: visible;
    }

    .componentDock {
        order: -1;
    }

    .workbenchEmptyPreview {
        min-height: 420px;
    }

    .workbenchEmptyTools {
        min-height: 180px;
    }
}

@media screen and (max-width: 700px) {
    #generatorWorkbench.generatorWorkbench {
        gap: 10px;
        padding: 8px;
    }

    .componentDockHeader {
        align-items: stretch;
    }

    .componentDockHeader > span {
        align-content: center;
    }

    .componentLibraryToggle {
        min-width: 88px;
        padding-inline: 8px;
    }

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

    .componentTabSlot {
        grid-template-columns: minmax(0, 1fr) 32px;
    }

    .componentRemove {
        width: 32px;
    }

    #generatorWorkbench .componentPage .workspacePreview,
    #generatorWorkbench[data-active-component="politics"] .componentPage .workspacePreview {
        min-height: 470px;
    }
}

@font-face {
    font-family: "RuiZheng";
    src: url(./fonts/FZRuiZhengHei-Regular.ttf) format("truetype");
    font-display: swap;
}

@font-face {
    font-family: "WenHanJianZhu";
    src: url(./fonts/FZWenHanJianZhu.ttf) format("truetype");
    font-display: swap;
}

* {
    text-decoration: none;
    text-rendering: optimizeLegibility;
}

body {
    background-color: var(--background);
    margin: 0;
    padding: 0 0 16px 0;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
}

.siteMasthead {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: var(--site-masthead-height);
    overflow: hidden;
    box-sizing: border-box;
    border-bottom: 3px solid #1a1a1a;
    background:
        linear-gradient(rgba(3, 9, 15, 0.28), rgba(3, 8, 13, 0.5)),
        url("./assets/branding/tno-map-masthead.png") center 58% / cover no-repeat;
    box-shadow:
        inset 0 -32px 38px rgba(0, 0, 0, 0.28),
        inset 0 1px rgba(255, 255, 255, 0.08);
}

.siteMasthead::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(470px, 42vw);
    height: 138%;
    transform: translate(-50%, -50%);
    background: radial-gradient(ellipse, rgba(225, 226, 218, 0.82) 0%, rgba(205, 208, 202, 0.46) 43%, transparent 73%);
    pointer-events: none;
}

.siteMasthead img {
    position: relative;
    z-index: 1;
    display: block;
    width: auto;
    height: calc(100% - 10px);
    max-width: min(36vw, 330px);
    object-fit: contain;
    mix-blend-mode: multiply;
    filter: contrast(1.13) saturate(1.1);
}

.siteMastheadEdition {
    position: absolute;
    z-index: 2;
    right: 24px;
    bottom: 17px;
    padding: 7px 10px 6px 13px;
    border-left: 4px solid #a30000;
    color: #f2f1ea;
    background: rgba(7, 10, 13, 0.78);
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: clamp(15px, 1.22vw, 22px);
    letter-spacing: 0.08em;
    line-height: 1;
    text-shadow: 0 1px 2px #000;
    white-space: nowrap;
}

nav {
    display: flex;
    gap: 3px;
    background-color: var(--background);
}

nav>div,
nav>a {
    display: flex;
    flex: 1 1 0;
    padding: 8px;
    font-size: 16px;
    text-align: center;
    align-items: center;
    background-color: var(--button);
    cursor: pointer;
}

nav>div:hover,
nav>a:hover,
ideology:hover,
poliideology:hover,
.buttonGroup button:hover,
#equalizationButton:hover,
#randomizationButton:hover,
#ideologizationButton:hover,
#diploDownload:hover,
#toleranceSlider:hover,
#portraitTools button:hover,
.backgroundContainer:hover {
    filter: brightness(1.1);
}

#logo {
    display: flex;
    gap: 8px;
}

#logo img {
    height: 32px;
    width: 32px;
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    image-rendering: optimize-contrast;
    -ms-interpolation-mode: nearest-neighbor;
}

.navButton {
    justify-content: center;
}

#diploSection {
    display: grid;
    grid-template-columns: 564px 1fr;
    grid-template-rows: 310px min-content;
    grid-column-gap: 16px;
    grid-row-gap: 16px;
}
#poliSection {
    display: grid;
    grid-template-columns: 564px 1fr;
    grid-template-rows: 482px min-content;
    grid-column-gap: 16px;
    grid-row-gap: 16px;
}

#diploScreenshot {
    width: 532px;
    height: 311px;
    grid-area: 1 / 1 / 2 / 2;
}
#poliScreenshot {
    width: 541px;
    height: 481px;
    grid-area: 1 / 1 / 2 / 2;
}

#diploFront,#poliFront {
    position: absolute;
    z-index: 2;
}

#diploOverlay {
    display: block;
    position: absolute;
    z-index: 1;
    width: 532px;
    height: 311px;
    background-image: url(./diploOverlay.png);
}

.diploLocalizedLabel {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    color: #f7f7f7;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    line-height: 1;
    pointer-events: none;
}

.diploLocalizedTitle {
    left: 0;
    top: 0;
    width: 319px;
    height: 39px;
    justify-content: flex-start;
    padding-left: 39px;
    background: linear-gradient(to bottom, #636363 0 1px, #494949 1px 2px, #323232 2px 100%);
    font-size: 29px;
    letter-spacing: 2px;
}

.diploLocalizedTab {
    top: 51px;
    height: 22px;
    background: linear-gradient(
        to bottom,
        #010101 0%,
        #050505 5%,
        #0a0c0b 10%,
        #0e1110 15%,
        #111313 20%,
        #151817 35%,
        #151817 70%,
        #111313 85%,
        #0e1110 90%,
        #0a0c0b 95%,
        #050505 100%
    );
    font-size: 16px;
    letter-spacing: 1px;
}

.diploLocalizedDiplomacy {
    left: 149px;
    width: 170px;
}

.diploLocalizedIntel {
    left: 344px;
    width: 174px;
}

#poliOverlay {
    display: block;
    position: absolute;
    z-index: 1;
    width: 541px;
    height: 481px;
    background-image: url(./politicalOverlay.png);
}

#diploBack,#poliBack {
    position: absolute;
    z-index: 0;
}

#flagOverlay {
    display: block;
    position: absolute;
    width: 86px;
    height: 64px;
    left: 33px;
    top: 81px;
    background-image: url("./flagOverlay.png");
}
#flag {
    display: block;
    position: absolute;
    width: 82px;
    height: 52px;
    left: 33px;
    top: 86.5px;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    background-image: url(./Flag.png);
    background-color: #000;
}
#icon {
    display: block;
    position: absolute;
    width: 66px;
    height: 66px;
    left: 151px;
    top: 81px;
    background-image: url(./icon/Despotism/Absolute\ Monarchy.png);
}
#poliicon {
    display: block;
    position: absolute;
    width: 44px;
    height: 44px;
    left: 333px;
    top: 247px;
    background-size: contain;
    background-position: bottom;
    background-repeat: no-repeat;
    background-image: url(./icon/Despotism/Absolute\ Monarchy.png);
}

#topNames {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 224px;
    top: 87px;
    color: var(--white);
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 16px;
    letter-spacing: -0.1px;
    text-shadow: 1px 0 black, -1px 0 black, 0 1px black, 0 -1px black, 1px 1px black, -1px -1px black, -1px 1px black, 1px -1px black;    width: 280px;
    width: 280px;
}
#polileader {
    display: flex;
    flex-direction: column-reverse;
    position: absolute;
    left: 6px;
    top: 261px;
    color: var(--white);
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 18px;
    letter-spacing: 0px;
    text-shadow: 1px 0 black, -1px 0 black, 0 1px black, 0 -1px black, 1px 1px black, -1px -1px black, -1px 1px black, 1px -1px black;    width: 280px;
    justify-content: center;
    align-items: center; /* Ensures vertical centering */
    position: absolute;
    text-align: center;
    width: 152px;
    max-height: 20px;
    padding: 9px 0px ;
}

#country {
    height: 18px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
#faction {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#leader {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#stability {
    left: 441.5px;
}

#warSupport {
    left: 482.5px;
}

.unity {
    position: absolute;
    width: 44px;
    top: 22px;
    transform: translateX(-50%);
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0px;
    line-height: 16px;
    text-align: center;
    white-space: nowrap;
    cursor: text;
    text-shadow: 0 -1px 0 black;
}

#bottomNames {
    display: flex;
    flex-direction: column;
    gap: 1.5px;
    position: absolute;
    left: 245px;
    top: 167px;
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 17px;
    letter-spacing: 0.1px;
    text-shadow: 0 -1px 0 black;
    width: 270px;
}

#party {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
#poliparty {
    flex-direction: column;
    position: absolute;
    left: 379px;
    top: 250px;
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 17px;
    letter-spacing: 0.2px;
    text-shadow: 0 -1px 0 black;
    max-width: 154px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#polisubideology {
    display: flex;
    flex-direction: column;
    position: absolute;
    left: 379px;
    top: 268px;
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 13.8px;
    letter-spacing: 0.2px;
    text-shadow: 0 -1px 0 black;
    width: 154px;
}
#election {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#portraitBackground {
    display: block;
    position: absolute;
    width: 115px;
    height: 155px;
    left: 16px;
    top: 161px;
    background-image: url(./assets/tno-portrait-background.png);
    background-size: cover;
}

#poliportraitBackground {
    display: block;
    position: absolute;
    width: 115px;
    height: 155px;
    left: 16px;
    top: 161px;
    background-image: url(./assets/tno-portrait-background.png);
    background-size: cover;
}
#portrait {
    display: block;
    position: absolute;
    width: 115px;
    height: 155px;
    top:-10px;
    background-size: contain;
    background-position: bottom;
    background-repeat: no-repeat;
    background-image: url(./Puzak.png);
}

#poliportrait {
    display: block;
    position: absolute;
    width: 156px;
    height: 210px;
    top:-110px;
    left:-12px;
    background-size: contain;
    background-position: bottom;
    background-repeat: no-repeat;
    background-image: url(./Puzak.png);
}

#pieChart {
    display: block;
    position: absolute;
    width: 62px;
    height: 62px;
    left: 155px;
    top: 162px;
    border-radius: 100%;
    transform: scaleX(-1) rotate(-90deg);
    transform-origin: center;
}
#polipieChart {
    display: block;
    position: absolute;
    width: 142px;
    height: 142px;
    left: 361px;
    top: 308px;
    border-radius: 100%;
    transform: scaleX(-1) rotate(-90deg);
    transform-origin: center;
}

#topButtons,#politopButtons {
    color: var(--white);
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 20px;
}

#focusIcon {
    display: block;
    position: absolute;
    width: 86px;
    height: 69px;
    left: 143px;
    top: 238px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./Focus.png);
}
#polifocusIcon {
    display: block;
    position: absolute;
    width: 94px;
    height: 76px;
    left: 171px;
    top: 61px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./Focus.png);
}

#focus {
    display: flex;
    justify-content: center;
    align-items: center; /* Ensures vertical centering */
    position: absolute;
    width: 232px;
    height: 34px;
    left: 244px;
    top: 244px;
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 20px;
    letter-spacing: 0px;
    text-align: center;
    padding: 9px 21px ;
}
#polifocus {
    display: flex;
    justify-content: center;
    align-items: center; /* Ensures vertical centering */
    position: absolute;
    width: 172px;
    height: 18px;
    left: 292px;
    top: 79px;
    color: var(--f);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 18px;
    letter-spacing: 0px;
    text-align: center;
    padding: 9px 21px ;
}
#factionStatus {
    display: block;
    position: absolute;
    width: 64px;
    height: 64px;
    left: 458px;
    top: 82px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

#polifactionStatus {
    display: block;
    position: absolute;
    width: 52.5px;
    height: 52.5px;
    left: 274px;
    top: 238px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

#polifactionIcon {
    display: block;
    position: absolute;
    width: 49.5px;
    height: 49.5px;
    left: 194px;
    top: 238px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

#polihog {
    display: block;
    position: absolute;
    width: 65px;
    height: 67px;
    left: 35px;
    top: 320px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./minister.png);
}

#polifor {
    display: block;
    position: absolute;
    width: 65px;
    height: 67px;
    left: 35px;
    top: 410px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./minister.png);
}

#polieco {
    display: block;
    position: absolute;
    width: 65px;
    height: 67px;
    left: 135px;
    top: 410px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./minister.png);
}

#polisec {
    display: block;
    position: absolute;
    width: 65px;
    height: 67px;
    left: 235px;
    top: 410px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image: url(./minister.png);
}

#diploIdeologyMenu,#poliIdeologyMenu {
    grid-area: 1 / 2 / 3 / 3;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 16px 0 0;
}

.picker {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

ideology,poliideology,faction,polifaction {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-color: var(--button);
    padding: 8px;
    border-radius: 8px;
    color: var(--white);
    text-align: center;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-weight: 600;
    font-size: 12px;
    width: 100px;
    height: 100px;
    cursor: pointer;
    letter-spacing: .5px;
    border: 3px solid var(--border);
    outline-offset: -6px;
}

ideology:active,
poliideology:active,
faction:active,
polifaction:active
.buttonGroup button:active,
#equalizationButton:active,
#randomizationButton:active,
#ideologizationButton:active,
#diploDownload:active,
#portraitTools button:active {
    filter: brightness(.9);
}

ideology img {
    width: 66px;
    height: 66px;
}

ideology div {
    display: flex;
    align-items: center;
    height: 32px;
}

ideology div {
    display: flex;
    align-items: center;
    height: 100px;
}

.title {
    display: flex;
    align-items: center;
    background-color: transparent;
    font-size: 18px;
    border: none;
    outline: none;
    margin: 3px;
    cursor: auto;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
}

.polititle {
    display: flex;
    align-items: center;
    background-color: transparent;
    font-size: 18px;
    border: none;
    outline: none;
    margin: 3px;
    cursor: auto;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
}

#ideologyDescription,#poliideologyDescription,
#polisubideologyDescription,
#subideologyDescription,
#factionDescription,#polifactionDescription,#polistatusDescription
#statusDescription {
    background-color: var(--button);
    border-radius: 3px;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: .5px;
    color: var(--white);
    padding: 12px;
}

#subideologyDescription,#polisubideologyDescription,
#factionDescription,#polifactionDescription,#polistatusDescription
#statusDescription {
    font-size: 12px;
    font-weight: 500;
}

#diploTools,#poliTools {
    grid-area: 2 / 1 / 3 / 2;
    padding-left: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#diploTools>*,#poliTools>* {
    flex: none;
}

.buttonGroup,.polibuttonGroup {
    display: flex;
    gap: 8px;
    flex-grow: 1;
}
.buttonGroup button/*,.polibuttonGroup button*/ {
    border: none;
    border-radius: 3px;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .5px;
    color: var(--white);
    background-color: var(--button);
    cursor: pointer;
    padding: 12px;
    width: 100%;
    height: 48px;
}

.polibuttonGroup button {
    border: none;
    border-radius: 3px;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: .5px;
    color: var(--white);
    background-color: var(--button);
    cursor: pointer;
    width: 100%;
    height: 48px;
}

#popularityTools button,
#diploDownload,#polipopularityTools button,
#poliDownload {
    border: none;
    border-radius: 3px;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: .5px;
    color: var(--white);
    background-color: var(--button);
    cursor: pointer;
    padding: 12px;
    width: 100%;
}

#popularityTools,#polipopularityTools {
    height: -20px;
}

#popularityInputs,#polipopularityInputs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0;
    justify-content: center;
}

.percentageControl {
    display: flex;
    align-items: center;
}

.percentageControl input {
    padding: 8px;
    border: none;
    border-radius: 6px;
    width: 44px;
    border: solid 2px var(--background);
    background-color: var(--white);
    transition: .15s;
    color: var(--background);
}

.percentageControl div {
    width: 24px;
    height: 24px;
    cursor: pointer;
    border: solid 2px var(--background);
    margin-left: 3px;
    transition: .15s;
}

.percentageControl div:hover {
    filter: brightness(1.1);
    z-index: 1;
}

.percentageControl div:active {
    filter: brightness(.9);
    z-index: 1;
}

input:disabled {
    background-color: var(--button);
    color: var(--white);
}

#country,
#faction,
#leader,
.unity,
#party,
#subideology,
#election,
#focus,
#policountry,
#polileader,
#poliparty,
#polisubideology,
#polielection,
#polifocus {
    cursor: text;
}


@media screen and (max-width: 1120px) {

    #diploSection,
    #poliSection {
        display: flex;
        flex-direction: column;
    }
    #diploTools,
    #diploIdeologyMenu,#poliTools,#poliIdeologyMenu {
        padding: 0 16px;
    }

    #popularityInputs,#polipopularityInputs {
        gap: 16px;
        margin: 8px 0;
    }

}

/* 生成器工作区：左侧成品预览，右侧按制作顺序操作 */
#diploSection.generatorWorkspace,
#poliSection.generatorWorkspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(520px, 33vw, 660px);
    grid-template-rows: minmax(0, 1fr);
    gap: 18px;
    height: calc(100dvh - var(--site-masthead-height) - 44px);
    min-height: 640px;
    padding: 18px;
    overflow: hidden;
    box-sizing: border-box;
}

.workspacePreview {
    position: relative;
    display: grid;
    grid-template-rows: 44px minmax(0, 1fr);
    align-items: stretch;
    justify-items: stretch;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #505753;
    background:
        radial-gradient(circle at 50% 43%, #303432 0%, #1d201e 56%, #111312 100%);
    box-shadow:
        inset 0 0 0 1px #0b0c0b,
        inset 0 0 72px rgba(0, 0, 0, 0.56);
}

.workspacePreview::before {
    content: none;
}

.workspacePreviewChrome {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    min-height: 44px;
    padding: 0 6px 0 14px;
    box-sizing: border-box;
}

.workspacePreviewIdentity {
    display: flex;
    align-items: baseline;
    min-width: 0;
    gap: 9px;
    white-space: nowrap;
}

.workspacePreviewIdentity strong {
    color: #dde5e1;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.14em;
}

.workspacePreviewIdentity span {
    color: #7f908b;
    font-size: 10px;
    letter-spacing: 0.08em;
}

.workspacePreviewCanvas {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.previewScaler {
    --preview-scale: 1;
    --preview-x: 0px;
    --preview-y: 0px;
    position: relative;
    flex: none;
    transform: translate3d(var(--preview-x), var(--preview-y), 0) scale(var(--preview-scale));
    transform-origin: center;
    transition: transform 140ms ease;
    will-change: transform;
}

.previewScalerDiplo {
    --preview-scale: 1.35;
}

.previewScalerPolitical {
    --preview-scale: 0.85;
}

.previewScaler.isDragging {
    transition: none;
}

.previewDragHandle {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 30;
    width: 100%;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
}

.previewDragHandle:active,
.previewScaler.isDragging .previewDragHandle {
    cursor: grabbing;
}

.previewDragHandle:focus-visible {
    outline: 2px solid #d65757;
    outline-offset: -3px;
}

.previewDragHandleDiplo {
    height: 39px;
}

.previewDragHandlePolitical {
    height: 49px;
}

.previewZoomControl {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.previewZoomControl label {
    display: flex;
    align-items: center;
    gap: 7px;
}

.previewZoomControl label > span {
    color: #b8c8c4;
    font-size: 11px;
    white-space: nowrap;
}

.previewZoomControl input[type="range"] {
    width: 118px;
    accent-color: #55c6c4;
}

.previewZoomControl output {
    min-width: 38px;
    color: #d9e5e1;
    font-size: 11px;
    text-align: right;
}

.previewZoomControl button {
    min-width: 48px;
    height: 28px;
    padding: 0 8px;
    color: #d8dfdb;
    background: #292d2b;
    border: 1px solid #616963;
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}

#diploScreenshot,
#poliScreenshot {
    position: relative;
    isolation: isolate;
    flex: none;
}

.workflowSidebar {
    grid-area: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 0;
    height: 100%;
    padding: 0 6px 8px 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-color: #696e69 #1a1c1b;
    box-sizing: border-box;
}

#diploTools.workflowSidebar,
#poliTools.workflowSidebar,
#diploIdeologyMenu,
#poliIdeologyMenu {
    grid-area: auto;
}

#diploTools.workflowSidebar,
#poliTools.workflowSidebar {
    padding-left: 0;
}

#diploIdeologyMenu,
#poliIdeologyMenu {
    padding: 0;
}

.workflowSidebarHeader {
    display: grid;
    gap: 2px;
    padding: 13px 14px 12px;
    border: 1px solid #515652;
    background:
        linear-gradient(90deg, rgba(134, 141, 126, 0.12), transparent 62%),
        #2d302e;
    color: #f0f0ea;
}

.workflowSidebarHeader > span {
    color: #a6ab9f;
    font-size: 10px;
    letter-spacing: 0.18em;
}

.workflowSidebarHeader > strong {
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 21px;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.workflowSidebarHeader > small {
    color: #a9ada8;
    font-size: 11px;
}

.workflowStep {
    flex: none;
    border: 1px solid #484d49;
    border-radius: 2px;
    overflow: clip;
    color: #eeeeea;
    background: #252826;
}

.workflowStep > summary {
    position: relative;
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    min-height: 49px;
    padding: 7px 11px 7px 8px;
    box-sizing: border-box;
    list-style: none;
    cursor: pointer;
    user-select: none;
    background: #303431;
}

.workflowStep > summary::-webkit-details-marker {
    display: none;
}

.workflowStep > summary::after {
    content: "›";
    position: absolute;
    right: 12px;
    color: #8f958f;
    font-size: 20px;
    transform: rotate(90deg);
}

.workflowStep[open] > summary {
    border-bottom: 1px solid #484d49;
    background: #383c38;
}

.workflowStep[open] > summary::after {
    transform: rotate(-90deg);
}

.workflowStepNumber {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid #686e68;
    color: #c7cbbf;
    background: #232624;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.workflowStep > summary > span:last-of-type {
    display: grid;
    min-width: 0;
    gap: 2px;
    padding-right: 22px;
}

.workflowStep > summary strong {
    font-size: 14px;
    font-weight: 600;
}

.workflowStep > summary small {
    overflow: hidden;
    color: #a8aca6;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflowStepBody {
    display: grid;
    gap: 9px;
    padding: 10px;
}

.workflowField,
.workflowFieldRow {
    min-width: 0;
}

.workflowField {
    display: grid;
    gap: 5px;
    color: #b8bcb5;
    font-size: 11px;
}

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

.workflowField input {
    width: 100%;
    min-width: 0;
    height: 36px;
    box-sizing: border-box;
    padding: 7px 9px;
    border: 1px solid #565c57;
    border-radius: 2px;
    outline: 0;
    color: #f0f1ed;
    background: #181b19;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 13px;
}

.workflowField input:focus {
    border-color: #949b90;
    box-shadow: 0 0 0 2px rgba(148, 155, 144, 0.12);
}

.workflowSidebar .picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    gap: 6px;
}

.workflowSidebar .picker > .title {
    grid-column: 1 / -1;
    width: auto;
    height: auto;
    min-height: 25px;
    margin: 0;
    padding: 0 2px;
    border: 0;
    justify-content: flex-start;
    background: transparent;
    font-size: 14px;
}

.workflowSidebar ideology,
.workflowSidebar poliideology,
.workflowSidebar faction,
.workflowSidebar polifaction {
    width: auto;
    min-width: 0;
    height: 94px;
    padding: 6px;
    border-width: 2px;
    border-radius: 3px;
    box-sizing: border-box;
    font-size: 10px;
}

.workflowSidebar ideology img,
.workflowSidebar poliideology img,
.workflowSidebar faction img,
.workflowSidebar polifaction img {
    width: 56px;
    height: 56px;
    max-width: 100%;
    object-fit: contain;
}

.workflowSidebar ideology div,
.workflowSidebar poliideology div,
.workflowSidebar faction div,
.workflowSidebar polifaction div {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 24px;
}

.workflowSidebar #ideologyDescription,
.workflowSidebar #poliideologyDescription,
.workflowSidebar #subideologyDescription,
.workflowSidebar #polisubideologyDescription,
.workflowSidebar #factionDescription,
.workflowSidebar #polifactionDescription,
.workflowSidebar #statusDescription,
.workflowSidebar #polistatusDescription {
    padding: 9px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.35;
}

.workflowButtonGrid,
.workflowSidebar .buttonGroup,
.workflowSidebar .polibuttonGroup {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.workflowSidebar .buttonGroup button,
.workflowSidebar .polibuttonGroup button,
.workflowSidebar #popularityTools button,
.workflowSidebar #polipopularityTools button {
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 40px;
    padding: 8px 9px;
    box-sizing: border-box;
    border: 1px solid #4f5550;
    border-radius: 2px;
    color: #e9eae6;
    background: #393d3a;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
}

.workflowSidebar .secondaryAction {
    color: #b9bbb7;
    background: #292c2a;
}

.workflowSidebar .workflowFullAction {
    grid-column: 1 / -1;
    min-height: 44px;
    color: #f2efe2;
    border-color: #777966;
    background:
        linear-gradient(90deg, rgba(179, 175, 145, 0.12), transparent 70%),
        #424740;
}

.workflowSidebar #popularityTools,
.workflowSidebar #polipopularityTools {
    height: auto;
}

.workflowSidebar #popularityInputs,
.workflowSidebar #polipopularityInputs {
    gap: 9px;
    margin: 6px 0 0;
}

.workflowSidebar .percentageControl input {
    width: 42px;
}

.workflowDownload {
    position: static;
    z-index: 4;
    flex: none;
    min-height: 50px;
    margin-top: 3px;
    border: 1px solid #858876 !important;
    color: #f5f1dd !important;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
        #4a4e43 !important;
    box-shadow: none;
}

/* 政治界面的固定中文标签：遮住原图中的英文，并随导出一起保存 */
#poliOverlay {
    pointer-events: none;
}

.poliLocalizedLabel {
    position: absolute;
    z-index: 2;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    color: #f6f6f3;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    line-height: 1;
    text-shadow:
        1px 1px 0 #000,
        -1px -1px 0 #000,
        1px -1px 0 #000,
        -1px 1px 0 #000;
}

.poliLocalizedTitle {
    left: 0;
    top: 1px;
    width: 250px;
    height: 37px;
    padding-left: 39px;
    background: linear-gradient(to bottom, #444 0 1px, #333 1px 100%);
    font-size: 29px;
    letter-spacing: 2px;
}

.poliLocalizedSpirit {
    left: 166px;
    top: 144px;
    width: 166px;
    height: 23px;
    padding-left: 4px;
    background: #171a18;
    font-size: 16px;
}

.poliLocalizedGovernment,
.poliLocalizedMinisters {
    left: 39px;
    width: 215px;
    height: 25px;
    padding-left: 7px;
    background:
        linear-gradient(180deg, #343736 0%, #222524 48%, #1c1f1e 100%);
    font-size: 16px;
}

.poliLocalizedGovernment {
    top: 294px;
}

.poliLocalizedMinisters {
    top: 385px;
}

#polinationalSpirit {
    display: flex;
    position: absolute;
    left: 176px;
    top: 171px;
    width: 351px;
    height: 58px;
    align-items: flex-start;
    gap: 3px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

#polinationalSpirit::-webkit-scrollbar {
    display: none;
}

.nationalSpiritScroller {
    position: absolute;
    left: 176px;
    top: 229px;
    z-index: 3;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 18px;
    align-items: center;
    width: 351px;
    height: 18px;
    box-sizing: border-box;
}

.nationalSpiritScroller[hidden] {
    display: none;
}

.nationalSpiritScroller button {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
}

.nationalSpiritScroller button:disabled {
    opacity: 0.28;
    cursor: default;
}

.nationalSpiritScroller input[type="range"] {
    width: 100%;
    height: 18px;
    margin: 0;
}

.nationalSpiritItem {
    flex: 0 0 56px;
    height: 56px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    scroll-snap-align: start;
}

.nationalSpiritManager {
    display: grid;
    min-width: 0;
    gap: 6px;
}

.nationalSpiritManagerHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    gap: 10px;
    padding: 8px 9px;
    box-sizing: border-box;
}

.nationalSpiritManagerHeader > span {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.nationalSpiritManagerHeader strong {
    color: #e4e9e5;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.08em;
}

.nationalSpiritManagerHeader small {
    color: #8f9b95;
    font-size: 10px;
    letter-spacing: 0.03em;
}

.nationalSpiritManagerHeader .workflowInlineStatus {
    flex: none;
    max-width: 210px;
}

.nationalSpiritManagerList {
    display: grid;
    align-content: start;
    min-width: 0;
    max-height: 250px;
    gap: 3px;
    padding: 5px;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-color: #65706b #101615;
    scrollbar-width: thin;
}

.nationalSpiritManagerEmpty {
    display: grid;
    place-items: center;
    min-height: 72px;
    padding: 12px;
    color: #7f8a85;
    font-size: 11px;
    line-height: 1.5;
    text-align: center;
}

.nationalSpiritManagerItem {
    display: grid;
    grid-template-columns: 18px 44px minmax(0, 1fr) 27px 27px 31px;
    align-items: center;
    min-width: 0;
    min-height: 58px;
    gap: 5px;
    padding: 5px 6px;
    box-sizing: border-box;
    cursor: grab;
}

.nationalSpiritManagerItem.isDragging {
    opacity: 0.48;
    cursor: grabbing;
}

.nationalSpiritManagerItem.isDropTarget {
    outline: 1px solid #d85858;
    outline-offset: -2px;
}

.nationalSpiritDragHandle {
    width: 16px;
    height: 36px;
}

.nationalSpiritManagerPreview {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    overflow: hidden;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.nationalSpiritManagerPreview img,
.assetLibrarySelectionPreview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.assetLibrarySelectionPreview img[hidden] {
    display: none;
}

.nationalSpiritManagerPreview.hasError::after,
.assetLibrarySelectionPreview.hasError::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("./assets/interface-ui/close-small.webp") center / 22px 22px no-repeat;
}

.nationalSpiritManagerNames {
    display: grid;
    min-width: 0;
    gap: 2px;
    line-height: 1.18;
}

.nationalSpiritManagerNames strong {
    display: -webkit-box;
    overflow: hidden;
    color: #e0e5e1;
    font-size: 12px;
    font-weight: 400;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.nationalSpiritManagerNames small {
    overflow: hidden;
    color: #89948f;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nationalSpiritOrderButton,
.nationalSpiritDeleteButton {
    width: 27px;
    height: 27px;
    padding: 0;
    border: 0;
    background-color: transparent;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
}

.nationalSpiritDeleteButton {
    width: 31px;
    height: 31px;
}

.nationalSpiritOrderButton:disabled {
    opacity: 0.28;
    cursor: default;
}

@media screen and (min-width: 1180px) and (max-height: 760px) {
    :root {
        --site-masthead-height: 92px;
    }

    #diploSection.generatorWorkspace,
    #poliSection.generatorWorkspace {
        min-height: 0;
    }

    .previewScalerDiplo {
        --preview-scale: 1.18;
    }

    .previewScalerPolitical {
        --preview-scale: 0.8;
    }
}

@media screen and (min-width: 1180px) {
    body {
        padding-bottom: 0;
        overflow: hidden;
    }
}

@media screen and (max-width: 1179px) {
    :root {
        --site-masthead-height: 116px;
    }

    .siteMasthead img {
        max-width: min(48vw, 250px);
    }

    .siteMastheadEdition {
        right: 14px;
        bottom: 10px;
        font-size: 13px;
    }

    body {
        overflow: auto;
    }

    #diploSection.generatorWorkspace,
    #poliSection.generatorWorkspace {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 0;
        padding: 12px;
        overflow: visible;
    }

    #diploSection .workspacePreview {
        min-height: 470px;
    }

    #poliSection .workspacePreview {
        min-height: 600px;
    }

    .previewScalerDiplo {
        --preview-scale: 1.12;
    }

    .previewScalerPolitical {
        --preview-scale: 0.84;
    }

    .workflowSidebar {
        height: auto;
        padding: 0;
        overflow: visible;
    }
}

@media screen and (max-width: 700px) {
    .generatorWorkspace {
        gap: 10px;
        padding: 8px;
    }

    #diploSection .workspacePreview {
        min-height: 330px;
    }

    #poliSection .workspacePreview {
        min-height: 420px;
    }

    .previewScalerDiplo {
        --preview-scale: 0.76;
    }

    .previewScalerPolitical {
        --preview-scale: 0.76;
    }

    .previewZoomControl {
        gap: 4px;
    }

    .workspacePreviewIdentity span,
    .previewZoomControl label > span {
        display: none;
    }

    .previewZoomControl input[type="range"] {
        width: 78px;
    }

    .previewZoomControl button {
        min-width: 42px;
        padding-inline: 5px;
    }

    .workflowFieldRow,
    .workflowButtonGrid,
    .workflowSidebar .buttonGroup,
    .workflowSidebar .polibuttonGroup {
        grid-template-columns: 1fr;
    }

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

.toolPanel {
    border: 1px solid #505050;
    border-radius: 4px;
    background: #292929;
    overflow: hidden;
}

.toolPanel > summary {
    padding: 11px 13px;
    color: var(--white);
    background: #353535;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.toolPanel[open] > summary {
    border-bottom: 1px solid #505050;
}

.toolPanel > .buttonGroup,
.toolPanel > .polibuttonGroup {
    padding: 8px;
}

.toolPanel > .buttonGroup + .buttonGroup,
.toolPanel > .polibuttonGroup + .polibuttonGroup {
    padding-top: 0;
}

.portraitStudio[hidden],
.portraitEditorStage[hidden],
.portraitSourceStage[hidden],
.portraitControlPanel[hidden],
.portraitControlPanel label[hidden],
.assetLibraryModal[hidden] {
    display: none !important;
}

body.portraitStudioOpen {
    overflow: hidden;
}

body.assetLibraryOpen {
    overflow: hidden;
}

.portraitStudio {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.82);
    box-sizing: border-box;
}

.portraitStudioDialog {
    width: min(1060px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    color: #ededed;
    background: #202020;
    border: 1px solid #5a5a5a;
    box-shadow: 0 18px 70px rgba(0, 0, 0, 0.7);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
}

.portraitStudioHeader {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    background: #2e2e2e;
    border-bottom: 1px solid #555;
}

.portraitStudioHeader h2 {
    margin: 0 0 5px;
    font-size: 22px;
    font-weight: 600;
}

.portraitStudioHeader p {
    margin: 0;
    color: #bdbdbd;
    font-size: 13px;
}

.portraitStudioClose {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border: 1px solid #686868;
    border-radius: 3px;
    color: #fff;
    background: #222;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.portraitSourceStage {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr);
    gap: 16px;
    padding: 20px;
}

.portraitSourceBlock {
    padding: 16px;
    background: #292929;
    border: 1px solid #484848;
}

.portraitSectionHeading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.portraitSectionHeading strong,
.portraitSectionHeading span {
    display: block;
}

.portraitSectionHeading strong {
    margin-bottom: 4px;
    font-size: 17px;
}

.portraitSectionHeading span {
    color: #aaa;
    font-size: 12px;
}

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

.portraitPresetCard {
    display: flex;
    min-width: 0;
    min-height: 145px;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    border: 1px solid #5b5b5b;
    border-radius: 3px;
    color: #e7e7e7;
    background: #1c1c1c;
    cursor: pointer;
    text-align: left;
}

.portraitPresetCard img {
    display: block;
    width: 100%;
    aspect-ratio: 156 / 210;
    object-fit: cover;
}

.portraitPresetMeta {
    display: grid;
    min-width: 0;
    flex: 1;
    align-content: start;
    gap: 2px;
    padding: 8px 9px 9px;
    border-top: 1px solid rgba(104, 130, 126, 0.45);
    background: rgba(3, 10, 11, 0.94);
}

.portraitPresetName,
.portraitPresetOriginal,
.portraitPresetFaction {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portraitPresetName {
    color: #f0f1e9;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    overflow: visible;
    text-overflow: clip;
    white-space: pre-line;
}

.portraitPresetOriginal {
    color: #9ea8a4;
    font-size: 10px;
    line-height: 1.2;
}

.portraitPresetFaction {
    color: #76c6c4;
    font-size: 10px;
    line-height: 1.25;
}

.portraitPresetCard.isEmpty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-style: dashed;
    color: #777;
    cursor: default;
}

.portraitPresetEmptyIcon {
    font-size: 28px;
    line-height: 1;
}

.portraitDropZone {
    width: 100%;
    min-height: 310px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    border: 2px dashed #666;
    border-radius: 4px;
    color: #f2f2f2;
    background: #202020;
    cursor: pointer;
    transition: border-color 120ms ease, background-color 120ms ease;
}

.portraitDropZone:hover,
.portraitDropZone.isDragging {
    border-color: #8eb6b6;
    background: #263030;
}

.portraitDropZone small {
    color: #9b9b9b;
}

.portraitDropIcon {
    font-size: 42px;
    line-height: 1;
    color: #9bc0c0;
}

.portraitEditorStage {
    padding: 0 20px 20px;
}

.portraitStageTabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin: 0 -20px 20px;
    border-bottom: 1px solid #555;
}

.portraitStageTabs button {
    padding: 13px 10px;
    border: 0;
    border-right: 1px solid #484848;
    color: #aaa;
    background: #262626;
    font: inherit;
    cursor: pointer;
}

.portraitStageTabs button:last-child {
    border-right: 0;
}

.portraitStageTabs button.isActive {
    color: #fff;
    background: #3a3a3a;
    box-shadow: inset 0 -3px 0 #8eb6b6;
}

.portraitStageTabs span {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: 7px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 12px;
}

.portraitWorkspace {
    display: grid;
    grid-template-columns: minmax(332px, 1fr) minmax(290px, 360px);
    gap: 22px;
    align-items: start;
}

.portraitCanvasColumn {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.portraitCanvasShell {
    position: relative;
    width: 312px;
    height: 420px;
    max-width: 100%;
    overflow: hidden;
    background-color: #bcbcbc;
    background-image:
        linear-gradient(45deg, #8e8e8e 25%, transparent 25%),
        linear-gradient(-45deg, #8e8e8e 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #8e8e8e 75%),
        linear-gradient(-45deg, transparent 75%, #8e8e8e 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    border: 1px solid #6a6a6a;
    box-shadow: 0 0 0 8px #161616;
    touch-action: none;
}

.portraitCanvasShell canvas,
.portraitCanvasShell img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

#portraitMaskCanvas {
    z-index: 2;
    cursor: crosshair;
}

#portraitFrameGuide {
    z-index: 3;
    opacity: 0.42;
    image-rendering: pixelated;
    pointer-events: none;
}

.portraitCanvasColumn p {
    max-width: 420px;
    margin: 18px 0 0;
    color: #bdbdbd;
    font-size: 12px;
    text-align: center;
}

.portraitControls {
    min-height: 420px;
}

.portraitControlPanel {
    padding: 16px;
    background: #292929;
    border: 1px solid #505050;
}

.portraitControlPanel h3 {
    margin: 0 0 10px;
    font-size: 17px;
}

.portraitControlPanel p {
    margin: 0 0 14px;
    color: #b8b8b8;
    font-size: 12px;
    line-height: 1.6;
}

.portraitControlPanel label {
    display: grid;
    gap: 6px;
    margin: 12px 0;
    color: #d6d6d6;
    font-size: 13px;
}

.portraitControlPanel input[type="range"] {
    width: 100%;
}

.portraitControlPanel input[type="color"] {
    width: 100%;
    height: 38px;
    padding: 2px;
    border: 1px solid #666;
    background: #1f1f1f;
}

.portraitControlPanel select {
    width: 100%;
    padding: 9px;
    border: 1px solid #666;
    border-radius: 3px;
    color: #eee;
    background: #1d1d1d;
    font: inherit;
}

.portraitControlPanel button,
.portraitStudioFooter > button,
.portraitFooterActions button {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #666;
    border-radius: 3px;
    color: #eee;
    background: #3b3b3b;
    font: inherit;
    cursor: pointer;
}

.portraitControlPanel button:hover,
.portraitStudioFooter > button:hover,
.portraitFooterActions button:hover,
.portraitStudioClose:hover {
    filter: brightness(1.12);
}

.portraitPrimaryButton {
    border-color: #6f9999 !important;
    background: #385757 !important;
}

.portraitToggle {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 8px !important;
}

.portraitSegmentedButtons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin: 12px 0;
}

.portraitSegmentedButtons button.isActive {
    border-color: #90bcbc;
    color: #fff;
    background: #466666;
}

.portraitFineMode {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #515151;
}

.portraitFineMode > summary {
    color: #d9d9d9;
    cursor: pointer;
}

.portraitFineMode[open] > summary {
    margin-bottom: 12px;
}

.portraitStudioFooter {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
    gap: 20px;
    align-items: end;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #515151;
}

.portraitFinalPreviewWrap {
    display: grid;
    justify-items: center;
    gap: 6px;
    color: #aaa;
    font-size: 11px;
}

.portraitFooterActions {
    display: grid;
    gap: 8px;
}

#portraitFinalPreview {
    width: 78px;
    height: 105px;
    border: 1px solid #666;
    background: #111;
}

@media screen and (max-width: 760px) {
    .portraitStudio {
        padding: 0;
    }

    .portraitStudioDialog {
        width: 100%;
        max-height: 100vh;
        min-height: 100vh;
    }

    .portraitSourceStage,
    .portraitWorkspace {
        grid-template-columns: 1fr;
    }

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

    .portraitCanvasShell {
        width: min(312px, calc(100vw - 58px));
        height: auto;
        aspect-ratio: 312 / 420;
    }

    .portraitStudioFooter {
        grid-template-columns: 1fr 1fr;
    }

    .portraitFinalPreviewWrap {
        grid-column: 1 / -1;
        grid-row: 1;
    }
}

/* 本地素材库 */
.assetLibraryNavButton {
    position: relative;
    color: #e5e2d6;
    background:
        linear-gradient(180deg, rgba(124, 117, 92, 0.28), rgba(29, 30, 28, 0.2)),
        var(--button);
}

.assetLibraryNavButton::before {
    content: "";
    width: 8px;
    height: 8px;
    margin-right: 8px;
    border: 1px solid #cdc7ad;
    transform: rotate(45deg);
    box-shadow: inset 0 0 0 2px #33372f;
}

.portraitLibraryShortcut {
    flex: 0 0 auto;
    padding: 8px 11px;
    border: 1px solid #676451;
    color: #e8e3cf;
    background: #34352f;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    cursor: pointer;
}

.assetLibraryModal {
    position: fixed;
    inset: 0;
    z-index: 1000001;
    display: grid;
    place-items: center;
    box-sizing: border-box;
    padding: 18px;
    background:
        radial-gradient(circle at 50% 0%, rgba(115, 115, 93, 0.16), transparent 38%),
        rgba(5, 7, 7, 0.9);
    backdrop-filter: blur(3px);
}

.assetLibraryDialog {
    display: grid;
    grid-template-rows: auto auto auto minmax(220px, 1fr) auto;
    width: min(1220px, 100%);
    height: min(850px, calc(100vh - 36px));
    min-height: 560px;
    overflow: hidden;
    color: #e9e9e3;
    background:
        linear-gradient(105deg, rgba(255, 255, 255, 0.018), transparent 35%),
        #1c1f1e;
    border: 1px solid #62645d;
    box-shadow:
        0 24px 90px rgba(0, 0, 0, 0.78),
        inset 0 0 0 1px rgba(255, 255, 255, 0.025);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
}

.assetLibraryHeader {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 17px 20px 15px;
    background:
        linear-gradient(90deg, rgba(136, 129, 94, 0.14), transparent 56%),
        #292c2a;
    border-bottom: 1px solid #55584f;
}

.assetLibraryHeader h2,
.assetLibraryHeader p {
    margin: 0;
}

.assetLibraryHeader h2 {
    margin-top: 1px;
    color: #f1f0e8;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: clamp(21px, 2.5vw, 28px);
    font-weight: 500;
    letter-spacing: 0.08em;
}

.assetLibraryHeader > div > p:last-child {
    margin-top: 5px;
    color: #b5b7ae;
    font-size: 13px;
}

.assetLibraryEyebrow {
    color: #9fa08f;
    font-size: 10px;
    letter-spacing: 0.26em;
}

.assetLibraryClose {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid #676a62;
    border-radius: 2px;
    color: #eee;
    background: #202321;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.assetLibraryTabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1px;
    padding: 0;
    background: #464a45;
    border-bottom: 1px solid #55584f;
}

.assetLibraryTabs button {
    min-height: 43px;
    padding: 9px 12px;
    border: 0;
    border-bottom: 3px solid transparent;
    color: #babdb5;
    background: #303431;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 15px;
    cursor: pointer;
}

.assetLibraryTabs button:hover,
.assetLibraryTabs button:focus-visible {
    color: #fff;
    background: #3b403c;
}

.assetLibraryTabs button.isActive {
    color: #f0ead5;
    background: #41463f;
    border-bottom-color: #beb99e;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}

.assetLibraryToolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1.55fr) repeat(3, minmax(150px, 0.8fr));
    gap: 10px;
    padding: 12px 14px;
    background: #242725;
    border-bottom: 1px solid #424641;
}

.assetLibraryToolbar.isFocusMode {
    grid-template-columns: minmax(220px, 1.45fr) repeat(4, minmax(135px, 0.8fr));
}

.assetLibraryToolbar > [hidden] {
    display: none !important;
}

.assetLibraryToolbar label {
    display: grid;
    gap: 5px;
    min-width: 0;
    color: #aaada5;
    font-size: 11px;
}

.assetLibraryToolbar input,
.assetLibraryToolbar select {
    width: 100%;
    min-width: 0;
    height: 36px;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid #565a54;
    border-radius: 2px;
    outline: 0;
    color: #ebede7;
    background: #191c1a;
    font: inherit;
    font-size: 13px;
}

.assetLibraryToolbar input:focus,
.assetLibraryToolbar select:focus {
    border-color: #aaa78f;
    box-shadow: 0 0 0 2px rgba(170, 167, 143, 0.13);
}

.assetLibraryBody {
    min-height: 0;
    overflow: auto;
    padding: 12px 14px 18px;
    scrollbar-color: #666a63 #1b1e1c;
}

.assetLibraryStatus {
    position: sticky;
    top: -12px;
    z-index: 2;
    margin: -1px 0 10px;
    padding: 8px 9px;
    color: #afb2aa;
    background: rgba(28, 31, 30, 0.95);
    border-bottom: 1px solid #363a36;
    font-size: 12px;
}

.assetLibraryStatus.isError {
    color: #e1aaa2;
}

.assetLibraryGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 9px;
}

.assetLibraryCard {
    display: grid;
    grid-template-rows: 154px minmax(92px, auto);
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #444944;
    border-radius: 2px;
    color: #e4e5df;
    background: #282c29;
    text-align: left;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.assetLibraryGrid:not([data-asset-type="leaders"]) .assetLibraryCard {
    grid-template-rows: 128px minmax(92px, auto);
}

.assetLibraryCard:hover,
.assetLibraryCard:focus-visible {
    z-index: 1;
    border-color: #7c8075;
    background: #323733;
    transform: translateY(-1px);
}

.assetLibraryCard.isSelected {
    border-color: #c3bea1;
    background: #393d37;
    box-shadow:
        0 0 0 2px rgba(195, 190, 161, 0.2),
        inset 0 0 18px rgba(195, 190, 161, 0.05);
}

.assetLibraryCardVisual {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background-color: #171a18;
    background-image:
        linear-gradient(45deg, #202421 25%, transparent 25%),
        linear-gradient(-45deg, #202421 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #202421 75%),
        linear-gradient(-45deg, transparent 75%, #202421 75%);
    background-position: 0 0, 0 7px, 7px -7px, -7px 0;
    background-size: 14px 14px;
}

.assetLibraryCardVisual::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 -18px 24px rgba(0, 0, 0, 0.22);
}

.assetLibraryCardVisual img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.assetLibraryGrid[data-asset-type="leaders"] .assetLibraryCardVisual img {
    object-position: center bottom;
}

.assetLibraryCardVisual.hasError::before {
    content: "暂无可用预览";
    color: #858a82;
    font-size: 12px;
}

.assetLibraryCardCopy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 5px;
    padding: 9px;
    box-sizing: border-box;
}

.assetLibraryCardCopy strong,
.assetLibraryCardCopy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assetLibraryCardCopy strong {
    min-height: 34px;
    color: #f1f0e8;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.assetLibraryCardCopy small {
    color: #adb1a9;
    font-size: 11px;
    line-height: 1.25;
    white-space: nowrap;
}

.assetLibraryBadges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: auto;
}

.assetLibraryBadge {
    max-width: 100%;
    overflow: hidden;
    padding: 3px 5px 2px;
    border: 1px solid #4c514b;
    color: #bcbdb4;
    background: #202421;
    font-size: 9px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.assetLibraryLoadMore {
    display: block;
    width: min(360px, 100%);
    margin: 16px auto 0;
    padding: 10px 16px;
    border: 1px solid #62675f;
    color: #e2e2d8;
    background: #303530;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    cursor: pointer;
}

.assetLibraryLoadMore[hidden] {
    display: none !important;
}

.assetLibraryFooter {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    background: #292d2a;
    border-top: 1px solid #55594f;
}

.assetLibrarySelection {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.assetLibrarySelection > span:last-child {
    min-width: 0;
}

.assetLibrarySelectionPreview {
    position: relative;
    display: grid;
    place-items: center;
    width: 46px;
    height: 54px;
    overflow: hidden;
    border: 1px solid #555a54;
    background-color: #181b19;
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
}

.assetLibrarySelection strong,
.assetLibrarySelection small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.assetLibrarySelection strong {
    color: #f0f0e7;
    font-size: 14px;
    font-weight: 500;
}

.assetLibrarySelection small {
    margin-top: 3px;
    color: #a6aaa2;
    font-size: 11px;
}

.assetLibraryNameSync {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #c6c8c0;
    font-size: 12px;
    white-space: nowrap;
}

.assetLibraryNameSync input {
    accent-color: #8f927d;
}

.assetLibraryApply {
    min-height: 40px;
    padding: 8px 18px;
    border: 1px solid #918f79;
    color: #f3f0dd;
    background: linear-gradient(#4d5044, #363a32);
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    cursor: pointer;
}

.assetLibraryApply:disabled {
    border-color: #4b4e49;
    color: #777b75;
    background: #303330;
    cursor: not-allowed;
}

@media screen and (max-width: 900px) {
    .assetLibraryToolbar,
    .assetLibraryToolbar.isFocusMode {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .assetLibrarySearch {
        grid-column: 1 / -1;
    }

    .assetLibraryDialog {
        height: calc(100vh - 24px);
    }

    .assetLibraryModal {
        padding: 12px;
    }
}

@media screen and (max-width: 620px) {
    .assetLibraryModal {
        padding: 0;
    }

    .assetLibraryDialog {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        border: 0;
    }

    .assetLibraryHeader {
        padding: 13px 14px 11px;
    }

    .assetLibraryHeader > div > p:last-child {
        display: none;
    }

    .assetLibraryTabs button {
        min-height: 40px;
        padding: 7px 4px;
        font-size: 13px;
    }

    .assetLibraryToolbar,
    .assetLibraryToolbar.isFocusMode {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        padding: 9px;
    }

    .assetLibraryToolbar label:last-child {
        grid-column: 1 / -1;
    }

    .assetLibraryBody {
        padding: 9px;
    }

    .assetLibraryGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .assetLibraryCard,
    .assetLibraryGrid:not([data-asset-type="leaders"]) .assetLibraryCard {
        grid-template-rows: 124px minmax(84px, auto);
    }

    .assetLibraryFooter {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 8px;
        padding: 8px 9px;
    }

    .assetLibraryNameSync {
        display: none;
    }

    .assetLibraryApply {
        padding-inline: 12px;
    }

    .assetLibrarySelection {
        grid-template-columns: 38px minmax(0, 1fr);
        gap: 7px;
    }

    .assetLibrarySelectionPreview {
        width: 36px;
        height: 44px;
    }

    .assetLibrarySelection small {
        display: none;
    }

    .portraitSectionHeading {
        align-items: flex-start;
        gap: 10px;
    }
}

/* Keep the extended diplomacy export height after the legacy base geometry. */
#generatorWorkbench #diploScreenshot {
    height: 422px;
}

/* 头像工坊：算法说明与真实处理示例 */
.portraitAlgorithmProof {
    display: grid;
    min-width: 0;
    gap: 14px;
    margin-top: 18px;
    padding-top: 16px;
}

.portraitAlgorithmProofHeader {
    display: grid;
    gap: 2px;
    padding: 9px 12px;
}

.portraitAlgorithmProofHeader small {
    color: #8fa09b;
    font-size: 9px;
    letter-spacing: 0.16em;
}

.portraitAlgorithmProofHeader h3 {
    margin: 0;
    color: #eef1ed;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.06em;
}

.portraitAlgorithmCopy {
    display: grid;
    gap: 9px;
}

.portraitAlgorithmCopy p,
.portraitAlgorithmExample p,
.portraitAlgorithmNote,
.portraitAlgorithmLicense {
    margin: 0;
    color: #b7c0bc;
    font-family: "RuiZheng", "PingFang SC", sans-serif;
    font-size: 11px;
    line-height: 1.65;
}

.portraitAlgorithmExample {
    display: grid;
    gap: 6px;
    padding: 11px 12px;
}

.portraitAlgorithmExample > strong {
    color: #e8eeea;
    font-family: "WenHanJianZhu", "RuiZheng", "PingFang SC", sans-serif;
    font-size: 15px;
    font-weight: 500;
}

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

.portraitAlgorithmComparison figure {
    display: grid;
    min-width: 0;
    justify-items: center;
    gap: 8px;
    margin: 0;
}

.portraitAlgorithmImageFrame {
    width: min(100%, 156px);
    aspect-ratio: 156 / 210;
    overflow: hidden;
    box-sizing: border-box;
}

.portraitAlgorithmImageFrame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portraitAlgorithmComparison figure:first-child img {
    object-position: 50% 30%;
}

.portraitAlgorithmComparison figcaption {
    display: grid;
    min-width: 0;
    gap: 2px;
    text-align: center;
}

.portraitAlgorithmComparison figcaption strong {
    color: #ebefeb;
    font-size: 12px;
    font-weight: 600;
}

.portraitAlgorithmComparison figcaption span {
    color: #8f9a96;
    font-size: 9px;
    line-height: 1.35;
}

.portraitAlgorithmNote {
    color: #87938e;
    font-size: 9px;
}

.portraitAlgorithmLicense {
    padding: 11px 12px;
    color: #cad6d1;
}

/* Give the custom portrait and algorithm proof enough reading width. */
.portraitStudioDialog {
    width: min(1320px, 100%);
}

.portraitSourceStage {
    grid-template-columns: minmax(620px, 1.18fr) minmax(480px, 0.92fr);
    gap: 18px;
}

.portraitAlgorithmImageFrame {
    width: min(100%, 180px);
}

.portraitAlgorithmCopy p,
.portraitAlgorithmExample p,
.portraitAlgorithmLicense {
    font-size: 12px;
}

@media screen and (max-width: 1100px) {
    .portraitSourceStage {
        grid-template-columns: minmax(0, 1fr) minmax(400px, 0.92fr);
    }
}

@media screen and (max-width: 900px) {
    .portraitSourceStage {
        grid-template-columns: 1fr;
    }
}
