@font-face {
    font-family: "TimeFont1";
    src: url("./fonts/TimeFont1.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont2";
    src: url("./fonts/TimeFont2.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont3";
    src: url("./fonts/TimeFont3.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont4";
    src: url("./fonts/TimeFont4.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont5";
    src: url("./fonts/TimeFont5.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont6";
    src: url("./fonts/TimeFont6.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont7";
    src: url("./fonts/TimeFont7.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont8";
    src: url("./fonts/TimeFont8.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont9";
    src: url("./fonts/TimeFont9.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont10";
    src: url("./fonts/TimeFont10.woff2") format("woff2");
    font-display: swap;
}
@font-face {
    font-family: "TimeFont11";
    src: url("./fonts/TimeFont11.woff2") format("woff2");
    font-display: swap;
}

@font-face {
    font-family: "DataFont";
    src: url("./fonts/datafont.woff2") format("woff2");
    font-display: swap;
}

:root {
    --bg-main: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --accent: #10b981;
    --accent-hover: #059669;
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --preview-size: 240px;
    --text-attention: #ffaa01;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
/* 桌面/PWA 滚动条：与深色主题保持一致 */
html { scrollbar-color: #475569 #0f172a; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { border: 2px solid #0f172a; border-radius: 999px; background: #475569; }
::-webkit-scrollbar-thumb:hover { background: #10b981; }
::-webkit-scrollbar-corner { background: #0f172a; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    padding-bottom: 196px;
    font-size: 12px;
}
.update-notice {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 3000;
    display: flex;
    width: min(calc(100% - 24px), 420px);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--accent);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-main);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
    font-size: 13px;
}
.update-notice[hidden] {
    display: none;
}
.update-notice button {
    flex: 0 0 auto;
    border: 0;
    border-radius: 6px;
    padding: 7px 10px;
    background: var(--accent);
    color: #000;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.pull-refresh-indicator {
    position: fixed;
    top: calc(4px + env(safe-area-inset-top, 0px));
    left: 50%;
    z-index: 110;
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--card-border);
    border-radius: 50%;
    background: var(--card-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -44px);
    transition:
        transform 0.18s ease,
        opacity 0.18s ease;
    will-change: transform, opacity;
}
.pull-refresh-indicator.is-pulling {
    opacity: 1;
    transform: translate(-50%, var(--pull-offset, -10px));
}
.pull-refresh-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-sub);
    border-top-color: transparent;
    border-radius: 50%;
}
.pull-refresh-indicator.is-ready .pull-refresh-spinner {
    border-color: var(--accent);
    border-top-color: transparent;
    transform: rotate(135deg);
}

/* 顶部表盘预览区 */
.preview-header {
    --preview-control-right: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.preview-stage {
    display: flex;
    width: 100%;
    justify-content: center;
    gap: 12px;
}
.preview-guide-row {
    position: absolute;
    right: var(--preview-control-right);
    bottom: 6px;
    display: flex;
    width: auto;
    justify-content: flex-end;
    pointer-events: none;
}
.preview-guide-button {
    min-height: 30px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    padding: 5px 9px;
    background: #334155;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    pointer-events: auto;
}
.preview-guide-button:hover,
.preview-guide-button:focus-visible {
    border-color: var(--accent);
    outline: none;
}
@media (min-width: 820px) {
    .preview-guide-row {
        width: auto;
    }
}
.preview-toolbar {
    display: flex;
    width: min(100%, var(--preview-size));
    align-items: stretch;
    gap: 4px;
    margin-bottom: 4px;
}
.preview-panel {
    display: none;
    width: var(--preview-size);
    height: var(--preview-size);
    flex: 0 0 var(--preview-size);
}
.preview-panel.active {
    display: block;
}
.preview-mode-tabs {
    display: flex;
    min-width: 0;
    flex: 1;
    margin-bottom: 0;
    padding: 2px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: #0f172a;
}
.preview-mode-tab {
    flex: 1;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--text-sub);
    padding: 4px 6px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.preview-mode-tab.active {
    background: var(--card-bg);
    color: var(--accent);
}
.preview-header.minimal-preview-disabled .preview-mode-tabs,
.preview-header.minimal-preview-disabled #minimalPreviewPanel {
    display: none;
}
.preview-header.minimal-preview-disabled .preview-toolbar {
    display: none;
}
.pwa-install-button {
    position: absolute;
    top: calc(38px + env(safe-area-inset-top, 0px));
    right: var(--preview-control-right);
    z-index: 1;
    width: 32px;
    height: 32px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--accent);
    cursor: pointer;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
}
.preview-header.minimal-preview-disabled .pwa-install-button {
    top: calc(6px + env(safe-area-inset-top, 0px));
}
.pwa-install-button:hover,
.pwa-install-button:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.watch-screen {
    --label-color: currentColor;
    --time-font-family: "TimeFont4";
    --time-display-width: calc(100% - 36px);
    --time-font-size: 55px;
    --time-letter-spacing: -1px;
    width: var(--preview-size);
    height: var(--preview-size);
    font-family: "DataFont", sans-serif;
    border-radius: 50%;
    background-color: #000;
    background-image: url("./img/bg.svg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    border: 4px solid #334155;
    position: relative;
    display: block;
    padding: 18px;
    overflow: hidden;
    clip-path: circle(50%);
    transition: background-color 0.3s;
}

/* 表盘内部布局预览 */
.preview-row {
    position: absolute;
    right: 18px;
    left: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    z-index: 2;
}
.preview-row2 {
    position: absolute;
    left: 50%;
    width: 56%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 12px;
    transform: translateX(-50%);
    z-index: 2;
}
.preview-top-row {
    top: 25px;
    justify-content: center;
}
.preview-top-combined {
    display: flex;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
}
.preview-top-row .preview-item {
    font-size: 12px;
    flex: 0 1 auto;
}
.preview-upper-row {
    top: 47px;
}
.preview-bottom-row {
    top: calc(50% + 67px);
}
.preview-bottom-row .preview-item {
    font-size: 12px;
}
.preview-field {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    gap: 1px;
}
.preview-align-left {
    align-items: flex-start;
    text-align: left;
}
.preview-align-center {
    align-items: center;
    text-align: center;
}
.preview-align-right {
    align-items: flex-end;
    text-align: right;
}
.preview-label {
    min-height: 9px;
    font-size: 12px;
    /* font-weight: 700; */
    line-height: 1;
    opacity: 0.7;
    color: var(--label-color);
    white-space: nowrap;
}
.preview-center {
    text-align: center;
    /* font-weight: bold; */
    width: 100%;
}
.preview-time {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--time-display-width);
    font-family: var(--time-font-family), sans-serif;
    font-size: var(--time-font-size);
    /* font-weight: 800; */
    line-height: 1;
    margin: 0;
    text-align: center;
    letter-spacing: var(--time-letter-spacing);
    transform: translate(-50%, -50%);
    white-space: nowrap;
    z-index: 2;
}
.preview-one-by-one {
    position: absolute;
    top: calc(50% + 40px);
    right: 18px;
    left: 18px;
    z-index: 2;
}
.preview-one-by-one .preview-item {
    display: block;
    width: 70%;
    max-width: 100%;
    font-size: 12px;
    opacity: 0.9;
}
.preview-item {
    opacity: 0.9;
    white-space: nowrap;
    font-size: 12px;
    overflow: hidden;
    text-overflow: clip;
}

.minimal-watch-screen {
    background-color: #000;
    background-image: none;
}
.minimal-time-cluster {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--time-display-width);
    transform: translate(-50%, -50%);
}
.minimal-preview-time {
    width: 100%;
    font-family: var(--time-font-family), sans-serif;
    font-size: var(--time-font-size);
    /* font-weight: 800; */
    line-height: 1;
    margin: 0;
    text-align: center;
    letter-spacing: var(--time-letter-spacing);
    white-space: nowrap;
}
.minimal-data-row {
    position: absolute;
    right: 10px;
    left: 12px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.minimal-data-upper {
    bottom: calc(100% + 8px);
}
.minimal-data-lower {
    top: calc(100% + 8px);
}
.minimal-data {
    max-width: calc(50% - 4px);
    overflow: hidden;
    font-size: 12px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.minimal-data-left {
    text-align: left;
}
.minimal-data-right {
    text-align: right;
}

@media (min-width: 524px) {
    .preview-header {
        --preview-control-right: 20px;
    }
    .preview-toolbar {
        display: none;
    }
    .preview-mode-tabs {
        display: none;
    }
    .pwa-install-button {
        top: calc(6px + env(safe-area-inset-top, 0px));
        width: 34px;
        height: 34px;
    }
    .preview-panel {
        display: block;
    }
}

/* 布局与卡片容器 */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

.settings-grid {
    display: grid;
    gap: 8px;
}

.settings-section {
    min-width: 0;
}

@media (max-width: 819px) {
    .settings-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .settings-left-column {
        display: contents;
    }

    .settings-left-column > .settings-section:first-of-type {
        order: 1;
    }

    #areaDataSettingsSection {
        order: 2;
    }

    .settings-left-column > .settings-section:not(:first-of-type) {
        order: 3;
    }
}

.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--accent);
    margin: 20px 0 10px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

@media (min-width: 820px) {
    .container {
        max-width: 1120px;
        padding: 20px;
    }

    .settings-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 20px;
        row-gap: 12px;
    }

    .settings-section {
        margin-bottom: 0;
    }

    .settings-left-column {
        grid-column: 1;
        grid-row: 1;
        min-width: 0;
    }

    #areaDataSettingsSection {
        grid-column: 2;
        grid-row: 1;
    }

    .settings-section .section-title {
        margin-top: 12px;
    }
}

.form-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.form-group:last-child {
    border-bottom: none;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    flex: 1;
    padding-right: 10px;
}
.color-form-copy {
    flex: 1;
    min-width: 0;
}
.color-form-copy .form-label {
    padding-right: 0;
}
.color-hint {
    margin-top: 3px;
    color: var(--text-sub);
    font-size: 11px;
    line-height: 1.2;
}
.format-setting-hint {
    max-width: 240px;
    padding: 7px 10px;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text-sub);
    font-size: 12px;
    line-height: 1.35;
    text-align: right;
}

select,
input[type="number"],
input[type="date"] {
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    max-width: 200px;
    text-align: right;
    text-align-last: right;
}
select:focus,
input:focus {
    border-color: var(--accent);
}

/* Switch 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: 0.3s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:checked + .slider:before {
    transform: translateX(20px);
}

/* 颜色卡片与色板弹窗 */
.color-picker-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 104px;
    justify-content: flex-end;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 5px 8px;
    background: #0f172a;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
}
.color-picker-trigger:focus-visible,
.palette-color-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.color-value {
    font-family: monospace;
    font-size: 12px;
}

/* 屏幕模式 Tab 切换 */
.screen-tabs {
    display: flex;
    background: #0f172a;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--card-border);
    margin-bottom: 12px;
}
.tab-btn {
    flex: 1;
    padding: 8px;
    text-align: center;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-sub);
    transition: 0.2s;
}
.tab-btn.active {
    background: var(--card-bg);
    color: var(--accent);
}

/* 网格多选 */
.grid-switches {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 6px;
}
.grid-switch-item {
    background: #0f172a;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}
.weather-switch-copy {
    min-width: 0;
    padding-right: 8px;
}
.weather-switch-label {
    display: block;
}
.weather-source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 5px;
    margin-top: 4px;
    font-size: 10px;
    line-height: 1.2;
}
.weather-source {
    white-space: nowrap;
}
.weather-source.is-supported {
    color: #6ee7b7;
}
.weather-source.is-unsupported {
    color: var(--text-sub);
    opacity: 0.72;
}
@media (max-width: 523px) {
    #cusSummaryGrid {
        grid-template-columns: 1fr;
    }
    .weather-switch-copy {
        flex: 1;
    }
}

/* 底部固定代码工具栏 */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--card-border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: transform 0.22s ease;
    will-change: transform;
}
.bottom-bar.is-hidden {
    pointer-events: none;
    transform: translateY(calc(100% + 8px));
}
.code-display {
    font-family: monospace;
    font-size: 12px;
    background: #000;
    color: #34d399;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    overflow-x: auto;
    overflow-y: hidden;
    text-align: left;
    user-select: all;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}
.btn-group {
    display: flex;
    gap: 10px;
}
.btn {
    flex: 1;
    padding: 12px 6px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}
.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:active {
    background: var(--accent-hover);
}
.btn-secondary {
    background: #334155;
    color: var(--text-main);
}

/* 本地配置方案 */
.saved-profile-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 8px;
}
.saved-profile-current,
.saved-profile-save,
.saved-profile-manage {
    min-height: 38px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: #0f172a;
    color: #eeeeee;
    cursor: pointer;
    font: inherit;
}
.saved-profile-current {
    min-width: 0;
    padding: 5px 10px;
    text-align: left;
}
.saved-profile-caption,
.saved-profile-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-profile-caption {
    color: var(--text-sub);
    font-size: 10px;
    line-height: 1.1;
}
.saved-profile-name {
    color: #6283cb;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
}
.saved-profile-save {
    border-color: #34559d;
    background: #0f172a;
    color: #6283cb;
    padding: 0 12px;
}
.saved-profile-save:hover,
.saved-profile-save:focus-visible {
    border-color: #60a5fa;
    background: #172554;
    outline: none;
}
.saved-profile-manage {
    padding: 0 12px;
}
.saved-profiles-modal {
    max-width: 520px;
}
.saved-profiles-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.saved-profiles-title {
    font-size: 16px;
    font-weight: 700;
}
.saved-profiles-subtitle {
    margin-top: 3px;
    color: var(--text-attention);
    font-size: 11px;
}
.icon-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--card-border);
    border-radius: 6px;
    background: #334155;
    color: var(--text-main);
    cursor: pointer;
    font: 20px/1 sans-serif;
}
.save-profile-form {
    display: flex;
    gap: 8px;
}
.save-profile-form input {
    min-width: 0;
    flex: 1;
    max-width: none;
    text-align: left;
    text-align-last: left;
}
.save-profile-form .btn {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    font-size: 12px;
}
.saved-profiles-list {
    display: flex;
    max-height: 64vh;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}
.saved-profile-item {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--card-border);
    border-radius: 7px;
    background: #0f172a;
    padding: 8px;
}
.saved-profile-item.active {
    border-color: var(--accent);
}
.saved-profile-swatch {
    width: 32px;
    height: 32px;
    border: 2px solid var(--secondary-color);
    border-radius: 50%;
    background: var(--main-color);
    box-shadow: inset 0 0 0 7px #000;
}
.saved-profile-load {
    min-width: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-align: left;
}
.saved-profile-item-name,
.saved-profile-item-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-profile-item-name {
    color: var(--text-main);
    font-size: 13px;
    font-weight: 700;
}
.saved-profile-item-meta {
    margin-top: 3px;
    color: var(--text-sub);
    font-size: 10px;
}
.saved-profile-actions {
    display: flex;
    gap: 4px;
}
.saved-profile-actions .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
}
.saved-profiles-section-heading {
    padding: 8px 2px 4px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}
.saved-profiles-empty {
    padding: 24px 12px;
    color: var(--text-sub);
    text-align: center;
}

@media (min-width: 820px) {
    body {
        padding-bottom: 124px;
    }
    .bottom-bar {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
        column-gap: 12px;
        row-gap: 8px;
        align-items: stretch;
    }
    .code-display {
        display: flex;
        align-items: center;
        min-width: 0;
    }
    .saved-profile-toolbar {
        min-width: 0;
    }
    .bottom-bar > .btn-group {
        grid-column: 1 / -1;
    }
}
.pwa-install-guide {
    max-width: 360px;
}
.pwa-install-guide-text {
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.5;
}
.modal-content.guide-modal-content {
    width: min(100%, 1233px);
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow: auto;
}
.guide-video-link {
    align-self: flex-start;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.guide-video-link:hover,
.guide-video-link:focus-visible {
    color: #34d399;
    text-decoration: underline;
    outline: none;
}
.guide-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: calc(100vh - 148px);
    max-height: calc(100dvh - 148px);
    margin: 0 auto;
    object-fit: contain;
}

/* Modal 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.active {
    display: flex;
}
.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    width: 100%;
    max-width: 450px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modal-content textarea {
    width: 100%;
    height: 100px;
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    font-family: monospace;
    resize: none;
}
.btn-send-watch {
    background: #7c3aed;
    color: #fff;
    flex-direction: column;
    gap: 1px;
    line-height: 1.05;
    padding: 4px 6px;
}
.send-watch-label {
    display: block;
    padding: 4px;
}
.send-watch-sub {
    display: block;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.82;
    text-decoration: underline;
}
.send-watch-modal {
    max-width: 500px;
}
.send-watch-intro {
    margin: 0;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
    padding: 4px 0;
}
.send-watch-step input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 12px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
    background: #0f172a;
    color: var(--text-main);
    font-size: 14px;
}
.send-watch-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.send-watch-error {
    min-height: 18px;
    color: #f87171;
    font-size: 12px;
}
.theme-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.theme-option {
    flex: 1;
    min-width: 90px;
    cursor: pointer;
}
.theme-option input {
    position: absolute;
    opacity: 0;
}
.theme-option span {
    display: block;
    text-align: center;
    padding: 12px 8px;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-main);
}
.theme-status {
    display: block;
    min-height: 30px;
    margin-top: 5px;
    color: var(--text-sub);
    font-size: 11px;
    line-height: 1.45;
    text-align: center;
    white-space: pre-line;
    overflow: visible;
    word-break: normal;
}
.theme-status.is-sent {
    color: #34d399;
}
.theme-status.is-pending {
    color: #fbbf24;
}
.theme-status.is-failed {
    color: #f87171;
}
.watch-shared-update-alert {
    margin: 10px 0;
    padding: 14px 10px;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.6;
    text-align: center;
}
.watch-shared-update-alert[hidden] {
    display: none;
}
.watch-shared-update-message {
    margin-bottom: 8px;
    font-size: 15px;
    animation: watch-alert-pulse 1.2s ease-in-out infinite;
}
.watch-todo-image {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    border-radius: 6px;
}
.watch-todo-image-button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
}
.todo-image-modal {
    z-index: 3000;
    padding: 12px;
}
.todo-image-modal-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.todo-image-modal-content img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.todo-image-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
}
@keyframes watch-alert-pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.03);
    }
}
@media (prefers-reduced-motion: reduce) {
    .watch-shared-update-message {
        animation: none;
    }
}
.theme-option input:checked + span {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.2);
}
.change-activation-link {
    border: 0;
    background: none;
    color: var(--text-sub);
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
    align-self: flex-start;
    padding: 6px 0;
}
.send-watch-result {
    color: #86efac;
    line-height: 1.7;
    font-size: 18px;
    text-align: center;
    white-space: pre-line;
    padding: 12px 0 14px 0;
}
.send-watch-status {
    margin: 8px 0;
    color: var(--text-sub);
    font-size: 12px;
}
.send-watch-done-button {
    width: 100%;
    margin-top: 8px;
    font-size: 16px;
}
@media (max-width: 560px) {
    .send-watch-modal {
        max-width: none;
        padding: 16px;
    }
    .send-watch-actions {
        flex-wrap: wrap;
    }
    .send-watch-actions .btn {
        flex: 1;
    }
}
.mip-color-notice-content {
    max-width: 390px;
}
.mip-color-notice-content p {
    color: var(--text-main);
    font-size: 13px;
    line-height: 1.65;
}
.mip-color-notice-content p a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}
.mip-notice-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-sub);
    font-size: 12px;
    cursor: pointer;
}
.mip-notice-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}
.color-modal {
    align-items: flex-end;
    padding: 0;
    background: rgba(0, 0, 0, 0.65);
}
.color-modal .modal-content {
    max-width: 520px;
    max-height: min(86vh, 720px);
    padding: 0;
    border-radius: 18px 18px 0 0;
    gap: 0;
    overflow: hidden;
}
.color-modal-header,
.color-modal-footer {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.color-modal-header {
    border-bottom: 1px solid var(--card-border);
    font-weight: 700;
    font-size: 13px;
}
.screen-eyedropper-button { min-height:28px; padding:4px 6px; font-size:10px; margin-left:auto; flex:0 0 auto; }
.eyedropper-result { display:flex; align-items:center; gap:4px; color:var(--text-sub); font:10px monospace; white-space:nowrap; }
.eyedropper-result i { display:inline-block; width:16px; height:16px; border:1px solid var(--card-border); border-radius:4px; background:#000; }
.screen-eyedropper-button[hidden], .eyedropper-result[hidden] { display:none; }
.color-picker-close {
    flex: 0 0 auto;
    min-width: 52px;
    padding: 6px 10px;
    line-height: 1;
    white-space: nowrap;
}
.color-modal-body {
    overflow-y: auto;
    padding: 12px;
}
.palette-mode-label {
    color: var(--text-sub);
    font-size: 11px;
    text-align: center;
    margin-bottom: 8px;
}
.color-recommendations {
    margin: 0 0 10px;
    padding: 8px 0 10px;
    border-top: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
}
.color-recommendation-heading {
    color: var(--text-main);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}
.color-recommendation-grid {
    /* Grid 不被旧安卓 WebView 支持时，使用可换行的 Flex 布局。 */
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: -4px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.color-recommendation-btn {
    width: calc(25% - 8px);
    margin: 4px;
    -webkit-flex: 0 0 calc(25% - 8px);
    flex: 0 0 calc(25% - 8px);
    height: 30px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    background: var(--color);
    cursor: pointer;
}
.color-recommendation-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.color-recommendation-btn.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.45);
    transform: scale(1.06);
}
.color-palette-grid {
    /* 先声明 Flex 回退：不支持 CSS Grid 的旧浏览器不会把色块压成一条线。 */
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    margin: -4px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.palette-color-btn {
    width: calc(16.6667% - 8px);
    height: 44px;
    margin: 4px;
    -webkit-flex: 0 0 calc(16.6667% - 8px);
    flex: 0 0 calc(16.6667% - 8px);
    aspect-ratio: 1;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9px;
    background: var(--color);
    cursor: pointer;
    transition:
        transform 0.15s,
        box-shadow 0.15s,
        border-color 0.15s;
}
/* 现代浏览器继续使用原本等宽方形的 Grid 布局；上面的尺寸仅服务旧浏览器。 */
@supports (display: grid) {
    .color-recommendation-grid,
    .color-palette-grid {
        margin: 0;
    }
    .color-recommendation-btn,
    .palette-color-btn {
        width: auto;
        margin: 0;
    }
    .palette-color-btn {
        -webkit-flex: initial;
        flex: initial;
    }
}
@supports (aspect-ratio: 1) {
    .palette-color-btn {
        height: auto;
    }
}
/* MIP 调色板：每色以“色名色块 + 色码”呈现。A 屏不使用这些规则。 */
.color-palette-grid.mip-color-palette {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.mip-color-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: auto;
    aspect-ratio: auto;
    margin: 0;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
    color: var(--text-main);
    transform: none;
}
.mip-color-card .mip-color-name {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 4px 3px;
    background: var(--color);
    color: var(--mip-text-color, #fff);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    word-break: break-all;
}
.mip-color-card .mip-color-code {
    display: block;
    padding: 4px 2px 5px;
    color: var(--text-sub);
    font: 10px/1.1 monospace;
    letter-spacing: 0.2px;
    text-align: center;
}
.palette-color-btn.mip-color-card:active,
.palette-color-btn.mip-color-card.selected {
    transform: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}
/* 不支持 Grid 的浏览器继续使用三列可换行 Flex 布局。 */
@supports not (display: grid) {
    .color-palette-grid.mip-color-palette .mip-color-card {
        width: calc(33.3334% - 8px);
        margin: 4px;
        -webkit-flex: 0 0 calc(33.3334% - 8px);
        flex: 0 0 calc(33.3334% - 8px);
    }
}
@media (min-width: 460px) {
    .color-palette-grid.mip-color-palette {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
.palette-color-btn:active,
.palette-color-btn.selected {
    transform: scale(1.08);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
}
.custom-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--card-border);
}
.custom-color-row label {
    color: var(--text-sub);
    font-size: 12px;
}
.custom-color-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.custom-color-controls input[type="text"] {
    width: 88px;
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px;
    border-radius: 7px;
    font: 12px monospace;
    text-transform: uppercase;
}
.custom-color-controls input[type="text"].is-invalid {
    border-color: #fb7185;
}
.native-color-input {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--card-border);
    border-radius: 50%;
    overflow: hidden;
    background: none;
    cursor: pointer;
}
.native-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}
.native-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}
@media (min-width: 540px) {
    .color-modal {
        align-items: center;
        padding: 20px;
    }
    .color-modal .modal-content {
        border-radius: 18px;
    }
}

@media (min-height: 720px) {
    .color-modal {
        --preview-clearance: 304px;
        align-items: flex-end;
        padding: var(--preview-clearance) 0 0;
        background: linear-gradient(to bottom, transparent 0, transparent var(--preview-clearance), rgba(0, 0, 0, 0.65) var(--preview-clearance));
    }
    .color-modal .modal-content {
        max-height: calc(100vh - var(--preview-clearance));
        border-radius: 14px 14px 0 0;
    }
}

@media (max-width: 523px) and (min-height: 720px) {
    .color-modal {
        --preview-clearance: calc(320px + env(safe-area-inset-top, 0px));
    }
}
