* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    background: #f7f7f7;
    color: #222222;
    font-family: "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.page {
    width: 100%;
    max-width: 800px;
    min-height: 100vh;
    margin: 0 auto;
    background: #ffffff;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    height: 44px;
    background: #08c25e;
    color: #ffffff;
    text-align: center;
}

.topbar h1 {
    margin: 0;
    font-size: 18px;
}

.topbar-back {
    border: 0;
    background: none;
    color: #ffffff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.topbar-home {
    font-size: 14px;
}

.almanac {
    padding: 10px 10px 30px;
    --red: #ff2d55;
    --green: #2f9e44;
    --line: #e4e4e4;
}

/* 日期选择 */
.alm-date {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    margin-bottom: 4px;
    color: #666666;
    font-size: 13px;
}

.alm-date input,
.alm-date select {
    height: 32px;
    padding: 0 4px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: #222222;
    font-size: 20px;
    text-align: center;
}

.alm-date input {
    width: 70px;
}

.alm-date select {
    width: 52px;
}

.alm-date input:focus,
.alm-date select:focus {
    outline: 0;
    border-bottom-color: var(--red);
}

/* 农历日期与前后切换 */
.alm-lunar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 6px 0 8px;
}

.alm-lunar strong {
    min-width: 130px;
    color: var(--red);
    font-size: 28px;
    font-weight: 500;
    text-align: center;
}

.alm-lunar button {
    border: 0;
    background: none;
    color: var(--red);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.alm-jieqi {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #aaaaaa;
    font-size: 14px;
}

/* 通用方框 */
.alm-box {
    margin-bottom: 8px;
    border: 1px solid var(--line);
}

/* 干支 + 相冲 */
.alm-ganzhi {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.alm-ganzhi-left {
    padding: 8px 10px;
    border-right: 1px solid var(--line);
}

.alm-gz-row {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr 1.1fr;
    gap: 4px;
    padding: 3px 0;
    font-size: clamp(14px, 3.4vw, 24px);
}

.alm-red {
    color: var(--red);
}

.alm-ganzhi-right {
    display: grid;
    grid-template-rows: repeat(3, 1fr);
}

.alm-chong-row {
    display: grid;
    grid-template-columns: 1.6em 1fr;
    align-items: center;
    padding: 4px 8px;
    font-size: clamp(14px, 3.4vw, 24px);
}

.alm-chong-row .alm-label {
    color: var(--red);
    line-height: 1.2;
    word-break: break-all;
}

.alm-chong-row .alm-value {
    text-align: center;
}

/* 宜 / 星宿歌诀 / 忌 */
.alm-yiji {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
}

.alm-col {
    min-width: 0;
    border-right: 1px solid var(--line);
}

.alm-col:last-child {
    border-right: 0;
}

.alm-cell {
    padding: 8px 8px 10px;
}

.alm-cell + .alm-cell {
    border-top: 1px solid var(--line);
}

.alm-badge {
    display: block;
    width: fit-content;
    margin: 0 auto 6px;
    padding: 1px 6px;
    border-radius: 10px;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.4;
}

.alm-badge-yi {
    background: var(--green);
    border-radius: 50%;
    padding: 1px 6px;
}

.alm-badge-ji {
    background: #444444;
    border-radius: 50%;
    padding: 1px 6px;
}

.alm-badge-song {
    background: var(--red);
    font-size: 11px;
    margin-top: 8px;
}

.alm-sub {
    display: block;
    margin-bottom: 4px;
    color: var(--red);
    font-size: 11px;
    text-align: center;
}

.alm-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 8px;
    font-size: clamp(15px, 3.6vw, 26px);
    line-height: 1.35;
}

.alm-tags-yi {
    color: var(--green);
}

.alm-tags-ji {
    color: #222222;
}

.alm-tags-xiong {
    color: #c0392b;
}

.alm-col-song p {
    margin: 0;
    padding: 0 8px 10px;
    font-size: clamp(14px, 3.5vw, 24px);
    line-height: 1.5;
}

/* 财神位 / 阴阳 */
.alm-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.alm-two > div {
    padding: 8px 10px;
}

.alm-two > div:first-child {
    border-right: 1px solid var(--line);
}

.alm-two h2 {
    margin: 0 0 6px;
    color: var(--red);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

.alm-pair {
    display: grid;
    grid-template-columns: 5em 1fr;
    gap: 6px;
    padding: 3px 0;
    font-size: clamp(14px, 3.4vw, 22px);
}

.alm-pair .alm-label {
    color: var(--red);
}

/* 通栏行：彭祖百忌、日值九星 */
.alm-line {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.alm-line .alm-pair {
    grid-template-columns: 4.5em 1fr;
    padding: 8px 10px;
    border-right: 1px solid var(--line);
}

.alm-line .alm-pair:last-child {
    border-right: 0;
}

/* 月相 物候 岁煞 六曜 */
.alm-four {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.alm-four .alm-pair {
    grid-template-columns: 3em 1fr;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}

.alm-four .alm-pair:nth-child(odd) {
    border-right: 1px solid var(--line);
}

.alm-four .alm-pair:nth-last-child(-n + 2) {
    border-bottom: 0;
}
