:root {
    --paper: #f5eee2;
    --paper-soft: #eee1cd;
    --paper-deep: #dfcaa9;
    --ink: #4b3824;
    --muted: #8a765f;
    --accent: #9a7445;
    --accent-dark: #684a2b;
    --line: #c4a77f;
    --wash: rgba(248, 241, 229, .90);
}

body.search-results-page {
    overflow: auto !important;
    color: #321f0f !important;
    background: #fffaf2 !important;
}
.search-results-page #sider {
    box-sizing: border-box;
    width: min(100%, 980px);
    min-height: 100%;
    margin: 0 auto;
    padding: 18px;
    color: #321f0f !important;
    background: #fffaf2 !important;
}
.search-results-page #result_title {
    box-sizing: border-box;
    width: 100%;
    height: auto;
    min-height: 44px;
    padding: 8px 12px;
    color: var(--ink);
    background: var(--paper-soft);
    border-bottom: 1px solid var(--line);
}
.search-results-page a.return {
    float: none;
    display: inline-block;
    box-sizing: border-box;
    width: auto;
    min-width: 110px;
    height: 38px;
    margin: 10px 0;
    padding: 0 12px;
    line-height: 36px;
    color: var(--ink);
    background: var(--paper-deep);
    border: 1px solid var(--line);
}
.search-results-page #sider > .content,
.search-results-page #sider > div[style*="height"] {
    box-sizing: border-box;
    height: auto !important;
    overflow: visible !important;
}
.search-results-page ul.CATALOG li a {
    display: block;
    min-height: 32px;
    padding: 6px 10px;
    color: #321f0f !important;
    background: #ffffff !important;
    border-bottom: 1px solid #d8c6aa;
    font-size: 16px;
    line-height: 1.6;
}
.search-results-page ul.CATALOG li a:visited {
    color: #63492f !important;
}
.search-results-page ul.CATALOG li a:hover,
.search-results-page ul.CATALOG li a:focus,
.search-results-page ul.CATALOG li a:active {
    color: #ffffff !important;
    background: #76522d !important;
}
.search-results-page #condition,
.search-results-page #condition h3,
.search-results-page #condition p,
.search-results-page .PAGINATION,
.search-results-page .PAGINATION a {
    color: #321f0f !important;
}

body.data-stat-page {
    min-height: 100%;
    overflow: auto !important;
    color: #321f0f !important;
    background: #fffaf2 !important;
}
.data-stat-page > .content {
    min-height: 100%;
    color: #321f0f !important;
    background: #fffaf2 !important;
}
.data-stat-page .area {
    color: #321f0f !important;
    background: #ffffff !important;
    border-color: #c4a77f !important;
}
.data-stat-page h2,
.data-stat-page h3,
.data-stat-page label {
    color: #321f0f !important;
}
.data-stat-page input,
.data-stat-page select {
    color: #321f0f !important;
    background-color: #ffffff !important;
    border: 1px solid #c4a77f !important;
}
.data-stat-page .buttonsarea input {
    color: #ffffff !important;
    background: #76522d !important;
}

body.data-stat-results-page {
    height: 100vh !important;
    overflow: hidden !important;
}
.data-stat-results-page #sider {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}
.search-results-page.data-stat-results-page #sider > .stat-scroll {
    box-sizing: border-box;
    height: calc(100vh - 116px) !important;
    min-height: 220px;
    padding-bottom: 72px;
    overflow-x: hidden !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}
body.search-results-page.data-stat-results-page #sider .stat-scroll > div.content {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}


@media screen and (max-width: 768px) {
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
    body {
        color: var(--ink) !important;
        background-color: var(--paper) !important;
        background-image:
            linear-gradient(var(--wash), var(--wash)),
            url(images/main_bg.jpg) !important;
        background-repeat: repeat, no-repeat !important;
        background-position: 0 0, right bottom !important;
        background-size: auto, cover !important;
        font-family: "Noto Serif CJK TC", "Songti TC", simsun, serif !important;
    }

    #header {
        box-sizing: border-box;
        width: 100%;
        height: 184px;
        min-height: 184px;
        padding: 10px 12px 9px;
        background: transparent !important;
    }
    h1#title {
        display: block;
        box-sizing: border-box;
        height: 42px;
        margin: 0 0 7px;
        padding: 2px 8px 6px;
        overflow: hidden;
        border: 0;
        border-bottom: 1px solid var(--line);
        color: var(--ink);
        background: rgba(255,255,255,.34);
        font-size: 25px;
        line-height: 34px;
        font-style: normal;
        letter-spacing: .16em;
        text-align: center;
    }
    h1#title span.extra { display: none; }

    #searchForm { margin: 0; padding: 0; }
    #toolbar {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin: 0;
        padding: 0;
        color: var(--ink);
    }
    #toolbar li {
        display: block;
        float: none;
        min-width: 0;
        margin: 0;
    }
    #searchTextMI {
        grid-column: 1 / -1;
        display: flex !important;
        align-items: center;
        gap: 7px;
        box-sizing: border-box;
        width: 100% !important;
        height: 35px;
        padding: 3px 8px;
        color: var(--ink);
        background: rgba(255,255,255,.5) !important;
        border: 1px solid var(--line);
        border-radius: 3px;
        font-size: 15px;
    }
    #searchText {
        flex: 1;
        box-sizing: border-box;
        min-width: 0;
        width: auto;
        height: 27px;
        border: 1px solid var(--line);
        background: rgba(255,255,255,.82);
        color: var(--ink);
        font-size: 16px;
    }
    #toolbar li a {
        box-sizing: border-box;
        width: 100%;
        height: 34px;
        line-height: 32px;
        border: 1px solid var(--line);
        border-radius: 3px;
        color: var(--ink);
        background: linear-gradient(rgba(255,255,255,.72), rgba(255,255,255,.28));
        font-size: 14px;
        text-shadow: none;
    }

    #sider {
        box-sizing: border-box;
        min-height: 100%;
        margin: 0;
        background-color: var(--paper-soft);
        background-image:
            linear-gradient(var(--wash), var(--wash)),
            url(images/sider_bg.gif);
        background-repeat: repeat, no-repeat;
        background-position: 0 0, bottom left;
        background-size: auto, 100% auto;
    }
    #sider #title,
    #result_title {
        box-sizing: border-box;
        width: 100%;
        height: 44px;
        line-height: 44px;
        background-color: rgba(255,255,255,.44);
        background-position: 12px center;
        border-bottom: 1px solid var(--line);
    }
    #sider #title {
        background-image: none !important;
        text-align: center;
    }
    #sider #title::before {
        content: "目錄";
        color: var(--ink);
        font-size: 19px;
        font-weight: bold;
        letter-spacing: .35em;
    }
    #result_title {
        padding-left: 14px;
        background-image: none !important;
        color: var(--ink);
    }
    #sider .content {
        box-sizing: border-box;
        height: calc(100% - 44px) !important;
        padding: 14px 18px 28px;
        overflow: auto !important;
        font-size: 17px;
        line-height: 1.55;
    }
    ul.CATALOG { margin-left: .55em; line-height: 1.55em; }
    ul.CATALOG li { margin-left: 18px; }
    ul.CATALOG li a {
        display: inline-block;
        min-height: 31px;
        padding: 3px 5px 2px;
        color: var(--ink) !important;
        font-size: 17px;
    }
    ul.CATALOG li a:hover,
    ul.CATALOG li a.ACTIVE {
        color: var(--ink) !important;
        background: var(--paper-deep) !important;
        border-color: var(--accent);
    }

    body > .content,
    body .content {
        box-sizing: border-box;
        width: 100%;
        max-width: 920px;
        margin: 0 auto;
        padding: 20px 18px 48px;
        color: var(--ink);
        font-size: 18px !important;
        line-height: 1.78;
    }
    h2, h3, h4,
    h2.title, h2.subtitle {
        color: var(--ink) !important;
        line-height: 1.45;
    }
    h2.title { font-size: 1.45em; }
    h2.subtitle, h3, h4 { font-size: 1em; }
    p { margin-left: 0; line-height: 1.85; }
    span.comment, p.gl { color: var(--muted); }

    .area {
        box-sizing: border-box;
        margin: 12px 0;
        padding: 4px;
        border-color: var(--line);
        background: rgba(255,255,255,.52);
    }
    .parttitle { background: none; border-bottom: 1px solid var(--line); }
    .parttitle h2 {
        float: none;
        width: auto;
        padding-left: 12px;
        color: var(--ink);
        background: transparent;
    }
    .nametitle { border-color: var(--accent); }
    .buttonsarea input,
    input, select, textarea, button {
        box-sizing: border-box;
        max-width: 100%;
        min-height: 38px;
        font-size: 16px;
    }
    textarea[name="poemContent"] {
        display: block;
        position: relative;
        z-index: 1;
        width: 100% !important;
        min-height: 260px;
        margin: 0;
        padding: 12px;
        overflow: auto;
        border: 1px solid var(--line);
        border-radius: 3px;
        color: var(--ink);
        background: rgba(255,255,255,.86);
        font: 18px/1.75 "Noto Serif CJK TC", "Songti TC", simsun, serif;
        caret-color: var(--ink);
        resize: vertical;
        -webkit-user-select: text !important;
        user-select: text !important;
        -webkit-touch-callout: default !important;
        touch-action: auto !important;
    }
    .buttonsarea input {
        width: min(100%, 288px);
        color: var(--ink);
        border: 1px solid var(--line);
        background: rgba(255,255,255,.68);
    }
    div.left, div.right,
    #glarea, #kwarea, #sdtcarea,
    #sdgroup, #tcgroup {
        float: none;
        width: 100%;
        margin: 0 0 12px;
    }
    table { display: block; max-width: 100%; overflow-x: auto; }
    img { max-width: 100%; height: auto; }

    body.search-results-page.data-stat-results-page #sider .stat-scroll > div.content:first-child {
        padding: 8px 12px 4px !important;
    }
    body.search-results-page.data-stat-results-page #sider .stat-scroll > div.content:nth-child(2) {
        padding: 0 12px 56px !important;
    }
    .data-stat-results-page #condition {
        display: grid;
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 5px 8px;
        align-items: start;
        margin: 0;
        padding: 8px 0;
        border-bottom: 1px dotted var(--line);
    }
    .data-stat-results-page #condition h3 {
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        font-size: 15px;
        line-height: 1.55;
        text-align: left;
        white-space: nowrap;
    }
    .data-stat-results-page #condition p {
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.55;
    }
    .data-stat-results-page .stat-scroll > div.content:nth-child(2) > .split:first-child {
        display: none;
    }
    .data-stat-results-page ul.CATALOG > h3 {
        margin: 10px 0 8px !important;
        line-height: 1.45;
    }
}
