/*
 * 单位换算
 *
 * 版式跟计算器一套（同一个弹窗外壳、同样的浅灰面板和按键）：
 *   标题栏 → 分类 → 「输入卡」→ 圆形交换键 → 「结果卡」→ 数字键盘
 *
 * 分类做成 4×2 网格：8 个标签用一行横滑时最后一个总被切掉一半，网格不会。
 * 只有 1x1：卡片是图标，点开弹窗。
 */

/* ---------- 卡片 ---------- */

.app-card--conv {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.app-icon.conv-mini {
    border: 0;
    padding: 0;
    cursor: pointer;
    background: transparent;
    overflow: hidden;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .5),
        0 6px 16px rgba(15, 23, 42, .16),
        0 1px 3px rgba(15, 23, 42, .12);
    transition: transform .18s cubic-bezier(.2, .7, .3, 1), box-shadow .18s ease;
}

.app-icon.conv-mini:hover {
    transform: translateY(-2px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .55),
        0 14px 28px rgba(15, 23, 42, .22);
}

.app-icon.conv-mini img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ---------- 弹窗 ---------- */

.cv-panel {
    position: relative;
    width: min(376px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 0 0 10px;
    border-radius: 12px;
    background: #f3f3f3;
    color: #1a1a1a;
    box-shadow: 0 30px 80px rgba(8, 12, 22, .34);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.cv-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px 4px 14px;
}

.cv-title {
    margin: 0;
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: .2px;
    color: #1a1a1a;
}

.cv-head .cs-x {
    position: static;
    width: 34px;
    height: 30px;
    border-radius: 6px;
    background: transparent;
    color: #4b4b4b;
}

.cv-head .cs-x:hover {
    background: #e8e8e8;
}

/* ---------- 分类 ---------- */

.cv-cats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 0 12px 10px;
}

.cv-cat {
    height: 30px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 15px;
    background: #ebebeb;
    color: #4b4b4b;
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.cv-cat:hover {
    background: #e3e3e3;
}

.cv-cat.is-on {
    background: #ffffff;
    border-color: #d5d5da;
    color: #1a1a1a;
    font-weight: 600;
}

/* ---------- 输入 / 结果两张卡 ---------- */

.cv-cards {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 0 12px;
}

.cv-card {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 80px;
    padding: 8px 12px 10px;
    border: 1px solid #e7e7e7;
    border-radius: 10px;
    background: #ffffff;
}

/* 数值外面套一层：上面一行小字「输入 / 结果」，下面才是数字 */
.cv-field {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.cv-label {
    font-size: 11.5px;
    line-height: 16px;
    color: #8a8a8a;
    text-align: right;
}

.cv-value {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 32px;
    font-weight: 300;
    line-height: 48px;
    letter-spacing: -.4px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    outline: none;
}

/* 结果是 output，按文字排版 */
output.cv-value {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cv-card.is-out .cv-value.is-dim {
    color: #b0b0b0;
}

.cv-unit {
    flex: none;
    width: 116px;
    height: 44px;
    padding: 0 8px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fafafa;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6b6b6b 50%),
    linear-gradient(135deg, #6b6b6b 50%, transparent 50%);
    background-position: calc(100% - 13px) 19px, calc(100% - 8px) 19px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.cv-unit:hover {
    border-color: #cfcfcf;
}

.cv-unit:focus {
    outline: none;
    border-color: #0067c0;
    box-shadow: 0 0 0 2px rgba(0, 103, 192, .16);
}

/* 交换：卡在两行中间的圆形按钮，跟参考图那个箭头一个意思 */
.cv-swap {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 2;
    width: 36px;
    height: 36px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    background: #ffffff;
    color: #0067c0;
    cursor: pointer;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
    transition: background .12s ease, color .12s ease;
}

.cv-swap svg {
    width: 18px;
    height: 18px;
}

.cv-swap:hover {
    background: #eaf2fd;
}

.cv-swap:active {
    background: #dce9fb;
}

/* ---------- 数字键盘 ---------- */

.cv-pad {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 14px 12px 0;
}

.cv-key {
    height: 46px;
    padding: 0;
    border: 1px solid #e7e7e7;
    border-radius: 8px;
    background: #fbfbfb;
    color: #1a1a1a;
    font-family: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .12s ease, border-color .12s ease;
}

.cv-key:focus,
.cv-key:focus-visible {
    outline: none;
}

.cv-key:hover {
    background: #f3f3f3;
    border-color: #dedede;
}

.cv-key:active {
    background: #e8e8e8;
}

.cv-key.is-fn {
    background: #efefef;
    color: #3a3a3a;
    font-size: 15px;
}

@media (max-width: 420px) {
    .cv-unit {
        width: 100px;
    }

    .cv-value {
        font-size: 26px;
    }
}
