/* 键值设置弹窗（屏幕键盘）· 贴纸玩具主题
 *
 * 独立于主样式表，作为通用组件存在。
 */

.kb-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
}

.kb-modal.show { display: block; }

.kb-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(18, 16, 14, 0.45);
}

.kb-modal-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(820px, calc(100vw - 20px));
    max-height: calc(100vh - 30px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--ink);
    background: var(--paper);
    border: var(--line) solid var(--ink);
    border-radius: var(--r);
    box-shadow: var(--sh-3);
    animation: kbPop .28s var(--ease-bounce) both;
}

.kb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: 13px 16px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 17px;
    background: var(--lemon);
    border-bottom: var(--line) solid var(--ink);
}

.kb-modal-body {
    padding: var(--sp-3) 16px;
    overflow: auto;
}

.kb-modal-footer {
    display: flex;
    gap: var(--sp-2);
    padding: 12px 16px;
    background: var(--cream-2);
    border-top: var(--line) solid var(--ink);
}

.kb-modal-footer .secondary-button,
.kb-modal-footer .primary-button {
    flex: 1;
    margin: 0;
    padding: 11px 0;
}

/* 事件切换 */
.kb-event-tabs {
    display: flex;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.kb-event-tab {
    flex: 1;
    padding: 9px 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    background: var(--cream-2);
    border: var(--line) solid var(--ink);
    border-radius: var(--r-xs);
    box-shadow: var(--sh-1);
    cursor: pointer;
    transition: background .15s, transform .13s var(--ease-bounce), box-shadow .13s var(--ease-out);
}

.kb-event-tab:hover { transform: translate(-1px, -1px); box-shadow: var(--sh-2); }
.kb-event-tab.active { background: var(--sky); transform: translate(-1px, -1px); box-shadow: var(--sh-2); }

/* 当前键值 */
.kb-current {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.kb-current-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.kb-chips {
    flex: 1;
    min-height: 32px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--cream-2);
    border: 2.5px dashed rgba(18, 16, 14, .3);
    border-radius: var(--r-xs);
}

.kb-chip {
    display: inline-block;
    padding: 2px 10px 3px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    background: var(--mint);
    border: 2.5px solid var(--ink);
    border-radius: 999px;
}

.kb-chip-empty { font-size: 13px; color: var(--ink-soft); }

.kb-current-clear {
    padding: 7px 13px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    background: var(--coral);
    border: var(--line) solid var(--ink);
    border-radius: var(--r-xs);
    box-shadow: var(--sh-1);
    cursor: pointer;
    white-space: nowrap;
}

.kb-current-clear:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }

/* 键盘 */
.kb-board {
    overflow-x: auto;
    padding-bottom: 4px;
}

.kb-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 6px;
    min-width: max-content;
}

.kb-key {
    min-width: 42px;
    height: 38px;
    padding: 0 11px;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 13px;
    color: var(--ink);
    background: var(--paper);
    border: 2.5px solid var(--ink);
    border-radius: var(--r-xs);
    box-shadow: 2px 2px 0 var(--ink);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background .14s, transform .1s var(--ease-bounce), box-shadow .1s;
}

.kb-key:hover { background: var(--cream); }
.kb-key:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }

.kb-key.kb-key-mod { color: #1B5FA8; background: #E8F3FF; }
.kb-key.kb-key-space { min-width: 240px; }

.kb-key.active {
    background: var(--mint);
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 var(--ink);
}

.kb-key.kb-key-mod.active {
    color: var(--ink);
    background: var(--sky);
}

.kb-tip {
    margin-top: var(--sp-3);
    font-size: 12px;
    line-height: 1.5;
    color: var(--ink-soft);
}

/* 设置页中的键值摘要 */
.keyboard-key-summary {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: var(--sp-2);
    font-size: 13px;
}

.keyboard-key-summary .kbs-row { display: flex; gap: var(--sp-1); }

.keyboard-key-summary .kbs-name {
    flex: 0 0 42px;
    color: var(--ink-soft);
}

.keyboard-key-summary .kbs-val {
    flex: 1;
    min-width: 0;
    font-family: var(--font-display);
    font-weight: 600;
    word-break: break-all;
}

@keyframes kbPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.95); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .kb-modal-panel { animation: none; }
}
