:root {
  font-family: Inter, Arial, sans-serif;
  color: #f7f3ff;
  background: #130b27;
  font-synthesis: none;
  letter-spacing: 0;
  --bg: #130b27;
  --panel: #201435;
  --panel-deep: #100c20;
  --line: #0a0811;
  --line-soft: #55436d;
  --muted: #bcb1d1;
  --cyan: #19e4e6;
  --yellow: #f5ed42;
  --pink: #ff4cc7;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  background-image: radial-gradient(#45305f 1px, transparent 1px);
  background-size: 23px 23px;
}
.topbar {
  min-height: 68px;
  border-bottom: 3px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px max(24px, calc((100vw - 1180px) / 2));
  background: #100b1e;
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 950; font-size: 22px; white-space: nowrap; }
.brand img { border: 2px solid var(--line); object-fit: cover; }
.brand-accent { color: var(--cyan); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-meta { color: var(--yellow); font-size: 11px; font-weight: 900; }
.workspace { width: min(100% - 48px, 1120px); margin: 0 auto; flex: 1; padding: 34px 0 50px; }
.work-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.mode-actions { display: flex; gap: 12px; margin-bottom: 26px; }
.mode-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-width: 180px; min-height: 50px; padding: 8px 18px; border: 3px solid var(--line); border-radius: 2px; box-shadow: 4px 4px 0 var(--line); color: var(--muted); background: #21172f; font-size: 13px; font-weight: 900; text-transform: uppercase; }
.mode-button svg { width: 18px; height: 18px; flex: none; }
.mode-button:hover { color: #fff; background: #352447; }
.mode-button-egg[aria-pressed="true"] { color: var(--line); background: var(--cyan); }
.mode-button-pet[aria-pressed="true"] { color: var(--line); background: var(--yellow); }
.mode-button[aria-pressed="true"] { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--line); }
.eyebrow { font-size: 11px; font-weight: 900; color: var(--yellow); margin: 0 0 9px; }
h1 { font-size: clamp(24px, 3vw, 36px); line-height: 1.08; margin: 0; font-weight: 950; max-width: 680px; }
.icon-button {
  border: 2px solid var(--line);
  background: #281942;
  color: #fff;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 2px;
  flex: none;
  box-shadow: 3px 3px 0 var(--line);
}
.icon-button:hover { background: #3d245c; color: var(--cyan); }
.icon-button svg { width: 19px; height: 19px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr); gap: 26px; align-items: start; }
.controls, .result {
  border: 2px solid var(--line);
  border-radius: 2px;
  box-shadow: 6px 6px 0 var(--line);
}
.controls { padding: 26px 28px; background: var(--panel); display: grid; gap: 23px; }
.field-block { min-width: 0; border: 0; padding: 0; margin: 0; }
.field-block > label, .field-block legend, .label-line label { display: block; font-size: 12px; font-weight: 900; margin-bottom: 10px; text-transform: uppercase; }
.label-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-line label { margin-bottom: 10px; }
.label-line small, .field-help { font-size: 11px; color: var(--muted); }
.pet-selector {
  display: flex;
  align-items: center;
  gap: 13px;
  border: 2px solid var(--line);
  background: var(--panel-deep);
  padding: 9px 10px;
  min-height: 66px;
}
.pet-visual { width: 50px; height: 50px; object-fit: contain; flex: none; }
.pet-identity { min-width: 0; display: grid; gap: 4px; flex: 1; }
.pet-identity strong { font-size: 16px; overflow-wrap: anywhere; }
.pet-identity small { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.pet-selector .icon-button { width: 36px; height: 36px; background: var(--cyan); color: var(--line); }
.pet-selector .icon-button:hover { background: #77f7f5; }
.numeric-wrap { display: flex; align-items: center; border: 2px solid var(--line); background: var(--panel-deep); height: 52px; }
.numeric-wrap:focus-within { border-color: var(--cyan); }
.numeric-wrap input { border: 0; outline: 0; padding: 0 14px; min-width: 0; width: 100%; height: 100%; color: #fff; font-size: 21px; font-weight: 800; background: transparent; }
.numeric-wrap span { padding: 0 15px; color: var(--cyan); font-weight: 900; }
.field-help { display: block; margin-top: 8px; }
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 2px solid var(--line); background: var(--panel-deep); }
.segmented button { border: 0; border-right: 2px solid var(--line); background: transparent; color: var(--muted); min-height: 44px; font-size: 12px; font-weight: 900; padding: 5px; overflow-wrap: anywhere; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: #fff; background: #392451; }
.segmented button.active { background: var(--cyan); color: var(--line); }
.mutation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mutation-option { border: 2px solid var(--line); background: var(--panel-deep); min-height: 43px; display: flex; align-items: center; gap: 8px; padding: 0 9px; font-size: 12px; font-weight: 800; cursor: pointer; min-width: 0; }
.mutation-option:hover { border-color: var(--pink); }
.mutation-option:has(input:checked) { border-color: var(--pink); background: #3a194b; }
.mutation-option input { accent-color: var(--pink); margin: 0; flex: none; }
.mutation-option span { overflow-wrap: anywhere; }
.mutation-option small { margin-left: auto; color: var(--yellow); font-size: 11px; white-space: nowrap; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 2px solid #3a2b4d; padding-top: 20px; cursor: pointer; }
.toggle-row > span:first-child { display: grid; gap: 4px; }
.toggle-row strong { font-size: 13px; }
.toggle-row small { color: var(--muted); font-size: 12px; }
.toggle-row input { position: absolute; opacity: 0; }
.switch { position: relative; width: 44px; height: 25px; background: #766788; border: 2px solid var(--line); flex: none; transition: background .2s; }
.switch:after { content: ""; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; background: #fff; transition: transform .2s; }
.toggle-row input:checked + .switch { background: var(--yellow); }
.toggle-row input:checked + .switch:after { transform: translateX(19px); background: var(--line); }
.toggle-row input:focus-visible + .switch { outline: 3px solid var(--yellow); outline-offset: 3px; }
.result { background: #1a1031; color: #fff; padding: 28px; min-height: 460px; position: sticky; top: 20px; }
.result-top { display: flex; justify-content: space-between; align-items: center; color: var(--cyan); font-size: 11px; font-weight: 900; }
.result-dot { width: 8px; height: 8px; background: var(--pink); box-shadow: 0 0 0 3px #ff4cc72e; }
.result-value { color: var(--yellow); font-size: clamp(26px, 3vw, 40px); font-weight: 950; margin-top: 30px; line-height: 1.16; overflow-wrap: anywhere; }
.result-unit { font-size: 14px; color: var(--muted); margin-top: 4px; }
.result-divider { height: 2px; background: #5b3b77; margin: 31px 0 14px; }
.result-row { display: flex; align-items: baseline; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid #49335f; font-size: 13px; }
.result-row span { color: var(--muted); }
.result-row strong { text-align: right; overflow-wrap: anywhere; }
.result-row:has(#mutationGain) strong { color: var(--cyan); }
#mutationComparison[hidden] { display: none; }
.result-actions { margin-top: 25px; }
.primary-button { width: 100%; min-height: 48px; border: 2px solid var(--line); border-radius: 2px; background: var(--cyan); color: var(--line); font-weight: 900; display: flex; justify-content: center; align-items: center; gap: 9px; box-shadow: 4px 4px 0 var(--line); }
.primary-button:hover:not(:disabled) { background: #78f6f6; transform: translate(1px, 1px); box-shadow: 3px 3px 0 var(--line); }
.primary-button svg { width: 17px; height: 17px; }
.result-note { font-size: 11px; line-height: 1.4; color: var(--muted); margin: 18px 0 0; }
.pet-dialog, .info-dialog { border: 2px solid var(--line); border-radius: 2px; padding: 0; background: var(--panel); color: #fff; box-shadow: 8px 8px 0 var(--line); }
.pet-dialog { width: min(640px, calc(100vw - 24px)); height: min(760px, calc(100dvh - 24px)); max-height: none; }
.pet-dialog[open] { display: flex; flex-direction: column; }
.info-dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.pet-dialog::backdrop, .info-dialog::backdrop { background: #090613d9; }
.dialog-head { min-height: 64px; padding: 10px 18px 10px 23px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 2px solid var(--line); background: #180f2c; }
.dialog-head h2 { font-size: 17px; margin: 0; font-weight: 950; }
.info-content { padding: 20px 23px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.info-content p { margin: 0 0 13px; }
.info-content p:last-child { margin-bottom: 0; }
.info-content a { color: var(--cyan); }
.channel-info { padding-bottom: 18px; margin-bottom: 17px; border-bottom: 2px solid #49335f; }
.channel-info > span { display: block; color: var(--yellow); font-size: 11px; font-weight: 900; margin-bottom: 7px; }
.channel-info > a { display: inline-flex; align-items: center; gap: 7px; color: var(--cyan); font-size: 19px; font-weight: 900; text-decoration: none; overflow-wrap: anywhere; }
.channel-info > a svg { width: 16px; height: 16px; flex: none; }
.channel-info p { margin: 9px 0 0; }
.legal-link { display: inline-block; margin-top: 5px; font-size: 11px; }
.credits-page { width: min(100% - 40px, 700px); margin: 0 auto; padding: 36px 0 70px; line-height: 1.6; }
.credits-page h1 { margin: 22px 0; font-size: 28px; }
.credits-page p { color: var(--muted); }
.credits-page a { color: var(--cyan); }
.search-wrap { display: flex; align-items: center; flex: none; gap: 10px; height: 48px; margin: 16px 20px 12px; padding: 0 14px; border: 2px solid var(--line); background: var(--panel-deep); }
.search-wrap svg { width: 18px; height: 18px; color: var(--cyan); }
.search-wrap input { flex: 1; border: 0; outline: 0; min-width: 0; color: #fff; background: transparent; }
.search-wrap input::placeholder { color: var(--muted); }
.filter-row { display: flex; flex: none; gap: 7px; padding: 0 20px 12px; }
.filter-row button { border: 2px solid var(--line); background: var(--panel-deep); color: var(--muted); padding: 8px 13px; font-size: 12px; font-weight: 900; }
.filter-row button[aria-selected=true] { background: var(--yellow); color: var(--line); }
.rarity-filters { display: flex; flex: none; flex-wrap: wrap; gap: 6px; padding: 0 20px 14px; border-bottom: 2px solid var(--line); }
.rarity-filters button { border: 2px solid var(--line); background: var(--panel-deep); color: var(--muted); min-height: 32px; padding: 5px 9px; font-size: 11px; font-weight: 800; }
.rarity-filters button:hover { border-color: var(--cyan); color: #fff; }
.rarity-filters button[aria-pressed=true] { background: var(--cyan); color: var(--line); }
.pet-list { flex: 1; min-height: 0; overflow: auto; padding: 8px 12px 16px; }
.pet-list-item { border: 0; border-bottom: 1px solid #49335f; background: transparent; color: #fff; width: 100%; min-height: 64px; padding: 8px 10px; display: flex; align-items: center; text-align: left; gap: 10px; }
.pet-list-item:hover, .pet-list-item:focus-visible { background: #392452; }
.list-pet-visual { width: 46px; height: 46px; object-fit: contain; flex: none; }
.list-identity { display: grid; gap: 3px; min-width: 0; flex: 1; }
.list-identity strong { font-size: 13px; overflow-wrap: anywhere; }
.list-identity small { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.pet-list-item > span:last-child { font-size: 12px; font-weight: 900; color: var(--yellow); white-space: nowrap; }
.empty-list { text-align: center; color: var(--muted); margin: 35px 0; }

@media (max-width: 780px) {
  .topbar { min-height: 58px; padding: 8px 16px; }
  .workspace { width: calc(100% - 32px); padding: 25px 0 36px; }
  .work-head { margin-bottom: 18px; }
  .mode-actions { gap: 9px; margin-bottom: 20px; }
  .mode-button { min-width: 0; flex: 1; min-height: 48px; padding: 7px 9px; font-size: 12px; }
  .layout { grid-template-columns: 1fr; gap: 16px; }
  .controls { padding: 19px; gap: 20px; }
  .result { position: static; min-height: 0; padding: 23px; }
  .result-value { font-size: 30px; margin-top: 20px; }
  .result-divider { margin: 24px 0 10px; }
}
@media (max-width: 380px) {
  .topbar-meta { display: none; }
  .segmented button { font-size: 11px; padding: 4px 2px; }
  .mutation-option { padding: 0 6px; gap: 5px; }
  .mutation-option small { font-size: 10px; }
}
