/* ============================================================
   断局页 + 记录库（手机端）
   配色沿用 base.css：宣纸 / 松烟墨 / 朱砂 / 细金线
   所有类名以 jd- / rec- 开头，避免与其他组件样式冲突。
   ============================================================ */

/* 弹性容器必须允许收缩，避免长文本把 390px 页面撑宽 */
.jd-head,
.jd-head-copy,
.jd-title-row,
.jd-acc,
.jd-seg,
.rec-head,
.rec-head-copy,
.rec-stat,
.rec-stat-main,
.rec-stat-block,
.rec-stat-flags,
.rec-chips,
.rec-chip,
.rec-list,
.rec-list-head,
.rec-row,
.rec-row-top,
.rec-row-meta,
.rec-row-actions,
.rec-cat-list,
.rec-cat-option,
.rec-newcat,
.rec-sheet-head,
.rec-sheet-heading,
.rec-sheet-body,
.rec-sheet-foot,
.rec-confirm,
.rec-confirm-sub {
    min-width: 0;
}

/* ============================================================
   断局页
   ============================================================ */

.jd-page {
    gap: 12px;
}

.jd-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 2px 0;
}

.jd-head-copy {
    flex: 1 1 auto;
}

.jd-title-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.jd-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.1em;
    line-height: 1.2;
    color: var(--ink);
}

.jd-mode-badge {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 500;
    line-height: 1;
    padding: 4px 7px;
    border-radius: 5px;
    color: var(--ink-soft);
    background: var(--paper-mid);
    border: 1px solid var(--line-soft);
    white-space: nowrap;
}

.jd-save {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 14px;
    font-size: 13px;
    letter-spacing: 0.12em;
}

.jd-top {
    padding: 11px 12px 12px;
}

.jd-top .section-head {
    margin-bottom: 9px;
}

/* 局信息条：沿用 base.css 的 .meta-bar/.meta-item，只改分节线 */
.jd-meta {
    margin-top: 10px;
    padding: 9px 2px 0;
    border-top: 1px dashed var(--line-soft);
    border-bottom: 0;
}

.jd-board-card {
    padding: 10px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.jd-write {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.jd-write .section-head {
    margin-bottom: 0;
}

.jd-textarea {
    width: 100%;
    display: block;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card-alt);
    color: var(--ink);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.78;
    padding: 10px 11px;
    resize: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.jd-textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(176, 138, 62, 0.14);
}

.jd-textarea::placeholder {
    color: var(--ink-faint);
}

/* 断语至少 8 行高，内容超出时框内滚动 */
.jd-duanyu {
    min-height: 182px;
    max-height: 46vh;
}

.jd-feedback {
    min-height: 116px;
    max-height: 40vh;
}

/* 评价三选一：手机友好的 segmented 按钮 */
.jd-acc {
    display: flex;
    align-items: center;
    gap: 10px;
}

.jd-acc-label {
    flex: 0 0 auto;
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--ink-faint);
}

.jd-seg {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper-mid);
}

.jd-seg-btn {
    height: 36px;
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ink-soft);
    letter-spacing: 0.06em;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.jd-seg-btn:active {
    opacity: 0.8;
}

.jd-seg-btn.active {
    background: var(--card);
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(43, 39, 33, 0.14), inset 0 0 0 1px rgba(176, 138, 62, 0.45);
}

.jd-seg-ok.active {
    color: var(--wood);
    box-shadow: 0 1px 3px rgba(43, 39, 33, 0.14), inset 0 0 0 1px rgba(47, 107, 58, 0.42);
}

.jd-seg-bad.active {
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(43, 39, 33, 0.14), inset 0 0 0 1px rgba(156, 43, 43, 0.42);
}

.jd-hint {
    padding: 0 4px 8px;
    text-align: center;
    font-size: 9.5px;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
}

/* ============================================================
   记录库
   ============================================================ */

.rec-page {
    gap: 11px;
}

.rec-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 2px 0;
}

.rec-head-copy {
    flex: 1 1 auto;
}

.rec-head-title {
    margin-top: 2px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.1em;
    line-height: 1.2;
    color: var(--ink);
}

.rec-head-new {
    flex: 0 0 auto;
    height: 38px;
    padding: 0 12px;
    font-size: 12px;
    letter-spacing: 0.04em;
}

/* ---------------- 顶部统计卡 ---------------- */

.rec-stat {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rec-stat-main {
    display: flex;
    align-items: center;
    gap: 14px;
}

.rec-stat-block {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rec-stat-label {
    font-size: 10px;
    letter-spacing: 0.14em;
    color: var(--ink-faint);
}

.rec-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.rec-stat-unit {
    margin-left: 4px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
}

.rec-stat-rate {
    color: var(--accent);
}

.rec-stat-divider {
    flex: 0 0 auto;
    width: 1px;
    align-self: stretch;
    background: linear-gradient(180deg, transparent, var(--line), transparent);
}

.rec-stat-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rec-mini {
    font-size: 10.5px;
    line-height: 1;
    padding: 6px 9px;
    border-radius: 999px;
    border: 1px solid var(--line-soft);
    background: var(--card-alt);
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rec-mini-ok {
    color: var(--wood);
    border-color: rgba(47, 107, 58, 0.28);
    background: rgba(47, 107, 58, 0.06);
}

.rec-mini-bad {
    color: var(--accent);
    border-color: rgba(156, 43, 43, 0.26);
    background: rgba(156, 43, 43, 0.05);
}

.rec-mini-none {
    color: var(--ink-faint);
}

/* ---------------- 分类横向 chips ---------------- */

.rec-chips {
    display: flex;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 2px 3px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-x;
}

.rec-chips::-webkit-scrollbar {
    display: none;
}

.rec-chip {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    min-width: 92px;
    max-width: 220px;
    min-height: 46px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--card);
    text-align: left;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.rec-chip:active {
    background: var(--paper-mid);
}

.rec-chip.active {
    border-color: var(--gold);
    background: linear-gradient(180deg, #FFFAF0, #FBF2DF);
    box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.22);
}

.rec-chip-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ink);
}

.rec-chip.active .rec-chip-name {
    color: var(--accent);
}

.rec-chip-meta {
    font-size: 9.5px;
    line-height: 1;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rec-chip.active .rec-chip-meta {
    color: var(--gold-deep);
}

/* 分类操作按钮（仅选中自建分类时出现） */
.rec-cat-tools {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: -3px;
}

.rec-btn-sm {
    height: 36px;
    padding: 0 12px;
    font-size: 12px;
    letter-spacing: 0.04em;
}

/* ---------------- 记录列表 ---------------- */

.rec-list-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 2px 0;
}

.rec-list-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--ink);
}

.rec-list-title::before {
    content: "";
    flex: 0 0 auto;
    width: 3px;
    height: 12px;
    border-radius: 1px;
    background: linear-gradient(180deg, var(--gold), rgba(176, 138, 62, 0.35));
}

.rec-list-meta {
    flex: 0 0 auto;
    font-size: 10px;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.rec-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rec-row {
    padding: 11px 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.rec-row-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.rec-row-time {
    flex: 0 0 auto;
    margin-right: 2px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.rec-badge {
    flex: 0 0 auto;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 5px;
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.rec-badge-style {
    color: var(--accent);
    background: rgba(156, 43, 43, 0.06);
    border-color: rgba(156, 43, 43, 0.2);
}

.rec-badge-ok {
    color: var(--wood);
    background: rgba(47, 107, 58, 0.08);
    border-color: rgba(47, 107, 58, 0.26);
}

.rec-badge-bad {
    color: var(--accent);
    background: rgba(156, 43, 43, 0.08);
    border-color: rgba(156, 43, 43, 0.26);
}

.rec-badge-none {
    color: var(--ink-faint);
    background: var(--card-alt);
    border-color: var(--line-soft);
}

.rec-row-note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.rec-row-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 9.5px;
    line-height: 1.4;
    color: var(--ink-faint);
}

.rec-row-cat {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--gold-deep);
}

.rec-row-created {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

.rec-row-actions {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--line-soft);
}

.rec-act {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 37px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--card-alt);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.05em;
    transition: background 0.12s ease, transform 0.12s ease;
}

.rec-act:active {
    transform: scale(0.985);
    background: var(--paper-deep);
}

.rec-act-main {
    color: var(--accent);
    font-weight: 600;
    background: rgba(156, 43, 43, 0.05);
    border-color: rgba(156, 43, 43, 0.26);
}

.rec-act-danger {
    color: var(--accent);
    background: transparent;
    border-color: rgba(156, 43, 43, 0.18);
}

/* ---------------- 空状态 ---------------- */

.rec-empty {
    padding: 34px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.rec-empty-seal {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    border: 1px solid rgba(176, 138, 62, 0.5);
    background: rgba(233, 218, 185, 0.25);
    color: var(--gold-deep);
    font-size: 15px;
    font-family: "Kaiti SC", "STKaiti", "KaiTi", var(--font);
}

.rec-empty-text {
    max-width: 250px;
    font-size: 12px;
    line-height: 1.85;
    color: var(--ink-faint);
}

.rec-foot-note {
    padding: 2px 4px 6px;
    text-align: center;
    font-size: 9.5px;
    line-height: 1.7;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
}

.rec-foot-warn {
    display: block;
    margin-top: 3px;
    color: var(--accent);
}

/* ============================================================
   通用底部弹层
   ============================================================ */

.rec-sheet-mask {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(43, 39, 33, 0.44);
    animation: rec-mask-in 0.18s ease;
}

.rec-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--kb, 0px);
    z-index: 71;
    display: flex;
    flex-direction: column;
    max-height: 84vh;
    /* 键盘弹出时用 --kb 把弹层顶到键盘上方，并限制高度，保证底部按钮始终可点 */
    max-height: calc(100vh - var(--kb, 0px) - 10px);
    max-height: calc(100dvh - var(--kb, 0px) - 10px);
    padding: 8px 14px calc(12px + var(--safe-bottom));
    background: var(--card);
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 36px rgba(43, 39, 33, 0.2);
    animation: rec-sheet-in 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.rec-sheet-grip {
    flex: 0 0 auto;
    width: 38px;
    height: 4px;
    margin: 2px auto 6px;
    border-radius: 2px;
    background: var(--line);
}

.rec-sheet-head {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 0 2px 8px;
    border-bottom: 1px solid var(--line-soft);
}

.rec-sheet-heading {
    flex: 1 1 auto;
}

.rec-sheet-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.08em;
    line-height: 1.35;
    color: var(--ink);
}

.rec-sheet-sub {
    margin-top: 4px;
    font-size: 10.5px;
    line-height: 1.6;
    color: var(--ink-faint);
}

.rec-sheet-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--paper-mid);
    color: var(--ink-faint);
    font-size: 14px;
    line-height: 1;
}

.rec-sheet-close:active {
    background: var(--paper-deep);
}

.rec-sheet-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px 2px 4px;
}

.rec-sheet-foot {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

.rec-sheet-act {
    width: 100%;
    height: 44px;
}

/* ---------------- 弹层内：分类选择 ---------------- */

.rec-cat-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rec-cat-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: var(--card-alt);
    color: var(--ink);
    font-size: 13px;
    text-align: left;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.rec-cat-option:active {
    background: var(--paper-deep);
}

.rec-cat-option.active {
    border-color: var(--gold);
    background: #FFF8E9;
    box-shadow: inset 0 0 0 1px rgba(176, 138, 62, 0.25);
}

.rec-cat-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rec-cat-tick {
    flex: 0 0 auto;
    color: var(--gold-deep);
    font-size: 12px;
}

.rec-sheet-empty {
    padding: 2px 2px 4px;
    font-size: 11px;
    line-height: 1.7;
    color: var(--ink-faint);
}

/* ---------------- 弹层内：新建分类 ---------------- */

.rec-newcat {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rec-newcat-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.rec-newcat-open {
    width: 100%;
    min-height: 40px;
    margin-top: 10px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: transparent;
    color: var(--gold-deep);
    font-size: 12.5px;
    letter-spacing: 0.06em;
}

.rec-newcat-open:active {
    background: var(--card-alt);
}

.rec-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #FFFDF8, #FBF6EC);
    color: var(--ink);
    font-family: var(--font);
    font-size: 14px;
}

.rec-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(176, 138, 62, 0.14);
}

.rec-input::placeholder {
    color: var(--ink-faint);
}

/* ---------------- 弹层内：二次确认 ---------------- */

.rec-confirm {
    font-size: 13px;
    line-height: 1.75;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.rec-confirm-sub {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.75;
    color: var(--ink-faint);
}

/* ============================================================
   顶部轻提示
   ============================================================ */

.rec-toast {
    position: fixed;
    left: 50%;
    top: calc(var(--safe-top) + 64px);
    z-index: 95;
    max-width: calc(100vw - 48px);
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(43, 39, 33, 0.92);
    color: #FFF8EA;
    font-size: 12.5px;
    letter-spacing: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: var(--shadow-float);
    pointer-events: none;
    transform: translateX(-50%);
    animation: rec-toast-life 2.4s ease forwards;
}

/* ============================================================
   动画
   ============================================================ */

@keyframes rec-mask-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes rec-sheet-in {
    from {
        transform: translateY(20px);
        opacity: 0.7;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes rec-toast-life {
    0% {
        opacity: 0;
        transform: translate(-50%, -8px);
    }

    10% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    76% {
        opacity: 1;
        transform: translate(-50%, 0);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -5px);
    }
}

@media (prefers-reduced-motion: reduce) {

    .rec-sheet-mask,
    .rec-sheet,
    .rec-toast {
        animation-duration: 0.01s;
    }
}
