* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}
[hidden] {
    display: none !important;
}

:root {
    --bg: #f4f4f6;
    --card: #ffffff;
    --border: #e9e9ee;
    --text: #1d1d21;
    --text2: #77777f;
    --text3: #a9a9b1;
    --accent: #4f46e5;
    --accent2: #818cf8;
    --fill-live: rgba(79, 70, 229, 0.14);
    --fill-done: #f1f1f4;
    --bar-done: #d7d7dd;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    padding-bottom: calc(48px + env(safe-area-inset-bottom));
}

.wrap {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 18px;
}

/* ===== 顶部 ===== */
header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(244, 244, 246, 0.85);
    backdrop-filter: blur(18px) saturate(1.6);
    -webkit-backdrop-filter: blur(18px) saturate(1.6);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
header .wrap {
    padding-top: 16px;
    padding-bottom: 14px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}
.eyebrow {
    font-size: 12px;
    color: var(--text3);
    letter-spacing: 0.4px;
    margin-bottom: 2px;
}
h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 1px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.clock {
    text-align: right;
}
.clock span {
    display: block;
    font-size: 10px;
    color: var(--text3);
    letter-spacing: 3px;
    margin-bottom: 1px;
}
.clock b {
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.edit-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.2s;
}
.edit-btn:active {
    transform: scale(0.94);
}
.edit-btn svg {
    display: block;
}

.seg {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: #e9e9ee;
    border-radius: 14px;
    padding: 4px;
    margin-top: 16px;
}
.seg-btn {
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text2);
    padding: 8px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s;
}
.seg-btn.today:not(.active) {
    color: var(--accent);
    font-weight: 600;
}
.seg-btn.active {
    background: var(--text);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

/* ===== 深色实时状态卡 ===== */
.hero {
    margin-top: 16px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border: 2px solid transparent;
    background: linear-gradient(135deg, #1c1c22 0%, #2a2a33 100%);
    border-radius: 20px;
    padding: 18px 18px 16px;
    color: #fff;
    box-shadow: 0 12px 32px rgba(20, 20, 26, 0.28);
}
.hero.off {
    display: none;
}
.hero-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(255, 255, 255, 0.13);
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
}
.hero-chip i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent2);
}
.hero.live .hero-chip i {
    animation: pulse 1.8s ease-out infinite;
}
.hero-right {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.65);
    font-variant-numeric: tabular-nums;
}
.hero-subject {
    font-size: 19px;
    font-weight: 600;
    margin-top: 12px;
    letter-spacing: 0.3px;
}
.hero-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 13px;
    transition: opacity 0.45s ease;
}
.hero.next .hero-progress {
    opacity: 0;
}
.hero-track {
    flex: 1;
    height: 6px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.13);
    overflow: hidden;
}
.hero-track i {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent2), #a5b4fc);
    transition: width 1s linear;
}
.hero-pct {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    min-width: 34px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.55);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(129, 140, 248, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0);
    }
}

/* 课间状态：白底描边，整卡作为进度条填充 #1c1c22 */
.hero.next {
    background: #fff;
    border-color: #1c1c22;
    box-shadow: 0 10px 28px rgba(20, 20, 26, 0.16);
}
.hero.next::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--gap, 0%);
    background: #1c1c22;
    z-index: -1;
    transition: width 1s linear;
}
.hero.next .hero-chip b,
.hero.next .hero-right,
.hero.next .hero-subject,
.hero.next .hero-pct {
    color: #fff;
    mix-blend-mode: difference;
}
.hero.next .hero-chip {
    background: transparent;
}
.hero.next .hero-track {
    background: #e9e9ee;
}
.hero.next .hero-track i {
    background: #1c1c22;
}

/* ===== 分区标题 ===== */
.sec-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 24px 2px 12px;
}
.day.active > .sec-head:first-child {
    margin-top: 20px;
}
.sec-head::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: var(--text3);
    opacity: 0.6;
}
.sec-head h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    letter-spacing: 2px;
}
.sec-head::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ===== 课程卡片 ===== */
.day {
    display: none;
}
.day.active {
    display: block;
    animation: fade 0.35s ease;
}
@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.card {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 12px;
    --p: 0%;
}
.card + .card {
    margin-top: 10px;
}

.time {
    padding-top: 15px;
    text-align: right;
}
.time b {
    display: block;
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: color 0.3s;
}
.time span {
    display: block;
    font-size: 11px;
    color: var(--text3);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.inner {
    position: relative;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px 15px;
    overflow: hidden;
    transition:
        border-color 0.3s,
        box-shadow 0.3s;
}
.inner::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: var(--p);
    background: var(--fill, transparent);
    border-right: 2px solid transparent;
    transition:
        width 1s linear,
        background 0.3s;
    z-index: 0;
}
.inner::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: var(--p);
    background: var(--barc, transparent);
    transition:
        width 1s linear,
        background 0.3s;
    z-index: 1;
}

.row {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.subject {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
    transition: color 0.3s;
}
.badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    background: #f2f2f5;
    padding: 3px 10px;
    border-radius: 999px;
    transition: all 0.3s;
    font-variant-numeric: tabular-nums;
}
.meta {
    position: relative;
    z-index: 2;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text3);
    letter-spacing: 0.3px;
}

.card.is-done {
    --fill: var(--fill-done);
    --barc: var(--bar-done);
}
.card.is-done .subject {
    color: #9c9ca4;
}
.card.is-done .meta {
    color: #bdbdc4;
}
.card.is-done .time b {
    color: #b3b3ba;
}

.card.is-live {
    --fill: var(--fill-live);
    --barc: var(--accent);
}
.card.is-live .inner {
    border-color: #c7d2fe;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.14);
}
.card.is-live .inner::before {
    border-right-color: var(--accent);
}
.card.is-live .badge {
    background: var(--accent);
    color: #fff;
}
.card.is-live .badge::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #fff;
    margin-right: 6px;
    animation: blink 1.6s infinite;
}
.card.is-live .time b {
    color: var(--accent);
}
@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.25;
    }
}

/* 无课占位卡 */
.card.is-free .inner {
    border-style: dashed;
    background: #fafafb;
    display: flex;
    align-items: center;
    min-height: 62px;
}
.card.is-free .subject {
    color: #b0b0b8;
    font-weight: 500;
    letter-spacing: 2px;
}
.card.is-free.is-done .subject {
    color: #b0b0b8;
}

/* ===== 编辑器 ===== */
.editor {
    position: fixed;
    inset: 0;
    z-index: 50;
}
.ed-sheet {
    position: absolute;
    inset: 0;
    margin: 0 auto;
    max-width: 520px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    animation: sheetIn 0.32s cubic-bezier(0.2, 0.8, 0.3, 1);
}
@keyframes sheetIn {
    from {
        transform: translateY(6%);
        opacity: 0;
    }
}

.ed-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(244, 244, 246, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}
.ed-head b {
    font-size: 16px;
}
.ed-cancel {
    border: 0;
    background: none;
    font: inherit;
    font-size: 14px;
    color: var(--text2);
    padding: 8px 4px;
    cursor: pointer;
}
.ed-save {
    border: 0;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    padding: 7px 18px;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s;
}
.ed-save:active {
    transform: scale(0.94);
}

.ed-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
}

.ed-days {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: #e9e9ee;
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 14px;
}
.ed-days button {
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    padding: 7px 0;
    border-radius: 9px;
    color: var(--text2);
    cursor: pointer;
}
.ed-days button.on {
    background: #fff;
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.ed-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 14px 8px;
    margin-bottom: 10px;
}
.ed-card.free {
    border-style: dashed;
}
.ed-time {
    font-size: 12px;
    color: var(--text2);
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}
.ed-subject {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    font: inherit;
    font-size: 15px;
    background: #fff;
    transition: border-color 0.2s;
}
.ed-subject:focus {
    outline: none;
    border-color: var(--accent2);
}
.ed-subject:disabled {
    background: #f4f4f6;
    color: var(--text3);
}

.ed-campus {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.cap-btn {
    border: 1px solid var(--border);
    background: #fff;
    font: inherit;
    font-size: 12.5px;
    padding: 5px 14px;
    border-radius: 999px;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.2s;
}
.cap-btn.on {
    background: var(--text);
    border-color: var(--text);
    color: #fff;
    font-weight: 500;
}
.ed-tip {
    font-size: 11px;
    color: var(--text3);
}

.ed-toggles {
    margin-top: 10px;
}
.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0;
    border-top: 1px solid #f1f1f4;
    font-size: 13.5px;
    color: var(--text2);
}
.switch {
    position: relative;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}
.switch input {
    position: absolute;
    opacity: 0;
    inset: 0;
    margin: 0;
    cursor: pointer;
    z-index: 1;
}
.switch i {
    position: absolute;
    inset: 0;
    background: #dcdce2;
    border-radius: 999px;
    transition: background 0.25s;
}
.switch i::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + i {
    background: var(--accent);
}
.switch input:checked + i::after {
    transform: translateX(18px);
}

.ed-io {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.ed-io button {
    flex: 1;
    border: 1px dashed #cfcfd6;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--text2);
    padding: 11px 0;
    border-radius: 12px;
    cursor: pointer;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #1c1c22;
    color: #fff;
    font-size: 13px;
    padding: 10px 22px;
    border-radius: 999px;
    z-index: 99;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.3s;
    white-space: nowrap;
}
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, -8px);
    }
}
