/* XLB · 极简分组列表主题 */
:root {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --separator: rgba(60, 60, 67, 0.12);
    --text: #1c1c1e;
    --text-2: #3a3a3c;
    --text-3: #8e8e93;
    --primary: #5856d6;
    --primary-press: #4745b5;
    --primary-bg: #ededff;
    --green: #34c759;
    --green-bg: #e8faf0;
    --red: #ff3b30;
    --red-bg: #ffeceb;
    --orange: #ff9500;
    --orange-bg: #fff4e5;
    --radius: 12px;
    --radius-lg: 16px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --header-h: 52px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    padding-bottom: var(--safe-b);
}

a { color: inherit; text-decoration: none; }

.mi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    vertical-align: middle;
    user-select: none;
    color: inherit;
}

.mi svg {
    display: block;
    width: 20px;
    height: 20px;
}

.mi svg.mi-spin {
    animation: mi-spin 0.8s linear infinite;
    transform-origin: center;
}

@keyframes mi-spin {
    to { transform: rotate(360deg); }
}

.page {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.page-wide {
    max-width: 960px;
}

/* 顶栏 */
.page-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    padding: 0 8px 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(242, 242, 247, 0.88);
    backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 0.5px solid var(--separator);
}

.page-header h1 {
    flex: 1;
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    padding-right: 40px;
}

.page-header .page-back {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--primary);
    transition: background 0.15s var(--ease);
}

.page-header .page-back:active {
    background: rgba(88, 86, 214, 0.12);
}

.page-header.is-home h1 {
    text-align: left;
    padding: 0 12px;
    font-size: 20px;
    font-weight: 700;
}

.page-header.is-home .page-back {
    display: none;
}

.page-main {
    flex: 1;
    padding: 12px 16px 24px;
}

/* 公告条 */
.banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--primary-bg);
    color: var(--primary-press);
    font-size: 14px;
    line-height: 1.55;
    font-weight: 500;
}

/* 分组 */
.group {
    margin-bottom: 22px;
}

.group-label {
    padding: 0 12px 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.group-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 52px;
    position: relative;
    transition: background 0.12s var(--ease);
}

.row:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 56px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--separator);
}

.row:active {
    background: rgba(0, 0, 0, 0.04);
}

.row-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 20px;
}

.row-icon.purple { background: #ededff; color: var(--primary); }
.row-icon.green { background: var(--green-bg); color: var(--green); }
.row-icon.blue { background: #e3f2fd; color: #1976d2; }
.row-icon.orange { background: var(--orange-bg); color: var(--orange); }
.row-icon.gray { background: #f2f2f7; color: var(--text-2); }

.row-body {
    flex: 1;
    min-width: 0;
}

.row-title {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
}

.row-desc {
    display: block;
    font-size: 13px;
    color: var(--text-3);
    margin-top: 1px;
    line-height: 1.4;
}

.row-chevron {
    color: var(--text-3);
    font-size: 20px;
    opacity: 0.5;
}

.row-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
    margin-left: 6px;
    vertical-align: 2px;
}

.row-badge.admin { background: var(--orange-bg); color: #c93400; }
.row-badge.user { background: var(--primary-bg); color: var(--primary); }

.page-foot {
    text-align: center;
    padding: 8px 16px 20px;
    font-size: 12px;
    color: var(--text-3);
}

/* 表单页 */
.sheet {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin-bottom: 16px;
}

.sheet-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.sheet-desc {
    font-size: 14px;
    color: var(--text-3);
    line-height: 1.55;
    margin-bottom: 20px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    font: inherit;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    border: none;
    border-radius: var(--radius);
    outline: none;
    transition: box-shadow 0.15s var(--ease);
}

.field textarea {
    min-height: 100px;
    padding: 12px 14px;
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

.field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    padding: 0 20px;
    border: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s var(--ease), opacity 0.15s, background 0.15s;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-fill {
    color: #fff;
    background: var(--primary);
}

.btn-fill:active:not(:disabled) {
    background: var(--primary-press);
}

.btn-tint {
    color: var(--primary);
    background: var(--primary-bg);
}

.btn-plain {
    color: var(--primary);
    background: transparent;
    min-height: 44px;
}

.btn.is-loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn.is-loading .mi {
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 结果卡片 */
.result {
    display: none;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 14px;
    line-height: 1.55;
    animation: slideUp 0.35s var(--ease);
}

.result.is-show {
    display: flex;
}

.result.ok {
    background: var(--green-bg);
    color: #1a7f3c;
}

.result.err {
    background: var(--red-bg);
    color: #c41e16;
}

.result strong { font-weight: 700; }

.result-title {
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 15px;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 折叠说明 */
.details {
    background: var(--surface);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

.details summary {
    list-style: none;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.details summary::after {
    content: '';
    width: 8px;
    height: 8px;
    margin-left: 8px;
    border-right: 2px solid var(--text-3);
    border-bottom: 2px solid var(--text-3);
    transform: rotate(45deg);
    transition: transform 0.2s var(--ease);
}

.details[open] summary::after {
    transform: rotate(225deg);
}

.details-body {
    padding: 0 16px 14px;
    font-size: 14px;
    color: var(--text-3);
    line-height: 1.65;
}

.details-body ol {
    padding-left: 18px;
}

.details-body li {
    margin-bottom: 6px;
}

/* 卡密列表 */
.key-box {
    margin-top: 16px;
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 8px;
}

.key-line {
    padding: 10px 12px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    border-radius: 8px;
}

.key-line + .key-line {
    margin-top: 4px;
}

.key-line:nth-child(odd) {
    background: rgba(255, 255, 255, 0.7);
}

.link-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.link-row .btn {
    flex: 1;
}

/* Toast */
.toast-host {
    position: fixed;
    left: 50%;
    bottom: calc(20px + var(--safe-b));
    transform: translateX(-50%) translateY(20px);
    z-index: 9999;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: rgba(28, 28, 30, 0.92);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s var(--ease);
    white-space: nowrap;
}

.toast-host.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 统计条 */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-cell {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 8px;
    text-align: center;
}

.stat-cell b {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-cell span {
    font-size: 11px;
    color: var(--text-3);
}

.empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-3);
    font-size: 14px;
}

.data-list {
    font-size: 14px;
    color: var(--text-2);
    line-height: 1.6;
}

.data-list li {
    padding: 8px 0;
    border-bottom: 0.5px solid var(--separator);
    word-break: break-all;
}

.data-list li:last-child {
    border-bottom: none;
}

@media (min-width: 640px) {
    .page-main {
        padding: 20px 24px 32px;
    }

    .field-row {
        grid-template-columns: 1fr 1fr;
    }
}

.home-lead {
    margin: 4px 0 20px;
    padding: 0 4px;
    font-size: 14px;
    color: var(--text-3);
    line-height: 1.5;
}

.row.is-static {
    cursor: default;
}

.row.is-static:active {
    background: transparent;
}

.row-tap-copy {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.row-tap-copy:active {
    background: rgba(0, 0, 0, 0.04);
}

.row-tap-copy .copy-url {
    word-break: break-all;
}

.row-copy-hint {
    opacity: 0.35;
    flex-shrink: 0;
}

.row-tap-copy.is-done .row-copy-hint {
    opacity: 1;
    color: var(--green);
}

.page-foot-link {
    display: inline-block;
    margin-left: 10px;
    color: var(--text-3);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.page-foot-link:active {
    color: var(--primary);
}

.voice-picker {
    max-height: 220px;
    overflow: auto;
    border: 0.5px solid var(--separator);
    border-radius: var(--radius);
    margin-top: 8px;
    background: var(--surface);
}

.voice-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}

.voice-item:last-child {
    border-bottom: 0;
}

.voice-item.is-active {
    background: var(--primary-bg);
}

.voice-item strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.voice-item span {
    display: block;
    font-size: 12px;
    color: var(--text-3);
    margin-top: 2px;
}

.player-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.selected-voice-pill {
    min-height: 50px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--bg);
    font-size: 15px;
    color: var(--text-3);
    line-height: 1.4;
}

.selected-voice-pill.is-picked {
    color: var(--primary-press);
    font-weight: 600;
    background: var(--primary-bg);
}

.play-result[hidden] {
    display: none !important;
}

.play-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 4px 0;
}

.play-btn {
    width: 64px;
    height: 64px;
    border: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--primary);
    box-shadow: 0 4px 14px rgba(88, 86, 214, 0.3);
    cursor: pointer;
    transition: transform 0.12s var(--ease), background 0.15s var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.play-btn .mi svg {
    width: 28px;
    height: 28px;
}

.play-btn:active {
    transform: scale(0.94);
}

.play-btn.is-playing {
    background: var(--green);
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
}

.play-hint {
    font-size: 13px;
    color: var(--text-3);
}

.details-note {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--text-3);
    line-height: 1.55;
}

.field input[type="range"] {
    min-height: auto;
    padding: 0;
    background: transparent;
    accent-color: var(--primary);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
