/* Jev 第二意見面板 — owner: jev. Uses shell tokens (tokens.css) with safe fallbacks. */

.jev {
  --jev-accent: var(--accent, #6c8cff);
  --jev-warn: var(--warn, #f5b544);
  --jev-muted: var(--muted, #8190ac);
  --jev-border: var(--border, rgba(150, 172, 230, 0.11));
  --jev-panel: var(--panel-2, rgba(22, 32, 58, 0.72));
  --jev-r: var(--r-lg, 14px);
  display: grid;
  gap: var(--sp-3, 12px);
  font-family: var(--font-sans, system-ui, sans-serif);
  color: var(--text, #e7edf8);
  min-width: 0;
}

.jev__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3, 12px);
  flex-wrap: wrap;
}
.jev__title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.jev__title h3 { margin: 0; font-size: var(--fs-lg, 15px); font-weight: 650; letter-spacing: 0.02em; }
.jev__title p { margin: 2px 0 0; font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); }
.jev__logo {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  font: 700 15px/1 var(--font-mono, ui-monospace, monospace);
  color: var(--on-accent, #050814);
  background: conic-gradient(from 210deg, var(--jev-accent), #c77dff, #43c6d9, var(--jev-accent));
  box-shadow: 0 0 18px var(--accent-glow, rgba(108, 140, 255, 0.45));
}
.jev__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.jev-chip {
  font: 500 var(--fs-2xs, 10.5px)/1 var(--font-mono, ui-monospace, monospace);
  color: var(--text-2, #b9c4da);
  padding: 5px 7px;
  border-radius: var(--r-pill, 999px);
  border: 1px solid var(--jev-border);
  background: rgba(255, 255, 255, 0.03);
}

.jev-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: 600 var(--fs-sm, 12.5px)/1 var(--font-sans, system-ui);
  color: var(--text, #e7edf8);
  padding: 9px 14px;
  border-radius: var(--r-pill, 999px);
  border: 1px solid var(--border-strong, rgba(150, 172, 230, 0.22));
  background: var(--jev-panel);
  cursor: pointer;
  transition: transform var(--dur-1, 120ms) var(--ease-out, ease-out), box-shadow var(--dur-2, 200ms), background var(--dur-2, 200ms), opacity var(--dur-2, 200ms);
}
.jev-btn:hover:not(:disabled) { transform: translateY(-1px); background: var(--panel-hover, rgba(34, 48, 84, 0.55)); }
.jev-btn:focus-visible { outline: 2px solid var(--ring, var(--jev-accent)); outline-offset: 2px; }
.jev-btn:disabled { opacity: 0.55; cursor: default; }
.jev-btn.is-primary {
  color: var(--on-accent, #050814);
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent-strong, #8aa4ff), var(--jev-accent));
  box-shadow: 0 6px 22px -6px var(--accent-glow, rgba(108, 140, 255, 0.45));
}
.jev-btn__spark { font-size: 13px; }
.jev-btn:not(:disabled) .jev-btn__spark { animation: jev-twinkle 2.4s ease-in-out infinite; }

.jev__disclaimer {
  margin: 0;
  font-size: var(--fs-xs, 11.5px);
  line-height: 1.6;
  color: var(--jev-muted);
  padding: 8px 10px;
  border-left: 2px solid var(--jev-warn);
  background: var(--warn-soft, rgba(245, 181, 68, 0.08));
  border-radius: 0 var(--r-sm, 8px) var(--r-sm, 8px) 0;
}
.jev__disclaimer b { color: var(--jev-warn); font-weight: 600; }

.jev-hint { font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); }

/* ---------- idle / empty states ---------- */
.jev-idle ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.jev-idle li {
  font-size: var(--fs-sm, 12.5px); color: var(--text-2, #b9c4da);
  padding: 8px 10px; border-radius: var(--r-sm, 8px);
  border: 1px dashed var(--jev-border);
}
.jev-idle li b { color: var(--text, #e7edf8); font-weight: 600; }

.jev-empty {
  padding: 12px 14px;
  border-radius: var(--jev-r);
  border: 1px solid var(--jev-border);
  background: var(--jev-panel);
  font-size: var(--fs-sm, 12.5px);
}
.jev-empty strong { display: block; margin-bottom: 4px; }
.jev-empty p { margin: 4px 0; color: var(--text-2, #b9c4da); }
.jev-empty pre {
  margin: 8px 0; padding: 8px 10px; overflow-x: auto;
  font: 12px/1.5 var(--font-mono, ui-monospace, monospace);
  background: rgba(0, 0, 0, 0.28); border-radius: var(--r-sm, 8px);
  color: var(--accent-strong, #8aa4ff);
}
.jev-empty.tone-warn { border-color: color-mix(in srgb, var(--jev-warn) 45%, transparent); }
.jev-empty.tone-warn strong { color: var(--jev-warn); }
.jev-empty.tone-error { border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent); }
.jev-empty.tone-error strong { color: var(--danger, #ff6b6b); }

.jev-loading { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm, 12.5px); color: var(--text-2, #b9c4da); }
.jev-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--jev-accent); box-shadow: 0 0 0 0 var(--accent-glow); animation: jev-pulse 1s ease-out infinite; }

/* ---------- results ---------- */
.jev-results { display: grid; gap: var(--sp-3, 12px); transition: opacity var(--dur-2, 200ms), filter var(--dur-2, 200ms); }
.jev-results.is-stale .jev-grid { opacity: 0.5; filter: saturate(0.4); }
.jev-stale {
  font-size: var(--fs-xs, 11.5px); color: var(--jev-warn);
  padding: 6px 10px; border-radius: var(--r-sm, 8px); background: var(--warn-soft, rgba(245, 181, 68, 0.12));
}

.jev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  gap: var(--sp-3, 12px);
}

.jev-card {
  position: relative;
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px 14px 14px;
  border-radius: var(--jev-r);
  border: 1px solid var(--jev-border);
  background:
    radial-gradient(120% 80% at 100% 0%, var(--accent-soft, rgba(108, 140, 255, 0.1)), transparent 60%),
    var(--jev-panel);
  box-shadow: var(--shadow-1, 0 1px 0 rgba(255, 255, 255, 0.03) inset);
  animation: jev-rise var(--dur-3, 360ms) var(--ease-out, ease-out) both;
}
.jev-grid > .jev-card:nth-child(2) { animation-delay: 60ms; }
.jev-grid > .jev-card:nth-child(3) { animation-delay: 120ms; }
.jev-grid > .jev-card:nth-child(4) { animation-delay: 180ms; }
.jev-choice, .jev-score { grid-column: 1 / -1; }
@container (min-width: 720px) { .jev-choice, .jev-score { grid-column: auto; } }

.jev-card__head { display: flex; align-items: center; gap: 8px; }
.jev-card__head h4 { margin: 0; font-size: var(--fs-md, 13.5px); font-weight: 650; }
.jev-card__type {
  font: 600 var(--fs-2xs, 10.5px)/1 var(--font-sans, system-ui);
  color: var(--jev-accent); padding: 3px 6px; border-radius: var(--r-xs, 5px); background: var(--accent-soft, rgba(108, 140, 255, 0.16));
}
.jev-card__q { margin: 0; font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); }

.tone-accent { color: var(--jev-accent); }
.tone-warn { color: var(--jev-warn); }
.tone-muted { color: var(--text-2, #b9c4da); }
.tone-mid { color: var(--text, #e7edf8); }

/* noul gauge */
.jev-noul__body { display: grid; justify-items: center; gap: 8px; text-align: center; }
.jev-noul__gauge { position: relative; width: min(100%, 168px); }
.jev-gauge { width: 100%; height: auto; display: block; overflow: visible; }
.jev-gauge__track { fill: none; stroke: rgba(150, 172, 230, 0.12); stroke-width: 9; stroke-linecap: round; }
.jev-gauge__zone { fill: none; stroke-width: 2; stroke-linecap: round; transform: translateY(8px); opacity: 0.55; }
.jev-gauge__zone.zone-low { stroke: var(--jev-muted); }
.jev-gauge__zone.zone-high { stroke: var(--jev-accent); }
.jev-gauge__fill {
  fill: none; stroke-width: 9; stroke-linecap: round;
  stroke-dashoffset: var(--jev-to);
  animation: jev-sweep 900ms var(--ease-out, cubic-bezier(0.2, 0.8, 0.2, 1)) both;
  filter: drop-shadow(0 0 6px currentColor);
}
.jev-gauge__fill.tone-accent { stroke: var(--jev-accent); color: var(--accent-glow, rgba(108, 140, 255, 0.5)); }
.jev-gauge__fill.tone-warn { stroke: var(--jev-warn); color: rgba(245, 181, 68, 0.45); }
.jev-gauge__fill.tone-muted { stroke: var(--jev-muted); color: transparent; }
.jev-gauge__fill.tone-mid { stroke: var(--text-2, #b9c4da); color: transparent; }
.jev-gauge__tick { stroke: var(--faint, #56627c); stroke-width: 1.2; }
.jev-noul__readout { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; display: grid; }
.jev-noul__num { font: 700 26px/1 var(--font-mono, ui-monospace, monospace); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.jev-noul__readout small { font-size: var(--fs-2xs, 10.5px); color: var(--jev-muted); margin-top: 3px; }
.jev-noul__side { display: grid; gap: 3px; min-width: 0; justify-items: center; }
.jev-verdict { font-size: var(--fs-md, 13.5px); font-weight: 650; }

/* choice distribution */
.jev-choice__pick { display: flex; align-items: center; gap: 10px; }
.jev-choice__pick strong { display: block; font-size: var(--fs-xl, 18px); font-weight: 700; }
.jev-choice__pick small { font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); }
.jev-choice__icon {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 19px;
  border-radius: 11px; background: var(--accent-soft, rgba(108, 140, 255, 0.16)); color: var(--jev-accent);
}
.jev-dist { list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 5px; }
.jev-dist__row {
  display: grid; grid-template-columns: minmax(92px, 7.5em) 1fr 3.4em; align-items: center; gap: 8px;
  font-size: var(--fs-xs, 11.5px); color: var(--text-2, #b9c4da);
}
.jev-dist__row.is-zero { opacity: 0.45; }
.jev-dist__row.is-chosen { color: var(--text, #e7edf8); font-weight: 600; }
.jev-dist__label { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jev-dist__label i { font-style: normal; width: 1.2em; text-align: center; opacity: 0.8; }
.jev-dist__bar { height: 8px; border-radius: 99px; background: rgba(150, 172, 230, 0.09); overflow: hidden; }
.jev-dist__fill {
  display: block; height: 100%; width: var(--w); border-radius: inherit;
  background: var(--jev-muted);
  transform-origin: left; animation: jev-grow 700ms var(--ease-out, ease-out) both; animation-delay: calc(var(--i, 0) * 45ms + 120ms);
}
.jev-dist__row.is-chosen .jev-dist__fill { background: linear-gradient(90deg, var(--jev-accent), var(--accent-strong, #8aa4ff)); box-shadow: 0 0 10px var(--accent-glow, rgba(108, 140, 255, 0.45)); }
.jev-dist__pct { text-align: right; font-family: var(--font-mono, ui-monospace, monospace); font-variant-numeric: tabular-nums; }

/* score legend scale */
.jev-score__head strong { font-size: var(--fs-xl, 18px); font-weight: 700; margin-right: 8px; }
.jev-score__head small { font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); }
.jev-scale { display: grid; gap: 4px; margin-top: 4px; }
.jev-scale__hist { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; height: 54px; align-items: end; }
.jev-scale__col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.jev-scale__col em { position: absolute; top: 0; font: 500 var(--fs-2xs, 10.5px)/1 var(--font-mono, ui-monospace, monospace); font-style: normal; color: var(--jev-muted); }
.jev-scale__bar {
  width: 60%; height: calc(var(--h) * 0.72); min-height: 2px; border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg, var(--accent-strong, #8aa4ff), color-mix(in srgb, var(--jev-accent) 40%, transparent));
  transform-origin: bottom; animation: jev-rise-bar 700ms var(--ease-out, ease-out) both; animation-delay: calc(var(--i, 0) * 60ms + 150ms);
}
.jev-scale__track { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 3px; padding-top: 6px; margin-bottom: 30px; }
.jev-scale__seg {
  display: grid; justify-items: center; gap: 2px; padding: 6px 2px 5px;
  font-size: var(--fs-2xs, 10.5px); color: var(--jev-muted); text-align: center;
  border-radius: 6px; border-top: 3px solid;
  background: rgba(150, 172, 230, 0.05);
  cursor: help;
}
.jev-scale__seg b { font: 600 var(--fs-2xs, 10.5px)/1 var(--font-mono, ui-monospace, monospace); opacity: 0.7; }
.jev-scale__seg.lvl-0 { border-color: rgba(150, 172, 230, 0.18); }
.jev-scale__seg.lvl-1 { border-color: color-mix(in srgb, var(--jev-accent) 30%, transparent); }
.jev-scale__seg.lvl-2 { border-color: color-mix(in srgb, var(--jev-accent) 50%, transparent); }
.jev-scale__seg.lvl-3 { border-color: color-mix(in srgb, var(--jev-accent) 75%, transparent); }
.jev-scale__seg.lvl-4 { border-color: var(--jev-accent); }
.jev-scale__seg.is-near { color: var(--text, #e7edf8); background: var(--accent-soft, rgba(108, 140, 255, 0.16)); }
.jev-scale__marker {
  position: absolute; bottom: -8px; left: var(--x); width: 0; height: 0;
  animation: jev-slide 900ms var(--ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)) both;
}
.jev-scale__marker::before {
  content: ""; position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--text, #e7edf8); box-shadow: 0 0 0 3px var(--jev-accent), 0 0 14px var(--accent-glow, rgba(108, 140, 255, 0.6));
}
.jev-scale__marker span {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  font: 700 var(--fs-2xs, 10.5px)/1 var(--font-mono, ui-monospace, monospace);
  color: var(--on-accent, #050814); background: var(--jev-accent); padding: 3px 5px; border-radius: 5px; white-space: nowrap;
}
.jev-score__legend summary, .jev-state summary {
  cursor: pointer; font-size: var(--fs-xs, 11.5px); color: var(--text-2, #b9c4da); user-select: none;
}
.jev-score__legend ol { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 4px; font-size: var(--fs-xs, 11.5px); color: var(--jev-muted); line-height: 1.5; }
.jev-score__legend b { color: var(--text-2, #b9c4da); }

/* transparency: state sent to Jev */
.jev-state { border: 1px solid var(--jev-border); border-radius: var(--jev-r); padding: 10px 12px; background: rgba(0, 0, 0, 0.12); }
.jev-state[open] summary { margin-bottom: 8px; }
.jev-state__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px 14px; }
.jev-state__group h5 { margin: 0 0 4px; font-size: var(--fs-xs, 11.5px); font-weight: 650; color: var(--text, #e7edf8); }
.jev-state__group h5 small { display: block; font-weight: 400; color: var(--faint, #56627c); font-size: var(--fs-2xs, 10.5px); }
.jev-state__group dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: var(--fs-2xs, 10.5px); }
.jev-state__group dt { color: var(--jev-muted); }
.jev-state__group dd { margin: 0; text-align: right; font-family: var(--font-mono, ui-monospace, monospace); font-variant-numeric: tabular-nums; color: var(--text-2, #b9c4da); overflow-wrap: anywhere; }

.jev-note { margin: 0; font-size: var(--fs-2xs, 10.5px); line-height: 1.6; color: var(--jev-muted); }
.jev-foot { margin: 0; font: 400 var(--fs-2xs, 10.5px)/1.5 var(--font-mono, ui-monospace, monospace); color: var(--faint, #56627c); }

/* skeleton */
.jev-skel { min-height: 150px; gap: 10px; }
.jev-skel span { display: block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, rgba(150, 172, 230, 0.06), rgba(150, 172, 230, 0.16), rgba(150, 172, 230, 0.06)); background-size: 200% 100%; animation: jev-shimmer 1.1s linear infinite; }
.jev-skel span:nth-child(1) { width: 40%; }
.jev-skel span:nth-child(2) { width: 80%; }
.jev-skel span:nth-child(3) { width: 60%; height: 54px; }

/* animations */
@keyframes jev-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes jev-sweep { from { stroke-dashoffset: var(--jev-len); } to { stroke-dashoffset: var(--jev-to); } }
@keyframes jev-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes jev-rise-bar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes jev-slide { from { left: 0; opacity: 0; } to { left: var(--x); opacity: 1; } }
@keyframes jev-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes jev-pulse { 0% { box-shadow: 0 0 0 0 var(--accent-glow, rgba(108, 140, 255, 0.5)); } 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes jev-twinkle { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.55; transform: scale(0.85) rotate(20deg); } }

.jev-results.no-anim *, .jev-results.no-anim *::before { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  .jev *, .jev *::before { animation: none !important; transition: none !important; }
}

/* light theme tweaks */
html[data-theme="light"] .jev-empty pre { background: rgba(0, 0, 0, 0.05); }
html[data-theme="light"] .jev-state { background: rgba(0, 0, 0, 0.02); }

/* ---------- Jev 金鑰（BYOK, Cloudflare Pages edge mode; jev-key.js） ---------- */
.help__settings { margin-top: var(--sp-5, 20px); padding-top: var(--sp-3, 12px); border-top: 1px solid var(--border, rgba(150, 172, 230, 0.11)); }
.help__settings h3 { font-size: var(--fs-xs, 11.5px); color: var(--muted, #8190ac); font-weight: 500; margin: 0 0 var(--sp-2, 8px); }
.jevkey { display: grid; gap: 8px; font-size: var(--fs-sm, 13px); color: var(--text-2, #b9c4da); min-width: 0; }
.jevkey__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.jevkey__head strong { color: var(--text, #e7edf8); font-weight: 600; }
.jevkey__state { font-size: var(--fs-xs, 11.5px); color: var(--muted, #8190ac); }
.jevkey__state.is-set { color: var(--accent, #6c8cff); }
.jevkey__state code { font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: 0.04em; }
.jevkey__form, .jevkey__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.jevkey__input {
  flex: 1 1 220px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-md, 9px);
  border: 1px solid var(--border-strong, rgba(150, 172, 230, 0.22));
  background: var(--bg, #060a14);
  color: var(--text, #e7edf8);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13px;
}
.jevkey__input:focus { outline: 2px solid color-mix(in srgb, var(--accent, #6c8cff) 60%, transparent); outline-offset: 1px; }
.jevkey__status { margin: 0; font-size: var(--fs-xs, 11.5px); }
.jevkey__status.tone-ok { color: var(--accent, #6c8cff); }
.jevkey__status.tone-error { color: var(--warn, #f5b544); }
.jevkey__note { margin: 0; font-size: var(--fs-xs, 11.5px); line-height: 1.6; color: var(--muted, #8190ac); }
.jev-byok__field { margin-top: 10px; }
