:root {
    color-scheme: dark;
    --base-size: min(40vw, 60vh);
    --rectsize: var(--base-size);
    --radius: calc(var(--rectsize) * 0.0952);
    --font-size: calc(var(--rectsize) * 0.992);
    --spacing: calc(var(--rectsize) * 0.08);
    --div-thick: calc(var(--rectsize) * 0.0083);
    --ampm-size: calc(var(--rectsize) * 0.1);
    --ampm-offset: calc(var(--rectsize) * 0.08);

    --bg-screen: #000000;
    --bg-card: #0f0f0f;
    --color-font: #b7b7b7;
    --color-div-black: #000000;
    --color-div-gray: #1a1a1a;

    --color-white: #ffffff;
    --color-black: #000000;
    --color-screen-border: #202323;
    --color-content: #090b0b;
    --color-content-muted: #a8adab;
    --color-content-line: #69716f;
    --color-content-heading: #f4f6f5;
    --color-content-secondary: #8f9693;
    --color-content-strong: #d7dcda;
    --color-content-label: #dfe3e1;
    --color-content-rule: #262a29;
    --color-card: #111414;
    --color-card-border: #242827;
    --color-card-hover: #151918;
    --color-card-hover-border: #3a403e;
    --color-card-number: #555d5a;
    --color-card-heading: #f0f3f2;
    --color-link: #ced3d1;
    --color-link-border: #303534;
    --color-link-hover-border: #535b58;
    --color-link-hover: #171b1a;
    --color-footer: #626966;
    --color-footer-border: #222625;
    --color-toolbar: rgba(24, 24, 28, 0.65);
    --color-toolbar-border: rgba(255, 255, 255, 0.08);
    --color-control-muted: #888888;
    --color-control-hover: #d0d0d0;
    --color-control-active: #111111;
    --color-accent-mint: #6ed7c3;
    --color-accent-peach: #f0b783;
    --color-accent-lilac: #aab7f0;
    --color-accent-yellow: #d5d878;
    --color-toolbar-fullscreen: rgba(15, 15, 18, 0.4);
    --color-hover-surface: rgba(255, 255, 255, 0.08);
    --color-toolbar-highlight: rgba(255, 255, 255, 0.05);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-control: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-card-hover: 0 16px 32px rgba(0, 0, 0, 0.22);

}

@font-face {
    font-family: 'FlipClockFont';
    src: url('./flipClockFont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

html {
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

html::-webkit-scrollbar {
    display: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-screen);
    font-family: 'FlipClockFont', sans-serif;
    color: var(--color-font);
    transition: background-color 0.3s ease;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

body::-webkit-scrollbar {
    display: none;
}

body.cursor-hidden .clock-section,
body.cursor-hidden .clock-section * {
    cursor: none !important;
}

body.fullscreen {
    background-color: var(--color-black);
}

body.locked {
    overflow: hidden !important;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
    touch-action: none;
    -ms-touch-action: none;
}

.clock-section {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-screen);
    transition: background-color 0.3s ease;
}

body.fullscreen .clock-section {
    background-color: var(--color-black);
}

.clock-container {
    display: flex;
    gap: var(--spacing);
    transition: gap 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.clock-container:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-white) 75%, transparent);
    outline-offset: 12px;
}

.flip-clock {
    position: relative;
    width: var(--rectsize);
    height: var(--rectsize);
    background-color: var(--bg-card);
    border-radius: var(--radius);
    perspective: 2000px;
    box-shadow: var(--shadow-card);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.3s ease,
        box-shadow 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.text-wrapper {
    position: absolute;
    width: 100%;
    height: var(--rectsize);
    font-size: var(--font-size);
    color: var(--color-font);
    line-height: var(--rectsize);
    text-align: center;
    left: 0;
    transition: font-size 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        line-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
}

.half {
    position: absolute;
    width: 100%;
    height: 50%;
    overflow: hidden;
    background-color: var(--bg-card);
    transition: background-color 0.3s;
    pointer-events: none;
}

.half.top {
    top: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}

.half.top .text-wrapper {
    top: 0;
}

.half.bottom {
    bottom: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

.half.bottom .text-wrapper {
    bottom: 0;
}

.flap-top,
.flap-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    overflow: hidden;
    background-color: var(--bg-card);
    z-index: 2;
    pointer-events: none;
}

.flap-top {
    top: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    transform-origin: bottom;
}

.flap-top .text-wrapper {
    top: 0;
}

.flap-bottom {
    bottom: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    transform-origin: top;
    transform: rotateX(90deg);
}

.flap-bottom .text-wrapper {
    bottom: 0;
}

.flap-top.flipping {
    animation: flipTopDown 0.3s ease-in forwards;
    will-change: transform, filter;
}

.flap-bottom.flipping {
    animation: flipBottomDown 0.3s ease-out 0.3s forwards;
    will-change: transform, filter;
}

@keyframes flipTopDown {
    0% {
        transform: rotateX(0deg);
        filter: brightness(1);
    }

    100% {
        transform: rotateX(-90deg);
        filter: brightness(0.15);
    }
}

@keyframes flipBottomDown {
    0% {
        transform: rotateX(90deg);
        filter: brightness(0.15);
    }

    100% {
        transform: rotateX(0deg);
        filter: brightness(1);
    }
}

.divider {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: var(--div-thick);
    background-color: var(--color-div-black);
    transform: translateY(-50%);
    border-bottom: 1px solid var(--color-div-gray);
    z-index: 10;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.ampm-indicator {
    position: absolute;
    left: calc(var(--radius) * 0.8);
    font-size: var(--ampm-size);
    color: var(--color-font);
    z-index: 15;
    display: none;
    line-height: 1;
    transition: font-size 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
}

.mode-12h .ampm-indicator {
    display: block;
}

.ampm-indicator.is-am {
    top: var(--ampm-offset);
    bottom: auto;
}

.ampm-indicator.is-pm {
    bottom: var(--ampm-offset);
    top: auto;
}

#clock-seconds {
    opacity: 0;
    width: 0;
    margin-left: calc(-1 * var(--spacing));
    overflow: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.clock-container.show-seconds #clock-seconds {
    opacity: 1;
    width: var(--rectsize);
    margin-left: 0;
    overflow: visible;
}

.fullscreen-hint {
    position: absolute;
    left: 50%;
    bottom: 104px;
    margin: 0;
    transform: translateX(-50%);
    color: color-mix(in srgb, var(--color-white) 48%, transparent);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 0.8125rem;
    letter-spacing: 0.04em;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    white-space: nowrap;
}

.fullscreen-hint.is-hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
}

/* ──────────── 下方内容区域 ──────────── */
.content-section {
    position: relative;
    overflow: hidden;
    background-color: var(--color-content);
    padding: 112px 32px 32px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--color-content-muted);
    min-height: 60vh;
    border-top: 1px solid var(--color-screen-border);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    isolation: isolate;
}

.content-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: min(1040px, calc(100% - 64px));
    height: 1px;
    background: var(--color-content-line);
    opacity: 0.45;
    transform: translateX(-50%);
    z-index: -1;
}

body.fullscreen .content-section {
    background-color: var(--color-black);
    border-top-color: var(--color-link-hover);
}

.content-section .content-inner {
    max-width: 1040px;
    margin: 0 auto;
}

.content-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
    gap: clamp(48px, 8vw, 112px);
    align-items: end;
    padding-bottom: 64px;
    border-bottom: 1px solid var(--color-content-rule);
}

.content-header {
    max-width: 780px;
}

.section-kicker {
    margin: 0 0 20px;
    color: var(--color-accent-mint);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.16em;
}

.content-section h1 {
    max-width: 780px;
    color: var(--color-content-heading);
    font-size: 2.5rem;
    font-weight: 650;
    line-height: 1.22;
    margin: 0 0 22px;
    letter-spacing: 0;
    text-align: left;
    text-wrap: balance;
}

.content-section .lead-text {
    max-width: 760px;
    color: var(--color-content-secondary);
    font-size: 1.0625rem;
    margin: 0;
    line-height: 1.85;
    text-align: left;
}

.content-section .lead-text strong {
    color: var(--color-content-strong);
    font-weight: 600;
}

.content-section h2 {
    color: var(--color-content-label);
    font-size: 0.8125rem;
    font-weight: 650;
    margin: 72px 0 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.content-section h2::after {
    content: '';
    height: 1px;
    flex: 1;
    background: var(--color-content-rule);
}

.usage-guide h2,
.feature-section h2 {
    margin-top: 0;
}

.usage-guide {
    max-width: none;
    margin-top: 0;
    padding: 4px 0 4px 28px;
    border-left: 1px solid var(--color-content-line);
}

.usage-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.usage-list li {
    display: grid;
    gap: 6px;
    padding: 14px 0;
    border-bottom: 1px solid var(--color-content-rule);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.usage-list li:first-child {
    border-top: 1px solid var(--color-content-rule);
}

.usage-list strong {
    color: var(--color-content-heading);
    font-weight: 600;
}

.usage-list span {
    color: var(--color-content-secondary);
}

.feature-section {
    margin-top: 72px;
}

.feature-grid {
    counter-reset: feature;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.feature-card {
    --feature-accent: var(--color-accent-mint);
    counter-increment: feature;
    position: relative;
    min-height: 196px;
    overflow: hidden;
    box-sizing: border-box;
    background: var(--color-card);
    border-radius: 8px;
    padding: 28px 24px 24px;
    border: 1px solid var(--color-card-border);
    transition: transform 0.25s ease, background-color 0.25s ease, border-color 0.25s ease,
        box-shadow 0.25s ease;
}

.feature-card:nth-child(2) {
    --feature-accent: var(--color-accent-peach);
}

.feature-card:nth-child(3) {
    --feature-accent: var(--color-accent-lilac);
}

.feature-card:nth-child(4) {
    --feature-accent: var(--color-accent-yellow);
}

.feature-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 24px;
    width: 42px;
    height: 3px;
    background: var(--feature-accent);
}

.feature-card::after {
    content: '0' counter(feature);
    position: absolute;
    top: 22px;
    right: 22px;
    color: var(--color-card-number);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
}

.feature-card h4 {
    color: var(--color-card-heading);
    font-size: 1.0625rem;
    line-height: 1.4;
    margin: 0 36px 18px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: 0;
}

.feature-card h4::before {
    content: '';
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: var(--feature-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--feature-accent) 14%, transparent);
}

.feature-card p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--color-content-secondary);
}

@media (hover: hover) {
    .feature-card:hover {
        background-color: var(--color-card-hover);
        transform: translateY(-4px);
        border-color: var(--color-card-hover-border);
        box-shadow: var(--shadow-card-hover);
    }
}

.back-home-row {
    text-align: left;
    margin: 34px 0 0;
}

.back-home-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    box-sizing: border-box;
    color: var(--color-link);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 10px 18px;
    border: 1px solid var(--color-link-border);
    border-radius: 8px;
    background: var(--color-card);
    transition: color 0.2s, border-color 0.2s, background-color 0.2s, transform 0.2s;
}

.back-home-link:hover {
    color: var(--color-white);
    border-color: var(--color-link-hover-border);
    background-color: var(--color-link-hover);
    transform: translateX(-2px);
}

.back-home-link:focus-visible {
    outline: 2px solid var(--color-white);
    outline-offset: 3px;
}

.footer-note {
    text-align: left;
    color: var(--color-footer);
    font-size: 0.8125rem;
    margin: 80px 0 0;
    padding-top: 24px;
    border-top: 1px solid var(--color-footer-border);
    letter-spacing: 0;
}

/* ═══════════════════════════════════════════
   Apple风格底部工具栏
   ═══════════════════════════════════════════ */

.controls {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    display: flex;
    gap: 6px;

    /* 现代磨砂玻璃背景 */
    background: var(--color-toolbar);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);

    padding: 8px;
    border-radius: 40px;
    border: 1px solid var(--color-toolbar-border);
    box-shadow: var(--shadow-card), inset 0 1px 0 var(--color-toolbar-highlight);

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    opacity: 1;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s ease;
    z-index: 100;
    white-space: nowrap;
}

.controls.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

body.fullscreen .controls {
    bottom: 40px;
    background: var(--color-toolbar-fullscreen);
}

/* 视觉隐藏原生复选框，同时保留键盘焦点和无障碍语义 */
.controls input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* 标签基础样式 */
.controls label {
    cursor: pointer;
    display: block;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

/* 胶囊文字按钮 (默认未选中状态) */
.pill-text {
    display: inline-block;
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-control-muted);
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0;
    user-select: none;
    -webkit-user-select: none;
}

/* 鼠标悬停状态 */
@media (hover: hover) {
    .controls label:hover .pill-text {
        color: var(--color-control-hover);
        background: var(--color-hover-surface);
    }
}

/* 选中/激活状态 */
.controls input[type="checkbox"]:checked+.pill-text {
    background: var(--color-white);
    color: var(--color-control-active);
    font-weight: 600;
    box-shadow: var(--shadow-control);
}

.controls input[type="checkbox"]:focus-visible+.pill-text,
.controls input[type="checkbox"]:focus-visible+.lock-icon {
    outline: 2px solid var(--color-white);
    outline-offset: 2px;
}

/* ──────────── 锁定图标 ──────────── */
.lock-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--color-control-muted);
    transition: color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .controls label:hover .lock-icon {
        color: var(--color-control-hover);
        background: var(--color-hover-surface);
    }
}

#setting-lock-label.lock-active .lock-icon {
    color: var(--color-control-active);
    background: var(--color-white);
    box-shadow: var(--shadow-control);
}

/* 全屏下禁用锁定按钮 */
#setting-lock-label.lock-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

.controls label.control-disabled {
    opacity: 0.35;
    pointer-events: none;
    cursor: not-allowed;
}

/* ──────────── 响应式适配 ──────────── */
@media (max-width: 900px) {
    .content-overview {
        gap: 48px;
    }

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

    .feature-card {
        min-height: 156px;
    }
}

@media (max-width: 600px) {
    .controls {
        gap: 6px;
        padding: 8px;
        border-radius: 24px;
        bottom: calc(24px + env(safe-area-inset-bottom));
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 90%;
        max-width: 340px;
    }

    #setting-lock-label {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .fullscreen-hint {
        bottom: calc(116px + env(safe-area-inset-bottom));
        font-size: 0.75rem;
    }

    #setting-fullscreen-label {
        grid-column: span 2;
    }

    .pill-text {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        padding: 12px 10px;
        font-size: 13px;
        border-radius: 18px;
    }

    body.fullscreen .controls {
        bottom: calc(30px + env(safe-area-inset-bottom));
    }

    .content-section {
        padding: 64px 20px 72px;
    }

    .content-overview {
        display: block;
        padding-bottom: 48px;
    }

    .content-section::before {
        width: calc(100% - 40px);
    }

    .content-section h1 {
        font-size: 1.75rem;
        line-height: 1.3;
        margin-bottom: 18px;
    }

    .content-section .lead-text {
        font-size: 0.9375rem;
        line-height: 1.75;
    }

    .usage-guide {
        margin-top: 48px;
        padding: 32px 0 0;
        border-top: 1px solid var(--color-content-line);
        border-left: 0;
    }

    .content-section h2 {
        font-size: 0.75rem;
        margin: 52px 0 18px;
        gap: 12px;
    }

    .usage-guide h2,
    .feature-section h2 {
        margin-top: 0;
    }

    .feature-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .feature-card {
        min-height: 0;
        padding: 26px 22px;
    }

    .feature-card::before {
        left: 22px;
    }

    .feature-card::after {
        top: 21px;
        right: 22px;
    }

    .feature-card h4 {
        margin-bottom: 12px;
    }

    .back-home-row {
        margin-top: 28px;
    }

    .footer-note {
        margin-top: 56px;
    }
}

@media (max-width: 360px) {
    .controls {
        grid-template-columns: 1fr 1fr;
        width: calc(100% - 24px);
        padding: 6px;
        border-radius: 20px;
    }

    .pill-text {
        padding: 10px;
        font-size: 13px;
    }

    .content-section {
        padding: 52px 16px 64px;
    }

    .content-section::before {
        width: calc(100% - 32px);
    }

    .content-section h1 {
        font-size: 1.55rem;
    }

    .feature-card {
        padding: 24px 20px;
    }

    .feature-card::before {
        left: 20px;
    }

    .feature-card::after {
        right: 20px;
    }
}

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

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-delay: 0ms !important;
        transition-duration: 0.01ms !important;
    }
}
