:root {
    --cci-line: #dedede;
    --cci-line-light: #eceff3;
    --cci-text: #282828;
    --cci-text-muted: #61666c;
    --cci-text-soft: #6b7480;
    --cci-blue: #0086d2;
    --cci-red: #e81b27;
    --cci-green: #52c41a;
    --cci-amber: #faad14;
    --cci-yellow: #ffde08;
    --cci-surface: #ffffff;
    --cci-surface-soft: #f7f9fc;
}

/* ---------------- 基础 ---------------- */
html, body {
    background: var(--cci-surface-soft);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    color: var(--cci-text);
    padding-bottom: 0;
    -webkit-font-smoothing: antialiased;
}

main {
    display: block;
}

/* ---------------- 头部 ---------------- */
.site-header {
    text-align: center;
    padding: 30px 10px 14px;
}

.site-header h1 {
    font-size: 26px;
    font-weight: 700;
    margin: 0 0 8px;
    letter-spacing: 1px;
    color: var(--cci-text);
}

.site-header .subtitle {
    color: var(--cci-text-soft);
    font-size: 13px;
    margin: 0;
}

/* ---------------- 提示条 ---------------- */
.tip-bar {
    background: #fffbe6;
    border: 1px solid var(--cci-yellow);
    color: #8a6d0b;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    line-height: 1.75;
    margin-bottom: 18px;
}

.tip-bar .glyphicon {
    margin-right: 5px;
}

/* ---------------- 卡片 ---------------- */
.card {
    background: var(--cci-surface);
    border-radius: 12px;
    box-shadow: 0 2px 14px rgba(35, 60, 90, .07);
    padding: 18px 20px;
    margin-bottom: 18px;
    border: 1px solid var(--cci-line-light);
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--cci-text-muted);
    margin: 0 0 14px;
    letter-spacing: .5px;
}

.card-title .glyphicon {
    margin-right: 6px;
    color: var(--cci-blue);
}

.control-label {
    font-size: 13px;
    color: var(--cci-text-muted);
    font-weight: 500;
}

/* ---------------- 速度选择 ---------------- */
.speed-group {
    margin-bottom: 4px;
}

.speed-group .btn {
    margin: 0 6px 8px 0;
    min-width: 54px;
    border-radius: 20px !important;
    font-weight: 500;
    color: var(--cci-text-muted);
    border-color: var(--cci-line);
    background: var(--cci-surface-soft);
    transition: all .15s;
}

.speed-group .btn:hover {
    border-color: var(--cci-blue);
    color: var(--cci-blue);
    background: var(--cci-surface);
}

.speed-group .btn.active,
.speed-group .btn.active:focus,
.speed-group .btn.active:hover {
    background: var(--cci-blue);
    border-color: var(--cci-blue);
    color: #fff;
    box-shadow: 0 3px 10px rgba(0, 134, 210, .35);
}

.speed-fine {
    max-width: 120px;
    margin-top: 2px;
}

.speed-fine .form-control {
    text-align: center;
    font-weight: 600;
    color: var(--cci-text);
}

.speed-fine .btn {
    color: var(--cci-text-muted);
}

.speed-fine .btn:hover {
    color: var(--cci-blue);
}

/* ---------------- 字号控制 ---------------- */
.fontsize-ctrl {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 0px;
}

.fontsize-ctrl .btn {
    color: var(--cci-text-muted);
    border-color: var(--cci-line);
    background: var(--cci-surface-soft);
    font-weight: 500;
    transition: all .15s;
}

.fontsize-ctrl .btn:hover {
    border-color: var(--cci-blue);
    color: var(--cci-blue);
    background: var(--cci-surface);
}

.fontsize-ctrl .btn.active,
.fontsize-ctrl .btn.active:focus,
.fontsize-ctrl .btn.active:hover {
    background: var(--cci-blue);
    border-color: var(--cci-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 134, 210, .3);
}

.fontsize-val {
    display: inline-block;
    min-width: 52px;
    text-align: center;
    font-size: 12px;
    color: var(--cci-text-soft);
    font-variant-numeric: tabular-nums;
}

/* ---------------- 字幕区 ---------------- */
.caption-wrap {
    position: relative;
    margin-bottom: 16px;
}

.caption-box {
    background: var(--cci-surface);
    border-radius: 12px;
    box-shadow: 0 2px 14px rgba(35, 60, 90, .07);
    border: 1px solid var(--cci-line-light);
    padding: 26px 22px;
    max-height: 260px;
    min-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.caption-text {
    font-size: 28px;
    line-height: 1.85;
    letter-spacing: 1.5px;
    word-break: break-word;
    white-space: pre-wrap;
    text-align: center;
    display: block;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    cursor: default;
}

.ch {
    padding: 1px 1px;
    border-radius: 3px;
    color: var(--cci-text);
    transition: color .12s, background-color .12s;
}

.ch.ok {
    color: var(--cci-green);
}

.ch.bad {
    color: var(--cci-red);
    background: #fff0f0;
}

.ch.cur {
    background: var(--cci-blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 134, 210, .4);
}

.caption-empty {
    font-size: 15px;
    color: var(--cci-text-soft);
}

/* 暂停遮罩 */
.pause-overlay {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(255, 255, 255, .88);
    border-radius: 12px;
    border: 1px solid var(--cci-line-light);
    display: none;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    z-index: 5;
    cursor: pointer;
    text-align: center;
    padding: 20px;
}

.pause-overlay.show {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
}

.pause-overlay .glyphicon {
    font-size: 38px;
    color: var(--cci-amber);
    margin-bottom: 12px;
    animation: pausePulse 1.6s ease-in-out infinite;
}

@keyframes pausePulse {
    0%, 100% {
        opacity: .75;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

.pause-overlay .po-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--cci-text);
    margin: 0 0 6px;
}

.pause-overlay .po-desc {
    color: var(--cci-text-soft);
    font-size: 12px;
    margin: 0;
}

/* ---------------- 节奏条 ---------------- */
.rhythm-wrap {
    margin-bottom: 18px;
}

.rhythm-head {
    font-size: 12px;
    color: var(--cci-text-soft);
    margin-bottom: 4px;
    height: 20px;
    line-height: 20px;
}

.rhythm-head .pull-right .label {
    font-weight: 500;
    font-size: 11px;
}

.rhythm-track-wrap {
    padding: 8px 0;
}

.rhythm-track {
    position: relative;
    height: 12px;
    background: var(--cci-line-light);
    border-radius: 6px;
}

.rhythm-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--cci-blue), var(--cci-green));
    transition: width .08s linear;
}

.rhythm-target {
    position: absolute;
    top: -7px;
    left: 0;
    width: 3px;
    height: 26px;
    margin-left: -1.5px;
    background: var(--cci-amber);
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(250, 173, 20, .6);
    transition: left .08s linear;
}

.rhythm-legend {
    font-size: 11px;
    color: var(--cci-text-soft);
    margin-top: 8px;
}

.dot-user {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: linear-gradient(90deg, var(--cci-blue), var(--cci-green));
    margin: 0 4px 0 12px;
    vertical-align: middle;
}

.dot-target {
    display: inline-block;
    width: 3px;
    height: 12px;
    background: var(--cci-amber);
    margin: 0 4px 0 12px;
    vertical-align: middle;
    border-radius: 2px;
}

/* ---------------- 统计 ---------------- */
.stats-row {
    margin: 0 -6px 16px;
}

.stat-item {
    text-align: center;
    padding: 8px 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--cci-text);
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 12px;
    color: var(--cci-text-soft);
    margin-top: 3px;
}

.stat-item.is-paused .stat-value {
    color: var(--cci-text-soft);
}

/* ---------------- 输入框 ---------------- */
.type-input {
    font-size: 20px;
    line-height: 1.7;
    letter-spacing: 1px;
    padding: 16px 18px;
    border-radius: 12px;
    border: 2px solid var(--cci-line);
    resize: none;
    height: 110px;
    color: var(--cci-text);
    box-shadow: none;
    transition: border-color .18s, box-shadow .18s;
    background: var(--cci-surface);
}

.type-input:focus {
    border-color: var(--cci-blue);
    box-shadow: 0 0 0 4px rgba(0, 134, 210, .12);
    outline: none;
}

.type-input::-webkit-input-placeholder {
    color: #b8c5d1;
}

.type-input:-moz-placeholder {
    color: #b8c5d1;
}

.type-input::-moz-placeholder {
    color: #b8c5d1;
}

.type-input:-ms-input-placeholder {
    color: #b8c5d1;
}

/* ---------------- 操作按钮 ---------------- */
.action-row {
    margin-top: 14px;
    text-align: center;
}

.action-row .btn {
    border-radius: 20px;
    padding: 7px 24px;
    font-weight: 500;
    border-color: var(--cci-line);
    color: var(--cci-text-muted);
    background: var(--cci-surface);
    margin: 0 4px 8px;
    transition: all .15s;
}

.action-row .btn:hover {
    border-color: var(--cci-blue);
    color: var(--cci-blue);
}

.action-row .btn:focus {
    outline: none;
    border-color: var(--cci-blue);
    color: var(--cci-blue);
    box-shadow: 0 0 0 3px rgba(0, 134, 210, .15);
}

.action-row .btn-primary {
    background: var(--cci-blue);
    border-color: var(--cci-blue);
    color: #fff;
}

.action-row .btn-primary:hover,
.action-row .btn-primary:focus {
    background: #0070b0;
    border-color: #0070b0;
    color: #fff;
}

.action-row .btn[disabled] {
    opacity: .5;
    cursor: not-allowed;
}

/* ---------------- 结果弹窗 ---------------- */
#resultModal .modal-dialog {
    margin-top: 12vh;
    margin-left: auto;
    margin-right: auto;
    max-width: 420px;
    padding-left: 15px;
    padding-right: 15px;
}

#resultModal .modal-content {
    border-radius: 14px;
    border: none;
    box-shadow: 0 12px 48px rgba(35, 60, 90, .18);
}

#resultModal .modal-header {
    border-bottom: none;
    padding-bottom: 0;
}

#resultModal .modal-title {
    font-size: 15px;
    color: var(--cci-text-soft);
    font-weight: 500;
}

#resultModal .modal-footer {
    border-top: none;
    text-align: center;
    padding-bottom: 22px;
}

#resultModal .modal-footer .btn {
    border-radius: 20px;
    padding: 6px 22px;
    font-weight: 500;
    margin: 0 4px;
}

#resultModal .modal-footer .btn-default {
    border-color: var(--cci-line);
    color: var(--cci-text-muted);
}

#resultModal .modal-footer .btn-primary {
    background: var(--cci-blue);
    border-color: var(--cci-blue);
}

#resultModal .modal-footer .btn-primary:hover {
    background: #0070b0;
    border-color: #0070b0;
}

.result-grade {
    text-align: center;
    padding: 4px 0 18px;
}

.grade-badge {
    display: inline-block;
    width: 74px;
    height: 74px;
    line-height: 70px;
    border-radius: 50%;
    font-size: 34px;
    font-weight: 800;
    margin-bottom: 12px;
}

.grade-text {
    font-size: 14px;
    color: var(--cci-text-soft);
}

.g-s .grade-badge {
    background: #fff7e6;
    color: var(--cci-amber);
    border: 2px solid var(--cci-amber);
}

.g-a .grade-badge {
    background: #f0fff0;
    color: var(--cci-green);
    border: 2px solid var(--cci-green);
}

.g-b .grade-badge {
    background: #e6f4ff;
    color: var(--cci-blue);
    border: 2px solid var(--cci-blue);
}

.g-c .grade-badge {
    background: #f4f5f7;
    color: var(--cci-text-soft);
    border: 2px solid var(--cci-text-soft);
}

.g-d .grade-badge {
    background: #fff0f0;
    color: var(--cci-red);
    border: 2px solid var(--cci-red);
}

.result-grid {
    border-top: 1px solid var(--cci-line-light);
    padding-top: 4px;
}

.result-row {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    padding: 10px 2px;
    border-bottom: 1px dashed var(--cci-line-light);
    font-size: 14px;
}

.result-row:last-child {
    border-bottom: none;
}

.result-row .rr-icon {
    width: 20px;
    text-align: center;
    color: var(--cci-text-soft);
    margin-right: 10px;
    font-size: 14px;
}

.result-row .rr-label {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    color: var(--cci-text-soft);
}

.result-row .rr-value {
    color: var(--cci-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------------- 页脚 ---------------- */
.site-footer {
    background: var(--cci-surface);
    border-top: 1px solid var(--cci-line-light);
    margin-top: 34px;
    padding: 28px 0 26px;
    color: var(--cci-text-muted);
    font-size: 13px;
    line-height: 1.9;
}

.site-footer h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--cci-text);
    margin: 0 0 10px;
}

.site-footer h3 {
    font-size: 13px;
    font-weight: 700;
    color: var(--cci-text);
    margin: 16px 0 6px;
}

.site-footer ul {
    padding-left: 18px;
    margin: 0 0 8px;
}

.site-footer li {
    margin-bottom: 3px;
}

.site-footer .copyright {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--cci-line-light);
    color: var(--cci-text-soft);
    font-size: 12px;
    text-align: center;
}

/* ---------------- 无障碍辅助 ---------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 991px) {
    .caption-text {
        letter-spacing: 1px;
    }
}

@media (max-width: 767px) {
    .site-header {
        padding: 20px 6px 10px;
    }

    .site-header h1 {
        font-size: 20px;
    }

    .site-header .subtitle {
        font-size: 12px;
    }

    .caption-box {
        padding: 18px 12px;
        max-height: 300px;
        min-height: 130px;
    }

    .type-input {
        font-size: 17px;
        height: 96px;
    }

    .stat-value {
        font-size: 18px;
    }

    .card {
        padding: 14px 14px;
    }

    .speed-group .btn {
        min-width: 46px;
        padding: 5px 10px;
        font-size: 12px;
    }

    #resultModal .modal-dialog {
        margin-top: 8vh;
    }

    .grade-badge {
        width: 64px;
        height: 64px;
        line-height: 60px;
        font-size: 28px;
    }

    .action-row .btn {
        padding: 6px 16px;
        font-size: 13px;
    }
}

@media (max-width: 479px) {
    .caption-box {
        max-height: 260px;
    }

    .stats-row {
        margin-bottom: 10px;
    }

    .stat-item {
        padding: 6px 2px;
    }
}