/*! CSS Portal — JavaScript Key Code & Event Inspector (builds on code-tool.css) */
.ev { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.ev [hidden] { display: none !important; }
.ev code { font-family: var(--ct-mono); font-size: .92em; }
.ev-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ev-muted { font-size: 13px; color: var(--ct-muted); }

/* ---------- tabs ---------- */
.ev-tabs { display: flex; gap: 4px; padding: 4px; width: max-content; max-width: 100%; background: var(--ct-surface-2); border-radius: 12px; }
.ev-tabs [role="tab"] { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 18px; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ct-muted); background: none; border: 0; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.ev-tabs [role="tab"] i { font-size: 18px; }
.ev-tabs [role="tab"]:hover { color: var(--ct-text); }
.ev-tabs [role="tab"][aria-selected="true"] { color: var(--ct-text); background: var(--ct-bg); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.ev-tabs [role="tab"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ct-accent-soft), inset 0 0 0 1px var(--ct-accent); }
.ev-panel { display: grid; gap: 16px; min-width: 0; }

/* ---------- cards ---------- */
.ev-card { min-width: 0; background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: var(--ct-radius); overflow: hidden; }
.ev-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 48px; padding: 8px 12px 8px 16px; background: var(--ct-surface); border-bottom: 1px solid var(--ct-border); }
.ev-card__head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 15px; font-weight: 700; color: var(--ct-text); }
.ev-card__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-left: auto; }
.ev-switches { gap: 8px 16px; }
.ev-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.ev-card__head .ct-seg { margin: 0; }
.ev-select { height: 34px; max-width: 100%; padding: 0 30px 0 10px; font: inherit; font-size: 13.5px; color: var(--ct-text); background: var(--ct-bg); border: 1px solid var(--ct-border-strong); border-radius: 8px; }
.ev-select:focus-visible { outline: none; border-color: var(--ct-accent); box-shadow: 0 0 0 3px var(--ct-accent-soft); }

/* ---------- keyboard ---------- */
.ev-keycard { display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.ev-keypad { position: relative; display: grid; place-items: center; flex: 1; min-height: 300px; padding: 28px 16px; text-align: center; background: var(--ct-surface); border: 2px dashed var(--ct-border-strong); border-radius: 12px; cursor: text; outline: none; transition: border-color .15s, background-color .15s, box-shadow .15s; }
.ev-keypad:focus { border-style: solid; border-color: var(--ct-accent); background: var(--ct-bg); box-shadow: 0 0 0 4px var(--ct-accent-soft); }
.ev-keypad__empty { display: grid; justify-items: center; gap: 6px; color: var(--ct-muted); }
.ev-keypad__empty i { font-size: 46px; color: var(--ct-accent); }
.ev-keypad__empty strong { font-size: 20px; color: var(--ct-text); }
.ev-keypad__empty span { font-size: 13.5px; }
.ev-keypad:focus .ev-keypad__empty:not(.is-touch) span { visibility: hidden; }
.ev-keypad__empty.is-touch span { max-width: 260px; }
.ev-keypad__show { display: grid; justify-items: center; gap: 14px; width: 100%; min-width: 0; }
.ev-keypad__type { position: absolute; top: 10px; left: 12px; padding: 2px 8px; font: 600 12px var(--ct-mono); color: var(--ct-muted); background: var(--ct-surface-2); border-radius: 6px; }
.ev-bigkey { display: grid; place-items: center; min-width: 120px; max-width: 100%; min-height: 120px; padding: 10px 24px; font: 700 64px/1.1 var(--ct-mono); color: var(--ct-text); background: var(--ct-bg); border: 1px solid var(--ct-border-strong); border-bottom-width: 5px; border-radius: 16px; overflow-wrap: anywhere; }
.ev-bigkey.is-long { font-size: 36px; }
.ev-bigkey.is-space { min-width: 260px; font-size: 32px; }
.ev-bigsub { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.ev-bigsub span { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 8px; }
.ev-bigsub small { font-size: 12px; color: var(--ct-muted); }
.ev-bigsub b { font: 700 18px var(--ct-mono); color: var(--ct-accent); }
.ev-mods { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.ev-mod { padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--ct-gutter); border: 1px solid var(--ct-border); border-radius: 99px; }
.ev-mod.is-on { color: var(--ct-on-accent); background: var(--ct-accent); border-color: var(--ct-accent); }
.ev-keyfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.ev-history { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; min-height: 28px; margin: 0; padding: 0; list-style: none; }
.ev-cap { min-width: 28px; padding: 3px 7px; font: 600 12px/1.4 var(--ct-mono); text-align: center; color: var(--ct-text); background: var(--ct-surface); border: 1px solid var(--ct-border-strong); border-bottom-width: 3px; border-radius: 6px; }
.ev-cap:first-child { border-color: var(--ct-accent); }
.ev-hint { margin: 0; font-size: 12.5px; color: var(--ct-muted); }
.ev-note { margin: 0; padding: 8px 12px; font-size: 13px; color: var(--ct-text); background: var(--ct-accent-soft); border-radius: 8px; }

/* ---------- property rows ---------- */
.ev-props { display: grid; }
.ev-prop { display: grid; grid-template-columns: minmax(150px, auto) minmax(70px, 1fr); gap: 2px 14px; align-items: baseline; width: 100%; padding: 8px 16px; font: inherit; text-align: left; color: var(--ct-text); background: none; border: 0; border-bottom: 1px solid var(--ct-border); cursor: copy; }
.ev-prop:last-child { border-bottom: 0; }
.ev-prop:hover { background: var(--ct-surface); }
.ev-prop:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--ct-accent); }
.ev-prop__name { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ct-muted); }
.ev-prop__name code { font-size: 13px; color: var(--ct-text); }
.ev-prop__val { font: 700 14px var(--ct-mono); color: var(--ct-text); overflow-wrap: anywhere; }
.ev-prop__note { grid-column: 1 / -1; font-size: 12px; line-height: 1.45; color: var(--ct-muted); }
.ev-prop__note:empty { display: none; }
.ev-prop.is-old .ev-prop__val { color: var(--ct-muted); }
.ev-v-string { color: var(--sx-str) !important; }
.ev-v-number { color: var(--sx-num) !important; }
.ev-v-boolean { color: var(--sx-at) !important; }
.ev-v-boolean.is-true { color: var(--ct-ok) !important; }
.ev-tag { padding: 1px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--ct-warn); background: rgba(180, 83, 9, .1); border-radius: 4px; }

.ev-groups { columns: 2; column-gap: 0; column-rule: 1px solid var(--ct-border); padding-bottom: 6px; }
.ev-group { min-width: 0; break-inside: avoid; }
.ev-group h3 { margin: 0; padding: 12px 14px 4px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ct-muted); }
.ev-prop--sm { grid-template-columns: minmax(84px, auto) minmax(0, 1fr); padding: 5px 14px; border-bottom: 0; }
.ev-prop--sm .ev-prop__val { font-size: 13px; }
.ev-prop--sm .ev-prop__note { font-size: 11.5px; }
.ev-last { margin-left: auto; font-size: 13px; color: var(--ct-muted); }
.ev-last code { color: var(--ct-accent); font-weight: 700; }

/* ---------- pointer pad ---------- */
.ev-padcard { display: flex; flex-direction: column; }
.ev-pad { position: relative; flex: 1; min-height: 420px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair;
	background-color: var(--ct-surface);
	background-image: linear-gradient(var(--ct-border) 1px, transparent 1px), linear-gradient(90deg, var(--ct-border) 1px, transparent 1px);
	background-size: 40px 40px; background-position: -1px -1px; }
.ev-pad > * { pointer-events: none; }
.ev-pad__hint { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 20px; text-align: center; color: var(--ct-muted); transition: opacity .3s; }
.ev-pad__hint i { font-size: 42px; color: var(--ct-accent); }
.ev-pad__hint strong { font-size: 17px; color: var(--ct-text); }
.ev-pad__hint span { max-width: 300px; font-size: 13px; }
.ev-pad__hint.is-gone { opacity: 0; }
.ev-cross { position: absolute; inset: 0; }
.ev-cross::before, .ev-cross::after { content: ""; position: absolute; background: var(--ct-accent); opacity: .35; }
.ev-cross::before { left: 0; right: 0; top: var(--y); height: 1px; }
.ev-cross::after { top: 0; bottom: 0; left: var(--x); width: 1px; }
.ev-dot { --s: 18px; position: absolute; top: 0; left: 0; width: 0; height: 0; will-change: transform; }
.ev-dot::before { content: ""; position: absolute; left: calc(var(--s) / -2); top: calc(var(--s) / -2); width: var(--s); height: var(--s); border: 2px solid var(--ct-accent); border-radius: 50%; background: var(--ct-accent-soft); transition: width .08s, height .08s, left .08s, top .08s; }
.ev-dot.is-down::before { background: var(--ct-accent); }
.ev-dot[data-type="touch"]::before { border-color: #0d9488; background: rgba(13, 148, 136, .25); }
.ev-dot[data-type="pen"]::before { border-color: #9333ea; background: rgba(147, 51, 234, .25); }
.ev-dot__label { position: absolute; left: 16px; top: 12px; padding: 2px 6px; font: 600 11.5px var(--ct-mono); white-space: nowrap; color: var(--ct-text); background: var(--ct-bg); border: 1px solid var(--ct-border); border-radius: 5px; }
.ev-dot__label.is-flip { left: auto; right: 16px; }
.ev-ripple { position: absolute; width: 0; height: 0; }
.ev-ripple::before { content: ""; position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border: 3px solid var(--ct-accent); border-radius: 50%; animation: ev-ripple .65s ease-out forwards; }
.ev-ripple[data-button="1"]::before { border-color: #0d9488; }
.ev-ripple[data-button="2"]::before { border-color: #ea580c; }
.ev-ripple[data-button="3"]::before, .ev-ripple[data-button="4"]::before { border-color: #9333ea; }
@keyframes ev-ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ev-ripple::before { animation-duration: .01s; } }

/* ---------- code ---------- */
.ev-code { margin: 0; padding: 14px 16px; overflow: auto; font: 13.5px/1.65 var(--ct-mono); color: var(--ct-text); background: var(--ct-bg); white-space: pre; tab-size: 2; }
.ev-code .t-cm { color: var(--sx-comment); font-style: italic; }
.ev-code .t-pn { color: var(--sx-punct); }
.ev-code .t-at { color: var(--sx-at); }
.ev-code .t-num { color: var(--sx-num); }
.ev-code .t-str { color: var(--sx-str); }
.ev-code .t-fn { color: var(--sx-fn); }

/* ---------- log ---------- */
.ev-logbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px; border-bottom: 1px solid var(--ct-border); }
.ev-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-right: auto; }
.ev-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; font: inherit; font-size: 13px; color: var(--ct-muted); background: var(--ct-bg); border: 1px solid var(--ct-border-strong); border-radius: 99px; cursor: pointer; }
.ev-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); opacity: .35; }
.ev-chip[aria-pressed="true"] { color: var(--ct-text); border-color: var(--c); }
.ev-chip[aria-pressed="true"]::before { opacity: 1; }
.ev-chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ct-accent-soft); }
.ev-chip[data-family="key"], .ev-row[data-f="key"] { --c: #2563eb; }
.ev-chip[data-family="pointer"], .ev-row[data-f="pointer"] { --c: #9333ea; }
.ev-chip[data-family="mouse"], .ev-row[data-f="mouse"] { --c: #ea580c; }
.ev-chip[data-family="touch"], .ev-row[data-f="touch"] { --c: #0d9488; }
.ev-chip[data-family="wheel"], .ev-row[data-f="wheel"] { --c: #db2777; }
html.dark-mode .ev-chip[data-family="key"], html.dark-mode .ev-row[data-f="key"] { --c: #60a5fa; }
html.dark-mode .ev-chip[data-family="pointer"], html.dark-mode .ev-row[data-f="pointer"] { --c: #c084fc; }
html.dark-mode .ev-chip[data-family="mouse"], html.dark-mode .ev-row[data-f="mouse"] { --c: #fb923c; }
html.dark-mode .ev-chip[data-family="touch"], html.dark-mode .ev-row[data-f="touch"] { --c: #2dd4bf; }
html.dark-mode .ev-chip[data-family="wheel"], html.dark-mode .ev-row[data-f="wheel"] { --c: #f472b6; }

.ev-log__empty { margin: 0; padding: 28px 16px; font-size: 13.5px; text-align: center; color: var(--ct-muted); }
.ev-log { max-height: 380px; margin: 0; padding: 0; overflow: auto; list-style: none; font-size: 13px; }
.ev-row { display: grid; grid-template-columns: 70px 64px 150px minmax(0, 1fr); gap: 4px 12px; align-items: baseline; padding: 5px 16px; border-bottom: 1px solid var(--ct-border); }
.ev-row:nth-child(even) { background: var(--ct-surface); }
.ev-row:first-child { animation: ev-in .5s ease-out; }
@keyframes ev-in { from { background: var(--ct-accent-soft); } }
.ev-row__time { font: 12px var(--ct-mono); color: var(--ct-muted); }
.ev-row__delta { font: 12px var(--ct-mono); color: var(--ct-gutter); }
.ev-row__type { display: inline-flex; align-items: center; gap: 7px; font: 700 13px var(--ct-mono); color: var(--c); }
.ev-row__type::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.ev-row__det { display: flex; flex-wrap: wrap; gap: 2px 14px; font: 12.5px var(--ct-mono); color: var(--ct-text); }
.ev-row__det i { font-style: normal; color: var(--ct-muted); }
.ev-log.hide-key .ev-row[data-f="key"], .ev-log.hide-pointer .ev-row[data-f="pointer"], .ev-log.hide-mouse .ev-row[data-f="mouse"],
.ev-log.hide-touch .ev-row[data-f="touch"], .ev-log.hide-wheel .ev-row[data-f="wheel"] { display: none; }

/* ---------- status ---------- */
.ev-status { position: fixed; left: 50%; bottom: 24px; z-index: 50; padding: 8px 16px; font-size: 13.5px; font-weight: 600; color: #fff; background: #0f172a; border-radius: 8px; box-shadow: 0 6px 20px rgba(15, 23, 42, .25); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.ev-status.is-on { opacity: 1; transform: translate(-50%, 0); }
html.dark-mode .ev-status { color: #0f172a; background: #e2e8f0; }

/* ---------- about table ---------- */
.ev-tablewrap { overflow-x: auto; }
.ev-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ev-table th, .ev-table td { padding: 5px 10px 5px 0; text-align: left; border-bottom: 1px solid var(--ct-border); }
.ev-table th { font-size: 12px; font-weight: 700; color: var(--ct-muted); }
.ev-table td:last-child, .ev-table th:last-child { text-align: right; padding-right: 0; font-family: var(--ct-mono); }

html.dark-mode .ev-tag { background: rgba(251, 191, 36, .12); }
html.dark-mode .ev-tabs [role="tab"][aria-selected="true"] { box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
html.dark-mode .ev-dot[data-type="touch"]::before { border-color: #2dd4bf; }
html.dark-mode .ev-dot[data-type="pen"]::before { border-color: #c084fc; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
	.ev-cols { grid-template-columns: minmax(0, 1fr); }
	.ev-pad { min-height: 340px; }
}
@media (max-width: 600px) {
	.ev-tabs { width: 100%; }
	.ev-tabs [role="tab"] { flex: 1; justify-content: center; padding: 0 10px; }
	.ev-keypad { min-height: 240px; }
	.ev-bigkey { min-height: 96px; font-size: 48px; }
	.ev-bigkey.is-long { font-size: 28px; }
	.ev-bigkey.is-space { min-width: 200px; font-size: 26px; }
	.ev-groups { columns: 1; }
	.ev-prop--sm { grid-template-columns: minmax(96px, auto) minmax(0, 1fr); }
	.ev-prop--sm .ev-prop__val { text-align: right; }
	.ev-prop--sm .ev-prop__note { display: none; }
	.ev-prop { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 12px; }
	.ev-prop--sm { padding: 5px 12px; }
	.ev-card__head .ct-tool span { display: none; }
	.ev-switches .ct-switch { font-size: 12.5px; }
	.ev-row { grid-template-columns: auto auto minmax(0, 1fr); padding: 6px 12px; }
	.ev-row__det { grid-column: 1 / -1; }
	.ev-logbar { padding: 10px 12px; }
}
